Advertisement
DasAquatic

[RGSS] Dax Core 2.5

Mar 11th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # • Dax Core
  3. #==============================================================================
  4. # Autor: Dax
  5. # Versão: 2.5
  6. # Site: www.dax-soft.weebly.com
  7. # Requerimento: N/A
  8. #==============================================================================
  9. # • Descrição:
  10. #------------------------------------------------------------------------------
  11. #   Adiciona alguns requesitos necessarios para executar alguns script Dax.
  12. #==============================================================================
  13. # • Versões:
  14. #------------------------------------------------------------------------------
  15. # 1.0 :
  16. #     - ColorBasic : Módulo com informação de algumas cores.
  17. #     - API : Módulo com informação de algumas APIs.
  18. #     - Input : Módulo que permite você utilizar as várias teclas do teclado.
  19. #     - Zone : Calcular a zona de um objeto no outro.
  20. #     - Bitmap : Add-ons para está classe.
  21. #     - Mouse : Sistema do mouse.
  22. #     - Sprite_Picture : Correção de falhas.
  23. #     - Window_Base : Correção de falhas.
  24. #     - Game_Event : Add-ons para está classe.
  25. #     - String : Add-ons para está clasee.
  26. # 1.1 :
  27. #     - Bitmap : Add-ons para está classe.
  28. #     - Sprite : Add-ons para está classe.
  29. #     - String : Add-ons para está classe.
  30. #     - Integer : Add-ons para está classe.
  31. # 1.2 :
  32. #     - ColorBasic : Modificação e add-ons.
  33. #     - Sprite : Add-ons...
  34. #     - Bitmap : Modificações..
  35. #     - Mouse : Modificação..
  36. #     - Game_Event : Modificação..Add-ons.
  37. # 1.3 :
  38. #     - MessageBox : Sistema da caixa de mensage...
  39. #     - API : Add-ons...
  40. #     - ScreenWindow : Sistema que permite redimensionar a tela do jogo.
  41. #     - Game_Event : Modificações...
  42. # 1.4 :
  43. #     - Sprite : Add-ons..
  44. #     - Input : Módulo do Raizen884
  45. #     - Download : Sistema que permite baixar coisas da net.
  46. # 1.5 :
  47. #     - Sprite : Add-ons...
  48. #     - Game_Event : Add-ons...
  49. #     - API : Add-ons
  50. # 1.6 :
  51. #     - Variable : Módulo para guardar informações de variávels.
  52. #     - Switche : Módulo para guardar informações das switches.
  53. #     - Game_Event : Add-ons..
  54. # 1.7 :
  55. #     - Dax : Add-ons.
  56. #     - Object : Add-ons.
  57. # 1.8 :
  58. #     - ColorBasic : Novo método.
  59. #     - Object : Add-ons.
  60. # 1.9 :
  61. #     - API : Add-ons.
  62. #     - Object : Add-ons.
  63. #     - Window Core : Criado | 1.0
  64. #       - Window Core : Criado.
  65. #       - LetterInput : Criado.
  66. #       - Position and Size : Criado.
  67. #     - Psych : | 0.1
  68. #       - Psych Core: Criado.
  69. #       - LimitScreen : Criado.
  70. # 2.0 :
  71. #     - API : Add-ons.
  72. #     - Mouse : Add-ons.
  73. #     - Drag : Modificado.
  74. #     - Sprite : Add-ons.
  75. #     - Key : Novo módulo de usar todas as teclas do teclado.
  76. #     - Class Games : Add-ons e modificações :
  77. #       - Game_CommonEvent
  78. #     - Window Core : Modificado é atualizado | 1.2
  79. #       - Letter_Input : Modificado.
  80. #     - Object : Modificado.
  81. #     - Psych : Atualizado | 0.2
  82. #       - Path : Criado.
  83. #     - DRGSS | Criado | 0.1
  84. #     - Extension : Criado | 1.0
  85. #       - Mouse : Extensão para o mouse.
  86. #         - Touch_Picture | Criado.
  87. #         - Simple_Touch_Picture | Criado.
  88. #         - Touch_Icon | Criado.
  89. #         - Simple_Touch_Icon | Criado.
  90. # 2.1 :
  91. #     - MessageBox : Removida.
  92. #     - Extension : Atualizado | 1.1
  93. #         - Touch_Text : Criado.
  94. #         - Simple_Touch_Text : Criado.
  95. # 2.5 :
  96. #     - API : Add-ons.
  97. #     - Color : Add-ons.
  98. #     - ColorBasic : Add-ons;
  99. #     - Window Core : Atualizado | 1.3
  100. #       - DesignMenu : Criado.
  101. #         - SampleMenuStrip | Criado
  102. #         - MenuStrip : Criado.
  103. #     - Exension >> Mouse | Add-ons.
  104. #==============================================================================
  105. module Dax
  106.   extend self
  107.   #----------------------------------------------------------------------------
  108.   # • Font
  109.   #   Ajuste aqui as configurações básicas da fonte padrão do jogo.
  110.   #----------------------------------------------------------------------------
  111.   Font.default_name = ["VL Gothic"] # Nome padrão da fonte do jogo.
  112.   Font.default_size = 18 # Tamanho padrão da fonte do jogo.
  113.   Font.default_bold = false # true - Para usar negrito | false - para não usar.
  114.   Font.default_italic = false # true - Para usar italico | false - para não usar.
  115.   Font.default_shadow = false # true - Para usar sombra na fonte | false - para não usar.
  116.   Font.default_outline = true # true - Para usar borda da fonte | false - para não usar.
  117.   Font.default_out_color = Color.new(0, 0, 0) # Cor da fonte padrão da borda da fonte.
  118.   Font.default_color = Color.new(255, 255, 255) # Cor da fonte padrão.
  119.   #----------------------------------------------------------------------------
  120.   # • Variável e constantes.
  121.   #----------------------------------------------------------------------------
  122.   @imported = {} # Importar script.
  123.   @version_imported = {} # Versão do script importado.
  124.   @actor_imported = {} # Autor do script importado.
  125.   Core = true # Chave do módulo.
  126.   Version_PS = 0.2 # Versão do Psych.
  127.   Version_WC = 1.2 # Versão do Window Core.
  128.   Version_EX = 1.1 # Versão do Extension.
  129.   #----------------------------------------------------------------------------
  130.   # • Mouse
  131.   #   Configure aqui, algumas coisas do mouse.
  132.   #----------------------------------------------------------------------------
  133.   # Caso você queira, que não aparece nenhuma imagem ou ícone, representando o
  134.   # cursor do mouse, apenas deixe vázio as áspas. Caso você queira uma imagem,
  135.   # representando o mouse, ponha entre as áspas o nome da imagem, que deve de estar
  136.   # na pasta de Pictures. Caso você queira que um ícone represente o cursor do mouse
  137.   # ponha o ID do ícone no lugar das áspas.
  138.   Mouse_Name = ""
  139.   #----------------------------------------------------------------------------
  140.   # • Registrar script.
  141.   #----------------------------------------------------------------------------
  142.   def register(name, actor="Dax", version=2.5)
  143.     @imported[name] = true
  144.     @version_imported[name] = version
  145.     @actor_imported[name] = actor
  146.   end
  147.   #----------------------------------------------------------------------------
  148.   # • Cria uma condição de requerimento de script.
  149.   #----------------------------------------------------------------------------
  150.   def required(name, actor="Dax", version=2.5)
  151.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  152.   end
  153.   #----------------------------------------------------------------------------
  154.   # • Remover um script existente.
  155.   #----------------------------------------------------------------------------
  156.   def remove(name_symbol)
  157.     Object.send(:remove_const, name_symbol)
  158.   end
  159.   register(:Core)
  160. end
  161. #==============================================================================
  162. # • API
  163. #==============================================================================
  164. Dax.register(:API, 'Dax', 1.0)
  165. module API
  166.   extend self
  167.   #----------------------------------------------------------------------------
  168.   # • Constantes de APIs.
  169.   #----------------------------------------------------------------------------
  170.   # Permite acessar as teclas do teclado.
  171.   GetKeyState    = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  172.   # Permite ativar/desativar o ícone do mouse.
  173.   MouseShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
  174.   # Permite achar a posição do mouse.
  175.   CursorPosition = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  176.   # Permite achar o tamanho da screen.
  177.   ScreenToClient = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  178.   # Permite fazer a leitura do game.ini.
  179.   ReadIni = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  180.   # Permite achar o tamando da window.
  181.   FindWindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
  182.   # API da Message Box.
  183.   MessageBoxA = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i')
  184.   # Recupera uma string especificada de um arquivo em inicialização.
  185.   GetPrivateProfileString = Win32API.new('kernel32', 'GetPrivateProfileStringA',%w(p p p p l p),'l')
  186.   # Get Systeme Metrics  
  187.   GetSystemMetrics = Win32API.new("user32", "GetSystemMetrics", "i", "i")  
  188.   #Set Windows Pos  
  189.   SetWindowPos = Win32API.new("user32", "SetWindowPos", "lliiiii", "i")  
  190.   #Get Windows Rect  
  191.   GetWindowRect = Win32API.new('user32','GetWindowRect',%w(l p),'i')  
  192.   # Define a Win32API do comando print
  193.   MessageBoxW = Win32API.new("user32", "MessageBoxW", "LPPL", "L")
  194.   # Caps Lock
  195.   CapsLock = Win32API.new("user32", "GetKeyState", "i", "i").call(20) != 0
  196.   # State Key
  197.   StateKey = Win32API.new("user32", "GetKeyState", ["i"], "i")
  198.   # SetCursorPos
  199.   SetCursorPos    = Win32API.new("user32", "SetCursorPos", "ll", "i")
  200.   SetCursorPos    = Win32API.new("user32", "SetCursorPos", "ii", "i")
  201.   GetKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  202.   GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  203.   # Criar uma nova pasta.
  204.   CreateDirectory = Win32API.new("kernel32", "CreateDirectory", "p", "lll")
  205.   # Remover uma pasta existente.
  206.   RemoveDirectory = Win32API.new("kernel32", "RemoveDirectory", "p", "l")
  207.  
  208.   #----------------------------------------------------------------------------
  209.   # • createDirectory(name)
  210.   #   name : Nome.
  211.   # Função de criar uma nova pasta...
  212.   #----------------------------------------------------------------------------
  213.   def createDirectory(name)
  214.     CreateDirectory.call(name.to_s)
  215.   end
  216.   #----------------------------------------------------------------------------
  217.   # • removeDirectory(name)
  218.   #   name : Nome.
  219.   # Função de remover uma pasta existente.
  220.   #----------------------------------------------------------------------------
  221.   def removeDirectory(name)
  222.     RemoveDirectory.call(name.to_s)
  223.   end
  224. end
  225. #==============================================================================
  226. # • Color
  227. #==============================================================================
  228. Dax.register(:Color, "Dax", 0.5)
  229. class Color
  230.   #----------------------------------------------------------------------------
  231.   # • Efeito de cor opaca.
  232.   #----------------------------------------------------------------------------
  233.   def opacity
  234.     self.set(self.red, self.green, self.blue, 128)
  235.   end
  236.   #----------------------------------------------------------------------------
  237.   # • Inverter as cores.
  238.   #----------------------------------------------------------------------------
  239.   def invert
  240.     self.set(255-self.red, 255-self.green, 255-self.blue, self.alpha)
  241.   end
  242.   #----------------------------------------------------------------------------
  243.   # • Reverter as cores.
  244.   #----------------------------------------------------------------------------
  245.   def revert
  246.     colors = [self.red, self.green, self.blue, self.alpha].reverse!
  247.     self.set(*colors)
  248.   end
  249. end
  250. #==============================================================================
  251. # • Keyboard | Método para usar todas as teclas do teclado.
  252. #==============================================================================
  253. Dax.register(:Key, "Dax", 1.0)
  254. module Key
  255.   extend self
  256.   #--------------------------------------------------------------------------
  257.   # * Chaves diversos.
  258.   #--------------------------------------------------------------------------
  259.   CANCEL              = 0x03 # Control-Break Processing
  260.   BACKSPACE           = 0x08 # Backspace Key
  261.   TAB                 = 0x09 # Tab Key
  262.   CLEAR               = 0x0C # Clear Key
  263.   RETURN              = 0x0D # Enter Key
  264.   SHIFT               = 0x10 # Shift Key
  265.   CONTROL             = 0x11 # Ctrl Key
  266.   MENU                = 0x12 # Alt Key
  267.   PAUSE               = 0x13 # Pause Key
  268.   ESCAPE              = 0x1B # Esc Key
  269.   CONVERT             = 0x1C # IME Convert Key
  270.   NONCONVERT          = 0x1D # IME Nonconvert Key
  271.   ACCEPT              = 0x1E # IME Accept Key
  272.   SPACE               = 0x20 # Space Bar Key (Space, usually blank)
  273.   PRIOR               = 0x21 # Page Up Key
  274.   NEXT                = 0x22 # Page Down Key
  275.   ENDS                = 0x23 # End Key
  276.   HOME                = 0x24 # Home Key
  277.   LEFT                = 0x25 # Left Arrow Key
  278.   UP                  = 0x26 # Up Arrow Key
  279.   RIGHT               = 0x27 # Right Arrow Key
  280.   DOWN                = 0x28 # Down Arrow Key
  281.   SELECT              = 0x29 # Select Key
  282.   PRINT               = 0x2A # Print Key
  283.   EXECUTE             = 0x2B # Execute Key
  284.   SNAPSHOT            = 0x2C # Print Screen Key
  285.   DELETE              = 0x2E # Delete Key
  286.   HELP                = 0x2F # Help Key
  287.   LSHIFT              = 0xA0 # Left Shift Key
  288.   RSHIFT              = 0xA1 # Right Shift Key
  289.   LCONTROL            = 0xA2 # Left Control Key (Ctrl)
  290.   RCONTROL            = 0xA3 # Right Control Key (Ctrl)
  291.   LMENU               = 0xA4 # Left Menu Key (Alt)
  292.   RMENU               = 0xA5 # Right Menu Key (Alt)
  293.   PACKET              = 0xE7 # Used to Pass Unicode Characters as Keystrokes
  294.   MOUSE_RIGHT         = 0x01 # Button Mouse Right
  295.   MOUSE_LEFT          = 0x02 # Button Mouse Left
  296.   MOUSE_MIDDLE        = 0x04 # Button Mouse Middle
  297.   #--------------------------------------------------------------------------
  298.   # * Chaves de números.
  299.   #--------------------------------------------------------------------------
  300.   N0                  = 0x30 # 0 Key
  301.   N1                  = 0x31 # 1 Key
  302.   N2                  = 0x32 # 2 Key
  303.   N3                  = 0x33 # 3 Key
  304.   N4                  = 0x34 # 4 Key
  305.   N5                  = 0x35 # 5 Key
  306.   N6                  = 0x36 # 6 Key
  307.   N7                  = 0x37 # 7 Key
  308.   N8                  = 0x38 # 8 Key
  309.   N9                  = 0x39 # 9 Key
  310.   #--------------------------------------------------------------------------
  311.   # * Chaves de letras
  312.   #--------------------------------------------------------------------------
  313.   A                   = 0x41 # A Key
  314.   B                   = 0x42 # B Key
  315.   C                   = 0x43 # C Key
  316.   D                   = 0x44 # D Key
  317.   E                   = 0x45 # E Key
  318.   F                   = 0x46 # F Key
  319.   G                   = 0x47 # G Key
  320.   H                   = 0x48 # H Key
  321.   I                   = 0x49 # I Key
  322.   J                   = 0x4A # J Key
  323.   K                   = 0x4B # K Key
  324.   L                   = 0x4C # L Key
  325.   M                   = 0x4D # M Key
  326.   N                   = 0x4E # N Key
  327.   O                   = 0x4F # O Key
  328.   P                   = 0x50 # P Key
  329.   Q                   = 0x51 # Q Key
  330.   R                   = 0x52 # R Key
  331.   S                   = 0x53 # S Key
  332.   T                   = 0x54 # T Key
  333.   U                   = 0x55 # U Key
  334.   V                   = 0x56 # V Key
  335.   W                   = 0x57 # W Key
  336.   X                   = 0x58 # X Key
  337.   Y                   = 0x59 # Y Key
  338.   Z                   = 0x5A # Z Key
  339.   #--------------------------------------------------------------------------
  340.   # * Chaves de windows
  341.   #--------------------------------------------------------------------------
  342.   LWIN                = 0x5B # Left Windows Key (Natural keyboard)
  343.   RWIN                = 0x5C # Right Windows Key (Natural Keyboard)
  344.   APPS                = 0x5D # Applications Key (Natural keyboard)
  345.   SLEEP               = 0x5F # Computer Sleep Key
  346.   BROWSER_BACK        = 0xA6 # Browser Back Key
  347.   BROWSER_FORWARD     = 0xA7 # Browser Forward Key
  348.   BROWSER_REFRESH     = 0xA8 # Browser Refresh Key
  349.   BROWSER_STOP        = 0xA9 # Browser Stop Key
  350.   BROWSER_SEARCH      = 0xAA # Browser Search Key
  351.   BROWSER_FAVORITES   = 0xAB # Browser Favorites Key
  352.   BROWSER_HOME        = 0xAC # Browser Start and Home Key
  353.   VOLUME_MUTE         = 0xAD # Volume Mute Key
  354.   VOLUME_DOWN         = 0xAE # Volume Down Key
  355.   VOLUME_UP           = 0xAF # Volume Up Key
  356.   MEDIA_NEXT_TRACK    = 0xB0 # Next Track Key
  357.   MEDIA_PREV_TRACK    = 0xB1 # Previous Track Key
  358.   MEDIA_STOP          = 0xB2 # Stop Media Key
  359.   MEDIA_PLAY_PAUSE    = 0xB3 # Play/Pause Media Key
  360.   LAUNCH_MAIL         = 0xB4 # Start Mail Key
  361.   LAUNCH_MEDIA_SELECT = 0xB5 # Select Media Key
  362.   LAUNCH_APP1         = 0xB6 # Start Application 1 Key
  363.   LAUNCH_APP2         = 0xB7 # Start Application 2 Key
  364.   PROCESSKEY          = 0xE5 # IME Process Key
  365.   ATTN                = 0xF6 # Attn Key
  366.   CRSEL               = 0xF7 # CrSel Key
  367.   EXSEL               = 0xF8 # ExSel Key
  368.   EREOF               = 0xF9 # Erase EOF Key
  369.   PLAY                = 0xFA # Play Key
  370.   ZOOM                = 0xFB # Zoom Key
  371.   PA1                 = 0xFD # PA1 Key
  372.   #--------------------------------------------------------------------------
  373.   # * Chaves do Numpad
  374.   #--------------------------------------------------------------------------
  375.   NUMPAD0             = 0x60 # Numeric Keypad 0 Key
  376.   NUMPAD1             = 0x61 # Numeric Keypad 1 Key
  377.   NUMPAD2             = 0x62 # Numeric Keypad 2 Key
  378.   NUMPAD3             = 0x63 # Numeric Keypad 3 Key
  379.   NUMPAD4             = 0x64 # Numeric Keypad 4 Key
  380.   NUMPAD5             = 0x65 # Numeric Keypad 5 Key
  381.   NUMPAD6             = 0x66 # Numeric Keypad 6 Key
  382.   NUMPAD7             = 0x67 # Numeric Keypad 7 Key
  383.   NUMPAD8             = 0x68 # Numeric Keypad 8 Key
  384.   NUMPAD9             = 0x69 # Numeric Keypad 9 Key
  385.   MULTIPLY            = 0x6A # Multiply Key (*)
  386.   ADD                 = 0x6B # Add Key (+)
  387.   SEPARATOR           = 0x6C # Separator Key
  388.   SUBTRACT            = 0x6D # Subtract Key (-)
  389.   DECIMAL             = 0x6E # Decimal Key (.)
  390.   DIVIDE              = 0x6F # Divide Key (/)
  391.   #--------------------------------------------------------------------------
  392.   # * Chaves de funções
  393.   #--------------------------------------------------------------------------
  394.   F1                  = 0x70 # F1 Key
  395.   F2                  = 0x71 # F2 Key
  396.   F3                  = 0x72 # F3 Key
  397.   F4                  = 0x73 # F4 Key
  398.   F5                  = 0x74 # F5 Key
  399.   F6                  = 0x75 # F6 Key
  400.   F7                  = 0x76 # F7 Key
  401.   F8                  = 0x77 # F8 Key
  402.   F9                  = 0x78 # F9 Key
  403.   F10                 = 0x79 # F10 Key
  404.   F11                 = 0x7A # F11 Key
  405.   F12                 = 0x7B # F12 Key
  406.   F13                 = 0x7C # F13 Key
  407.   F14                 = 0x7D # F14 Key
  408.   F15                 = 0x7E # F15 Key
  409.   F16                 = 0x7F # F16 Key
  410.   F17                 = 0x80 # F17 Key
  411.   F18                 = 0x81 # F18 Key
  412.   F19                 = 0x82 # F19 Key
  413.   F20                 = 0x83 # F20 Key
  414.   F21                 = 0x84 # F21 Key
  415.   F22                 = 0x85 # F22 Key
  416.   F23                 = 0x86 # F23 Key
  417.   F24                 = 0x87 # F24 Key
  418.   #--------------------------------------------------------------------------
  419.   # * Chaves alternativas
  420.   #--------------------------------------------------------------------------
  421.   CAPITAL             = 0x14 # Caps Lock Key
  422.   KANA                = 0x15 # IME Kana Mode Key
  423.   HANGUL              = 0x15 # IME Hangul Mode Key
  424.   JUNJA               = 0x17 # IME Junja Mode Key
  425.   FINAL               = 0x18 # IME Final Mode Key
  426.   HANJA               = 0x19 # IME Hanja Mode Key
  427.   KANJI               = 0x19 # IME Kanji Mode Key
  428.   MODECHANGE          = 0x1F # IME Mode Change Request Key
  429.   INSERT              = 0x2D # Insert Key
  430.   NUMLOCK             = 0x90 # Num Lock Key
  431.   SCROLL              = 0x91 # Scroll Lock Key
  432.   #--------------------------------------------------------------------------
  433.   # * Chaves OEM, variadas
  434.   #--------------------------------------------------------------------------
  435.   OEM_1               = 0xBA # Misc Characters (; : in USA 101/102 Keyboards)
  436.   OEM_PLUS            = 0xBB # + = Key
  437.   OEM_COMMA           = 0xBC # , < Key
  438.   OEM_MINUS           = 0xBD # - _ Key
  439.   OEM_PERIOD          = 0xBE # . > Key
  440.   OEM_2               = 0xBF # Misc Characters (/ ? in USA 101/102 Keyboards)
  441.   OEM_3               = 0xC0 # Misc Characters (` ~ in USA 101/102 Keyboards)
  442.   OEM_4               = 0xDB # Misc Characters ([ { in USA 101/102 Keyboards)
  443.   OEM_5               = 0xDC # Misc Characters (\ | in USA 101/102 Keyboards)
  444.   OEM_6               = 0xDD # Misc Characters (] } in USA 101/102 Keyboards)
  445.   OEM_7               = 0xDE # Misc Characters (' " in USA 101/102 Keyboards)
  446.   OEM_8               = 0xDF # Misc Characters (Varies by Keyboard)
  447.   OEM_9               = 0xE1 # OEM Specific
  448.   OEM_10              = 0x92 # OEM Specific
  449.   OEM_11              = 0x93 # OEM Specific
  450.   OEM_12              = 0x94 # OEM Specific
  451.   OEM_13              = 0x95 # OEM Specific
  452.   OEM_14              = 0x96 # OEM Specific
  453.   OEM_15              = 0xE3 # OEM Specific
  454.   OEM_16              = 0xE4 # OEM Specific
  455.   OEM_17              = 0xE6 # OEM Specific
  456.   OEM_18              = 0xE9 # OEM Specific
  457.   OEM_19              = 0xEA # OEM Specific
  458.   OEM_20              = 0xEB # OEM Specific
  459.   OEM_21              = 0xEC # OEM Specific
  460.   OEM_22              = 0xED # OEM Specific
  461.   OEM_23              = 0xEE # OEM Specific
  462.   OEM_24              = 0xEF # OEM Specific
  463.   OEM_25              = 0xF1 # OEM Specific
  464.   OEM_26              = 0xF2 # OEM Specific
  465.   OEM_27              = 0xF3 # OEM Specific
  466.   OEM_28              = 0xF4 # OEM Specific
  467.   OEM_29              = 0xF5 # OEM Specific
  468.   OEM_102             = 0xE2 # Angle Bracket or Backslash on RT-102 Keyboards
  469.   OEM_CLEAR           = 0xFE # Clear Key
  470.   #--------------------------------------------------------------------------
  471.   # * Variáveis do módulo.
  472.   #--------------------------------------------------------------------------
  473.   @unpack_string = 'b'*256
  474.   @last_array = '0'*256
  475.   @press = Array.new(256, false)
  476.   @trigger = Array.new(256, false)
  477.   @repeat = Array.new(256, false)
  478.   @release = Array.new(256, false)
  479.   @repeat_counter = Array.new(256, 0)
  480.   @getKeyboardState = API::GetKeyboardState
  481.   @getAsyncKeyState = API::GetAsyncKeyState
  482.   @getKeyboardState.call(@last_array)
  483.   @last_array = @last_array.unpack(@unpack_string)
  484.   for i in 0...@last_array.size
  485.     @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # * Atualização dos objetos do módulo.
  489.   #--------------------------------------------------------------------------
  490.   def self.update
  491.     @trigger = Array.new(256, false)
  492.     @repeat = Array.new(256, false)
  493.     @release = Array.new(256, false)
  494.     array = '0'*256
  495.     @getKeyboardState.call(array)
  496.     array = array.unpack(@unpack_string)
  497.     for i in 0...array.size
  498.       if array[i] != @last_array[i]
  499.         @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  500.         if @repeat_counter[i] <= 0 && @press[i]
  501.           @repeat[i] = true
  502.           @repeat_counter[i] = 15
  503.         end
  504.         if !@press[i]
  505.           @release[i] = true
  506.         else
  507.           @trigger[i] = true
  508.         end
  509.       else
  510.         if @press[i] == true
  511.           @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  512.           @release[i] = true if !@press[i]
  513.         end
  514.         if @repeat_counter[i] > 0 && @press[i] == true
  515.           @repeat_counter[i] -= 1
  516.         elsif @repeat_counter[i] <= 0 && @press[i] == true
  517.           @repeat[i] = true
  518.           @repeat_counter[i] = 3
  519.         elsif @repeat_counter[i] != 0
  520.           @repeat_counter[i] = 0
  521.         end
  522.       end
  523.     end
  524.     @last_array = array
  525.   end
  526.   #--------------------------------------------------------------------------
  527.   # * Get Key Pressed State
  528.   #     key : key index
  529.   #--------------------------------------------------------------------------
  530.   def press?(key)
  531.     return @press[key]
  532.   end
  533.   #--------------------------------------------------------------------------
  534.   # * Get Key Triggered State
  535.   #     key : key index
  536.   #--------------------------------------------------------------------------
  537.   def trigger?(key)
  538.     return @trigger[key]
  539.   end
  540.   #--------------------------------------------------------------------------
  541.   # * Get Key Repeated State
  542.   #     key : key index
  543.   #--------------------------------------------------------------------------
  544.   def repeat?(key)
  545.     return @repeat[key]
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # * Get Key Released State
  549.   #     key : key index
  550.   #--------------------------------------------------------------------------
  551.   def release?(key)
  552.     return @release[key]
  553.   end
  554. end
  555. #==============================================================================
  556. # • Input | Atualização do Key
  557. #==============================================================================
  558. class << Input
  559.   alias key_update update
  560.   def update
  561.     key_update
  562.     Key.update
  563.   end
  564. end
  565. #============================================================================
  566. # • Zone
  567. #============================================================================
  568. Dax.register(:Zone, "Dax", 1.3)
  569. module Zone
  570.   extend self
  571.   #--------------------------------------------------------------------------
  572.   # • Verifica se um objeto está na área. Normal | Rect
  573.   #--------------------------------------------------------------------------
  574.   def rect(object, object2)
  575.     object.x >= object2.x && object.x <= object2.bitmap.width && object.y >= object2.y && object.y <= object2.bitmap.height
  576.   end
  577.   #--------------------------------------------------------------------------
  578.   # • Verifica se um objeto está na área. Círculo | Circle
  579.   #--------------------------------------------------------------------------
  580.   def circle(o, o2, size)
  581.     ( (o.x - o2.x) ** 2) + ( (o.y - o2.y) ** 2) <= (size ** 2)
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # • Verifica se um objeto está na área. Eclipse | Eclipse
  585.   #--------------------------------------------------------------------------
  586.   def eclipse(o, o2)
  587.     rate_x = ((o.x.to_f - o2.x.to_f) ** 2.0 / (o2.src_rect.width / 2.0))
  588.     rate_y = ((o.y.to_f - o2.y.to_f) ** 2.0 / (o2.src_rect.height / 2.0))
  589.     rate_x + rate_y <= 1
  590.   end
  591.   #----------------------------------------------------------------------------
  592.   # • object_in_area?(object, x, y, width, height)
  593.   #   object : Objeto.
  594.   #   x : Coordenadas X.
  595.   #   y : Coordenadas Y.
  596.   #   width : Largura.
  597.   #   heigt : Altura.
  598.   #----------------------------------------------------------------------------
  599.   #  Verifica se algum objeto está na área do object.
  600.   #----------------------------------------------------------------------------
  601.   def object_in_area?(object, x, y, width, height)
  602.     return object.x.between?(x, x + width) && object.y.between?(y, y + height)
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   # • Verifica se um objeto está na área. All | All
  606.   #--------------------------------------------------------------------------
  607.   def full(object, object2, size=0)
  608.     return rect(object, object2) || circle(object, object2, size) || eclipse(object, object2)
  609.   end
  610. end
  611. #==============================================================================
  612. # • Sprite
  613. #==============================================================================
  614. Dax.register(:Sprite, "Dax", 0.2)
  615. class Sprite
  616.   #----------------------------------------------------------------------------
  617.   # • Define aqui uma posição fixa para um objeto.
  618.   #----------------------------------------------------------------------------
  619.   def position(command=0)
  620.     return if command.nil?
  621.     case command
  622.     when 0 then self.x = 0
  623.     when 1 then self.x = Graphics.width / 2 - self.width / 2
  624.     when 2 then self.x = Graphics.width - self.width
  625.     when 3 then self.y = 0
  626.     when 4 then self.y = Graphics.height / 2 - self.height / 2
  627.     when 5 then self.y = Graphics.height - self.height
  628.     when :center
  629.       self.x = Graphics.width / 2 - self.width / 2
  630.       self.y = Graphics.height / 2 - self.height / 2
  631.     when :center_left
  632.       self.x = 0 + add_x
  633.       self.y = Graphics.height / 2 - self.height / 2
  634.     when :center_right
  635.       self.x = Graphics.width - self.height
  636.       self.y = Graphics.height / 2 - self.height / 2
  637.     end
  638.   end
  639.   #----------------------------------------------------------------------------
  640.   # • Se esta no alcance?
  641.   #----------------------------------------------------------------------------
  642.   def range?(pos, margin=0)
  643.     rect = self.src_rect
  644.     if pos.x >= rect.x + margin and pos.y >= rect.y + margin and
  645.       pos.x < rect.x + rect.width - margin and
  646.       pos.y < rect.y + rect.height - margin
  647.       return true
  648.     end
  649.     return false
  650.   end
  651.   #----------------------------------------------------------------------------
  652.   # • Se esta no alcance X?
  653.   #----------------------------------------------------------------------------
  654.   def range_x?(pos, margin=0)
  655.     rect = self.src_rect
  656.     if pos.x >= rect.x + margin and
  657.       pos.x < rect.x + rect.width - margin
  658.       return true
  659.     end
  660.     return false
  661.   end
  662.   #----------------------------------------------------------------------------
  663.   # • Se esta no alcance Y?
  664.   #----------------------------------------------------------------------------
  665.   def range_y?(pos, margin=0)
  666.     rect = self.src_rect
  667.      if pos.y >= rect.y + margin and
  668.       pos.y < rect.y + rect.height - margin
  669.       return true
  670.     end
  671.     return false
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # • Se esta no alcance na borda?
  675.   #--------------------------------------------------------------------------
  676.   def range_border?(pos, bs)
  677.     rect = self.rect(true)
  678.     arect = self.src_rect
  679.     dx = (rect.x - arect.x).abs == 0
  680.     dy = (rect.y - arect.y).abs == 0
  681.     dw = (rect.width - arect.width).abs == 0
  682.     dh = (rect.height - arect.height).abs == 0
  683.     sx = (!dx and pos.x < arect.x)
  684.     sy = (!dy and pos.y < arect.y)
  685.     sw = (!dw and pos.x > arect.x + arect.width)
  686.     sh = (!dh and pos.y > arect.y + arect.height)
  687.     if sx or sy or sw or sh
  688.       return
  689.     end
  690.     border_x = (((pos.x >= (rect.x - bs)) and (pos.x < (rect.x + bs))) or
  691.                 ((pos.x >= (rect.x + rect.width - bs)) and (pos.x < (rect.x + rect.width + bs))))
  692.     border_y = (((pos.y >= (rect.y - bs)) and (pos.y < (rect.y + bs))) or
  693.                 ((pos.y >= (rect.y + rect.height - bs)) and (pos.y < (rect.y + rect.height + bs))))
  694.     in_x = ((pos.x >= (rect.x - bs)) and (pos.x < (rect.x + rect.width + bs)))
  695.     in_y = ((pos.y >= (rect.y - bs)) and (pos.y < (rect.y + rect.height + bs)))
  696.     if ((border_x and in_y) or (border_y and in_x)) and
  697.       return true
  698.     end
  699.     return false
  700.   end
  701. end
  702. #==============================================================================
  703. # • Bitmap
  704. #==============================================================================
  705. Dax.register(:Bitmap, "Dax", 1.2)
  706. class Bitmap
  707.   #----------------------------------------------------------------------------
  708.   # • draw_bar(x, y, current, current_max, file)
  709.   #   x : Coordenadas X.
  710.   #   y : Coordenadas Y.
  711.   #   current : Valor atual da barra.
  712.   #   current_max : Valor maxímo da barra.
  713.   #   file : Imagem da barra.
  714.   #----------------------------------------------------------------------------
  715.   #  Permite adicionar uma barra.
  716.   #----------------------------------------------------------------------------
  717.   def draw_bar(x, y, current, current_max, file, folder=0)
  718.     bitmap = folder == 0 ? Cache.picture(file) : Cache.system(file)
  719.     cw = self.width * current / current_max
  720.     ch = self.height
  721.     src_rect = Rect.new(0, 0, cw, ch)
  722.     self.blt(x, y, bitmap, src_rect)
  723.   end
  724.   #----------------------------------------------------------------------------
  725.   # • draw_bar_gauge(x, y, current, current_max, border, colors)
  726.   #   x : Coordenadas X.
  727.   #   y : Coordenadas Y.
  728.   #   current : Valor atual da barra.
  729.   #   current_max : Valor maxímo da barra.
  730.   #   border : Expressura da borda.
  731.   #   colors : Cores. [0, 1, 2]
  732.   #----------------------------------------------------------------------------
  733.   #  Permite adicionar uma barra.
  734.   #----------------------------------------------------------------------------
  735.   def draw_bar_gauge(x, y, current, current_max, border, colors=[])
  736.     cw = self.width * current / current_max
  737.     ch = self.height
  738.     self._fill(x, y, self.width, self.height, colors[0], colors[0])
  739.     self.gradient_fill_rect(x+border, y+border, self.width-(border/2), self.height-(border/2), colors[1], colors[2])
  740.     src_rect = Rect.new(0, 0, cw, ch)
  741.     self.blt(x, y, self, src_rect)
  742.   end
  743.   #----------------------------------------------------------------------------
  744.   # • draw_icon(icon_index, x, y, enabled)
  745.   #   icon_index : ID do ícone.
  746.   #   x : Coordenadas X.
  747.   #   y : Coordenadas Y.
  748.   #   enabled : Habilitar flag, translucido quando false
  749.   #----------------------------------------------------------------------------  
  750.   #----------------------------------------------------------------------------
  751.   def draw_icon(icon_index, x, y, enabled = true)
  752.     bitmap = Cache.system("Iconset")
  753.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  754.     self.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  755.   end
  756.   #----------------------------------------------------------------------------
  757.   # • _fill(x, y, width, height, color1, color2)
  758.   #   x : Coordenada X.
  759.   #   y : Coordenada Y.
  760.   #   width : Largura da barra.
  761.   #   height : Altura da barra.
  762.   #   color1 : Cor da borda.
  763.   #   color2 : Cor da barra.
  764.   #----------------------------------------------------------------------------
  765.   #  Permite criar uma barra em fill_rect simples.
  766.   #----------------------------------------------------------------------------
  767.   def _fill(x, y, width, height, color1, color2)
  768.     self.fill_rect(x, y, width, height, color1)
  769.     self.fill_rect(x+1, y+1, width-2, height-2, color2)
  770.   end
  771.   #----------------------------------------------------------------------------
  772.   # • gradation_fill_rect(*args)
  773.   #   x : Posição X.
  774.   #   y : Posição Y.
  775.   #   width : Largura da barra.
  776.   #   height : Altura da barra.
  777.   #   color1 : Primeira cor.
  778.   #   color2 : Segunda cor.
  779.   #   aling  : 0 - Gradiação normal, 1 - Gradiação na Vertical, 2 - Gradiação concetrada
  780.   #----------------------------------------------------------------------------  
  781.   #  Faz uma gradiação;
  782.   #----------------------------------------------------------------------------
  783.   def gradation_fill_rect(x, y, width, height, color1, color2, align=0)
  784.     case align
  785.     when 0
  786.       for ix in x...x + width
  787.         red = color1.red + (color2.red - color1.red) * (ix - x) / (width - 1)
  788.         green = color1.green + (color2.green - color1.green) * (ix - x) / (width - 1)
  789.         blue = color1.blue + (color2.blue - color1.blue) * (i - x) / (width - 1)
  790.         alpha = color1.alpha + (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  791.         color = Color.new(red, green, blue, alpha)
  792.         self.fill_rect(ix, y, 1, height, color)
  793.       end
  794.     when 1
  795.       for iy in y...y + height
  796.         red   = color1.red + (color2.red - color1.red) * (iy - y) / (height - 1)
  797.         green = color1.green + (color2.green - color1.green) * (iy - y) / (height - 1)
  798.         blue  = color1.blue + (color2.blue - color1.blue) * (iy - y) / (height - 1)
  799.         alpha = color1.alpha + (color2.alpha - color1.alpha) * (iy - y) / (height - 1)
  800.         color = Color.new(red, green, blue, alpha)
  801.         fill_rect(x, iy, width, 1, color)
  802.       end
  803.     when 2
  804.       for ix in x...x + width
  805.         for ij in y...y + height
  806.           red   = color1.red + (color2.red - color1.red) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  807.           green = color1.green + (color2.green - color1.green) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  808.           blue  = color1.blue + (color2.blue - color1.blue) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  809.           alpha = color1.alpha + (color2.alpha - color1.alpha) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  810.           color = Color.new(red, green, blue, alpha)
  811.           set_pixel(ix, ij, color)
  812.         end
  813.       end
  814.     end
  815.   end
  816.   #----------------------------------------------------------------------------
  817.   # • draw_gradation_gauge(x, y, width, height, current, current_max, border, colors, align)
  818.   #   x : Coordenadas X.
  819.   #   y : Coordenadas Y.
  820.   #   width : Largura da barra.
  821.   #   height : Altura da barra.
  822.   #   current : Valor atual da barra.
  823.   #   current_max : Valor maxímo da barra.
  824.   #   border : Expressura da borda.
  825.   #   colors : Cores. [0, 1, 2]
  826.   #   align : Alinhamento.
  827.   #----------------------------------------------------------------------------
  828.   #  Permite adicionar uma barra.
  829.   #----------------------------------------------------------------------------
  830.   def draw_gradation_gauge(x, y, current, current_max, border, colors=[], align=2)
  831.     cw = self.width * current / current_max
  832.     ch = self.height
  833.     self._fill(x, y, self.width, self.height, colors[0], colors[0])
  834.     self.gradation_fill_rect(x+border, y+border, self.width-(border/2), self.height-(border/2), colors[1], colors[2], align)
  835.     src_rect = Rect.new(0, 0, cw, ch)
  836.     self.blt(x, y, self, src_rect)
  837.   end
  838.   #--------------------------------------------------------------------------
  839.   # • Desenho do gráfico de rosto
  840.   #     face_name  : nome do gráfico de face
  841.   #     face_index : índice do gráfico de face
  842.   #     x          : coordenada X
  843.   #     y          : coordenada Y
  844.   #     enabled    : habilitar flag, translucido quando false
  845.   #--------------------------------------------------------------------------
  846.   def draw_face(face_name, face_index, x, y, enabled = true)
  847.     bitmaps = Cache.face(face_name)
  848.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  849.     self.blt(x, y, bitmaps, rect, enabled ? 255 : translucent_alpha)
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # • Desenho do gráfico de face do herói
  853.   #     actor   : herói
  854.   #     x       : coordenada X
  855.   #     y       : coordenada Y
  856.   #     enabled : habilitar flag, translucido quando false
  857.   #--------------------------------------------------------------------------
  858.   def draw_actor_face(actor, x, y, enabled = true)
  859.     draw_face(actor.face_name, actor.face_index, x, y, enabled)
  860.   end
  861.   #--------------------------------------------------------------------------
  862.   # • Desenho do nível
  863.   #     actor : herói
  864.   #     x     : coordenada X
  865.   #     y     : coordenada Y
  866.   #--------------------------------------------------------------------------
  867.   def draw_actor_level(actor, x, y)
  868.     self.font.name = "Comic Sans MS"
  869.     self.font.color = ColorBasic.yellow
  870.     self.font.size = 18
  871.     self.draw_text(x, y, 32, 20, Vocab::level_a)
  872.     self.font.size = 22
  873.     draw_text(x + 16, y, 32, 20, actor.level, 2)
  874.   end
  875.   #----------------------------------------------------------------------------
  876.   # • Pegar a largura.
  877.   #----------------------------------------------------------------------------
  878.   def get_the_width(lstring)
  879.     string_rect = self.text_size(lstring)
  880.     width = string_rect.width
  881.     return width
  882.   end
  883.   #----------------------------------------------------------------------------
  884.   # • Desenhar um círuclo.
  885.   #----------------------------------------------------------------------------
  886.   def fill_circle(x, y, r, c)
  887.     rr = r*r
  888.     for i in 0...r
  889.       adj = Math.sqrt(rr - (i*i)).ceil
  890.       xd = x - adj
  891.       wd = 2 * adj
  892.       self.fill_rect(xd, y-i, wd, 1, c)
  893.       self.fill_rect(xd, y+i, wd, 1, c)
  894.     end
  895.   end
  896. end
  897. #==============================================================================
  898. # • Mouse
  899. #==============================================================================
  900. Dax.register(:Mouse, "Dax", 1.1)
  901. module Mouse
  902.   extend self
  903.   #--------------------------------------------------------------------------
  904.   # • Inicialização dos objetos.
  905.   #--------------------------------------------------------------------------
  906.   def start
  907.     @cursor = Sprite.new
  908.     @cursor.z = 100000
  909.     x = Dax::Mouse_Name.empty? ? 1 : 0
  910.     API::MouseShowCursor.call(x)
  911.     graphic(Dax::Mouse_Name)
  912.     update
  913.   end
  914.   #--------------------------------------------------------------------------
  915.   # • graphic(graphic_set)
  916.   #   graphic_set : Se for número é um ícone; Se for string é uma imagem.
  917.   #--------------------------------------------------------------------------
  918.   def graphic(graphic_set)
  919.     return if graphic_set.empty? or graphic_set.nil?
  920.     if graphic_set.is_a?(Fixnum)
  921.       @cursor.bitmap = Bitmap.new(24, 24)
  922.       @cursor.bitmap.draw_icon(graphic_set.to_i, 0, 0)
  923.     else
  924.       @cursor.bitmap = Cache.picture(graphic_set.to_s)
  925.     end
  926.   end
  927.   #--------------------------------------------------------------------------
  928.   # • show(visible)
  929.   #   visible : True - para mostrar o mouse | False - para esconder o mouse.
  930.   #--------------------------------------------------------------------------
  931.   def show(visible=true)
  932.     @cursor.visible = visible
  933.   end
  934.   #--------------------------------------------------------------------------
  935.   # • update (Atualização das coordenadas)
  936.   #--------------------------------------------------------------------------
  937.   def update
  938.     return if @cursor.nil?
  939.     @cursor.x, @cursor.y = position
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # • cursor
  943.   #--------------------------------------------------------------------------
  944.   def cursor
  945.     @cursor
  946.   end
  947.   #--------------------------------------------------------------------------
  948.   # • x (Coordenada X do Mouse)
  949.   #--------------------------------------------------------------------------
  950.   def x
  951.     @cursor.x
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # • y (Coordenada Y do Mouse)
  955.   #--------------------------------------------------------------------------
  956.   def y
  957.     @cursor.y
  958.   end
  959.   #--------------------------------------------------------------------------
  960.   # • position (Posição do Mouse!)
  961.   #--------------------------------------------------------------------------
  962.   def position
  963.     x, y = get_client_position
  964.     return x, y
  965.   end
  966.   #--------------------------------------------------------------------------
  967.   # • get_client_position (Posição original do Mouse!)
  968.   #--------------------------------------------------------------------------
  969.   def get_client_position
  970.     pos = [0, 0].pack('ll')
  971.     API::CursorPosition.call(pos)
  972.     API::ScreenToClient.call(WINDOW, pos)
  973.     return pos.unpack('ll')
  974.   end
  975.   #--------------------------------------------------------------------------
  976.   # • find_window (Tamanho da window)
  977.   #--------------------------------------------------------------------------
  978.   def find_window
  979.     game_name = '\0' * 256
  980.     API::ReadIni.call('Game', 'Title', '', game_name, 255, '.\\Game.ini')
  981.     game_name.delete!('\0')
  982.     return API::FindWindow.call('RGSS Player', game_name)
  983.   end
  984.   #--------------------------------------------------------------------------
  985.   # • Verificação se o mouse está na área de um determinado objeto.
  986.   #--------------------------------------------------------------------------
  987.   def in_area?(object_sprite)
  988.     return @cursor.x.between?(object_sprite.x, object_sprite.x + object_sprite.width) &&
  989.       @cursor.y.between?(object_sprite.y, object_sprite.y + object_sprite.height)
  990.   end
  991.   #--------------------------------------------------------------------------
  992.   # • Verificação um objeto está na área do mouse.
  993.   #--------------------------------------------------------------------------
  994.   def object_area?(x, y, xy, yx)
  995.     return Zone.object_in_area?(@cursor, x, y, xy, yx)
  996.   end
  997.   #----------------------------------------------------------------------------
  998.   # • Mudar posição do cursor.
  999.   #----------------------------------------------------------------------------
  1000.   def set_mouse(pos)
  1001.     SetCursorPos.call(pos.x, pos.y)
  1002.     update
  1003.     @cursor.x = @pos.x
  1004.     @cursor.y = @pos.y
  1005.   end
  1006.   #--------------------------------------------------------------------------
  1007.   # • Verificando se o mouse está na zona de um determinado objeto.
  1008.   #--------------------------------------------------------------------------
  1009.   def in_zone?(object, circled=0)
  1010.     Zone.full(self, object, circled)
  1011.   end
  1012.   WINDOW = find_window
  1013. end
  1014. class << DataManager
  1015.   alias init_mouse init
  1016.   def init
  1017.     Mouse.start
  1018.     init_mouse
  1019.   end
  1020. end
  1021. class << Input
  1022.   #----------------------------------------------------------------------------
  1023.   # • Atualização dos objetos.
  1024.   #----------------------------------------------------------------------------
  1025.   alias ds_core_engine_update update
  1026.   def update
  1027.     ds_core_engine_update
  1028.     Mouse.update
  1029.   end
  1030. end
  1031. #==============================================================================
  1032. # • Sprite_Picture
  1033. #==============================================================================
  1034. Dax.register(:Sprite_Picture, "Dax", 1.0)
  1035. class Sprite_Picture
  1036.   #--------------------------------------------------------------------------
  1037.   # • Atualização da tela
  1038.   #--------------------------------------------------------------------------
  1039.   def update
  1040.     super
  1041.     [update_bitmap, update_origin, update_position, update_zoom, update_other].each { |i|
  1042.       if @picture.name != ""
  1043.         i
  1044.       else
  1045.         self.bitmap.dispose unless self.bitmap.nil?
  1046.       end
  1047.     }
  1048.   end
  1049. end
  1050. #==============================================================================
  1051. # • Window_Base
  1052. #==============================================================================
  1053. Dax.register(:Window_Base, "Dax", 1.0)
  1054. class Window_Base < Window
  1055.   #----------------------------------------------------------------------------
  1056.   # • Fixa o lag, gerado pela draw_face.
  1057.   #----------------------------------------------------------------------------
  1058.   def draw_face(face_name, face_index, x, y, enabled = true)
  1059.     bitmap = Cache.face(face_name)
  1060.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  1061.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  1062.   end
  1063. end
  1064. #==============================================================================
  1065. # • Game_Event
  1066. #==============================================================================
  1067. Dax.register(:Game_Event, "Dax", 1.3)
  1068. class Game_Event < Game_Character
  1069.   #----------------------------------------------------------------------------
  1070.   # • check_comment(comment)
  1071.   #   comment : Comentário.
  1072.   #----------------------------------------------------------------------------  
  1073.   #  Permite checar o comentário.
  1074.   #----------------------------------------------------------------------------
  1075.   def check_comment(comment, command=:integer)
  1076.     for item in @list
  1077.       if item.code == 108 or item.code == 408
  1078.         case command
  1079.         when :include?
  1080.           if item.parameters[0].include?(comment)
  1081.             return true
  1082.           else
  1083.             return false
  1084.           end
  1085.         when :integer
  1086.           if item.parameters[0] =~ /#{comment} (\d+)/
  1087.             return $1.to_i
  1088.           end
  1089.           return 0
  1090.         when :string
  1091.           if item.parameters[0] =~ /#{comment} ([^>]*)/
  1092.             return $1
  1093.           end
  1094.           return ""
  1095.         when :word
  1096.           if item.parameters[0] =~ /#{comment} (\w+)/
  1097.             return $1.nil? ? "" : $1.to_s
  1098.           end
  1099.         end
  1100.       end
  1101.     end
  1102.   end
  1103.   #----------------------------------------------------------------------------
  1104.   # • check_name(comment)
  1105.   #----------------------------------------------------------------------------
  1106.   def check_name(comment, command)
  1107.     case command
  1108.     when :include?
  1109.       if event.name.include?(comment)
  1110.         return true
  1111.       end
  1112.       return false
  1113.     when :integer
  1114.       if event.name =~ /#{comment} (\d+)/
  1115.         return $1.to_i
  1116.       end
  1117.     when :word
  1118.       if event.name =~ /#{comment} (\w+))/
  1119.         return $1.to_s
  1120.       end
  1121.     end
  1122.   end
  1123.  
  1124. end
  1125. #==============================================================================
  1126. # • String
  1127. #==============================================================================
  1128. Dax.register(:String, "Dax", 1.0)
  1129. class String
  1130.   #--------------------------------------------------------------------------
  1131.   # • Quebra de linha
  1132.   #--------------------------------------------------------------------------
  1133.   def n
  1134.     expanded = []
  1135.     self.each_line do |line|
  1136.     line.gsub!(/^(.{8}*?)([^\t\r\n]{0,7})\t/) do
  1137.       "#{$1}#{$2}#{' ' * (8 - $2.size)}"
  1138.     end until line !~ /\t/
  1139.     expanded << line
  1140.     end
  1141.     expanded.join
  1142.   end
  1143.   #----------------------------------------------------------------------------
  1144.   # • Transformar em Integer.
  1145.   #----------------------------------------------------------------------------
  1146.   def i
  1147.     return self.to_i(36)
  1148.   end
  1149. end
  1150. #==============================================================================
  1151. # • Integer
  1152. #==============================================================================
  1153. Dax.register(:Integer, "Dax", 0.1)
  1154. class Integer
  1155.   #----------------------------------------------------------------------------
  1156.   # • Transformar em String.
  1157.   #----------------------------------------------------------------------------
  1158.   def s
  1159.     return self.to_s(36)
  1160.   end
  1161. end
  1162. #==============================================================================
  1163. # • Download Module;
  1164. #==============================================================================
  1165. Dax.register(:Download, "Dax & Berka", 1.0)
  1166. module Download
  1167.   #--------------------------------------------------------------------------
  1168.   # » Mensagens de erros.
  1169.   #--------------------------------------------------------------------------
  1170.   module DowError
  1171.     ConIn = "Não foi possível se conectar á Internet."
  1172.     ConFtp = "Não foi possível se conectar ao FTP."
  1173.     DownFtp = "Download ftp falhou."
  1174.     NoFFtpEx = "O arquivo de download não existe."
  1175.     Mkdir = "Não é possível criar um novo diretório."
  1176.     NoFile = "Não existe o arquivo."
  1177.     ConHttp = "Não foi possível conectar ao servidor."
  1178.   end
  1179.   #--------------------------------------------------------------------------
  1180.   # » Net(Principal¹)
  1181.   #--------------------------------------------------------------------------
  1182.   module Net
  1183.     W = 'wininet'
  1184.     SPC = Win32API.new('kernel32', 'SetPriorityClass', 'pi', 'i').call(-1, 128)
  1185.     IOA = Win32API.new(W, 'InternetOpenA', 'plppl', 'i').call('',0,'','',0)
  1186.     IC = Win32API.new(W, 'InternetConnectA', 'lplpplll', 'l')
  1187.     msgbox(DowError::ConIn) if IOA == 0
  1188.     #--------------------------------------------------------------------------
  1189.     # » FTP
  1190.     #--------------------------------------------------------------------------
  1191.     module FTP
  1192.       FSCD = Win32API.new(W, 'FtpSetCurrentDirectoryA', 'lp', 'l')
  1193.       FGF = Win32API.new(W,'FtpGetFileA','lppllll','l')
  1194.       FPF = Win32API.new(W,'FtpPutFile','lppll','l')
  1195.       FCD = Win32API.new(W,'FtpCreateDirectoryA','lp','l')
  1196.       #------------------------------------------------------------------------
  1197.       # » Executa a etapa principal
  1198.       #------------------------------------------------------------------------
  1199.       def self.new
  1200.         ftp = "ftp.server.com"
  1201.         port = 21
  1202.         indentifiant = "user"
  1203.         motdepasse = "password"
  1204.         @fb = IC.call(IOA,ftp,port,identifiant,motdepasse,1,0,0)
  1205.         ftp, port, identifiant, motdepasse = [nil] * 4
  1206.         (msgbox(DowError::ConFtp)) if @fb == 0
  1207.       end
  1208.       #------------------------------------------------------------------------
  1209.       # » Download
  1210.       #------------------------------------------------------------------------
  1211.       def self.download(ext, int = './')
  1212.         self.new if @fb.nil?
  1213.         c = ext.split('/').pop
  1214.         if FSCD.call(@fb,ext)&&File.exist?(int)
  1215.            msgbox(DowError::NoFFtpEx)if FPF.call(@fb,int,ext,2,0)==0
  1216.         else
  1217.            msgbox(DowError::NoFFtpEx)
  1218.         end
  1219.       end
  1220.       #------------------------------------------------------------------------
  1221.       # » Diretório
  1222.       #------------------------------------------------------------------------
  1223.       def self.mkdir(rep)
  1224.         self.new if @fb.nil?
  1225.         msgbox(DowError::Mkdir) if FCD.call(@fb, rep) == 0
  1226.       end
  1227.     end
  1228.     #--------------------------------------------------------------------------
  1229.     # » HTTP
  1230.     #--------------------------------------------------------------------------
  1231.     module HTTP
  1232.      IOU = Win32API.new(W, 'InternetOpenUrl', 'lppllp', 'l')
  1233.      IRF = Win32API.new(W, 'InternetReadFile', 'lpip', 'l')
  1234.      ICH = Win32API.new(W, 'InternetCloseHandle', 'l', 'l')
  1235.      HQI = Win32API.new(W, 'HttpQueryInfo', 'llppp', 'i')
  1236.      #------------------------------------------------------------------------
  1237.      # » Tamanho do load.
  1238.      #------------------------------------------------------------------------
  1239.      def self.sizeloaded(i='')
  1240.        @read[i]
  1241.      end
  1242.      #------------------------------------------------------------------------
  1243.      # » Transferência confirmada
  1244.      #------------------------------------------------------------------------
  1245.      def self.transfered
  1246.        @dloaded
  1247.      end
  1248.      #------------------------------------------------------------------------
  1249.      # » Transferências
  1250.      #------------------------------------------------------------------------
  1251.      def self.transfers
  1252.        @dls
  1253.      end
  1254.      #------------------------------------------------------------------------
  1255.      # » Progresso
  1256.      #------------------------------------------------------------------------
  1257.      def self.progress(i='')
  1258.        (@read[i].to_f / @size[i] * 100)
  1259.      end
  1260.      #------------------------------------------------------------------------
  1261.      # » Carregar
  1262.      #------------------------------------------------------------------------
  1263.      def self.loaded?(i='')
  1264.        @read[i] >= @size[i] rescue nil
  1265.      end
  1266.      #------------------------------------------------------------------------
  1267.      # » Temps
  1268.      #------------------------------------------------------------------------
  1269.      def self.temps(i='')
  1270.        @tps[i] if self.loaded?(i)
  1271.      end
  1272.      #------------------------------------------------------------------------
  1273.      # » Tamanho
  1274.      #------------------------------------------------------------------------
  1275.      def self.size(i='')
  1276.        @size[i]
  1277.      end
  1278.      #------------------------------------------------------------------------
  1279.      # » Download
  1280.      #------------------------------------------------------------------------
  1281.      def self.download(url, int='./')
  1282.         @dloaded ||= 0
  1283.         @dls ||={}
  1284.         @i ||= -1
  1285.         @size ||={}
  1286.         @read ||={}
  1287.         @tps={}
  1288.         a = url.split('/')
  1289.         serv, root, fich =a[2], a[3..a.size].join('/'), a[-1]
  1290.         msgbox(DowError::NoFile) if fich.nil?
  1291.         @dls[fich] = Thread.start(url,int) {|url,int| txt = ''
  1292.          t = Time.now
  1293.          DowError::ConHttp if (e = IC.call(IOA, serv, 80, '', '', 3, 1, 0)) == 0  
  1294.          f = IOU.call(IOA, url, nil, 0, 0, 0)
  1295.          HQI.call(f, 5, k = "\0" * 1024, [k.size-1].pack('l'), nil)
  1296.          @read[fich], @size[fich] = 0, k.delete!("\0").to_i
  1297.          loop do
  1298.            buf, n= ' ' * 1024, 0
  1299.            r = IRF.call(f, buf, 1024, o = [n].pack('i!'))
  1300.            n = o.unpack('i!')[0]
  1301.            break if r&&n == 0
  1302.            txt << buf[0, n]
  1303.            @read[fich]= txt.size
  1304.          end
  1305.         (File.open(int+fich,'wb')<<txt).close
  1306.         @dloaded+=@read[fich]
  1307.         ICH.call(f);sleep(0.01)
  1308.         @tps[fich]=Time.now-t}
  1309.       end
  1310.     end
  1311.   end
  1312.   #--------------------------------------------------------------------------
  1313.   # » Baixa um arquivo de um site.
  1314.   #--------------------------------------------------------------------------
  1315.   def self.url(url)
  1316.     Download::Net::HTTP.download(url)
  1317.   end
  1318. end
  1319. #==============================================================================
  1320. # • Variable
  1321. #==============================================================================
  1322. Dax.register(:Variable)
  1323. class Variables
  1324.   #----------------------------------------------------------------------------
  1325.   # • Iniciar
  1326.   #----------------------------------------------------------------------------
  1327.   def initialize
  1328.     @variable = []
  1329.   end
  1330.   #----------------------------------------------------------------------------
  1331.   # • ID da variável.
  1332.   #----------------------------------------------------------------------------
  1333.   def [](id)
  1334.     @variable[id] || 0
  1335.   end
  1336.   #----------------------------------------------------------------------------
  1337.   # • ID mais valor da variável.
  1338.   #----------------------------------------------------------------------------
  1339.   def []=(id, value)
  1340.     @variable[id] = value
  1341.   end
  1342. end
  1343. #==============================================================================
  1344. # • Switche
  1345. #==============================================================================
  1346. Dax.register(:Switche)
  1347. class Switches
  1348.   #----------------------------------------------------------------------------
  1349.   # • Iniciar
  1350.   #----------------------------------------------------------------------------
  1351.   def initialize
  1352.     @switche = []
  1353.   end
  1354.   #----------------------------------------------------------------------------
  1355.   # • ID da variável.
  1356.   #----------------------------------------------------------------------------
  1357.   def [](id)
  1358.     @switche[id] || false
  1359.   end
  1360.   #----------------------------------------------------------------------------
  1361.   # • ID mais valor da variável.
  1362.   #----------------------------------------------------------------------------
  1363.   def []=(id, value)
  1364.     @switche[id] = value
  1365.   end
  1366. end
  1367. #==============================================================================
  1368. # • DataManager
  1369. #==============================================================================
  1370. class << DataManager
  1371.   #--------------------------------------------------------------------------
  1372.   # • Criação dos objetos do jogo
  1373.   #--------------------------------------------------------------------------
  1374.   alias dax_create_game_objects create_game_objects
  1375.   def create_game_objects
  1376.     dax_create_game_objects
  1377.     $variables = Variables.new
  1378.     $switches = Switches.new
  1379.   end
  1380. end
  1381. #==============================================================================
  1382. # • Object
  1383. #==============================================================================
  1384. Dax.register(:Object)
  1385. class Object
  1386.   #----------------------------------------------------------------------------
  1387.   # • Checar..
  1388.   #----------------------------------------------------------------------------
  1389.   def check(regexp)
  1390.     self.each_line { |check| return true if check =~ /#{regexp}/i }
  1391.     return false
  1392.   end
  1393.   #----------------------------------------------------------------------------
  1394.   # • Trigger
  1395.   #----------------------------------------------------------------------------
  1396.   def trigger?(key)
  1397.     return key.is_a?(Symbol) ? Input.trigger?(key) : Key.trigger?(key)
  1398.   end
  1399.   #----------------------------------------------------------------------------
  1400.   # • Press
  1401.   #----------------------------------------------------------------------------
  1402.   def press?(key)
  1403.     return key.is_a?(Symbol) ? Input.press?(key) : Key.press?(key)
  1404.   end
  1405.   #----------------------------------------------------------------------------
  1406.   # • Repeat
  1407.   #----------------------------------------------------------------------------
  1408.   def repeat?(key)
  1409.     return key.is_a?(Symbol) ? Input.repeat?(key) : Key.repeat?(key)
  1410.   end
  1411.   #----------------------------------------------------------------------------
  1412.   # • Checar Regexp.
  1413.   #----------------------------------------------------------------------------
  1414.   def check_regexp(comment, type=:integer)
  1415.     return /<(?:#{comment.upcase!}|#{comment}):[ ]*(\d+)>/i if type == :integer
  1416.     return /<(?:#{comment.upcase!}|#{comment.downcase!}):[ ]*(\w+)>/i if type == :string
  1417.     return /<(?:#{comment.upcase!}|#{comment.downcase!})>/i if type == :include?
  1418.   end
  1419.   #----------------------------------------------------------------------------
  1420.   # • Chamar a class color.
  1421.   #----------------------------------------------------------------------------
  1422.   def RGB(*args)
  1423.     Color.new(*args)
  1424.   end
  1425. end
  1426. #==============================================================================
  1427. # • ColorBasic
  1428. #==============================================================================
  1429. Dax.register(:ColorBasic, "Dax", 1.2)
  1430. module ColorBasic
  1431.   extend self
  1432.   #----------------------------------------------------------------------------
  1433.   # • Cores básica.
  1434.   #----------------------------------------------------------------------------
  1435.   def new(basic=:white)
  1436.     case basic
  1437.     when :white && -1 then RGB(255, 255, 255)
  1438.     when :black && 7  then RGB(0, 0, 0)
  1439.     when :red && 36  then RGB(255, 0, 0)
  1440.     when :blue && 9  then RGB(0, 0, 255)
  1441.     when :green && 37  then RGB(0, 255, 0)
  1442.     when :yellow && 35  then RGB(255, 255, 0)
  1443.     when :orange && 38 then RGB(255, 128, 0)
  1444.     end
  1445.   end
  1446.   #----------------------------------------------------------------------------
  1447.   # • Cores em Index
  1448.   #----------------------------------------------------------------------------
  1449.   def [](id)
  1450.     case id
  1451.     when -1 then Color.new(255, 255, 255) # White
  1452.     when 0 then Color.new(240, 248, 255) # Alice Blue
  1453.     when 1 then Color.new(250, 235, 215) # Antique_White
  1454.     when 2 then Color.new(0, 255, 255) # Aqua
  1455.     when 3 then Color.new(127, 255, 255) # Aqua Marine
  1456.     when 4 then Color.new(240, 255, 255) # Azure
  1457.     when 5 then Color.new(245, 245, 220) # Beige
  1458.     when 6 then Color.new(255, 228, 196) # Bisque
  1459.     when 7 then Color.new(0, 0, 0) # Black
  1460.     when 8 then Color.new(255, 235, 205) # Blanchedalmond
  1461.     when 9 then Color.new(0, 0, 255) # Blue
  1462.     when 10 then Color.new(138, 43, 226) # Blue Violet
  1463.     when 11 then Color.new(165, 42, 42) # Brown
  1464.     when 12 then Color.new(222, 184, 135) # Burly Wood
  1465.     when 13 then Color.new(93, 158, 160) # Cadet Blue
  1466.     when 14 then Color.new(127, 255, 0) # Chatreuse
  1467.     when 15 then Color.new(210, 105, 30) # Chocolate
  1468.     when 16 then Color.new(255, 127, 80) # Coral
  1469.     when 17 then Color.new(100, 149, 237) # Corn Flower Blue
  1470.     when 18 then Color.new(255, 248, 220) # CornSilk
  1471.     when 19 then Color.new(220, 20, 60) # Crimson
  1472.     when 20 then Color.new(0, 255, 255) # Cyan
  1473.     when 21 then Color.new(0, 0, 139) # DarkBlue
  1474.     when 22 then Color.new(0, 139, 139) # DarkCyan
  1475.     when 23 then Color.new(184, 134, 11) # DarkGoldEnrod
  1476.     when 24 then Color.new(169, 169, 169) # Dark Gray
  1477.     when 25 then Color.new(0, 100, 0) # Dark Green
  1478.     when 26 then Color.new(189, 183, 107) # Dark Khaki
  1479.     when 27 then Color.new(139, 0, 139) # Dark Magenta
  1480.     when 28 then Color.new(85, 107, 47) # Dark Oliver Green
  1481.     when 29 then Color.new(255, 140, 0) # Dark Orange
  1482.     when 30 then Color.new(153, 50, 204) # Dark orchid
  1483.     when 31 then Color.new(139, 0, 0) # Dark Red
  1484.     when 32 then Color.new(233, 150, 120) # Dark Salmon
  1485.     when 33 then Color.new(143, 188, 143) # Dark Sea Green
  1486.     when 34 then Color.new(72, 61, 139) # Dark Slate Blue
  1487.     when 35 then RGB(255, 255, 0) # Yellow
  1488.     when 36 then RGB(255, 0, 0) # Red
  1489.     when 37 then RGB(0, 255, 0) # Green
  1490.     when 38 then RGB(255, 128, 0) # Orange
  1491.     end
  1492.   end
  1493.   #----------------------------------------------------------------------------
  1494.   # • Index das cores usadas para o Design de Windows.
  1495.   #----------------------------------------------------------------------------
  1496.   def window(index)
  1497.     case index.to_i
  1498.     when 0 then RGB(238, 238, 238) # Cinza | Barra de opções
  1499.     when 1 then RGB(165, 172, 178) # Cinza escuro | Barra de opções | Borda
  1500.     when 2 then RGB(255, 148, 40) # Laranja escuro | Barra de opções | Selecionada
  1501.     when 3 then RGB(245, 121, 0) # Laranja escuro ² | Barra de opções | Selecionada | Borda
  1502.     end
  1503.   end
  1504. end
  1505. #==============================================================================
  1506. # • Game_CommonEvent
  1507. #==============================================================================
  1508. Dax.register(:Game_CommonEvent, "Dax", 1.0)
  1509. class Game_CommonEvent
  1510.   #----------------------------------------------------------------------------
  1511.   # • Nova variável.
  1512.   #----------------------------------------------------------------------------
  1513.   alias dax_core_new_variable initialize
  1514.   def initialize(common_event_id)
  1515.     @common_event_id = common_event_id.to_i
  1516.     dax_core_new_variable(common_event_id)
  1517.   end
  1518.   #----------------------------------------------------------------------------
  1519.   # • Achar o nome do evento comum chamado.
  1520.   #----------------------------------------------------------------------------
  1521.   def name
  1522.     return $data_common_events[@common_event_id].name.to_s
  1523.   end
  1524.   #----------------------------------------------------------------------------
  1525.   # • Obter trigger.
  1526.   #----------------------------------------------------------------------------
  1527.   def trigger
  1528.     return $data_common_events[@common_event_id].trigger
  1529.   end
  1530.   #----------------------------------------------------------------------------
  1531.   # • Obter ID da Switche.
  1532.   #----------------------------------------------------------------------------
  1533.   def switche_id
  1534.     return $data_common_events[@common_event_id].switche_id.to_i
  1535.   end
  1536.   #----------------------------------------------------------------------------
  1537.   # • Obter a lista dos comandos.
  1538.   #----------------------------------------------------------------------------
  1539.   def list
  1540.     return $data_common_events[@common_event_id].list
  1541.   end
  1542. end
  1543. #==============================================================================
  1544. # • Window Core
  1545. #==============================================================================
  1546. # Autor: Dax
  1547. # Versão: 1.0
  1548. # Site: www.dax-soft.weebly.com
  1549. # Requerimento: Dax Core 1.9>
  1550. #==============================================================================
  1551. Dax.register(:Window_Core, "Dax", Dax::Version_WC)
  1552. #==============================================================================
  1553. # • WC
  1554. #==============================================================================
  1555. module WC
  1556.   extend self
  1557.   #----------------------------------------------------------------------------
  1558.   # • Variável e constantes.
  1559.   #----------------------------------------------------------------------------
  1560.   @imported = {} # Importar script.
  1561.   @version_imported = {} # Versão do script importado.
  1562.   @actor_imported = {} # Autor do script importado.
  1563.   #----------------------------------------------------------------------------
  1564.   # • Registrar script.
  1565.   #----------------------------------------------------------------------------
  1566.   def register(name, actor="Dax", version=1.0)
  1567.     @imported[name] = true
  1568.     @version_imported[name] = version
  1569.     @actor_imported[name] = actor
  1570.   end
  1571.   #----------------------------------------------------------------------------
  1572.   # • Cria uma condição de requerimento de script.
  1573.   #----------------------------------------------------------------------------
  1574.   def required(name, actor="Dax", version=1.0)
  1575.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  1576.   end
  1577. end
  1578. #==============================================================================
  1579. # • Letter Input
  1580. #==============================================================================
  1581. WC.register(:Letter_Input, "Dax", 1.0)
  1582. module WC::Letter_Input
  1583.   extend self
  1584.   #----------------------------------------------------------------------------
  1585.   # • Variáveis e constantes.
  1586.   #----------------------------------------------------------------------------
  1587.   $acent = nil
  1588.   $times = [25, 25, 25, 25, 25, 25, 25, 25, 25]
  1589.   #----------------------------------------------------------------------------
  1590.   # • Atualização dos objetos do módulo.
  1591.   #----------------------------------------------------------------------------
  1592.   def update
  1593.     $times[0] = $times[$times.size-1] if $times[0] < $times[$times.size-1] and API::StateKey.call(8) == 0
  1594.     $times[1] = $times[$times.size-1] if $times[1] < $times[$times.size-1] and API::StateKey.call(46) == 0
  1595.     $times[2] = $times[$times.size-1] if $times[2] < $times[$times.size-1] and API::StateKey.call(192) == 0
  1596.     $times[3] = $times[$times.size-1] if $times[3] < $times[$times.size-1] and API::StateKey.call(226) == 0
  1597.     $times[4] = $times[$times.size-1] if $times[4] < $times[$times.size-1] and API::StateKey.call(54) == 0
  1598.     $times[5] = $times[$times.size-1] if $times[5] < $times[$times.size-1] and API::StateKey.call(193) == 0
  1599.     $times[6] = $times[$times.size-1] if $times[6] < $times[$times.size-1] and API::StateKey.call(186) == 0
  1600.     $times[7] = $times[$times.size-1] if $times[7] < $times[$times.size-1] and API::StateKey.call(220) == 0
  1601.   end
  1602.   #----------------------------------------------------------------------------
  1603.   # • Input : Teclas.
  1604.   #----------------------------------------------------------------------------
  1605.   def input
  1606.     acent = get_acent
  1607.     na = false
  1608.     if !acent.nil?
  1609.       if $acent.nil?
  1610.         $acent = acent
  1611.         na = true
  1612.       else
  1613.         r = $acent + acent
  1614.         $acent = nil
  1615.         return r
  1616.       end
  1617.     end
  1618.     unless na
  1619.       r = get_symbol
  1620.       if !r.nil?
  1621.         if !$acent.nil?
  1622.           a = $acent
  1623.           $acent = nil
  1624.           return a + r.to_s
  1625.         else
  1626.           return r
  1627.         end
  1628.       end
  1629.       r = get_number
  1630.       if !r.nil?
  1631.         if !$acent.nil?
  1632.           a = $acent
  1633.           $acent = nil
  1634.           return a + r.to_s
  1635.         else
  1636.           return r
  1637.         end
  1638.       end
  1639.     end
  1640.     m = (get_shift or get_caps_lock)
  1641.     if $acent.nil?
  1642.       r = get_character(m)
  1643.       if r == ""
  1644.         if space?
  1645.           r = " "
  1646.         end
  1647.       end
  1648.     else
  1649.       r = get_character_acent($acent, m)
  1650.       if r != ""
  1651.         $acent = nil
  1652.       else
  1653.         if space?
  1654.           a = $acent
  1655.           $acent = nil
  1656.           r = a +  " "
  1657.         end
  1658.       end
  1659.     end
  1660.     return r if !r.empty?
  1661.   end
  1662.   #----------------------------------------------------------------------------
  1663.   # • Teclas.
  1664.   #----------------------------------------------------------------------------
  1665.   def space?; trigger?(Key::SPACE); end;
  1666.   def enter?; trigger?(Key::ENTER); end;
  1667.   def back?; trigger?(Key::BACKSPACE); end;
  1668.   def delete?; trigger?(Key::DELETE); end;
  1669.   def asp?; trigger?(Key::F8); end;
  1670.   def tra?; trigger?(226); end;
  1671.   def num6?; trigger?(Key::NUMPAD6); end;
  1672.   def backslash?; trigger?(193); end;
  1673.   def tc?; trigger?(186); end;
  1674.   def t220?; trigger?(220); end;
  1675.   def end?; trigger?(35); end;
  1676.   #----------------------------------------------------------------------------
  1677.   # • Acento.
  1678.   #----------------------------------------------------------------------------
  1679.   def acent
  1680.     if press?(16) and trigger?(19)
  1681.       return "`"
  1682.     elsif trigger?(19)
  1683.       return "´"
  1684.     elsif press?(16) and trigger?(222)
  1685.       return "^"
  1686.     elsif trigger?(222)
  1687.       return "~"
  1688.     elsif trigger?(54)
  1689.       return "¨"
  1690.     end
  1691.     return nil
  1692.   end
  1693.   #----------------------------------------------------------------------------
  1694.   # • Obter Caps Lock
  1695.   #----------------------------------------------------------------------------
  1696.   def get_caps_lock
  1697.     if API::StateKey.call(20) == 1
  1698.       return true
  1699.     else
  1700.       return false
  1701.     end
  1702.   end
  1703.   #----------------------------------------------------------------------------
  1704.   # • Obter Shift
  1705.   #----------------------------------------------------------------------------
  1706.   def get_shift
  1707.     if press?(Key::Shift)
  1708.       return true
  1709.     end
  1710.     return false
  1711.   end
  1712.   #----------------------------------------------------------------------------
  1713.   # • Obter Characters
  1714.   #----------------------------------------------------------------------------
  1715.   def get_character(up)
  1716.     c = ""
  1717.     if trigger?(Key::A)
  1718.       c = "a"
  1719.     elsif trigger?(Key::B)
  1720.       c = "b"
  1721.     elsif trigger?(Key::C)
  1722.       c = "c"
  1723.     elsif trigger?(Key::D)
  1724.       c = "d"
  1725.     elsif trigger?(Key::E)
  1726.       c = "e"
  1727.     elsif trigger?(Key::F)
  1728.       c = "f"
  1729.     elsif trigger?(Key::G)
  1730.       c = "g"
  1731.     elsif trigger?(Key::H)
  1732.       c = "h"
  1733.     elsif trigger?(Key::I)
  1734.       c = "i"
  1735.     elsif trigger?(Key::J)
  1736.       c = "j"
  1737.     elsif trigger?(Key::K)
  1738.       c = "k"
  1739.     elsif trigger?(Key::L)
  1740.       c = "l"
  1741.     elsif trigger?(Key::M)
  1742.       c = "m"
  1743.     elsif trigger?(Key::N)
  1744.       c = "n"
  1745.     elsif trigger?(Key::O)
  1746.       c = "o"
  1747.     elsif trigger?(Key::P)
  1748.       c = "p"
  1749.     elsif trigger?(Key::Q)
  1750.       c = "q"
  1751.     elsif trigger?(Key::R)
  1752.       c = "r"
  1753.     elsif trigger?(Key::S)
  1754.       c = "s"
  1755.     elsif trigger?(Key::T)
  1756.       c = "t"
  1757.     elsif trigger?(Key::U)
  1758.       c = "u"
  1759.     elsif trigger?(Key::V)
  1760.       c = "v"
  1761.     elsif trigger?(Key::W)
  1762.       c = "w"
  1763.     elsif trigger?(Key::X)
  1764.       c = "x"
  1765.     elsif trigger?(Key::Y)
  1766.       c = "y"
  1767.     elsif trigger?(Key::Z)
  1768.       c = "z"
  1769.     elsif tc?
  1770.       c = "ç"
  1771.     end
  1772.     if up
  1773.       c = c.upcase
  1774.     end
  1775.     return c
  1776.   end
  1777.   #----------------------------------------------------------------------------
  1778.   # • Obter acentos.
  1779.   #----------------------------------------------------------------------------
  1780.   def get_acent
  1781.     if press?(16) and trigger?(219)
  1782.       return "`"
  1783.     elsif trigger?(219)
  1784.       return "´"
  1785.     elsif press?(16) and trigger?(222)
  1786.       return "^"
  1787.     elsif trigger?(222)
  1788.       return "~"
  1789.     elsif press?(16) and trigger?(Key::N6)
  1790.       return "¨"
  1791.     end
  1792.   end
  1793.   #----------------------------------------------------------------------------
  1794.   # • Obter characters com acentos.
  1795.   #----------------------------------------------------------------------------
  1796.   def get_character_acent(acent, up)
  1797.     c = ""
  1798.     if trigger?(Key::A)
  1799.       if up
  1800.         case acent
  1801.         when "`"
  1802.           c = "À"
  1803.         when "´"
  1804.           c = "Á"
  1805.         when "^"
  1806.           c = "Â"
  1807.         when "~"
  1808.           c = "~A"
  1809.         when "¨"
  1810.           c = "Ä"
  1811.         end
  1812.       else
  1813.         case acent
  1814.         when "`"
  1815.           c = "à"
  1816.         when "´"
  1817.           c = "á"
  1818.         when "^"
  1819.           c = "â"
  1820.         when "~"
  1821.           c = "ã"
  1822.         when "¨"
  1823.           c = "ä"
  1824.         end
  1825.       end
  1826.       return c
  1827.     elsif trigger?(Key::E)
  1828.       if up
  1829.         case acent
  1830.         when "`"
  1831.           c = "È"
  1832.         when "´"
  1833.           c = "É"
  1834.         when "^"
  1835.           c = "Ê"
  1836.         when "~"
  1837.           c = "~E"
  1838.         when "¨"
  1839.           c = "Ë"
  1840.         end
  1841.       else
  1842.         case acent
  1843.         when "`"
  1844.           c = "è"
  1845.         when "´"
  1846.           c = "é"
  1847.         when "^"
  1848.           c = "ê"
  1849.         when "~"
  1850.           c = "~e"
  1851.         when "¨"
  1852.           c = "ë"
  1853.         end
  1854.       end
  1855.       return c
  1856.     elsif trigger?(Key::I)
  1857.       if up
  1858.         case acent
  1859.         when "`"
  1860.           c = "Ì"
  1861.         when "´"
  1862.           c = "Í"
  1863.         when "^"
  1864.           c = "Î"
  1865.         when "~"
  1866.           c = "~I"
  1867.         when "¨"
  1868.           c = "Ï"
  1869.         end
  1870.       else
  1871.         case acent
  1872.         when "`"
  1873.           c = "ì"
  1874.         when "´"
  1875.           c = "í"
  1876.         when "^"
  1877.           c = "î"
  1878.         when "~"
  1879.           c = "~i"
  1880.         when "¨"
  1881.           c = "ï"
  1882.         end
  1883.       end
  1884.       return c
  1885.     elsif trigger?(Key::O)
  1886.       if up
  1887.         case acent
  1888.         when "`"
  1889.           c = "Ò"
  1890.         when "´"
  1891.           c = "Ó"
  1892.         when "^"
  1893.           c = "Ô"
  1894.         when "~"
  1895.           c = "~O"
  1896.         when "¨"
  1897.           c = "Ö"
  1898.         end
  1899.       else
  1900.         case acent
  1901.         when "`"
  1902.           c = "ò"
  1903.         when "´"
  1904.           c = "ó"
  1905.         when "^"
  1906.           c = "ô"
  1907.         when "~"
  1908.           c = "õ"
  1909.         when "¨"
  1910.           c = "ö"
  1911.         end
  1912.       end
  1913.       return c
  1914.     elsif trigger?(Key::U)
  1915.       if up
  1916.         case acent
  1917.         when "`"
  1918.           c = "Ù"
  1919.         when "´"
  1920.           c = "Ú"
  1921.         when "^"
  1922.           c = "Û"
  1923.         when "~"
  1924.           c = "~U"
  1925.         when "¨"
  1926.           c = "Ü"
  1927.         end
  1928.       else
  1929.         case acent
  1930.         when "`"
  1931.           c = "ù"
  1932.         when "´"
  1933.           c = "ú"
  1934.         when "^"
  1935.           c = "û"
  1936.         when "~"
  1937.           c = "~u"
  1938.         when "¨"
  1939.           c = "ü"
  1940.         end
  1941.       end
  1942.       return c
  1943.     elsif trigger?(Key::B)
  1944.       c = acent + "b"
  1945.     elsif trigger?(Key::C)
  1946.       c = acent + "c"
  1947.     elsif trigger?(Key::D)
  1948.       c = acent + "d"
  1949.     elsif trigger?(Key::F)
  1950.       c = acent + "f"
  1951.     elsif trigger?(Key::G)
  1952.       c = acent + "g"
  1953.     elsif trigger?(Key::H)
  1954.       c = acent + "h"
  1955.     elsif trigger?(Key::J)
  1956.       c = acent + "j"
  1957.     elsif trigger?(Key::K)
  1958.       c = acent + "k"
  1959.     elsif trigger?(Key::L)
  1960.       c = acent + "l"
  1961.     elsif trigger?(Key::M)
  1962.       c = acent + "m"
  1963.     elsif trigger?(Key::N)
  1964.       c = acent + "n"
  1965.     elsif trigger?(Key::P)
  1966.       c = acent + "p"
  1967.     elsif trigger?(Key::Q)
  1968.       c = acent + "q"
  1969.     elsif trigger?(Key::R)
  1970.       c = acent + "r"
  1971.     elsif trigger?(Key::S)
  1972.       c = acent + "s"
  1973.     elsif trigger?(Key::T)
  1974.       c = acent + "t"
  1975.     elsif trigger?(Key::V)
  1976.       c = acent + "v"
  1977.     elsif trigger?(Key::W)
  1978.       c = acent + "w"
  1979.     elsif trigger?(Key::X)
  1980.       c = acent + "x"
  1981.     elsif trigger?(Key::Y)
  1982.       c = acent + "y"
  1983.     elsif trigger?(Key::Z)
  1984.       c = acent + "z"
  1985.     elsif tc?
  1986.       c = acent + "ç"
  1987.     end
  1988.     if up and c != ""
  1989.       c = c.upcase
  1990.     end
  1991.     return c
  1992.   end
  1993.   #----------------------------------------------------------------------------
  1994.   # • Obter número.
  1995.   #----------------------------------------------------------------------------
  1996.   def get_number
  1997.     if trigger?(Key::N0)
  1998.       c = 0
  1999.     elsif trigger?(Key::N1)
  2000.       c = 1
  2001.     elsif trigger?(Key::N2)
  2002.       c = 2
  2003.     elsif trigger?(Key::N3)
  2004.       c = 3
  2005.     elsif trigger?(Key::N4)
  2006.       c = 4
  2007.     elsif trigger?(Key::N5)
  2008.       c = 5
  2009.     elsif trigger?(Key::N6)
  2010.       c = 6
  2011.     elsif trigger?(Key::N7)
  2012.       c = 7
  2013.     elsif trigger?(Key::N8)
  2014.       c = 8
  2015.     elsif trigger?(Key::N9)
  2016.       c = 9
  2017.     elsif trigger?(Key::NUMPAD0)
  2018.       c = 0
  2019.     elsif trigger?(Key::NUMPAD1)
  2020.       c = 1
  2021.     elsif trigger?(Key::NUMPAD2)
  2022.       c = 2
  2023.     elsif trigger?(Key::NUMPAD3)
  2024.       c = 3
  2025.     elsif trigger?(Key::NUMPAD4)
  2026.       c = 4
  2027.     elsif trigger?(Key::NUMPAD5)
  2028.       c = 5
  2029.     elsif trigger?(Key::NUMPAD6)
  2030.       c = 6
  2031.     elsif trigger?(Key::NUMPAD7)
  2032.       c = 7
  2033.     elsif trigger?(Key::NUMPAD8)
  2034.       c = 8
  2035.     elsif trigger?(Key::NUMPAD9)
  2036.       c = 9
  2037.     end
  2038.   end
  2039.   #----------------------------------------------------------------------------
  2040.   # • Obter simbolos;
  2041.   #----------------------------------------------------------------------------
  2042.   def get_symbol
  2043.     if press?(16) and trigger?(189)
  2044.       c = "_"
  2045.     elsif trigger?(189)
  2046.       c = "-"
  2047.     elsif press?(17) and press?(18) and trigger?(187)
  2048.       c = "§"
  2049.     elsif press?(16) and trigger?(187)
  2050.       c = "+"
  2051.     elsif trigger?(187)
  2052.       c = "="
  2053.     elsif press?(17) and press?(18) and trigger?(221)
  2054.       c = "ª"
  2055.     elsif press?(16) and trigger?(221)
  2056.       c = "{"
  2057.     elsif trigger?(221)
  2058.       c = "["
  2059.     elsif press?(17) and press?(18) and t220?
  2060.       c = "º"
  2061.     elsif press?(16) and t220?
  2062.       c = "}"
  2063.     elsif t220?
  2064.       c = "]"
  2065.     elsif press?(16) and tra?
  2066.       c = "|"
  2067.     elsif tra?
  2068.       c = "\\"
  2069.     elsif press?(16) and trigger?(188)
  2070.       c = "<"
  2071.     elsif trigger?(188)
  2072.       c = ","
  2073.     elsif press?(16) and trigger?(190)
  2074.       c = ">"
  2075.     elsif trigger?(190)
  2076.       c = "."
  2077.     elsif press?(16) and trigger?(191)
  2078.       c = ":"
  2079.     elsif trigger?(191)
  2080.       c = ";"
  2081.     elsif press?(17) and press?(18) and backslash?
  2082.       c = "°"
  2083.     elsif press?(16) and backslash?
  2084.       c = "?"
  2085.     elsif backslash?
  2086.       c = "/"
  2087.     elsif press?(16) and asp?
  2088.       c = "\""
  2089.     elsif asp?
  2090.       c = "'"
  2091.     elsif trigger?(111)
  2092.       c = "/"
  2093.     elsif trigger?(106)
  2094.       c = "*"
  2095.     elsif trigger?(109)
  2096.       c = "-"
  2097.     elsif trigger?(107)
  2098.       c = "+"
  2099.     elsif trigger?(194)
  2100.       c = "."
  2101.     elsif trigger?(110)
  2102.       c = ","
  2103.     elsif press?(16) and trigger?(Key::N0)
  2104.       c = ")"
  2105.     elsif press?(17) and press?(18) and trigger?(Key::N1)
  2106.       c = "¹"
  2107.     elsif press?(16) and trigger?(Key::N1)
  2108.       c = "!"
  2109.     elsif press?(17) and press?(18) and trigger?(Key::N2)
  2110.       c = "²"
  2111.     elsif press?(16) and trigger?(Key::N3)
  2112.       c = "@"
  2113.     elsif press?(17) and press?(18) and trigger?(Key::N3)
  2114.       c = "³"
  2115.     elsif press?(16) and trigger?(Key::N3)
  2116.       c = "#"
  2117.     elsif press?(17) and press?(18) and trigger?(Key::N4)
  2118.       c = "£"
  2119.     elsif press?(16) and trigger?(Key::N4)
  2120.       c = "$"
  2121.     elsif press?(17) and press?(18) and trigger?(Key::N5)
  2122.       c = "¢"
  2123.     elsif press?(16) and trigger?(Key::N5)
  2124.       c = "%"
  2125.     elsif press?(17) and press?(18) and trigger?(Key::N6)
  2126.       c = "¬"
  2127.     elsif press?(16) and trigger?(Key::N7)
  2128.       c = "&"
  2129.     elsif press?(16) and trigger?(Key::N8)
  2130.       c = "*"
  2131.     elsif press?(16) and trigger?(Key::N9)
  2132.       c = "("
  2133.     end
  2134.   end
  2135. end
  2136.  
  2137. class << Input
  2138.   alias method_letter_input_update update
  2139.   def update
  2140.     method_letter_input_update
  2141.     WC::Letter_Input.update
  2142.   end
  2143. end
  2144. #==============================================================================
  2145. # • Position
  2146. #==============================================================================
  2147. WC.register(:Pos_Size, "Dax", 1.0)
  2148. class WC::Position < Struct.new(:x, :y)
  2149.   #----------------------------------------------------------------------------
  2150.   # • Inicialização dos objetos.
  2151.   #----------------------------------------------------------------------------
  2152.   def initialize(x, y)
  2153.     self.x = x.to_i
  2154.     self.y = y.to_i
  2155.   end
  2156.   #----------------------------------------------------------------------------
  2157.   # • Add.
  2158.   #----------------------------------------------------------------------------
  2159.   def +(add)
  2160.     rst = WC::Position.new(self.x, self.y)
  2161.     rst.x += add.x.to_i
  2162.     rst.y += add.y.to_i
  2163.     rst
  2164.   end
  2165.   #----------------------------------------------------------------------------
  2166.   # • Sub.
  2167.   #----------------------------------------------------------------------------
  2168.   def -(add)
  2169.     rst = WC::Position.new(self.x, self.y)
  2170.     rst.x -= add.x.to_i
  2171.     rst.y -= add.y.to_i
  2172.     rst
  2173.   end
  2174.   #----------------------------------------------------------------------------
  2175.   # • Set
  2176.   #----------------------------------------------------------------------------
  2177.   def set(pos)
  2178.     self.x = pos.x.to_i
  2179.     self.y = pos.y.to_i
  2180.   end
  2181.   #----------------------------------------------------------------------------
  2182.   # • Inspecionar
  2183.   #----------------------------------------------------------------------------
  2184.   def inspects
  2185.     "WC_Position#{self.to_s}"
  2186.   end
  2187.   #----------------------------------------------------------------------------
  2188.   # • Converter para string.
  2189.   #----------------------------------------------------------------------------
  2190.   def to_s
  2191.     "(#{self.x}, #{self.y})"
  2192.   end
  2193.   #----------------------------------------------------------------------------
  2194.   # • Converter para array.
  2195.   #----------------------------------------------------------------------------
  2196.   def to_a
  2197.     [self.x, self.y]
  2198.   end
  2199.   #----------------------------------------------------------------------------
  2200.   # • Achar o tamanho.
  2201.   #----------------------------------------------------------------------------
  2202.   def to_size
  2203.     WC::Size.new(self.x, self.y)
  2204.   end
  2205.   #----------------------------------------------------------------------------
  2206.   # • Verificar.
  2207.   #----------------------------------------------------------------------------
  2208.   def ==(obj)
  2209.     unless obj.is_a?(WC::Position)
  2210.       return false      
  2211.     end
  2212.     if self.x == obj.x and self.y == obj.y
  2213.       return true
  2214.     end
  2215.     return false
  2216.   end
  2217.   #----------------------------------------------------------------------------
  2218.   # • Converter para um valor bruto.
  2219.   #----------------------------------------------------------------------------
  2220.   def abs
  2221.     WC::Position.new(self.x.abs, self.y.abs)
  2222.   end
  2223. end
  2224. #==============================================================================
  2225. # • Size
  2226. #==============================================================================
  2227. WC.register(:Size, "Dax", 1.0)
  2228. class WC::Size < Struct.new(:width, :height)
  2229.   #----------------------------------------------------------------------------
  2230.   # • Add.
  2231.   #----------------------------------------------------------------------------
  2232.   def +(add)
  2233.     rst = WC::Size.new(self.width, self.height)
  2234.     rst.width += add.width
  2235.     rst.height += add.height
  2236.     rst
  2237.   end
  2238.   #----------------------------------------------------------------------------
  2239.   # • Sub.
  2240.   #----------------------------------------------------------------------------
  2241.   def -(add)
  2242.     rst = WC::Size.new(self.width, self.height)
  2243.     rst.width -= add.width
  2244.     rst.height -= add.height
  2245.     rst
  2246.   end
  2247.   #----------------------------------------------------------------------------
  2248.   # • Set
  2249.   #----------------------------------------------------------------------------
  2250.   def set(size)
  2251.     self.width = size.width
  2252.     self.height = size.height
  2253.   end
  2254.   #----------------------------------------------------------------------------
  2255.   # • Inspecionar
  2256.   #----------------------------------------------------------------------------
  2257.   def inspect
  2258.     "WC_Size#{self.to_s}"
  2259.   end
  2260.   #----------------------------------------------------------------------------
  2261.   # • Converter para string.
  2262.   #----------------------------------------------------------------------------
  2263.   def to_s
  2264.     "(#{self.width}, #{self.height})"
  2265.   end
  2266.   #----------------------------------------------------------------------------
  2267.   # • Converter para array.
  2268.   #----------------------------------------------------------------------------
  2269.   def to_a
  2270.     [self.width, self.height]
  2271.   end
  2272.   #----------------------------------------------------------------------------
  2273.   # • Converter para posição.
  2274.   #----------------------------------------------------------------------------
  2275.   def to_position
  2276.     WC::Position.new(self.width, self.height)
  2277.   end
  2278.   #----------------------------------------------------------------------------
  2279.   # • Igual
  2280.   #----------------------------------------------------------------------------
  2281.   def ==(s)
  2282.     unless s.is_a?(WC::Size)
  2283.       return false      
  2284.     end
  2285.     if self.width == s.width and self.height == s.height
  2286.       return true
  2287.     else
  2288.       return false
  2289.     end
  2290.   end
  2291.   #----------------------------------------------------------------------------
  2292.   # • Converter para valor bruto.
  2293.   #----------------------------------------------------------------------------
  2294.   def abs
  2295.     WC::Size.new(self.width.abs, self.height.abs)
  2296.   end
  2297. end
  2298. #==============================================================================
  2299. # • Kernel
  2300. #==============================================================================
  2301. WC.register(:Kernel, "Dax", 1.0)
  2302. module Kernel
  2303.   #----------------------------------------------------------------------------
  2304.   # • Achar a posição.
  2305.   #----------------------------------------------------------------------------
  2306.   def wc_pos(x, y)
  2307.     WC::Position.new(x, y)
  2308.   end
  2309.   #----------------------------------------------------------------------------
  2310.   # • Achar o tamanho.
  2311.   #----------------------------------------------------------------------------
  2312.   def wc_size(w, h)
  2313.     WC::Size.new(w, h)
  2314.   end
  2315. end
  2316. #==============================================================================
  2317. # • DesignMenu
  2318. #==============================================================================
  2319. WC.register(:DesignMenu, "Dax", 1.0)
  2320. module WC::DesignMenu
  2321.   #============================================================================
  2322.   # • SampleMenuStripButton |
  2323.   #============================================================================
  2324.   class SampleMenuStripButton < Sprite
  2325.     #--------------------------------------------------------------------------
  2326.     # • Variáveis públicas da instância.
  2327.     #--------------------------------------------------------------------------
  2328.     attr_reader  :area
  2329.     #--------------------------------------------------------------------------
  2330.     # • Inicialização dos objetos.
  2331.     #     title : Título do comando.
  2332.     #     action : Ação do comando.
  2333.     #     x : Posição X.
  2334.     #     y : Posição Y.
  2335.     #     z : Altura.
  2336.     #--------------------------------------------------------------------------
  2337.     def initialize(action, x, y, z)
  2338.       super()
  2339.       self.x, self.y, self.z = x, y, z
  2340.       self.bitmap = Bitmap.new(64, 20)
  2341.       @action = action.to_s
  2342.       self.bitmap.clear
  2343.       self.bitmap.fill_rect(0, 0, self.width, self.height, ColorBasic.window(1))
  2344.       self.bitmap.fill_rect(0, 0, self.width, self.height-1, ColorBasic[-1])
  2345.       self.bitmap.fill_rect(0, 0, self.width, self.height-2, ColorBasic.window(0))
  2346.       @clicked = false
  2347.       @area = false
  2348.     end
  2349.     #--------------------------------------------------------------------------
  2350.     # • Renovar os objetos.
  2351.     #--------------------------------------------------------------------------
  2352.     def dispose
  2353.       self.bitmap.dispose unless self.bitmap.disposed?
  2354.       super
  2355.     end
  2356.     #--------------------------------------------------------------------------
  2357.     # • Atualização dos objetos.
  2358.     #--------------------------------------------------------------------------
  2359.     def update(switche)
  2360.       if Mouse.in_area?(self)
  2361.         if switche
  2362.           on_area
  2363.           @clicked = trigger?(0x01) or repeat?(0x01)
  2364.           action if @clicked && trigger?(0x01) && repeat?(0x01)
  2365.         end
  2366.       else
  2367.         off_area
  2368.         @clicked = false if trigger?(0x01) or repeat?(0x01)
  2369.       end
  2370.     end
  2371.     #--------------------------------------------------------------------------
  2372.     # • Ação do comando.
  2373.     #--------------------------------------------------------------------------
  2374.     def action
  2375.     end
  2376.     #--------------------------------------------------------------------------
  2377.     # • Efeito fora da área.
  2378.     #--------------------------------------------------------------------------
  2379.     def off_area
  2380.       @area = false
  2381.       self.bitmap.fill_rect(0, 0, self.width, self.height-2, ColorBasic.window(0))
  2382.     end
  2383.     #--------------------------------------------------------------------------
  2384.     # • Efeito dentro da área.
  2385.     #--------------------------------------------------------------------------
  2386.     def on_area
  2387.       @area = true
  2388.       self.bitmap.fill_rect(0, 0, self.width, self.height-2, ColorBasic.window(2))
  2389.     end
  2390.   end
  2391.   #============================================================================
  2392.   # • MenuStrip
  2393.   #============================================================================
  2394.   class MenuStrip
  2395.     #--------------------------------------------------------------------------
  2396.     # • Inicialização dos objetos.
  2397.     #--------------------------------------------------------------------------
  2398.     def initialize(number,x,y,z,titles,actions,switche)
  2399.       @number = number rescue 0
  2400.       @titles = titles
  2401.       @actions = actions
  2402.       @x, @y, @z = x, y, z
  2403.       @sample = []
  2404.       @text = []
  2405.       @switche = switche
  2406.       (0..@number).each do |i|
  2407.         @sample[i] = SampleMenuStripButton.new(@actions[i], @x + (64 * i+1), @y, @z)
  2408.         @text[i] = Sprite.new
  2409.         @text[i].x, @text[i].y, @text[i].z = @x + (64 * i+1), @y, @z+1
  2410.         @text[i].bitmap = Bitmap.new(64, 22)
  2411.         @text[i].bitmap.font.name = "Arial"
  2412.         @text[i].bitmap.font.size = 14
  2413.         @text[i].bitmap.font.outline = false
  2414.         @text[i].color = ColorBasic[7]
  2415.         @text[i].bitmap.draw_text(0, -2, 64, 22, @titles[i], 1)
  2416.       end
  2417.     end
  2418.     #--------------------------------------------------------------------------
  2419.     # • Renovação dos objetos.
  2420.     #--------------------------------------------------------------------------
  2421.     def dispose
  2422.       @sample.each { |i| i.dispose }
  2423.       @text.each { |i| i.dispose }
  2424.     end
  2425.     #--------------------------------------------------------------------------
  2426.     # • Atualização dos objetos.
  2427.     #--------------------------------------------------------------------------
  2428.     def update
  2429.       (0..@number).each { |i|
  2430.         @sample[i].update(@switche[i])
  2431.         if @sample[i].area
  2432.           @text[i].color = ColorBasic[-1]
  2433.         else
  2434.           @text[i].color = ColorBasic[7]
  2435.         end
  2436.       }
  2437.     end
  2438.   end
  2439. end
  2440. #==============================================================================
  2441. # • Psych Core
  2442. #==============================================================================
  2443. # Autor: Dax
  2444. # Versão: 0.1
  2445. # Site: www.dax-soft.weebly.com
  2446. # Requerimento: Dax Core 1.9
  2447. #==============================================================================
  2448. # • Descrição:
  2449. #------------------------------------------------------------------------------
  2450. #  Trata-se de vários scripts para proporcionar uma física simples.
  2451. #==============================================================================
  2452. Dax.register(:Psych_Core, "Dax", Dax::Version_PS)
  2453. module PS
  2454.   extend self
  2455.   #----------------------------------------------------------------------------
  2456.   # • Variável e constantes.
  2457.   #----------------------------------------------------------------------------
  2458.   @imported = {} # Importar script.
  2459.   @version_imported = {} # Versão do script importado.
  2460.   @actor_imported = {} # Autor do script importado.
  2461.   #----------------------------------------------------------------------------
  2462.   # • Registrar script.
  2463.   #----------------------------------------------------------------------------
  2464.   def register(name, actor="Dax", version=Dax::Version_PS)
  2465.     @imported[name] = true
  2466.     @version_imported[name] = version
  2467.     @actor_imported[name] = actor
  2468.   end
  2469.   #----------------------------------------------------------------------------
  2470.   # • Cria uma condição de requerimento de script.
  2471.   #----------------------------------------------------------------------------
  2472.   def required(name, actor="Dax", version=Dax::Version_PS)
  2473.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  2474.   end
  2475. end
  2476. #==============================================================================
  2477. # • LimitScreen | Sisetma que cria uma condição para o objeto não passar os limites da tela.
  2478. #==============================================================================
  2479. PS.register(:LimitScreen, "Dax", 1.0)
  2480. class PS::LimitScreen
  2481.   #----------------------------------------------------------------------------
  2482.   # • Inicialização dos objetos.
  2483.   #----------------------------------------------------------------------------
  2484.   def initialize(object, limit_screen=[Graphics.width, Graphics.height])
  2485.     @object = object
  2486.     @limit_screen = limit_screen
  2487.     up?
  2488.     down?
  2489.     left?
  2490.     right?
  2491.   end
  2492.   #----------------------------------------------------------------------------
  2493.   # • Verificar se o objeto está tentando passar do limite de cima.
  2494.   #----------------------------------------------------------------------------
  2495.   def up?
  2496.     if @object.y <= 0
  2497.       @object.y = 0
  2498.     end
  2499.   end
  2500.   #----------------------------------------------------------------------------
  2501.   # • Verificar se o objeto está tentando passar do limite de baixo.
  2502.   #----------------------------------------------------------------------------
  2503.   def down?
  2504.     if @object.y >= @limit_screen[1] - @object.height
  2505.       @object.y = @limit_screen[1] - @object.height
  2506.     end
  2507.   end
  2508.   #----------------------------------------------------------------------------
  2509.   # • Verificar se o objeto está tentando passar do limite da esquerda.
  2510.   #----------------------------------------------------------------------------
  2511.   def left?
  2512.     if @object.x <= 0
  2513.       @object.x = 0
  2514.     end
  2515.   end
  2516.   #----------------------------------------------------------------------------
  2517.   # • Verificar se o object está tentando passar do limite da direita.
  2518.   #----------------------------------------------------------------------------
  2519.   def right?
  2520.     if @object.x >= @limit_screen[0] - @object.width
  2521.       @object.x = @limit_screen[0] - @object.height
  2522.     end
  2523.   end
  2524. end
  2525. #==============================================================================
  2526. # • Path
  2527. #==============================================================================
  2528. PS.register(:Path, "Dax", 1.0)
  2529. module Path
  2530.   extend self
  2531.   #----------------------------------------------------------------------------
  2532.   # • Checar a distância de um objeto com outro.
  2533.   #----------------------------------------------------------------------------
  2534.   def distance(x, x², y, y²)
  2535.     rise = x² -
  2536.     rub = x - y
  2537.     hypo_math = Math.hypot(rise, rub)
  2538.     return hypo_math
  2539.   end
  2540.   #----------------------------------------------------------------------------
  2541.   # • Verificar o caminho "a pé" até o alvo.
  2542.   #----------------------------------------------------------------------------
  2543.   def check_path(init_x, init_y, term_x, term_y, exclude=false)
  2544.     quadrant = term_y > init_y ? term_x > init_x ? 3 : 1 : term_x > init_x ? 9 : 7
  2545.     vert = ((term_x - init_x).abs < (term_y - init_y).abs)
  2546.     cardinal = vert ? (term_y > init_y ? 2 : 8) : (term_x > init_x ? 6 : 4)
  2547.     for test in 1..2
  2548.       jog = 0
  2549.       loop do
  2550.         pablo_x = init_x
  2551.         pablo_y = init_y
  2552.         steps = 0
  2553.         check = false
  2554.         loop do
  2555.           case test
  2556.           when 1
  2557.             if steps >= jog
  2558.               move_along = (pablo_x == term_x or pablo_y == term_y) ? 'card' : 'quad'
  2559.             else
  2560.               move_along = 'card'
  2561.             end
  2562.           when 2
  2563.             if steps >= jog
  2564.               move_along = ((pablo_x - term_x).abs == (pablo_y - term_y).abs) ? 'quad' : 'card'
  2565.             else
  2566.               move_along = 'quad'
  2567.             end
  2568.           end
  2569.           check_x = pablo_x
  2570.           check_y = pablo_y
  2571.           check_dir = move_along == 'quad' ? quadrant : cardinal
  2572.           exclude_coords = exclude ? [term_x, term_y] : nil
  2573.           if !@map.path_pass?(check_x, check_y, check_dir, exclude_coords)
  2574.             check = false
  2575.             break
  2576.           end
  2577.           d = move_along == 'quad' ? quadrant : cardinal
  2578.           pablo_x += (d%3==0) ? 1 : (d%3==1) ? -1 : 0
  2579.           pablo_y += ((d-1)/3==0) ? 1 : ((d-1)/3==2) ? -1 : 0
  2580.           steps += 1
  2581.           if pablo_x == term_x and pablo_y == term_y
  2582.             check = true
  2583.             break
  2584.           end
  2585.         end
  2586.         return [test, jog] if check
  2587.         jog += 1
  2588.         stop = ((init_x - term_x).abs - (init_y - term_y).abs).abs
  2589.         if test == 1
  2590.           break if jog > (vert ? (init_y-term_y).abs : (init_x-term_x).abs) - stop
  2591.         else
  2592.           break if jog > stop
  2593.         end
  2594.       end
  2595.     end
  2596.     return nil
  2597.   end
  2598.   #----------------------------------------------------------------------------
  2599.   # • Obter alcance
  2600.   #----------------------------------------------------------------------------
  2601.   def get_range(x, y)
  2602.     points = []
  2603.     graphics_counter = 0
  2604.     for check_x in 6...20
  2605.       for check_y in 1..15
  2606.         next if check_x == start_x and check_y == start_y
  2607.         if !check_path(start_x, start_y, check_x, check_y).nil?
  2608.           points.push([check_x, check_y])
  2609.         end
  2610.         graphics_counter += 1
  2611.         if graphics_counter == 50
  2612.           graphics_counter = 0
  2613.           Graphics.update
  2614.         end
  2615.       end
  2616.     end
  2617.     return points
  2618.   end
  2619.   #----------------------------------------------------------------------------
  2620.   # • Encontrar o lado mais próximo;
  2621.   #----------------------------------------------------------------------------
  2622.   def find_closest_side(start_x, start_y, target_x, target_y)
  2623.     possibles = []
  2624.     distances = []
  2625.     for i in 0..3
  2626.       check_x = target_x
  2627.       check_y = target_y
  2628.       check_x += (i == 1) ? -1 : (i == 2) ? 1 : 0
  2629.       check_y += (i == 3) ? -1 : (i == 0) ? 1 : 0
  2630.       blockage = check_path(start_x, start_y, check_x, check_y)
  2631.       if !blockage.nil?
  2632.         possibles.push([check_x, check_y])
  2633.         distances.push(distance(start_x, start_y, check_x, check_y))
  2634.       end
  2635.     end
  2636.     return nil if possibles.empty?
  2637.     return possibles[distances.index(distances.min)]
  2638.   end
  2639.   #----------------------------------------------------------------------------
  2640.   # • Escolha o lugar de destino com base numa restrição.
  2641.   #----------------------------------------------------------------------------
  2642.   def apply_restriction(init_x, init_y, term_x, term_y, restriction)
  2643.     if restriction.nil?
  2644.       return find_closest_side(init_x, init_y, term_x, term_y)
  2645.     end
  2646.     return [term_x, term_y]
  2647.   end
  2648.   #----------------------------------------------------------------------------
  2649.   # • Criar um caminho para o alvo.
  2650.   #----------------------------------------------------------------------------
  2651.   def get_nodes(pablo_x, pablo_y, target_x, target_y, restriction=nil, dir=nil)
  2652.     nodes = []
  2653.     goto = apply_restriction(pablo_x, pablo_y, target_x, target_y, restriction)
  2654.     goto = [target_x, target_y] if goto.nil?
  2655.     goto_x = goto[0]
  2656.     goto_y = goto[1]
  2657.     path = check_path(pablo_x, pablo_y, goto_x, goto_y, !restriction.nil?)
  2658.     if !path.nil?
  2659.       node = [goto_x, goto_y] + path
  2660.       nodes.push(node)
  2661.       return nodes
  2662.     else
  2663.       @save_info = true
  2664.       range = get_range(pablo_x, pablo_y)
  2665.       stones = []
  2666.       stones_steps = []
  2667.       for i in range
  2668.         if restriction.nil?
  2669.           point = apply_restriction(i[0], i[1], target_x, target_y, restriction)
  2670.           next if point.nil?
  2671.         else
  2672.           next if check_path(i[0], i[1], target_x, target_y, true).nil?
  2673.         end
  2674.         stones.push(i)
  2675.         steps = distance(pablo_x, pablo_y, i[0], i[1]) +
  2676.                 distance(goto_x, goto_y, i[0], i[1])
  2677.         stones_steps.push(steps)
  2678.       end
  2679.       if stones.empty?
  2680.         msgbox 'Falha no calculo da rota...'
  2681.       else
  2682.         best_stone = stones[stones_steps.index(stones_steps.min)]
  2683.         best_path = check_path(pablo_x, pablo_y, best_stone[0], best_stone[1])
  2684.         if restriction.nil?
  2685.           final_place = find_closest_side(best_stone[0], best_stone[1], goto_x, goto_y)
  2686.         else
  2687.           final_place = [goto_x, goto_y]
  2688.         end
  2689.         final_path = check_path(best_stone[0], best_stone[1], final_place[0], final_place[1], !restriction.nil?)
  2690.         nodes.push(best_stone+best_path, final_place+final_path)
  2691.         return nodes
  2692.       end
  2693.     end
  2694.   end
  2695.   #----------------------------------------------------------------------------
  2696.   # • Criar um caminho para o alvo.
  2697.   #----------------------------------------------------------------------------
  2698.   def create_path(mover_ev, target_ev, restriction=nil, dir=nil)
  2699.     @map = $game_map
  2700.     mover = @map.map.events[mover_ev.id]
  2701.     target = @map.map.events[target_ev.id]
  2702.     target_x = target.x
  2703.     target_y = target.y
  2704.     if !restriction.nil?
  2705.       if restriction == 'path_object'
  2706.         target_x += (dir == 6) ? -1 : (dir == 4) ? 1 : 0
  2707.         target_y += (dir == 8) ? 1 : (dir == 2) ? -2 : -1
  2708.       elsif restriction == 'exit'
  2709.         target_y += (dir == 4 or dir == 6) ? -1 : 0
  2710.       elsif restriction == 'force_dir'
  2711.         target_x += (dir == 4) ? -1 : (dir == 6) ? 1 : 0
  2712.         target_y += (dir == 8) ? -1 : (dir == 2) ? 1 : 0
  2713.       end
  2714.     end
  2715.     pablo_x = mover.x
  2716.     pablo_y = mover.y
  2717.     nodes = get_nodes(pablo_x, pablo_y, target_x, target_y, restriction, dir)
  2718.     route_nums = []
  2719.     for node in nodes
  2720.       target_x = node[0]
  2721.       target_y = node[1]
  2722.       pattern = node[2]
  2723.       jog_at = node[3]
  2724.       quadrant = target_y > pablo_y ? target_x > pablo_x ? 6 : 5 : target_x > pablo_x ? 8 : 7
  2725.  
  2726.       vert = ((target_x - pablo_x).abs < (target_y - pablo_y).abs)
  2727.       cardinal = vert ? (target_y > pablo_y ? 1 : 4) : (target_x > pablo_x ? 3 : 2)
  2728.       steps = [(target_x - pablo_x).abs, (target_y - pablo_y).abs].max
  2729.       if pattern == 1
  2730.         jog_length = [(target_x - pablo_x).abs, (target_y - pablo_y).abs].min
  2731.       else
  2732.         jog_length = ((target_x - pablo_x).abs - (target_y - pablo_y).abs).abs
  2733.       end
  2734.       nums = pattern == 1 ? [cardinal, quadrant] : [quadrant, cardinal]
  2735.       for i in 0...steps
  2736.         face_num = cardinal + 15
  2737.         if i == jog_at + jog_length
  2738.           route_nums.push(face_num) if pattern == 2
  2739.         elsif i == jog_at
  2740.           route_nums.push(face_num) if pattern == 1
  2741.         elsif i == 0
  2742.           route_nums.push(face_num) if pattern == 2
  2743.         end
  2744.         if i >= jog_at
  2745.           if i < jog_at + jog_length
  2746.             route_nums.push(nums[1])
  2747.           else
  2748.             route_nums.push(nums[0])
  2749.           end
  2750.         else
  2751.           route_nums.push(nums[0])
  2752.         end
  2753.       end
  2754.       pablo_x = target_x
  2755.       pablo_y = target_y
  2756.     end
  2757.     approach_route = RPG::MoveRoute.new
  2758.     approach_route.list = []
  2759.     for step in route_nums
  2760.       new_step = RPG::MoveCommand.new
  2761.       new_step.code = step
  2762.       approach_route.list.push(new_step)
  2763.     end
  2764.     return_nums = []
  2765.     for i in route_nums.reverse
  2766.       return_step = {1=>4,2=>3,3=>2,4=>1,5=>8,6=>7,7=>6,8=>5,
  2767.                      16=>nil,17=>nil,18=>nil,19=>nil}[i]
  2768.       return_nums.push(return_step) if !return_step.nil?
  2769.     end
  2770.     return_route = RPG::MoveRoute.new
  2771.     return_route.list = []
  2772.     for step in return_nums
  2773.       new_step = RPG::MoveCommand.new(step)
  2774.       return_route.list.push(new_step)
  2775.     end
  2776.     approach_route.list.push(RPG::MoveCommand.new)
  2777.     return_route.list.push(RPG::MoveCommand.new)
  2778.     speed = 3
  2779.     approach_route.list.insert(0, RPG::MoveCommand.new(29, [speed]))
  2780.     return_route.list.insert(0, RPG::MoveCommand.new(29, [speed]))
  2781.     approach_route.repeat = false
  2782.     return_route.repeat = false
  2783.     @a_route = approach_route
  2784.     @r_route = return_route
  2785.   end
  2786.   #----------------------------------------------------------------------------
  2787.   # • Retorna a rota de aproximação.
  2788.   #----------------------------------------------------------------------------
  2789.   def route_approach
  2790.     route = RPG::MoveRoute.new
  2791.     route.list = @a_route.list.dup
  2792.     route.repeat = false
  2793.     return route
  2794.   end
  2795.   #----------------------------------------------------------------------------
  2796.   # • Retorna a rota de retorno do passado.
  2797.   #----------------------------------------------------------------------------
  2798.   def route_return
  2799.     route = RPG::MoveRoute.new
  2800.     route.list = @r_route.list.dup
  2801.     route.repeat = false
  2802.     return route
  2803.   end
  2804. end
  2805. #==============================================================================
  2806. # • DRGSS | Comandos do RGSS...
  2807. #==============================================================================
  2808. Dax.register(:DRGSS, "Dax", 0.1)
  2809. module DRGSS
  2810.   extend self
  2811.   #----------------------------------------------------------------------------
  2812.   # • Executar ações...
  2813.   #----------------------------------------------------------------------------
  2814.   def eval(buffer)
  2815.     if (buffer =~ /event_call (\d+)/) # Chamar um evento comum.
  2816.       return $game_temp.reserve_common_event($1.to_i)
  2817.     end
  2818.     eval(buffer)
  2819.   end
  2820.   #----------------------------------------------------------------------------
  2821.   # • Executar ações das variáveis.
  2822.   #----------------------------------------------------------------------------
  2823.   def var(buffer)
  2824.     if buffer =~ /var\[(\d+)\] = (\d+)/ # Igualar valor
  2825.       return $game_variables[$1] = $2
  2826.     elsif buffer =~ /var\[(\d+)\] += (\d+)/ # Aumentar o valor
  2827.       return $game_variables[$1] += $2
  2828.     elsif buffer =~ /var\[(\d+)\] *= (\d+)/ # Diminuir o valor
  2829.       return $game_variables[$1] -= $2
  2830.     elsif buffer =~ /variable\[(\d+)\] = (\d+)/ # Igualar valor
  2831.       return $variables[$1] = $2
  2832.     elsif buffer =~ /variable\[(\d+)\] += (\d+)/ # Aumentar o valor
  2833.       return $variables[$1] += $2
  2834.     elsif buffer =~ /variable\[(\d+)\] *= (\d+)/ # Diminuir o valor
  2835.       return $variables[$1] -= $2
  2836.     end
  2837.     return
  2838.   end
  2839.   #----------------------------------------------------------------------------
  2840.   # • Executar ações das switches
  2841.   #----------------------------------------------------------------------------
  2842.   def switche(buffer)
  2843.   end
  2844.   #----------------------------------------------------------------------------
  2845.   # • Executar as várias funções.
  2846.   #----------------------------------------------------------------------------
  2847.   def call(buffer)
  2848.     var(buffer)
  2849.     switche(buffer)
  2850.     eval(buffer)
  2851.   end
  2852. end
  2853. #==============================================================================
  2854. # • Extension
  2855. #==============================================================================
  2856. # Autor: Dax
  2857. # Versão: 1.0
  2858. # Site: www.dax-soft.weebly.com
  2859. # Requerimento: Dax Core 1.9>
  2860. #==============================================================================
  2861. Dax.register(:Extension, "Dax", Dax::Version_EX)
  2862. #==============================================================================
  2863. # • WC
  2864. #==============================================================================
  2865. module Extension
  2866.   extend self
  2867.   #----------------------------------------------------------------------------
  2868.   # • Variável e constantes.
  2869.   #----------------------------------------------------------------------------
  2870.   @imported = {} # Importar script.
  2871.   @version_imported = {} # Versão do script importado.
  2872.   @actor_imported = {} # Autor do script importado.
  2873.   #----------------------------------------------------------------------------
  2874.   # • Registrar script.
  2875.   #----------------------------------------------------------------------------
  2876.   def register(name, actor="Dax", version=1.0)
  2877.     @imported[name] = true
  2878.     @version_imported[name] = version
  2879.     @actor_imported[name] = actor
  2880.   end
  2881.   #----------------------------------------------------------------------------
  2882.   # • Cria uma condição de requerimento de script.
  2883.   #----------------------------------------------------------------------------
  2884.   def required(name, actor="Dax", version=1.0)
  2885.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  2886.   end
  2887. end
  2888. #==============================================================================
  2889. # • Mouse Extension | Picture Touch
  2890. #==============================================================================
  2891. Extension.register(:Mouse_Extension, "Dax", 1.0)
  2892. class Touch_Picture < Sprite
  2893.   #----------------------------------------------------------------------------
  2894.   # • Inicialização dos objetos.
  2895.   #    name : Nome da picture.
  2896.   #    x : Posição X da picture.
  2897.   #    y : Posição Y da picture.
  2898.   #    z : Altura da picture.
  2899.   #----------------------------------------------------------------------------
  2900.   def initialize(name="",x=0,y=0,z=0,switche_id=nil)
  2901.     super()
  2902.     self.bitmap = Cache.picture(name)
  2903.     self.x, self.y, self.z = x, y, z
  2904.     @clicked = false
  2905.     @switche_id = switche_id
  2906.   end
  2907.   #----------------------------------------------------------------------------
  2908.   # • Renovação dos objetos.
  2909.   #----------------------------------------------------------------------------
  2910.   def dispose
  2911.     self.bitmap.dispose if !self.bitmap.nil?
  2912.     super
  2913.   end
  2914.   #----------------------------------------------------------------------------
  2915.   # • Atualizaçaõ dos objetos.
  2916.   #   action_clicked : Caso seja um nome em formato de String irá chamar uma
  2917.   # scene, caso seja em formato de número irá chamar um evento comum.
  2918.   #----------------------------------------------------------------------------
  2919.   def update
  2920.     self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  2921.     if Mouse.in_area?(self)
  2922.       effect_on_area?
  2923.       @clicked = trigger?(0x01) or repeat?(0x01)
  2924.       action if @clicked && trigger?(0x01) or repeat?(0x01)
  2925.     else
  2926.       effect_off_area?
  2927.       @clicked = false if trigger?(0x01) or repeat?(0x01)
  2928.     end
  2929.   end
  2930.   #----------------------------------------------------------------------------
  2931.   # • Acão após o clique na imagem.
  2932.   #----------------------------------------------------------------------------
  2933.   def action
  2934.   end
  2935.   #----------------------------------------------------------------------------
  2936.   # • Efeito quando estiver na área.
  2937.   #----------------------------------------------------------------------------
  2938.   def effect_on_area?
  2939.     self.opacity = 255
  2940.   end
  2941.   #----------------------------------------------------------------------------
  2942.   # • Efeito quando estiver fora da área.
  2943.   #----------------------------------------------------------------------------
  2944.   def effect_off_area?
  2945.     self.opacity = 128
  2946.   end
  2947. end
  2948. #==============================================================================
  2949. # • Simple Touch Picture | Mouse Extension
  2950. #==============================================================================
  2951. Extension.register(:Simple_Touch_Picture, "Dax", 1.0)
  2952. class Simple_Touch_Picture < Touch_Picture
  2953.   #----------------------------------------------------------------------------
  2954.   # • Inicialização dos objetos.
  2955.   #    name : Nome da picture.
  2956.   #    x : Posição X da picture.
  2957.   #    y : Posição Y da picture.
  2958.   #    z : Altura da picture.
  2959.   #    action : Ação após o clique do Mouse.
  2960.   #----------------------------------------------------------------------------
  2961.   def initialize(action, *args)
  2962.     super(*args)
  2963.     @action = action
  2964.   end
  2965.   #----------------------------------------------------------------------------
  2966.   # • Renovação dos objetos.
  2967.   #----------------------------------------------------------------------------
  2968.   def dispose
  2969.     super
  2970.   end
  2971.   #----------------------------------------------------------------------------
  2972.   # • Atualização dos objetos.
  2973.   #----------------------------------------------------------------------------
  2974.   def update
  2975.     super
  2976.   end
  2977.   #----------------------------------------------------------------------------
  2978.   # • Ação após o clique.
  2979.   #----------------------------------------------------------------------------
  2980.   def action
  2981.     eval(@action.to_s) unless @action.nil?
  2982.   end
  2983.   #----------------------------------------------------------------------------
  2984.   # • Efeito do objeto quando estiver na área.
  2985.   #----------------------------------------------------------------------------
  2986.   def effect_on_area?
  2987.     super
  2988.   end
  2989.   #----------------------------------------------------------------------------
  2990.   # • Efeito do objeto quando estiver fora da área.
  2991.   #----------------------------------------------------------------------------
  2992.   def effect_off_area?
  2993.     super
  2994.   end
  2995.   #----------------------------------------------------------------------------
  2996.   # • Retorna ao conteúdo.
  2997.   #----------------------------------------------------------------------------
  2998.   def contents
  2999.     self
  3000.   end
  3001. end
  3002. #==============================================================================
  3003. # • Mouse Extension | Touch Icon
  3004. #==============================================================================
  3005. Extension.register(:Touch_Icon, "Dax", 1.0)
  3006. class Touch_Icon < Sprite
  3007.   #----------------------------------------------------------------------------
  3008.   # • Inicialização dos objetos.
  3009.   #   id : ID do ícone no database.
  3010.   #   x : Posição X do objeto.
  3011.   #   y : Posição Y do objeto.
  3012.   #   z : Altura do objeto.
  3013.   #----------------------------------------------------------------------------
  3014.   def initialize(id=0, x=0, y=0, z=0, switche_id=nil,texts=["", ColorBasic.new(:white), 2],font=["Arial", 16])
  3015.     super()
  3016.     self.x, self.y, self.z = x, y, z
  3017.     self.bitmap = Bitmap.new(24, 24)
  3018.     self.bitmap.draw_icon(id.to_i, 0, 0)
  3019.     @clicked = false
  3020.     @switche_id = switche_id
  3021.     unless texts[0].empty?
  3022.       @text = Sprite.new
  3023.       @text.bitmap = Bitmap.new(100 + texts[0].split(//).size, 24)
  3024.       @text.x, @text.y, @text.z = self.x + (28 + texts[2]), self.y + texts[2], self.z
  3025.       @text.opacity = 0
  3026.       @text.bitmap.draw_text(0, 0, @text.width, @text.height, texts[0].to_s)
  3027.       @text.bitmap.font.name, @text.bitmap.font.size = font
  3028.     end
  3029.   end
  3030.   #----------------------------------------------------------------------------
  3031.   # • Renovação dos objetos.
  3032.   #----------------------------------------------------------------------------
  3033.   def dispose
  3034.     self.bitmap.dispose if !self.bitmap.nil?
  3035.     super
  3036.   end
  3037.   #----------------------------------------------------------------------------
  3038.   # • Atualizaçaõ dos objetos.
  3039.   #   action_clicked : Caso seja um nome em formato de String irá chamar uma
  3040.   # scene, caso seja em formato de número irá chamar um evento comum.
  3041.   #----------------------------------------------------------------------------
  3042.   def update
  3043.     self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  3044.     @text.visible = self.visible unless @text.nil?
  3045.     if Mouse.in_area?(self)
  3046.       @text.opacity = 255 unless @text.nil?
  3047.       effect_on_area?
  3048.       @clicked = trigger?(0x01) or repeat?(0x01)
  3049.       action if @clicked && trigger?(0x01) or repeat?(0x01)
  3050.     else
  3051.       @text.opacity = 0 unless @text.nil?
  3052.       effect_off_area?
  3053.       @clicked = false if trigger?(0x01) or repeat?(0x01)
  3054.     end
  3055.   end
  3056.   #----------------------------------------------------------------------------
  3057.   # • Acão após o clique na imagem.
  3058.   #----------------------------------------------------------------------------
  3059.   def action
  3060.     @text.visible = false unless @text.nil?
  3061.   end
  3062.   #----------------------------------------------------------------------------
  3063.   # • Efeito quando estiver na área.
  3064.   #----------------------------------------------------------------------------
  3065.   def effect_on_area?
  3066.     self.opacity = 255
  3067.   end
  3068.   #----------------------------------------------------------------------------
  3069.   # • Efeito quando estiver fora da área.
  3070.   #----------------------------------------------------------------------------
  3071.   def effect_off_area?
  3072.     self.opacity = 128
  3073.   end
  3074. end
  3075. #==============================================================================
  3076. # • Mouse Extension | Simple Touch Icon
  3077. #==============================================================================
  3078. Extension.register(:Simple_Touch_Icon, "Dax", 1.0)
  3079. class Simple_Touch_Icon < Touch_Icon
  3080.   #----------------------------------------------------------------------------
  3081.   # • Inicialização dos objetos.
  3082.   #----------------------------------------------------------------------------
  3083.   def initialize(action, *args)
  3084.     super(*args)
  3085.     self.opacity = 128
  3086.     @action = action
  3087.   end
  3088.   #----------------------------------------------------------------------------
  3089.   # • Renovação dos objetos.
  3090.   #----------------------------------------------------------------------------
  3091.   def dispose
  3092.     super
  3093.   end
  3094.   #----------------------------------------------------------------------------
  3095.   # • Atualização dos objetos.
  3096.   #----------------------------------------------------------------------------
  3097.   def update
  3098.     super
  3099.   end
  3100.   #----------------------------------------------------------------------------
  3101.   # • Ação após o clique.
  3102.   #----------------------------------------------------------------------------
  3103.   def action
  3104.     super
  3105.     eval(@action.to_s) unless @action.nil?
  3106.   end
  3107.   #----------------------------------------------------------------------------
  3108.   # • Efeito do objeto quando estiver na área.
  3109.   #----------------------------------------------------------------------------
  3110.   def effect_on_area?
  3111.     super
  3112.   end
  3113.   #----------------------------------------------------------------------------
  3114.   # • Efeito do objeto quando estiver fora da área.
  3115.   #----------------------------------------------------------------------------
  3116.   def effect_off_area?
  3117.     super
  3118.   end
  3119.   #----------------------------------------------------------------------------
  3120.   # • Retorna ao conteúdo.
  3121.   #----------------------------------------------------------------------------
  3122.   def contents
  3123.     self
  3124.   end
  3125. end
  3126. #==============================================================================
  3127. # • Mouse Extension | Touch Text
  3128. #==============================================================================
  3129. Extension.register(:Touch_Text, "Dax", 1.0)
  3130. class Touch_Text < Sprite
  3131.   #----------------------------------------------------------------------------
  3132.   # • Inicialização dos objetos.
  3133.   #   id : ID do ícone no database.
  3134.   #   x : Posição X do objeto.
  3135.   #   y : Posição Y do objeto.
  3136.   #   z : Altura do objeto.
  3137.   #----------------------------------------------------------------------------
  3138.   def initialize(text="", x=0, y=0, z=0, switche_id=nil,color=[ColorBasic.new(:white), ColorBasic[7]],font=["Arial", 16],align=0)
  3139.     super()
  3140.     self.x, self.y, self.z = x, y, z
  3141.     self.bitmap = Bitmap.new(font[1] + (text.split(//).size ** 2), font[1])
  3142.     self.bitmap.draw_text(0, 0, self.width, self.height, text, align)
  3143.     @clicked = false
  3144.     @switche_id = switche_id
  3145.     @color = color
  3146.     self.bitmap.font.name, self.bitmap.font.size = font
  3147.   end
  3148.   #----------------------------------------------------------------------------
  3149.   # • Renovação dos objetos.
  3150.   #----------------------------------------------------------------------------
  3151.   def dispose
  3152.     self.bitmap.dispose if !self.bitmap.nil?
  3153.     super
  3154.   end
  3155.   #----------------------------------------------------------------------------
  3156.   # • Atualizaçaõ dos objetos.
  3157.   #   action_clicked : Caso seja um nome em formato de String irá chamar uma
  3158.   # scene, caso seja em formato de número irá chamar um evento comum.
  3159.   #----------------------------------------------------------------------------
  3160.   def update
  3161.     self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  3162.     if Mouse.in_area?(self)
  3163.       effect_on_area?
  3164.       @clicked = trigger?(0x01) or repeat?(0x01)
  3165.       action if @clicked && trigger?(0x01) or repeat?(0x01)
  3166.     else
  3167.       effect_off_area?
  3168.       @clicked = false if trigger?(0x01) or repeat?(0x01)
  3169.     end
  3170.   end
  3171.   #----------------------------------------------------------------------------
  3172.   # • Acão após o clique na imagem.
  3173.   #----------------------------------------------------------------------------
  3174.   def action
  3175.    
  3176.   end
  3177.   #----------------------------------------------------------------------------
  3178.   # • Efeito quando estiver na área.
  3179.   #----------------------------------------------------------------------------
  3180.   def effect_on_area?
  3181.     self.color = @color[1]
  3182.   end
  3183.   #----------------------------------------------------------------------------
  3184.   # • Efeito quando estiver fora da área.
  3185.   #----------------------------------------------------------------------------
  3186.   def effect_off_area?
  3187.     self.color = @color[0]
  3188.   end
  3189. end
  3190. #==============================================================================
  3191. # • Mouse Extension | Simple Touch Icon
  3192. #==============================================================================
  3193. Extension.register(:Simple_Touch_Icon, "Dax", 1.0)
  3194. class Simple_Touch_Text < Touch_Text
  3195.   #----------------------------------------------------------------------------
  3196.   # • Inicialização dos objetos.
  3197.   #----------------------------------------------------------------------------
  3198.   def initialize(action, *args)
  3199.     super(*args)
  3200.     @action = action
  3201.   end
  3202.   #----------------------------------------------------------------------------
  3203.   # • Renovação dos objetos.
  3204.   #----------------------------------------------------------------------------
  3205.   def dispose
  3206.     super
  3207.   end
  3208.   #----------------------------------------------------------------------------
  3209.   # • Atualização dos objetos.
  3210.   #----------------------------------------------------------------------------
  3211.   def update
  3212.     super
  3213.   end
  3214.   #----------------------------------------------------------------------------
  3215.   # • Ação após o clique.
  3216.   #----------------------------------------------------------------------------
  3217.   def action
  3218.     eval(@action.to_s) unless @action.nil?
  3219.   end
  3220.   #----------------------------------------------------------------------------
  3221.   # • Efeito do objeto quando estiver na área.
  3222.   #----------------------------------------------------------------------------
  3223.   def effect_on_area?
  3224.     super
  3225.   end
  3226.   #----------------------------------------------------------------------------
  3227.   # • Efeito do objeto quando estiver fora da área.
  3228.   #----------------------------------------------------------------------------
  3229.   def effect_off_area?
  3230.     super
  3231.   end
  3232.   #----------------------------------------------------------------------------
  3233.   # • Retorna ao conteúdo.
  3234.   #----------------------------------------------------------------------------
  3235.   def contents
  3236.     self
  3237.   end
  3238. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement