Advertisement
DasAquatic

Dax Core X2

Jun 3rd, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 131.99 KB | None | 0 0
  1.  
  2.  
  3. #==============================================================================
  4. # • Dax Core X2
  5. #==============================================================================
  6. # Autor: Dax
  7. # Versão: X2
  8. # Site: www.dax-soft.weebly.com
  9. # Requerimento: N/A
  10. #==============================================================================
  11. # • Descrição:
  12. #------------------------------------------------------------------------------
  13. #   Adiciona alguns requesitos necessarios para executar alguns script Dax.
  14. #==============================================================================
  15. # • Versões:
  16. #------------------------------------------------------------------------------
  17. # X :
  18. #     - ColorBasic : Módulo que armazena informações de cores.
  19. #     - API : Módulo com informação de algumas APIs.
  20. #     - User32 : Módulo com informações de algumas APIs da dll User32. Em Inglês
  21. #     - Key : Permite você utilizar as várias teclas do teclado.
  22. #     - Zone : Calculos para achar a área de um objeto.
  23. #     - Bitmap : Add-ons para está classe.
  24. #     - Mouse : Sistema de mouse.
  25. #     - String : Add-ons para está clasee.
  26. #     - Sprite : Add-ons para está classe.
  27. #     - Integer : Add-ons para está classe.
  28. #     - Variable : Módulo para guardar informações de variávels em HASH.
  29. #     - Switche : Módulo para guardar informações das switches em HASH.
  30. #     - Object : Add-ons.
  31. #     - Window Core : Criado
  32. #       - Window Core : Criado.
  33. #       - LetterInput : Criado.
  34. #       - Position and Size : Criado.
  35. #       - Text Base
  36. #     - Psych : | 0.1
  37. #       - Psych Core: Criado.
  38. #       - LimitScreen : Criado.
  39. #     - DRGSS | Criado | 2.1
  40. #     - Extension : Criado | 1.0
  41. #       - Mouse : Extensão para o mouse.
  42. #         - Touch_Picture | Criado.
  43. #         - Simple_Touch_Picture | Criado.
  44. #         - Touch_Icon | Criado.
  45. #         - Simple_Touch_Icon | Criado.
  46. #         - Touch_Text : Criado.
  47. #         - Simple_Touch_Text : Criado.
  48. #     - Color : Add-ons.
  49. #     - Entries : Criado.
  50. #     - DMath : Criado. 1.0
  51. #     - Numeric : Add-ons : 0.1
  52. #     - Module : Add-ons.
  53. # X2 :
  54. #     - OutlineFillRect : Add-ons;
  55. #     - ColorMath : Criado.
  56. #==============================================================================
  57. module Dax
  58.   extend self
  59.   #----------------------------------------------------------------------------
  60.   # • Font
  61.   #   Ajuste aqui as configurações básicas da fonte padrão do jogo.
  62.   #----------------------------------------------------------------------------
  63.   Font.default_name = ["VL Gothic"] # Nome padrão da fonte do jogo.
  64.   Font.default_size = 18 # Tamanho padrão da fonte do jogo.
  65.   Font.default_bold = false # true - Para usar negrito | false - para não usar.
  66.   Font.default_italic = false # true - Para usar italico | false - para não usar.
  67.   Font.default_shadow = false # true - Para usar sombra na fonte | false - para não usar.
  68.   Font.default_outline = true # true - Para usar borda da fonte | false - para não usar.
  69.   Font.default_out_color = Color.new(0, 0, 0) # Cor da fonte padrão da borda da fonte.
  70.   Font.default_color = Color.new(255, 255, 255) # Cor da fonte padrão.
  71.   #----------------------------------------------------------------------------
  72.   # • Variável e constantes.
  73.   #----------------------------------------------------------------------------
  74.   @imported = {} # Importar script.
  75.   @version_imported = {} # Versão do script importado.
  76.   @actor_imported = {} # Autor do script importado.
  77.   @data = {}
  78.   Core = true # Chave do módulo.
  79.   Version_PS = 0.3 # Versão do Psych.
  80.   Version_WC = 1.2 # Versão do Window Core.
  81.   Version_EX = 1.4 # Versão do Extension.
  82.   DRGSS = 2.0 # Versão do Dax Rgss
  83.   #----------------------------------------------------------------------------
  84.   # • Mouse
  85.   #   Configure aqui, algumas coisas do mouse.
  86.   #----------------------------------------------------------------------------
  87.   # Caso você queira, que não aparece nenhuma imagem ou ícone, representando o
  88.   # cursor do mouse, apenas deixe vázio as áspas. Caso você queira uma imagem,
  89.   # representando o mouse, ponha entre as áspas o nome da imagem, que deve de estar
  90.   # na pasta de Pictures. Caso você queira que um ícone represente o cursor do mouse
  91.   # ponha o ID do ícone no lugar das áspas.
  92.   Mouse_Name = "Mouse"
  93.   #----------------------------------------------------------------------------
  94.   # • Registrar script.
  95.   #----------------------------------------------------------------------------
  96.   def register(name, actor="Dax", version="X2", data='')
  97.     @imported[name] = true
  98.     @version_imported[name] = version
  99.     @actor_imported[name] = actor
  100.     @data[name] = data
  101.   end
  102.   #----------------------------------------------------------------------------
  103.   # • Cria uma condição de requerimento de script.
  104.   #----------------------------------------------------------------------------
  105.   def required(name, actor="Dax", version="X2")
  106.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  107.   end
  108.   #----------------------------------------------------------------------------
  109.   # • Remover um script existente.
  110.   #----------------------------------------------------------------------------
  111.   def remove(name_symbol)
  112.     Object.send(:remove_const, name_symbol)
  113.   end
  114.   register(:Dax)
  115. end
  116. #==============================================================================
  117. # • Module
  118. #==============================================================================
  119. class Module
  120.   #----------------------------------------------------------------------------
  121.   # • Declarar uma variável pública da instância com valor.
  122.   #----------------------------------------------------------------------------
  123.   def attr_value_accessor(sym, default = 0)
  124.     attr_writer sym
  125.     attr_value_reader sym, default
  126.   end
  127.   #----------------------------------------------------------------------------
  128.   # • Declara uma variável pública de leitura com valor.
  129.   #----------------------------------------------------------------------------
  130.   def attr_value_reader(sym, default = 0)
  131.     sym = sym.id2name
  132.     string = "def #{sym};" +
  133.              "  @#{sym} = #{default}  if @#{sym}.nil?;" +
  134.              "  @#{sym};" +
  135.              "end;"
  136.     module_eval(string)
  137.   end
  138. end
  139. #==============================================================================
  140. # • API
  141. #==============================================================================
  142. Dax.register(:API, 'Dax', 1.0)
  143. module API
  144.   extend self
  145.   #----------------------------------------------------------------------------
  146.   # • Constantes de APIs.
  147.   #----------------------------------------------------------------------------
  148.   # Permite acessar as teclas do teclado.
  149.   GetKeyState    = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  150.   # Permite ativar/desativar o ícone do mouse.
  151.   MouseShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
  152.   # Permite achar a posição do mouse.
  153.   CursorPosition = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  154.   # Permite achar o tamanho da screen.
  155.   ScreenToClient = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  156.   # Permite fazer a leitura do game.ini.
  157.   ReadIni = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  158.   # Permite achar o tamando da window.
  159.   FindWindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
  160.   # API da Message Box.
  161.   MessageBoxA = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i')
  162.   # Recupera uma string especificada de um arquivo em inicialização.
  163.   GetPrivateProfileString = Win32API.new('kernel32', 'GetPrivateProfileStringA',%w(p p p p l p),'l')
  164.   # Get Systeme Metrics  
  165.   GetSystemMetrics = Win32API.new("user32", "GetSystemMetrics", "i", "i")  
  166.   #Set Windows Pos  
  167.   SetWindowPos = Win32API.new("user32", "SetWindowPos", "lliiiii", "i")  
  168.   #Get Windows Rect  
  169.   GetWindowRect = Win32API.new('user32','GetWindowRect',%w(l p),'i')  
  170.   # Define a Win32API do comando print
  171.   MessageBoxW = Win32API.new("user32", "MessageBoxW", "LPPL", "L")
  172.   # Caps Lock
  173.   CapsLock = Win32API.new("user32", "GetKeyState", "i", "i").call(20) != 0
  174.   # State Key
  175.   StateKey = Win32API.new("user32", "GetKeyState", ["i"], "i")
  176.   # SetCursorPos
  177.   SetCursorPos    = Win32API.new("user32", "SetCursorPos", "ll", "i")
  178.   SetCursorPos    = Win32API.new("user32", "SetCursorPos", "ii", "i")
  179.   GetKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  180.   GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  181.   # Criar uma nova pasta.
  182.   CreateDirectory = Win32API.new("kernel32", "CreateDirectory", "p", "lll")
  183.   # Remover uma pasta existente.
  184.   RemoveDirectory = Win32API.new("kernel32", "RemoveDirectory", "p", "l")
  185.   # retorna para a data do ponteiro.
  186.   def copymen(len)
  187.     buf = "\0" * len
  188.     Win32API.new("kernel32", "RtlMoveMemory", "ppl", "").call(buf, self, len)
  189.     buf
  190.   end
  191. end
  192. #==============================================================================
  193. # • User32
  194. #==============================================================================
  195. Dax.register(:user32, "Dax", 1.0, "18/05/13")
  196. module User32
  197.  
  198.   GSM                 = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
  199.   SetWindowPos        = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
  200.   SetWindowLong       = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
  201.   Keybd_Event         = Win32API.new('user32', 'keybd_event', 'LLLL', '')
  202.   FindWindow          = Win32API.new('user32', 'FindWindow', 'PP', 'L')
  203.   GetDesktopWindow    = Win32API.new('user32', 'GetDesktopWindow', '', 'L')
  204.   GetWindowInfo       = Win32API.new('user32', 'GetWindowInfo', 'LP', 'I')
  205.   SetForegroundWindow = Win32API.new('user32', 'SetForegroundWindow', 'L', 'L')
  206.   GetCursorPos        = Win32API.new('user32', 'GetCursorPos', 'P', 'I')
  207.   ShowCursor          = Win32API.new('user32', 'ShowCursor', 'L', 'L')
  208.   ScreenToClient      = Win32API.new('user32', 'ScreenToClient', 'LP', 'I')
  209.   GetKeyState         = Win32API.new('user32', 'GetKeyState', 'I', 'I')
  210.   GetAsyncKeyState    = Win32API.new('user32', 'GetAsyncKeyState', 'I', 'I')
  211.  
  212.  
  213.   # GSM Constants: Visit the site: microsoft msdn
  214.   # http://msdn.microsoft.com/en-us/library/ms724385(VS.85).aspx
  215.   SM_CXSCREEN      = 0  # Width of the current master screen resolution
  216.   SM_CYSCREEN      = 1  # Height of the current master screen resolution
  217.  
  218.   SM_CXVSCROLL     = 2  # Width of a vertical scroll bar
  219.   SM_CYHSCROLL     = 3  # Height of a horizontal scroll bar
  220.  
  221.   SM_CYCAPTION     = 4  # Height of a caption area
  222.  
  223.   SM_CXBORDER      = 5  # Width of a window border
  224.   SM_CYBORDER      = 6  # Height of a window border
  225.  
  226.   SM_CXDLGFRAME    = 7
  227.   SM_CXFIXEDFRAME  = 7  # Width of non-resizable captioned window frame
  228.   SM_CYDLGFRAME    = 8
  229.   SM_CYFIXEDFRAME  = 8  # Height of non-resizable captioned window frame
  230.  
  231.   SM_CYVTHUMB      = 9  # Height of a thumb button on vertical scrollbars
  232.   SM_CXHTHUMB      = 10 # Width of a thumb button on horizontal scrollbars
  233.  
  234.   SM_CXICON        = 11 # Default width of an icon
  235.   SM_CYICON        = 12 # Default height of an icon
  236.  
  237.   SM_CXCURSOR      = 13 # Width of a cursor
  238.   SM_CYCURSOR      = 14 # Height of a cursor
  239.  
  240.   SM_CYMENU        = 15 # Height of a single-line menu bar
  241.  
  242.   SM_CXFULLSCREEN  = 16 # Width of client rect for a full-screen window
  243.   SM_CYFULLSCREEN  = 17 # Height of client rect for a full-screen window
  244.  
  245.   SM_CYKANJIWINDOW = 18 # Height of kanji window at bottom of screen, if there
  246.  
  247.   SM_MOUSEPRESENT  = 19 # Non-zero if mouse is present; 0 if not
  248.  
  249.   SM_CYVSCROLL     = 20 # Height of the arrow bitmap on vertical scrollbars
  250.   SM_CXHSCROLL     = 21 # Width of the arrow bitmap on horizontal scrollbars
  251.  
  252.   SM_DEBUG         = 22 # Non-zero if debug User.exe is installed; 0 if not
  253.   SM_SWAPBUTTON    = 23 # Non-zero if mouse button values are swapped
  254.  
  255.   SM_CXMIN         = 28 # Minimum width of a window
  256.   SM_CYMIN         = 29 # Minimum height of a window
  257.  
  258.   SM_CXSIZE        = 30 # Width of a button in a window caption or title bar
  259.   SM_CYSIZE        = 31 # Height of a button in a window caption or title bar
  260.  
  261.   SM_CXFRAME       = 32
  262.   SM_CXSIZEFRAME   = 32 # Width of the sizing border around a resizable window
  263.   SM_CYFRAME       = 33
  264.   SM_CYSIZEFRAME   = 33 # Height of the sizing border around a resizable window
  265.  
  266.   SM_CXMINTRACK    = 34 # Minimum "tracking" width of a window
  267.   SM_CYMINTRACK    = 35 # Minimum "tracking" height of a window
  268.  
  269.   SM_CXDOUBLECLK   = 36 # Width of rect which second click must be in for double
  270.   SM_CYDOUBLECLK   = 37 # Hght of rect which second click must be in for double
  271.  
  272.   SM_CXICONSPACING = 38 # Width of a grid cell for items in large icon view
  273.   SM_CYICONSPACING = 39 # Height of a grid cell for items in large icon view
  274.  
  275.   SM_MENUDROPALIGNMENT = 40 # 0 if drop-down menus are left-aligned...
  276.  
  277.   SM_PENWINDOWS    = 41 # Non-zero if Microsoft Windows for Pen computing
  278.                         #  extensions are installed; 0 if not
  279.  
  280.   SM_DBCSENABLED   = 42 # Non-zero if user32.dll supports DBCS; 0 if not
  281.  
  282.   SM_CMOUSEBUTTONS = 43 # Number of available mouse buttons, or 0 for no mouse
  283.  
  284.   SM_SECURE        = 44 # Always returns 0
  285.  
  286.   SM_CXEDGE        = 45 # Width of a 3-D style border
  287.   SM_CYEDGE        = 46 # Height of a 3-D style border
  288.  
  289.   SM_CXMINSPACING  = 47 # Width of a grid cell for minimized windows
  290.   SM_CYMINSPACING  = 48 # Height of a grid cell for minimized windows
  291.  
  292.   SM_CXSMICON      = 49 # Recommended width of a small icon
  293.   SM_CYSMICON      = 50 # Recommended height of a small icon
  294.  
  295.   SM_CYSMCAPTION   = 51 # Height of a small caption
  296.   SM_CXSMSIZE      = 52 # Width of small caption buttons
  297.   SM_CYSMSIZE      = 53 # Height of small caption buttons
  298.   SM_CXMENUSIZE    = 54 # Width of menu bar buttons
  299.   SM_CYMENUSIZE    = 55 # Height of menu bar buttons
  300.  
  301.   SM_ARRANGE       = 56 # Flags about how system the arranges minimized windows
  302.   SM_CXMINIMIZED   = 57 # Width of a minimized window
  303.   SM_CYMINIMIZED   = 58 # Height of a minimized window
  304.  
  305.   SM_CXMAXTRACK    = 59 # Default maximum width of resizable windows
  306.   SM_CYMAXTRACK    = 60 # Default maximum height of resizable windows
  307.   SM_CXMAXIMIZED   = 61 # Default width of maximized top-level window
  308.   SM_CYMAXIMIZED   = 62 # Default height of maximized top-level window
  309.  
  310.   SM_NETWORK       = 63 # The least significant bit is set if a network is
  311.                         #  present; otherwise, it is cleared
  312.  
  313.   SM_CLEANBOOT     = 67 # System boot type; 0:Normal, 1:Safe, 2:Safe w/network
  314.  
  315.   SM_CXDRAG        = 68
  316.   SM_CYDRAG        = 69 # Number of pixels mouse can move before initiating drag
  317.  
  318.   SM_SHOWSOUNDS    = 70 # Non-zero if user requires visible output; 0 if not
  319.  
  320.   SM_CXMENUCHECK   = 71 # Width of the default menu check-mark bitmap
  321.   SM_CYMENUCHECK   = 72 # Height of the default menu check-mark bitmap
  322.  
  323.   SM_SLOWMACHINE   = 73 # Non-zero if system has a slow processor; 0 if not
  324.                         #  No, seriously, that's what Microsoft said!
  325.  
  326.   SM_MIDEASTENABLED = 74 # Non-zero if system can use Hebrew, Arabic languages
  327.  
  328.   SM_MOUSEWHEELPRESENT = 75 # Nonzero mouse has vertical scroll wheel; 0 if not
  329.  
  330.   SM_XVIRTUALSCREEN    = 76 # Coordinates of the left side of the virtual screen
  331.   SM_YVIRTUALSCREEN    = 77 # Coordinates of the top of the virtual screen
  332.   SM_CXVIRTUALSCREEN   = 78 # Virtual width of all screens put together
  333.   SM_CYVIRTUALSCREEN   = 79 # Virtual height of all screen put together
  334.   SM_CMONITORS         = 80 # Numbers of display monitors on a desktop
  335.   SM_SAMEDISPLAYFORMAT = 81 # Non-zero if all screen use same color depth...
  336.  
  337.   # SetWindowPos constants
  338.   HWND_NOTOPMOST      = -2  # Make window not always on top (and bring to front)
  339.   HWND_TOPMOST        = -1  # Put window in front and make it always on top
  340.   HWND_TOP            = 0   # Put window in front of all non-topmost windows
  341.   HWND_BOTTOM         = 1   # Put window behind all other windows
  342.  
  343.   SWP_NOSIZE          = 0x0001 # Keep current size (ignores w and h)
  344.   SWP_NOMOVE          = 0x0002 # Keep current position (ignores X and Y)
  345.   SWP_NOZORDER        = 0x0004 # Keep current Z order (ignores hWndInsertAfter)
  346.   SWP_NOREDRAW        = 0x0008 # Does NOT redraw changes
  347.   SWP_NOACTIVATE      = 0x0010 # Does NOT automatically activate the window
  348.   SWP_FRAMECHANGED    = 0x0020 # Applies new frame styles set with SetWindowLong
  349.   SWP_SHOWWINDOW      = 0x0040 # Displays the window
  350.   SWP_HIDEWINDOW      = 0x0080 # Hides the window
  351.   SWP_NOCOPYBITS      = 0x0100 # Discards the entire contents of the client area
  352.   SWP_NOOWNERZORDER   = 0x0200 # Doesn't change the window display order
  353.   SWP_NOSENDCHANGING  = 0x0400 # Don't send WM_WINDOWPOSCHANGING
  354.   SWP_DEFERERASE      = 0x2000 # Prevents generation of the WM_SYNCPAINT message
  355.   SWP_ASYNCWINDOWPOS  = 0x4000 # Use if calling thread does not own the window
  356.  
  357.   # SetWindowLong constants
  358.   GWL_USERDATA        = -21 # Sets data reserved for use by the application
  359.   GWL_EXSTYLE         = -20 # Sets a new extended window style
  360.   GWL_STYLE           = -16 # Sets a new window style
  361.   GWL_ID              = -12 # Sets a new identifier of the window
  362.   GWL_HWNDPARENT      = -8  # Sets a new parent hWnd
  363.   GWL_HINSTANCE       = -6  # Sets a new application instance handle
  364.   GWL_WNDPROC         = -4  # Sets a new addr for the window calling procedure
  365.   # Only available when the hWnd parameter identifies a dialog box:
  366.   DWL_MSGRESULT       = 0   # Sets the return message of the dialog box proc
  367.   DWL_DLGPROC         = 4   # Sets the new address of the dialog box proc
  368.   DWL_USER            = 8   # Sets new extra information private to application
  369.  
  370.   # Window Styles (SetWindowLong(hWnd, GWL_STYLE, WS_*))
  371.   WS_OVERLAPPED       = 0x00000000 # Overlapped window has title and border
  372.   WS_TABSTOP          = 0x00010000 # Can receive focus from TAB key
  373.   WS_GROUP            = 0x00020000 # First control of group of controls
  374.   WS_MAXIMIZEBOX      = 0x00010000 # Has a mazimize button
  375.   WS_MINIMIZEBOX      = 0x00020000 # Has a minimize button
  376.   WS_THICKFRAME       = 0x00040000 # Has sizing border
  377.   WS_SYSMENU          = 0x00080000 # Has buttons on title bar (reqs WS_CAPTION)
  378.   WS_HSCROLL          = 0x00100000 # Has horizontal scroll bar
  379.   WS_VSCROLL          = 0x00200000 # Has vertical scroll bar
  380.   WS_DLGFRAME         = 0x00400000 # Dialog-style border. Cannot have title bar
  381.   WS_BORDER           = 0x00800000 # Thin border
  382.   WS_CAPTION          = 0x00C00000 # Has a title bar (implies WS_BORDER)
  383.   WS_MAXIMIZE         = 0x01000000 # Initially maximized
  384.   WS_CLIPCHILDREN     = 0x02000000 # Exclude area for children when drawing
  385.   WS_CLIPSIBLINGS     = 0x04000000 # Exclude sibling client rects when drawing
  386.   WS_DISABLED         = 0x08000000 # Initially disabled (no input)
  387.   WS_VISIBLE          = 0x10000000 # Initially visible
  388.   WS_MINIMIZE         = 0x20000000 # Initially minimized
  389.   WS_CHILD            = 0x40000000 # Child cannot have menu bar or WS_POPUP
  390.   WS_POPUP            = 0x80000000 # Popup window
  391.   # Window style aliases
  392.   WS_OVERLAPPEDWINDOW = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|
  393.                         WS_MINIMIZEBOX|WS_MAXIMIZEBOX
  394.   WS_POPUPWINDOW      = WS_POPUP|WS_BORDER|WS_SYSMENU
  395.   WS_CHILDWINDOW      = WS_CHILD
  396.   WS_TILED            = WS_OVERLAPPED
  397.   WS_ICONIC           = WS_MINIMIZE
  398.   WS_SIZEBOX          = WS_THICKFRAME
  399.   WS_TILEDWINDOW      = WS_OVERLAPPEDWINDOW
  400. end
  401. #==============================================================================
  402. # • String
  403. #==============================================================================
  404. Dax.register(:String, "Dax", 1.2)
  405. class String
  406.   #----------------------------------------------------------------------------
  407.   # • Constantes
  408.   #----------------------------------------------------------------------------
  409.   CP_ACP   = 0         # ANSI
  410.   CP_UTF7  = 65000     # UTF-7
  411.   CP_UTF8  = 65001     # UTF-8
  412.   EMPTY_STR = "".freeze
  413.   #----------------------------------------------------------------------------
  414.   # • Variáveis
  415.   #----------------------------------------------------------------------------
  416.   @@rm = Win32API.new('kernel32','RtlZeroMemory',%w(p l),'l').freeze
  417.   @@mb2wc = Win32API.new('kernel32',
  418.                         'MultiByteToWideChar', %w(i l p i p i), 'l').freeze
  419.   @@wc2mb = Win32API.new('kernel32',
  420.                       'WideCharToMultiByte', %w(i l p i p i p p), 'l').freeze
  421.   #----------------------------------------------------------------------------
  422.   # • Tamanho.
  423.   #----------------------------------------------------------------------------
  424.   def fsized
  425.     self.to_s.split(//)
  426.   end
  427.   #----------------------------------------------------------------------------
  428.   # • Substituir.
  429.   #----------------------------------------------------------------------------
  430.   def substitute(binding=TOPLEVEL_BINDING)
  431.     eval(%{"#{self}"}, binding)
  432.   end
  433.   #----------------------------------------------------------------------------
  434.   # • Obter tamanho real.
  435.   #----------------------------------------------------------------------------
  436.   def real_size
  437.     _return, _next = 0, false
  438.     for i in 0...self.size
  439.       _next = false if _next
  440.       next unless _next
  441.       _return += 1
  442.       char = self[i]
  443.       _next = char == 195
  444.     end
  445.     _return
  446.   end
  447.   #----------------------------------------------------------------------------
  448.   # • Encode
  449.   #----------------------------------------------------------------------------
  450.   def encode_by_
  451.     for i in 0...(self.size)
  452.       self[i] = 256 - self[i]
  453.     end
  454.   end
  455.   #----------------------------------------------------------------------------
  456.   # • Criptografar.
  457.   #----------------------------------------------------------------------------
  458.   def crypt
  459.     return self.to_i(36)
  460.   end
  461. end
  462. #==============================================================================
  463. # • Numeric
  464. #==============================================================================
  465. Dax.register(:numeric, 'Dax', 0.1, '16/05/13')
  466. class Numeric
  467.   #----------------------------------------------------------------------------
  468.   # • Calculo de '+ ou -' com um determinado número.
  469.   #----------------------------------------------------------------------------
  470.   def ±(number)
  471.     return [self + number, self - number]
  472.   end
  473. end
  474. #==============================================================================
  475. # • Integer
  476. #==============================================================================
  477. Dax.register(:Integer, "Dax", 0.30)
  478. class Integer
  479.   #----------------------------------------------------------------------------
  480.   # • Criptografar.
  481.   #----------------------------------------------------------------------------
  482.   def crypt
  483.     return self.to_s(36)
  484.   end
  485.   #----------------------------------------------------------------------------
  486.   # • Transformar em porcentagem
  487.   #   actual : Atual.
  488.   #   max : Máximo.
  489.   #----------------------------------------------------------------------------
  490.   def to_p(actual, max=100)
  491.     self.to_f * actual.to_f / max.to_f
  492.   end
  493.   #----------------------------------------------------------------------------
  494.   # • Retorna uma casa... Número
  495.   #----------------------------------------------------------------------------
  496.   def return
  497.     return self - 1
  498.   end
  499. end
  500. #==============================================================================
  501. # • Color
  502. #==============================================================================
  503. Dax.register(:Color, "Dax", 1.0)
  504. class Color
  505.   HEXA = /\#([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})?/i
  506.   #----------------------------------------------------------------------------
  507.   # • Cores hexadécimal.
  508.   #----------------------------------------------------------------------------
  509.   alias dax_hex_color_initialize initialize
  510.   def initialize(*args)
  511.     if args.length == 1 and args[0].is_a? String and args[0][/\A#{HEX_REGEX}\z/]
  512.       dax_hex_color_initialize($1.hex, $2.hex, $3.hex, ($4 ? $4.hex : 255))
  513.     else
  514.       dax_hex_color_initialize(*args)
  515.     end
  516.   end
  517.   #----------------------------------------------------------------------------
  518.   # • Efeito de cor opaca.
  519.   #----------------------------------------------------------------------------
  520.   def opacity
  521.     self.set(self.red, self.green, self.blue, 128)
  522.   end
  523.   #----------------------------------------------------------------------------
  524.   # • Inverter as cores.
  525.   #----------------------------------------------------------------------------
  526.   def invert!
  527.     self.set(255-self.red, 255-self.green, 255-self.blue, self.alpha)
  528.   end
  529.   #----------------------------------------------------------------------------
  530.   # • Reverter as cores.
  531.   #----------------------------------------------------------------------------
  532.   def revert
  533.     colors = [self.red, self.green, self.blue, self.alpha].reverse!
  534.     self.set(*colors)
  535.   end
  536.   #----------------------------------------------------------------------------
  537.   # • Efeito de mudança de cores...Rotacionar..
  538.   #----------------------------------------------------------------------------
  539.   def rotate
  540.     colors = [self.red, self.green, self.blue, self.alpha].rotate!(rand(2) == 0 ? 1 : - 1)
  541.     self.set(*colors)
  542.   end
  543.   #----------------------------------------------------------------------------
  544.   # • Converte para string.
  545.   #----------------------------------------------------------------------------
  546.   def to_s
  547.     "red: #{self.red}\nblue: #{self.blue}\ngreen: #{self.green}\nalpha: #{self.alpha}"
  548.   end
  549. end
  550. #==============================================================================
  551. # • DMath
  552. #==============================================================================
  553. Dax.register(:dmath, 'Dax', 1.0, '04/05/13')
  554. module DMath
  555.   extend self
  556.   #----------------------------------------------------------------------------
  557.   # • circle_angle
  558.   #----------------------------------------------------------------------------
  559.   def circle_angle(iy, step)
  560.     return Math.asin(iy * step)
  561.   end
  562.   #----------------------------------------------------------------------------
  563.   # • circle_width
  564.   #----------------------------------------------------------------------------
  565.   def circle_width(r, angle)
  566.     return r * Math.cos(angle)
  567.   end
  568.   #----------------------------------------------------------------------------
  569.   # • elipse_arc
  570.   #----------------------------------------------------------------------------
  571.   def elipse_arc(i, height)
  572.     return Math.asin i / height
  573.   end
  574.   #----------------------------------------------------------------------------
  575.   # • elipse_width
  576.   #----------------------------------------------------------------------------
  577.   def elipse_width(arc, width)
  578.     return Math.cos(arc) * width
  579.   end
  580.   #----------------------------------------------------------------------------
  581.   # • Ângulo, para efeito de sombra.
  582.   #----------------------------------------------------------------------------
  583.   def angle_effect_shadow(ev1, ev2)
  584.     return Math.atan2(ev1.screen_y - ev2.screen_y, ev1.screen_x - ev2.screen_x)
  585.   end
  586.   #----------------------------------------------------------------------------
  587.   # • Método, para ângulo de sombras.
  588.   #----------------------------------------------------------------------------
  589.   def angle_effect_shadow_sprite(*args)
  590.     return -57.3 * angle_effect_shadow(*args) + 90
  591.   end
  592.   #----------------------------------------------------------------------------
  593.   # • Distância, para efeito de sombra.
  594.   #----------------------------------------------------------------------------
  595.   def distance_effect_shadow(ev1, ev2)
  596.     return Math.hypot(ev1.screen_y - ev2.screen_y, ev1.screen_x - ev2.screen_x)  
  597.   end
  598.   #----------------------------------------------------------------------------
  599.   # • Rotc | Rotacionar.
  600.   #----------------------------------------------------------------------------
  601.   def rotc(vmn, v, vmx, c = 100)
  602.     ((v - vmn) * c) / (vmx - vmn)
  603.   end
  604.   #----------------------------------------------------------------------------
  605.   # • Ângulo, círuclo em X.
  606.   #----------------------------------------------------------------------------
  607.   def angle_circle_x(angle, radius)
  608.     return Math.cos(angle * Math::PI / 180) * radius
  609.   end
  610.   #----------------------------------------------------------------------------
  611.   # • Ângulo, círuclo em Y.
  612.   #----------------------------------------------------------------------------
  613.   def angle_circle_y(angle, radius)
  614.     return Math.sin(angle * Math::PI / 180) * radius
  615.   end
  616.   #----------------------------------------------------------------------------
  617.   # • Obter o X do centro da tela para um determinado objeto|sprite,bitmap.
  618.   #----------------------------------------------------------------------------
  619.   def get_x_center_screen(width)
  620.     x = Graphics.width.to_f / 2.0 - (width.to_f / 2.0)
  621.     return x
  622.   end
  623.   #----------------------------------------------------------------------------
  624.   # • Obter o Y do centro da tela para um determinado objeto|sprite,bitmap.
  625.   #----------------------------------------------------------------------------
  626.   def get_y_center_screen(height)
  627.     y = Graphics.height.to_f / 2.0 - (height.to_f / 2.0)
  628.     return y
  629.   end
  630.   #----------------------------------------------------------------------------
  631.   # • Tangente de alteração de ângulo. Para efeitos.
  632.   #----------------------------------------------------------------------------
  633.   def acc_tan_effect
  634.     return Math.tan(Math::PI / 26)
  635.   end
  636.   #----------------------------------------------------------------------------
  637.   # • Converter em graus, multiplique a variável com isto.
  638.   #----------------------------------------------------------------------------
  639.   def graus
  640.     360 / (2 * Math::PI)
  641.   end
  642.   #----------------------------------------------------------------------------
  643.   # • Converter em degress
  644.   #----------------------------------------------------------------------------
  645.   def degrees(deg)
  646.     ((deg) / (2 * Math::PI)) * 360
  647.   end
  648.   #----------------------------------------------------------------------------
  649.   # • Para 4 decimals.
  650.   #----------------------------------------------------------------------------
  651.   def to_4_dec(n)
  652.     ((n * 1000).ceil) / 1000
  653.   end
  654.   #----------------------------------------------------------------------------
  655.   # • Área do quadrado.
  656.   #----------------------------------------------------------------------------
  657.   def square_area(l)
  658.     l ** 2
  659.   end
  660.   #----------------------------------------------------------------------------
  661.   # • Equação completa de 2 grau, retorna a uma array.
  662.   #----------------------------------------------------------------------------
  663.   def eq2(a,b,c)
  664.     ∆ = (b**2) - (4*a*c)
  665.     unless< 0
  666.       x1 = (-b + Math.sqrt()) / 2*a
  667.       x2 = (-b - Math.sqrt()) / 2*a
  668.       return [x1, x2]
  669.     end
  670.     return [nil, nil]
  671.   end
  672.   #----------------------------------------------------------------------------
  673.   # • Área de um retângulo.
  674.   #----------------------------------------------------------------------------
  675.   def rectangle_area(h, b)
  676.     h * b
  677.   end
  678.   #----------------------------------------------------------------------------
  679.   # • Área de um triângulo.
  680.   #----------------------------------------------------------------------------
  681.   def triangle_area(*args)
  682.     x, y, x2, y2, x3, y3 = *args
  683.     return (x2 - x) * (y3 - y) - (x3 - x) * (y2 - y)
  684.   end
  685.   #----------------------------------------------------------------------------
  686.   # • Calcular distância para scripts como sensor.
  687.   #----------------------------------------------------------------------------
  688.   def distance_sensor(target, target2)
  689.     return (target.x - target2.x).abs + (target.y - target2.y).abs
  690.   end
  691. end
  692. #==============================================================================
  693. # • ColorMath
  694. #==============================================================================
  695. Dax.register(:color_math, "Dax", 0.5, "22/05/13")
  696. module ColorMath
  697.   extend self
  698.   #----------------------------------------------------------------------------
  699.   # • Verificar se é uma cor?
  700.   #----------------------------------------------------------------------------
  701.   def is_color?(color, red, green, blue)
  702.     return (color.red == red and color.blue == blue and color.green == green)
  703.   end
  704.   #----------------------------------------------------------------------------
  705.   # • Verificar se é preto?
  706.   #----------------------------------------------------------------------------
  707.   def is_black?(color)
  708.     is_color?(color, 0, 0, 0)
  709.   end
  710.   #----------------------------------------------------------------------------
  711.   # • Verificar se é branco?
  712.   #----------------------------------------------------------------------------
  713.   def is_white?(color)
  714.     is_color?(color, 255, 255, 255)
  715.   end
  716.   #----------------------------------------------------------------------------
  717.   # • Verificar se é vermelho?
  718.   #----------------------------------------------------------------------------
  719.   def is_red?(color)
  720.     is_red?(color, 255, 0, 0)
  721.   end
  722. end
  723. #==============================================================================
  724. # • Keyboard | Método para usar todas as teclas do teclado.
  725. #==============================================================================
  726. Dax.register(:Key, "Dax", 1.0)
  727. module Key
  728.   extend self
  729.   #--------------------------------------------------------------------------
  730.   # * Chaves diversos.
  731.   #--------------------------------------------------------------------------
  732.   CANCEL              = 0x03 # Control-Break Processing
  733.   BACKSPACE           = 0x08 # Backspace Key
  734.   TAB                 = 0x09 # Tab Key
  735.   CLEAR               = 0x0C # Clear Key
  736.   RETURN              = 0x0D # Enter Key
  737.   SHIFT               = 0x10 # Shift Key
  738.   CONTROL             = 0x11 # Ctrl Key
  739.   MENU                = 0x12 # Alt Key
  740.   PAUSE               = 0x13 # Pause Key
  741.   ESCAPE              = 0x1B # Esc Key
  742.   CONVERT             = 0x1C # IME Convert Key
  743.   NONCONVERT          = 0x1D # IME Nonconvert Key
  744.   ACCEPT              = 0x1E # IME Accept Key
  745.   SPACE               = 0x20 # Space Bar Key (Space, usually blank)
  746.   PRIOR               = 0x21 # Page Up Key
  747.   NEXT                = 0x22 # Page Down Key
  748.   ENDS                = 0x23 # End Key
  749.   HOME                = 0x24 # Home Key
  750.   LEFT                = 0x25 # Left Arrow Key
  751.   UP                  = 0x26 # Up Arrow Key
  752.   RIGHT               = 0x27 # Right Arrow Key
  753.   DOWN                = 0x28 # Down Arrow Key
  754.   SELECT              = 0x29 # Select Key
  755.   PRINT               = 0x2A # Print Key
  756.   EXECUTE             = 0x2B # Execute Key
  757.   SNAPSHOT            = 0x2C # Print Screen Key
  758.   DELETE              = 0x2E # Delete Key
  759.   HELP                = 0x2F # Help Key
  760.   LSHIFT              = 0xA0 # Left Shift Key
  761.   RSHIFT              = 0xA1 # Right Shift Key
  762.   LCONTROL            = 0xA2 # Left Control Key (Ctrl)
  763.   RCONTROL            = 0xA3 # Right Control Key (Ctrl)
  764.   LMENU               = 0xA4 # Left Menu Key (Alt)
  765.   RMENU               = 0xA5 # Right Menu Key (Alt)
  766.   PACKET              = 0xE7 # Used to Pass Unicode Characters as Keystrokes
  767.   MOUSE_RIGHT         = 0x01 # Button Mouse Right
  768.   MOUSE_LEFT          = 0x02 # Button Mouse Left
  769.   MOUSE_MIDDLE        = 0x04 # Button Mouse Middle
  770.   #--------------------------------------------------------------------------
  771.   # * Chaves de números.
  772.   #--------------------------------------------------------------------------
  773.   N0                  = 0x30 # 0 Key
  774.   N1                  = 0x31 # 1 Key
  775.   N2                  = 0x32 # 2 Key
  776.   N3                  = 0x33 # 3 Key
  777.   N4                  = 0x34 # 4 Key
  778.   N5                  = 0x35 # 5 Key
  779.   N6                  = 0x36 # 6 Key
  780.   N7                  = 0x37 # 7 Key
  781.   N8                  = 0x38 # 8 Key
  782.   N9                  = 0x39 # 9 Key
  783.   #--------------------------------------------------------------------------
  784.   # * Chaves de letras
  785.   #--------------------------------------------------------------------------
  786.   A                   = 0x41 # A Key
  787.   B                   = 0x42 # B Key
  788.   C                   = 0x43 # C Key
  789.   D                   = 0x44 # D Key
  790.   E                   = 0x45 # E Key
  791.   F                   = 0x46 # F Key
  792.   G                   = 0x47 # G Key
  793.   H                   = 0x48 # H Key
  794.   I                   = 0x49 # I Key
  795.   J                   = 0x4A # J Key
  796.   K                   = 0x4B # K Key
  797.   L                   = 0x4C # L Key
  798.   M                   = 0x4D # M Key
  799.   N                   = 0x4E # N Key
  800.   O                   = 0x4F # O Key
  801.   P                   = 0x50 # P Key
  802.   Q                   = 0x51 # Q Key
  803.   R                   = 0x52 # R Key
  804.   S                   = 0x53 # S Key
  805.   T                   = 0x54 # T Key
  806.   U                   = 0x55 # U Key
  807.   V                   = 0x56 # V Key
  808.   W                   = 0x57 # W Key
  809.   X                   = 0x58 # X Key
  810.   Y                   = 0x59 # Y Key
  811.   Z                   = 0x5A # Z Key
  812.   #--------------------------------------------------------------------------
  813.   # * Chaves de windows
  814.   #--------------------------------------------------------------------------
  815.   LWIN                = 0x5B # Left Windows Key (Natural keyboard)
  816.   RWIN                = 0x5C # Right Windows Key (Natural Keyboard)
  817.   APPS                = 0x5D # Applications Key (Natural keyboard)
  818.   SLEEP               = 0x5F # Computer Sleep Key
  819.   BROWSER_BACK        = 0xA6 # Browser Back Key
  820.   BROWSER_FORWARD     = 0xA7 # Browser Forward Key
  821.   BROWSER_REFRESH     = 0xA8 # Browser Refresh Key
  822.   BROWSER_STOP        = 0xA9 # Browser Stop Key
  823.   BROWSER_SEARCH      = 0xAA # Browser Search Key
  824.   BROWSER_FAVORITES   = 0xAB # Browser Favorites Key
  825.   BROWSER_HOME        = 0xAC # Browser Start and Home Key
  826.   VOLUME_MUTE         = 0xAD # Volume Mute Key
  827.   VOLUME_DOWN         = 0xAE # Volume Down Key
  828.   VOLUME_UP           = 0xAF # Volume Up Key
  829.   MEDIA_NEXT_TRACK    = 0xB0 # Next Track Key
  830.   MEDIA_PREV_TRACK    = 0xB1 # Previous Track Key
  831.   MEDIA_STOP          = 0xB2 # Stop Media Key
  832.   MEDIA_PLAY_PAUSE    = 0xB3 # Play/Pause Media Key
  833.   LAUNCH_MAIL         = 0xB4 # Start Mail Key
  834.   LAUNCH_MEDIA_SELECT = 0xB5 # Select Media Key
  835.   LAUNCH_APP1         = 0xB6 # Start Application 1 Key
  836.   LAUNCH_APP2         = 0xB7 # Start Application 2 Key
  837.   PROCESSKEY          = 0xE5 # IME Process Key
  838.   ATTN                = 0xF6 # Attn Key
  839.   CRSEL               = 0xF7 # CrSel Key
  840.   EXSEL               = 0xF8 # ExSel Key
  841.   EREOF               = 0xF9 # Erase EOF Key
  842.   PLAY                = 0xFA # Play Key
  843.   ZOOM                = 0xFB # Zoom Key
  844.   PA1                 = 0xFD # PA1 Key
  845.   #--------------------------------------------------------------------------
  846.   # * Chaves do Numpad
  847.   #--------------------------------------------------------------------------
  848.   NUMPAD0             = 0x60 # Numeric Keypad 0 Key
  849.   NUMPAD1             = 0x61 # Numeric Keypad 1 Key
  850.   NUMPAD2             = 0x62 # Numeric Keypad 2 Key
  851.   NUMPAD3             = 0x63 # Numeric Keypad 3 Key
  852.   NUMPAD4             = 0x64 # Numeric Keypad 4 Key
  853.   NUMPAD5             = 0x65 # Numeric Keypad 5 Key
  854.   NUMPAD6             = 0x66 # Numeric Keypad 6 Key
  855.   NUMPAD7             = 0x67 # Numeric Keypad 7 Key
  856.   NUMPAD8             = 0x68 # Numeric Keypad 8 Key
  857.   NUMPAD9             = 0x69 # Numeric Keypad 9 Key
  858.   MULTIPLY            = 0x6A # Multiply Key (*)
  859.   ADD                 = 0x6B # Add Key (+)
  860.   SEPARATOR           = 0x6C # Separator Key
  861.   SUBTRACT            = 0x6D # Subtract Key (-)
  862.   DECIMAL             = 0x6E # Decimal Key (.)
  863.   DIVIDE              = 0x6F # Divide Key (/)
  864.   #--------------------------------------------------------------------------
  865.   # * Chaves de funções
  866.   #--------------------------------------------------------------------------
  867.   F1                  = 0x70 # F1 Key
  868.   F2                  = 0x71 # F2 Key
  869.   F3                  = 0x72 # F3 Key
  870.   F4                  = 0x73 # F4 Key
  871.   F5                  = 0x74 # F5 Key
  872.   F6                  = 0x75 # F6 Key
  873.   F7                  = 0x76 # F7 Key
  874.   F8                  = 0x77 # F8 Key
  875.   F9                  = 0x78 # F9 Key
  876.   F10                 = 0x79 # F10 Key
  877.   F11                 = 0x7A # F11 Key
  878.   F12                 = 0x7B # F12 Key
  879.   F13                 = 0x7C # F13 Key
  880.   F14                 = 0x7D # F14 Key
  881.   F15                 = 0x7E # F15 Key
  882.   F16                 = 0x7F # F16 Key
  883.   F17                 = 0x80 # F17 Key
  884.   F18                 = 0x81 # F18 Key
  885.   F19                 = 0x82 # F19 Key
  886.   F20                 = 0x83 # F20 Key
  887.   F21                 = 0x84 # F21 Key
  888.   F22                 = 0x85 # F22 Key
  889.   F23                 = 0x86 # F23 Key
  890.   F24                 = 0x87 # F24 Key
  891.   #--------------------------------------------------------------------------
  892.   # * Chaves alternativas
  893.   #--------------------------------------------------------------------------
  894.   CAPITAL             = 0x14 # Caps Lock Key
  895.   KANA                = 0x15 # IME Kana Mode Key
  896.   HANGUL              = 0x15 # IME Hangul Mode Key
  897.   JUNJA               = 0x17 # IME Junja Mode Key
  898.   FINAL               = 0x18 # IME Final Mode Key
  899.   HANJA               = 0x19 # IME Hanja Mode Key
  900.   KANJI               = 0x19 # IME Kanji Mode Key
  901.   MODECHANGE          = 0x1F # IME Mode Change Request Key
  902.   INSERT              = 0x2D # Insert Key
  903.   NUMLOCK             = 0x90 # Num Lock Key
  904.   SCROLL              = 0x91 # Scroll Lock Key
  905.   #--------------------------------------------------------------------------
  906.   # * Chaves OEM, variadas
  907.   #--------------------------------------------------------------------------
  908.   OEM_1               = 0xBA # Misc Characters (; : in USA 101/102 Keyboards)
  909.   OEM_PLUS            = 0xBB # + = Key
  910.   OEM_COMMA           = 0xBC # , < Key
  911.   OEM_MINUS           = 0xBD # - _ Key
  912.   OEM_PERIOD          = 0xBE # . > Key
  913.   OEM_2               = 0xBF # Misc Characters (/ ? in USA 101/102 Keyboards)
  914.   OEM_3               = 0xC0 # Misc Characters (` ~ in USA 101/102 Keyboards)
  915.   OEM_4               = 0xDB # Misc Characters ([ { in USA 101/102 Keyboards)
  916.   OEM_5               = 0xDC # Misc Characters (\ | in USA 101/102 Keyboards)
  917.   OEM_6               = 0xDD # Misc Characters (] } in USA 101/102 Keyboards)
  918.   OEM_7               = 0xDE # Misc Characters (' " in USA 101/102 Keyboards)
  919.   OEM_8               = 0xDF # Misc Characters (Varies by Keyboard)
  920.   OEM_9               = 0xE1 # OEM Specific
  921.   OEM_10              = 0x92 # OEM Specific
  922.   OEM_11              = 0x93 # OEM Specific
  923.   OEM_12              = 0x94 # OEM Specific
  924.   OEM_13              = 0x95 # OEM Specific
  925.   OEM_14              = 0x96 # OEM Specific
  926.   OEM_15              = 0xE3 # OEM Specific
  927.   OEM_16              = 0xE4 # OEM Specific
  928.   OEM_17              = 0xE6 # OEM Specific
  929.   OEM_18              = 0xE9 # OEM Specific
  930.   OEM_19              = 0xEA # OEM Specific
  931.   OEM_20              = 0xEB # OEM Specific
  932.   OEM_21              = 0xEC # OEM Specific
  933.   OEM_22              = 0xED # OEM Specific
  934.   OEM_23              = 0xEE # OEM Specific
  935.   OEM_24              = 0xEF # OEM Specific
  936.   OEM_25              = 0xF1 # OEM Specific
  937.   OEM_26              = 0xF2 # OEM Specific
  938.   OEM_27              = 0xF3 # OEM Specific
  939.   OEM_28              = 0xF4 # OEM Specific
  940.   OEM_29              = 0xF5 # OEM Specific
  941.   OEM_102             = 0xE2 # Angle Bracket or Backslash on RT-102 Keyboards
  942.   OEM_CLEAR           = 0xFE # Clear Key
  943.   #--------------------------------------------------------------------------
  944.   # * Variáveis do módulo.
  945.   #--------------------------------------------------------------------------
  946.   @unpack_string = 'b'*256
  947.   @last_array = '0'*256
  948.   @press = Array.new(256, false)
  949.   @trigger = Array.new(256, false)
  950.   @repeat = Array.new(256, false)
  951.   @release = Array.new(256, false)
  952.   @repeat_counter = Array.new(256, 0)
  953.   @getKeyboardState = API::GetKeyboardState
  954.   @getAsyncKeyState = API::GetAsyncKeyState
  955.   @getKeyboardState.call(@last_array)
  956.   @last_array = @last_array.unpack(@unpack_string)
  957.   for i in 0...@last_array.size
  958.     @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  959.   end
  960.   #--------------------------------------------------------------------------
  961.   # * Atualização dos objetos do módulo.
  962.   #--------------------------------------------------------------------------
  963.   def update
  964.     @trigger = Array.new(256, false)
  965.     @repeat = Array.new(256, false)
  966.     @release = Array.new(256, false)
  967.     array = '0'*256
  968.     @getKeyboardState.call(array)
  969.     array = array.unpack(@unpack_string)
  970.     for i in 0...array.size
  971.       if array[i] != @last_array[i]
  972.         @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  973.         if @repeat_counter[i] <= 0 && @press[i]
  974.           @repeat[i] = true
  975.           @repeat_counter[i] = 15
  976.         end
  977.         if !@press[i]
  978.           @release[i] = true
  979.         else
  980.           @trigger[i] = true
  981.         end
  982.       else
  983.         if @press[i] == true
  984.           @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  985.           @release[i] = true if !@press[i]
  986.         end
  987.         if @repeat_counter[i] > 0 && @press[i] == true
  988.           @repeat_counter[i] -= 1
  989.         elsif @repeat_counter[i] <= 0 && @press[i] == true
  990.           @repeat[i] = true
  991.           @repeat_counter[i] = 3
  992.         elsif @repeat_counter[i] != 0
  993.           @repeat_counter[i] = 0
  994.         end
  995.       end
  996.     end
  997.     @last_array = array
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # * Get Key Pressed State
  1001.   #     key : key index
  1002.   #--------------------------------------------------------------------------
  1003.   def press?(key)
  1004.     return @press[key]
  1005.   end
  1006.   #--------------------------------------------------------------------------
  1007.   # * Get Key Triggered State
  1008.   #     key : key index
  1009.   #--------------------------------------------------------------------------
  1010.   def trigger?(key)
  1011.     return @trigger[key]
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # * Get Key Repeated State
  1015.   #     key : key index
  1016.   #--------------------------------------------------------------------------
  1017.   def repeat?(key)
  1018.     return @repeat[key]
  1019.   end
  1020.   #--------------------------------------------------------------------------
  1021.   # * Get Key Released State
  1022.   #     key : key index
  1023.   #--------------------------------------------------------------------------
  1024.   def release?(key)
  1025.     return @release[key]
  1026.   end
  1027. end
  1028. #==============================================================================
  1029. # • Input | Atualização do Key
  1030. #==============================================================================
  1031. class << Input
  1032.   alias key_update update
  1033.   def update
  1034.     key_update
  1035.     Key.update
  1036.   end
  1037. end
  1038. #============================================================================
  1039. # • Zone
  1040. #============================================================================
  1041. Dax.register(:Zone, "Dax", 1.3)
  1042. class Zone
  1043.   #----------------------------------------------------------------------------
  1044.   # • Inicialização dos objetos.
  1045.   #----------------------------------------------------------------------------
  1046.   def initialize(object, object2)
  1047.     @object = object
  1048.     @object2 = object2
  1049.   end
  1050.   #--------------------------------------------------------------------------
  1051.   # • Verifica se um objeto está na área. Círculo | Circle
  1052.   #--------------------------------------------------------------------------
  1053.   def circle(size)
  1054.     ( (@object.x - @object2.x) ** 2) + ( (@object.y - @object2.y) ** 2) <= (size ** 2)
  1055.   end
  1056.   #--------------------------------------------------------------------------
  1057.   # • Verifica se um objeto está na área. Eclipse | Eclipse
  1058.   #--------------------------------------------------------------------------
  1059.   def eclipse
  1060.     rate_x = ((@object.x.to_f - @object2.x.to_f) ** 2.0 / (@object2.src_rect.width / 2.0))
  1061.     rate_y = ((@object.y.to_f - @object2.y.to_f) ** 2.0 / (@object2.src_rect.height / 2.0))
  1062.     rate_x + rate_y <= 1
  1063.   end
  1064.   #----------------------------------------------------------------------------
  1065.   # • Verifica se algum objeto está na área do object.
  1066.   #----------------------------------------------------------------------------
  1067.   def object_in_area?
  1068.     return @object.x.between?(@object2.x, @object2.x + @object2.bitmap.width) && @object.y.between?(@object2.y, @object2.y + @object2.bitmap.height)
  1069.   end
  1070. end
  1071. #==============================================================================
  1072. # • Sprite
  1073. #==============================================================================
  1074. Dax.register(:Sprite, "Dax", 0.2)
  1075. class Sprite
  1076.   #----------------------------------------------------------------------------
  1077.   # • Novo método.
  1078.   #----------------------------------------------------------------------------
  1079.   alias new_initialize initialize
  1080.   def initialize(viewport=nil)
  1081.     if viewport.is_a?(String)
  1082.       new_initialize(nil)
  1083.       self.bitmap = Bitmap.new(viewport)
  1084.     elsif viewport.is_a?(Array)
  1085.       new_initialize(nil)
  1086.       self.bitmap = Bitmap.new(viewport[0], viewport[1])
  1087.     elsif viewport.is_a?(Viewport)
  1088.       new_initialize(viewport)
  1089.     elsif viewport.nil?
  1090.       new_initialize(viewport)
  1091.     end
  1092.   end
  1093.   #----------------------------------------------------------------------------
  1094.   # • Define aqui uma posição fixa para um objeto.
  1095.   #----------------------------------------------------------------------------
  1096.   def position(command=0)
  1097.     return if command.nil?
  1098.     case command
  1099.     when 0 then self.x = 0
  1100.     when 1 then self.x = Graphics.width / 2 - self.width / 2
  1101.     when 2 then self.x = Graphics.width - self.width
  1102.     when 3 then self.y = 0
  1103.     when 4 then self.y = Graphics.height / 2 - self.height / 2
  1104.     when 5 then self.y = Graphics.height - self.height
  1105.     when :center
  1106.       self.x = Graphics.width / 2 - self.width / 2
  1107.       self.y = Graphics.height / 2 - self.height / 2
  1108.     when :center_left
  1109.       self.x = 0 + add_x
  1110.       self.y = Graphics.height / 2 - self.height / 2
  1111.     when :center_right
  1112.       self.x = Graphics.width - self.height
  1113.       self.y = Graphics.height / 2 - self.height / 2
  1114.     end
  1115.   end
  1116.   #----------------------------------------------------------------------------
  1117.   # • Se esta no alcance?
  1118.   #----------------------------------------------------------------------------
  1119.   def range?(pos, margin=0)
  1120.     rect = self.src_rect
  1121.     if pos.x >= rect.x + margin and pos.y >= rect.y + margin and
  1122.       pos.x < rect.x + rect.width - margin and
  1123.       pos.y < rect.y + rect.height - margin
  1124.       return true
  1125.     end
  1126.     return false
  1127.   end
  1128. end
  1129. #==============================================================================
  1130. # • Bitmap
  1131. #==============================================================================
  1132. Dax.register(:Bitmap, "Dax", 1.2)
  1133. class Bitmap
  1134.   #----------------------------------------------------------------------------
  1135.   # • Salvar em png.
  1136.   #----------------------------------------------------------------------------
  1137.   def save(file_name)
  1138.     def chunk(type, data)
  1139.       [data.size, type, data, Zlib.crc32(type + data)].pack("NA4A*N")
  1140.     end
  1141.     img_data = ""
  1142.     width, height = self.width, self.height
  1143.     for j in 0...(height)
  1144.       img_data << "\0"
  1145.       for i in 0...(width)
  1146.         pos_c = self.get_pixel(i, j)
  1147.         img_data << [pos_c.red, pos_c.green, pos_c.blue, pos_c.alpha].pack("C*")
  1148.       end
  1149.     end
  1150.     c = [
  1151.       "\x89PNG\r\n\x1a\n",
  1152.       chunk("IHDR", [width, height, 8, 6, 0, 0, 0].pack("N2C5")),
  1153.       chunk("IDAT", Zlib::Deflate.deflate(img_data)),
  1154.       chunk("IEND", "")
  1155.     ]
  1156.     File.open(file_name, "wb"){|file| c.each{|chunk| file.write(chunk) }}
  1157.   end
  1158.   #----------------------------------------------------------------------------
  1159.   # • Plano BLT.
  1160.   #----------------------------------------------------------------------------
  1161.   def plane_blt(dest_rect, bmp, src_rect=bmp.rect, op=255)
  1162.     stretch = (dest_rect.width != src_rect.width or
  1163.                dest_rect.height != src_rect.height)
  1164.     sx = src_rect.x % bmp.width
  1165.     dx = dest_rect.x
  1166.     swr = src_rect.width
  1167.     while (swr > 0)
  1168.       sy = src_rect.y % bmp.height
  1169.       dy = dest_rect.y
  1170.       shr = src_rect.height
  1171.       sw = [bmp.width - sx, swr].min
  1172.       dw = dest_rect.width * sw / src_rect.width
  1173.       while (shr > 0)
  1174.         sh = [bmp.height - sy, shr].min
  1175.         dh = dest_rect.height * sh / src_rect.height
  1176.         if stretch
  1177.           self.stretch_blt(Rect.new(dx,dy,dw,dh), bmp, Rect.new(sx,sy,sw,sh),op)
  1178.         else
  1179.           self.blt(dx, dy, bmp, Rect.new(sx, sy, sw, sh), op)
  1180.         end
  1181.         sy = 0    
  1182.         shr -= sh
  1183.         dy += dh  
  1184.       end
  1185.       sx = 0    
  1186.       swr -= sw
  1187.       dx += dw
  1188.     end
  1189.   end
  1190.   #----------------------------------------------------------------------------
  1191.   # • Efeito negativo.
  1192.   #----------------------------------------------------------------------------
  1193.   def negative
  1194.     for i in 0...(self.width)
  1195.       for j in 0...(self.height)
  1196.         pix = self.get_pixel(i, j)
  1197.         pix.red = (pix.red - 255) * -1
  1198.         pix.blue = (pix.blue - 255) * -1
  1199.         pix.green = (pix.green - 255) * -1
  1200.         self.set_pixel(i, j, pix)
  1201.       end
  1202.     end
  1203.   end
  1204.   #----------------------------------------------------------------------------
  1205.   # • Grayscale
  1206.   #----------------------------------------------------------------------------
  1207.   def grayscale(rect = Rect.new(0, 0, self.width, self.height))
  1208.     for i in rect.x...rect.x + rect.width
  1209.       for j in rect.y...rect.y + rect.height
  1210.         colour = self.get_pixel(i,j)
  1211.         grey_pixel = (colour.red*0.3 + colour.green*0.59 + colour.blue*0.11)
  1212.         colour.red = colour.green = colour.blue = grey_pixel
  1213.         self.set_pixel(i,j,colour)
  1214.       end
  1215.     end
  1216.   end
  1217.   #----------------------------------------------------------------------------
  1218.   # • Contorno.
  1219.   #----------------------------------------------------------------------------
  1220.   def doutline(tw, th, min, max, color)
  1221.     temp = self.dup
  1222.     nx   = self.width / tw
  1223.     ny   = self.height / th
  1224.     rect = Rect.new(0, 0, tw, th)
  1225.     for y in 0...ny
  1226.       rect.y = y * th
  1227.       for x in 0...nx
  1228.         rect.x = x * tw
  1229.         for ty in 0...rect.height
  1230.           y = ty + rect.y
  1231.           for tx in 0...rect.width
  1232.             x = tx + rect.x
  1233.             self.set_pixel(x, y, color) if temp.get_pixel(x, y).alpha >= max && ((tx > 0 && temp.get_pixel(x - 1, y).alpha <= min) || (tx < rect.width - 1 && temp.get_pixel(x + 1, y).alpha <= min) || (ty > 0 && temp.get_pixel(x, y - 1).alpha <= min) || (ty < rect.height - 1 && temp.get_pixel(x, y + 1).alpha <= min))
  1234.           end
  1235.         end
  1236.       end
  1237.     end
  1238.     temp.dispose
  1239.   end
  1240.   #----------------------------------------------------------------------------
  1241.   # • Novo fornecedor de pixel.
  1242.   #----------------------------------------------------------------------------
  1243.   def set_pixel_s(x, y, color, size)
  1244.     for i in 0...size
  1245.       self.set_pixel(x+i, y, color)
  1246.       self.set_pixel(x-i, y, color)
  1247.       self.set_pixel(x, y+i, color)
  1248.       self.set_pixel(x, y-i, color)
  1249.       self.set_pixel(x+i, y+i, color)
  1250.       self.set_pixel(x-i, y-i, color)
  1251.       self.set_pixel(x+i, y-i, color)
  1252.       self.set_pixel(x-i, y+i, color)
  1253.     end
  1254.   end
  1255.   #----------------------------------------------------------------------------
  1256.   # • Desenhar uma linha.
  1257.   #----------------------------------------------------------------------------
  1258.   def draw_line(start_x, start_y, end_x, end_y, color, size=1)
  1259.     set_pixel_s(start_x, start_y, color, size)
  1260.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  1261.     for i in 1..distance
  1262.       x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  1263.       y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  1264.       set_pixel_s(x, y, color, size)
  1265.     end
  1266.     set_pixel_s(end_x, end_y, color, size)
  1267.   end
  1268.   #----------------------------------------------------------------------------
  1269.   # • draw_bar(x, y, current, current_max, file)
  1270.   #   x : Coordenadas X.
  1271.   #   y : Coordenadas Y.
  1272.   #   current : Valor atual da barra.
  1273.   #   current_max : Valor maxímo da barra.
  1274.   #   file : Imagem da barra.
  1275.   #----------------------------------------------------------------------------
  1276.   #  Permite adicionar uma barra.
  1277.   #----------------------------------------------------------------------------
  1278.   def draw_bar(x, y, current, current_max, file, folder=0)
  1279.     bitmap = folder == 0 ? Cache.picture(file) : Cache.system(file)
  1280.     cw = self.width.to_p(current, current_max)    
  1281.     ch = self.height
  1282.     src_rect = Rect.new(0, 0, cw, ch)
  1283.     self.blt(x, y, bitmap, src_rect)
  1284.   end
  1285.   #----------------------------------------------------------------------------
  1286.   # • draw_bar_gauge(x, y, current, current_max, border, colors)
  1287.   #   x : Coordenadas X.
  1288.   #   y : Coordenadas Y.
  1289.   #   current : Valor atual da barra.
  1290.   #   current_max : Valor maxímo da barra.
  1291.   #   border : Expressura da borda.
  1292.   #   colors : Cores. [0, 1, 2]
  1293.   #----------------------------------------------------------------------------
  1294.   #  Permite adicionar uma barra.
  1295.   #----------------------------------------------------------------------------
  1296.   def draw_bar_gauge(x, y, current, current_max, colors=[])
  1297.     cw = self.width.to_p(current, current_max)    
  1298.     ch = self.height
  1299.     self.gradient_fill_rect(x, y, self.width, self.height, colors[0], colors[1])
  1300.     src_rect = Rect.new(0, 0, cw, ch)
  1301.     self.blt(x, y, self, src_rect)
  1302.   end
  1303.   #----------------------------------------------------------------------------
  1304.   # • draw_icon(icon_index, x, y, enabled)
  1305.   #   icon_index : ID do ícone.
  1306.   #   x : Coordenadas X.
  1307.   #   y : Coordenadas Y.
  1308.   #   enabled : Habilitar flag, translucido quando false
  1309.   #----------------------------------------------------------------------------  
  1310.   #----------------------------------------------------------------------------
  1311.   def draw_icon(icon_index, x, y, enabled = true)
  1312.     bitmap = Cache.system("Iconset")
  1313.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  1314.     self.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  1315.   end
  1316.   #----------------------------------------------------------------------------
  1317.   # • _fill(x, y, width, height, color1, color2)
  1318.   #   x : Coordenada X.
  1319.   #   y : Coordenada Y.
  1320.   #   width : Largura da barra.
  1321.   #   height : Altura da barra.
  1322.   #   color1 : Cor da borda.
  1323.   #   color2 : Cor da barra.
  1324.   #----------------------------------------------------------------------------
  1325.   #  Permite criar uma barra em fill_rect simples.
  1326.   #----------------------------------------------------------------------------
  1327.   def _fill(x, y, width, height, color1, color2)
  1328.     self.fill_rect(x, y, width, height, color1)
  1329.     self.fill_rect(x+1, y+1, width-2, height-2, color2)
  1330.   end
  1331.   #----------------------------------------------------------------------------
  1332.   # • gradation_fill_rect(*args)
  1333.   #   x : Posição X.
  1334.   #   y : Posição Y.
  1335.   #   width : Largura da barra.
  1336.   #   height : Altura da barra.
  1337.   #   color1 : Primeira cor.
  1338.   #   color2 : Segunda cor.
  1339.   #   aling  : 0 - Gradiação normal, 1 - Gradiação na Vertical, 2 - Gradiação concetrada
  1340.   #----------------------------------------------------------------------------  
  1341.   #  Faz uma gradiação;
  1342.   #----------------------------------------------------------------------------
  1343.   def gradation_fill_rect(x, y, width, height, color1, color2, align=0)
  1344.     case align
  1345.     when 0
  1346.       for ix in x...x + width
  1347.         red = color1.red + (color2.red - color1.red) * (ix - x) / (width - 1)
  1348.         green = color1.green + (color2.green - color1.green) * (ix - x) / (width - 1)
  1349.         blue = color1.blue + (color2.blue - color1.blue) * (i - x) / (width - 1)
  1350.         alpha = color1.alpha + (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  1351.         color = Color.new(red, green, blue, alpha)
  1352.         self.fill_rect(ix, y, 1, height, color)
  1353.       end
  1354.     when 1
  1355.       for iy in y...y + height
  1356.         red   = color1.red + (color2.red - color1.red) * (iy - y) / (height - 1)
  1357.         green = color1.green + (color2.green - color1.green) * (iy - y) / (height - 1)
  1358.         blue  = color1.blue + (color2.blue - color1.blue) * (iy - y) / (height - 1)
  1359.         alpha = color1.alpha + (color2.alpha - color1.alpha) * (iy - y) / (height - 1)
  1360.         color = Color.new(red, green, blue, alpha)
  1361.         fill_rect(x, iy, width, 1, color)
  1362.       end
  1363.     when 2
  1364.       for ix in x...x + width
  1365.         for ij in y...y + height
  1366.           red   = color1.red + (color2.red - color1.red) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  1367.           green = color1.green + (color2.green - color1.green) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  1368.           blue  = color1.blue + (color2.blue - color1.blue) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  1369.           alpha = color1.alpha + (color2.alpha - color1.alpha) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
  1370.           color = Color.new(red, green, blue, alpha)
  1371.           set_pixel(ix, ij, color)
  1372.         end
  1373.       end
  1374.     end
  1375.   end
  1376.   #----------------------------------------------------------------------------
  1377.   # • draw_gradation_gauge(x, y, width, height, current, current_max, border, colors, align)
  1378.   #   x : Coordenadas X.
  1379.   #   y : Coordenadas Y.
  1380.   #   width : Largura da barra.
  1381.   #   height : Altura da barra.
  1382.   #   current : Valor atual da barra.
  1383.   #   current_max : Valor maxímo da barra.
  1384.   #   border : Expressura da borda.
  1385.   #   colors : Cores. [0, 1, 2]
  1386.   #   align : Alinhamento.
  1387.   #----------------------------------------------------------------------------
  1388.   #  Permite adicionar uma barra.
  1389.   #----------------------------------------------------------------------------
  1390.   def draw_gradation_gauge(x, y, current, current_max, border, colors=[], align=2)
  1391.     cw = self.width.to_p(current, current_max)    
  1392.     ch = self.height
  1393.     self._fill(x, y, self.width, self.height, colors[0], colors[0])
  1394.     self.gradation_fill_rect(x+border, y+border, self.width-(border/2), self.height-(border/2), colors[1], colors[2], align)
  1395.     src_rect = Rect.new(0, 0, cw, ch)
  1396.     self.blt(x, y, self, src_rect)
  1397.   end
  1398.   #--------------------------------------------------------------------------
  1399.   # • Desenho do gráfico de rosto
  1400.   #     face_name  : nome do gráfico de face
  1401.   #     face_index : índice do gráfico de face
  1402.   #     x          : coordenada X
  1403.   #     y          : coordenada Y
  1404.   #     enabled    : habilitar flag, translucido quando false
  1405.   #--------------------------------------------------------------------------
  1406.   def draw_face(face_name, face_index, x, y, enabled = true)
  1407.     bitmaps = Cache.face(face_name)
  1408.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  1409.     self.blt(x, y, bitmaps, rect, enabled ? 255 : translucent_alpha)
  1410.   end
  1411.   #--------------------------------------------------------------------------
  1412.   # • Desenho do gráfico de face do herói
  1413.   #     actor   : herói
  1414.   #     x       : coordenada X
  1415.   #     y       : coordenada Y
  1416.   #     enabled : habilitar flag, translucido quando false
  1417.   #--------------------------------------------------------------------------
  1418.   def draw_actor_face(actor, x, y, enabled = true)
  1419.     draw_face(actor.face_name, actor.face_index, x, y, enabled)
  1420.   end
  1421.   #--------------------------------------------------------------------------
  1422.   # • Desenho do nível
  1423.   #     actor : herói
  1424.   #     x     : coordenada X
  1425.   #     y     : coordenada Y
  1426.   #--------------------------------------------------------------------------
  1427.   def draw_actor_level(actor, x, y)
  1428.     self.font.name = "Comic Sans MS"
  1429.     self.font.color = ColorBasic[35]
  1430.     self.font.size = 18
  1431.     self.draw_text(x, y, 32, 20, Vocab::level_a)
  1432.     self.font.size = 22
  1433.     draw_text(x + 16, y, 32, 20, actor.level, 2)
  1434.   end
  1435.   #----------------------------------------------------------------------------
  1436.   # • Pegar a largura.
  1437.   #----------------------------------------------------------------------------
  1438.   def get_the_width(lstring)
  1439.     string_rect = self.text_size(lstring)
  1440.     width = string_rect.width
  1441.     return width
  1442.   end
  1443.   #----------------------------------------------------------------------------
  1444.   # • Desenhar um círuclo preenchido.
  1445.   #----------------------------------------------------------------------------
  1446.   def fill_circle(x, y, r, c)
  1447.     rr = r*r
  1448.     for i in 0...r
  1449.       adj = Math.sqrt(rr - (i*i)).ceil
  1450.       xd = x - adj
  1451.       wd = 2 * adj
  1452.       self.fill_rect(xd, y-i, wd, 1, c)
  1453.       self.fill_rect(xd, y+i, wd, 1, c)
  1454.     end
  1455.   end
  1456.   #----------------------------------------------------------------------------
  1457.   # • Desenhar um triângulo preenchido.
  1458.   #----------------------------------------------------------------------------
  1459.   def fill_triangle(x, y, w, h, c)
  1460.     dx = w / 2
  1461.     dy = h
  1462.     d = Math.sqrt(dx*dx + dy*dy)
  1463.     for i in 0...d
  1464.       nx = ((dx*i) / d).round
  1465.       ny = ((dy*i) / d).round
  1466.       fill_rect(x-nx+dx, y+ny, nx*2, 1, c)
  1467.     end
  1468.     fill_rect(x, y+h, w, 1, c)
  1469.   end
  1470.   #----------------------------------------------------------------------------
  1471.   # • Desenhar um triângulo.
  1472.   #----------------------------------------------------------------------------
  1473.   def triangle(pts, c)
  1474.     p1, p2, p3 = pts
  1475.     dx1 = p3[0] - p2[0]
  1476.     dy1 = p3[1] - p2[1]
  1477.     d1 = Math.sqrt(dx1*dx1 + dy1*dy1)
  1478.     xs = p1[0]
  1479.     ys = p1[1]
  1480.     for i1 in 0...d1
  1481.       xe = ((dx1*i1) / d1) + p2[0]
  1482.       ye = ((dy1*i1) / d1) + p2[1]
  1483.       dx2 = xe - xs
  1484.       dy2 = ye - ys
  1485.       d2 = Math.sqrt(dx2*dx2 + dy2*dy2)
  1486.       for i2 in 0...d2
  1487.         xd = ((dx2*i2) / d2) + xs
  1488.         yd = ((dy2*i2) / d2) + ys
  1489.         self.set_pixel(xd, yd, c)
  1490.       end
  1491.     end
  1492.   end
  1493.   #----------------------------------------------------------------------------
  1494.   # • Desenhar um triângulo diferente.
  1495.   #----------------------------------------------------------------------------
  1496.   def fill_triangle3(pts, c, pos=[0, 0])
  1497.     return if pts.size != 3
  1498.     pts.sort! {|a, b| a[1] - b[1]}
  1499.     pt1, pt2, pt3 = pts
  1500.     dxt = (pt3[0] - pt1[0]) / 2
  1501.     dyt = (pt3[1] - pt1[1]) / 2
  1502.     dxm = pt2[0] - pt1[0]
  1503.     dym = pt2[1] - pt1[1]
  1504.     dm = dym.abs
  1505.     if dm > 0 and dyt != 0
  1506.       for i in 0...(dm+2)
  1507.         ix = ((dxm*i) / (dm+1))
  1508.         iy = ((dym*i) / (dm+1))
  1509.         edx = ix - (dxt * iy / dyt)
  1510.         self.fill_rect(ix+pt1[0]-[edx,0].max-2+pos[0], iy+pt1[1]+pos[1], edx.abs+4, 1, c)
  1511.       end
  1512.     end
  1513.     dxm = pt2[0] - pt3[0]
  1514.     dym = pt2[1] - pt3[1]
  1515.     dm = dym.abs
  1516.     if dm > 0 and dyt != 0
  1517.       for i in 0...(dm+2)
  1518.         ix = ((dxm*i) / (dm+1))
  1519.         iy = ((dym*i) / (dm+1))
  1520.         edx = ix - (dxt * iy / dyt)
  1521.         self.fill_rect(ix+pt3[0]-[edx,0].max-2+pos[0], iy+pt3[1]+pos[1], edx.abs+4, 1, c)
  1522.       end
  1523.     end
  1524.   end
  1525.   #----------------------------------------------------------------------------
  1526.   # • Desenhar um polígono.
  1527.   #----------------------------------------------------------------------------
  1528.   def fill_polygon(pts, c, pos=[0, 0])
  1529.     return if pts.size <= 2
  1530.     n = pts.size - 2
  1531.     for i in 0...n
  1532.       self.fill_triangle3(pts[i..(i + 2)], c, pos)
  1533.     end
  1534.   end
  1535.   #----------------------------------------------------------------------------
  1536.   # • Desenhar |ngon|
  1537.   #----------------------------------------------------------------------------
  1538.   def ngon(cx, cy, w, h, n, c, offset_angle = 0)
  1539.     return if (n < 3)
  1540.     center = [cx, cy]
  1541.     angle_step  = (Math::PI * 2 / n)
  1542.     angle       = (offset_angle * Math::PI / 180)
  1543.     p2          = [cx + Math.sin(angle) * w, cy - Math.cos(angle) * h]
  1544.     for i in 1..n
  1545.       angle += angle_step
  1546.       p1 = p2
  1547.       p2 = [cx + Math.sin(angle) * w, cy - Math.cos(angle) * h]
  1548.       self.fill_triangle3([p1, p2, center], c)
  1549.     end
  1550.   end
  1551. end
  1552. #==============================================================================
  1553. # • Mouse
  1554. #==============================================================================
  1555. Dax.register(:Mouse, "Dax", 1.1)
  1556. module Mouse
  1557.   extend self
  1558.   #--------------------------------------------------------------------------
  1559.   # • Inicialização dos objetos.
  1560.   #--------------------------------------------------------------------------
  1561.   def start
  1562.     @cursor = Sprite.new
  1563.     @cursor.z = 100000
  1564.     @cursor.bitmap = Bitmap.new(1, 1)
  1565.     x = Dax::Mouse_Name.empty? ? 1 : 0
  1566.     API::MouseShowCursor.call(x)
  1567.     graphic Dax::Mouse_Name
  1568.     update
  1569.   end
  1570.   #--------------------------------------------------------------------------
  1571.   # • graphic(graphic_set)
  1572.   #   graphic_set : Se for número é um ícone; Se for string é uma imagem.
  1573.   #--------------------------------------------------------------------------
  1574.   def graphic(graphic_set)
  1575.     return if graphic_set.empty? or graphic_set.nil?
  1576.     if graphic_set.is_a?(Fixnum)
  1577.       @cursor.bitmap = Bitmap.new(24, 24)
  1578.       @cursor.bitmap.draw_icon(graphic_set.to_i, 0, 0)
  1579.     else
  1580.       @cursor.bitmap = Cache.picture(graphic_set.to_s)
  1581.     end
  1582.   end
  1583.   #--------------------------------------------------------------------------
  1584.   # • show(visible)
  1585.   #   visible : True - para mostrar o mouse | False - para esconder o mouse.
  1586.   #--------------------------------------------------------------------------
  1587.   def show(visible=true)
  1588.     @cursor.visible = visible
  1589.   end
  1590.   #--------------------------------------------------------------------------
  1591.   # • update (Atualização das coordenadas)
  1592.   #--------------------------------------------------------------------------
  1593.   def update
  1594.     return if @cursor.nil?
  1595.     @cursor.x, @cursor.y = position
  1596.   end
  1597.   #----------------------------------------------------------------------------
  1598.   # • Atualizar o gráfico do mouse.
  1599.   #----------------------------------------------------------------------------
  1600.   def update_graphic
  1601.     return if @cursor.nil?
  1602.     @cursor.update if Graphics.frame_count % 5 == 1
  1603.   end
  1604.   #--------------------------------------------------------------------------
  1605.   # • cursor
  1606.   #--------------------------------------------------------------------------
  1607.   def cursor
  1608.     @cursor
  1609.   end
  1610.   #--------------------------------------------------------------------------
  1611.   # • x (Coordenada X do Mouse)
  1612.   #--------------------------------------------------------------------------
  1613.   def x
  1614.     @cursor.x
  1615.   end
  1616.   #--------------------------------------------------------------------------
  1617.   # • y (Coordenada Y do Mouse)
  1618.   #--------------------------------------------------------------------------
  1619.   def y
  1620.     @cursor.y
  1621.   end
  1622.   #--------------------------------------------------------------------------
  1623.   # • position (Posição do Mouse!)
  1624.   #--------------------------------------------------------------------------
  1625.   def position
  1626.     x, y = get_client_position
  1627.     return x, y
  1628.   end
  1629.   #--------------------------------------------------------------------------
  1630.   # • get_client_position (Posição original do Mouse!)
  1631.   #--------------------------------------------------------------------------
  1632.   def get_client_position
  1633.     pos = [0, 0].pack('ll')
  1634.     API::CursorPosition.call(pos)
  1635.     API::ScreenToClient.call(WINDOW, pos)
  1636.     return pos.unpack('ll')
  1637.   end
  1638.   #--------------------------------------------------------------------------
  1639.   # • find_window (Tamanho da window)
  1640.   #--------------------------------------------------------------------------
  1641.   def find_window
  1642.     game_name = '\0' * 256
  1643.     API::ReadIni.call('Game', 'Title', '', game_name, 255, '.\\Game.ini')
  1644.     game_name.delete!('\0')
  1645.     return API::FindWindow.call('RGSS Player', game_name)
  1646.   end
  1647.   #--------------------------------------------------------------------------
  1648.   # • Verificação se o mouse está na área de um determinado objeto.
  1649.   #--------------------------------------------------------------------------
  1650.   def in_area?(object_sprite)
  1651.     return @cursor.x.between?(object_sprite.x, object_sprite.x + object_sprite.width) &&
  1652.       @cursor.y.between?(object_sprite.y, object_sprite.y + object_sprite.height)
  1653.   end
  1654.   #--------------------------------------------------------------------------
  1655.   # • Verificação um objeto está na área do mouse.
  1656.   #--------------------------------------------------------------------------
  1657.   def object_area?(x, y, xy, yx)
  1658.     return Zone.object_in_area?(@cursor, x, y, xy, yx)
  1659.   end
  1660.   #----------------------------------------------------------------------------
  1661.   # • Mudar posição do cursor.
  1662.   #----------------------------------------------------------------------------
  1663.   def set_mouse(pos)
  1664.     SetCursorPos.call(pos.x, pos.y)
  1665.     update
  1666.     @cursor.x = @pos.x
  1667.     @cursor.y = @pos.y
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # • Verificando se o mouse está na zona de um determinado objeto.
  1671.   #--------------------------------------------------------------------------
  1672.   def in_zone?(object, circled=0)
  1673.     Zone.full(self, object, circled)
  1674.   end
  1675.   WINDOW = find_window
  1676. end
  1677. class << DataManager
  1678.   alias init_mouse init
  1679.   def init
  1680.     Mouse.start
  1681.     init_mouse
  1682.   end
  1683. end
  1684. class << Input
  1685.   #----------------------------------------------------------------------------
  1686.   # • Atualização dos objetos.
  1687.   #----------------------------------------------------------------------------
  1688.   alias ds_core_engine_update update
  1689.   def update
  1690.     ds_core_engine_update
  1691.     Mouse.update
  1692.   end
  1693. end
  1694. class << Graphics
  1695.   alias mouse_update_graphic update
  1696.   def update
  1697.     mouse_update_graphic
  1698.     Mouse.update_graphic
  1699.   end
  1700. end
  1701. #==============================================================================
  1702. # • Variable
  1703. #==============================================================================
  1704. Dax.register(:Variable)
  1705. class Variables
  1706.   #----------------------------------------------------------------------------
  1707.   # • Iniciar
  1708.   #----------------------------------------------------------------------------
  1709.   def initialize
  1710.     @variable = {}
  1711.   end
  1712.   #----------------------------------------------------------------------------
  1713.   # • ID da variável.
  1714.   #----------------------------------------------------------------------------
  1715.   def [](name)
  1716.     @variable[name] || 0
  1717.   end
  1718.   #----------------------------------------------------------------------------
  1719.   # • ID mais valor da variável.
  1720.   #----------------------------------------------------------------------------
  1721.   def []=(name, value)
  1722.     @variable[name] = value
  1723.   end
  1724. end
  1725. #==============================================================================
  1726. # • Switche
  1727. #==============================================================================
  1728. Dax.register(:Switche)
  1729. class Switches
  1730.   #----------------------------------------------------------------------------
  1731.   # • Iniciar
  1732.   #----------------------------------------------------------------------------
  1733.   def initialize
  1734.     @switche = {}
  1735.   end
  1736.   #----------------------------------------------------------------------------
  1737.   # • ID da variável.
  1738.   #----------------------------------------------------------------------------
  1739.   def [](name)
  1740.     @switche[name] || false
  1741.   end
  1742.   #----------------------------------------------------------------------------
  1743.   # • ID mais valor da variável.
  1744.   #----------------------------------------------------------------------------
  1745.   def []=(name, value)
  1746.     @switche[name] = value
  1747.   end
  1748. end
  1749. #==============================================================================
  1750. # • DataManager
  1751. #==============================================================================
  1752. class << DataManager
  1753.   #--------------------------------------------------------------------------
  1754.   # • Criação dos objetos do jogo
  1755.   #--------------------------------------------------------------------------
  1756.   alias dax_create_game_objects create_game_objects
  1757.   def create_game_objects
  1758.     dax_create_game_objects
  1759.     $variables = Variables.new
  1760.     $switches = Switches.new
  1761.   end
  1762. end
  1763. #==============================================================================
  1764. # • Object
  1765. #==============================================================================
  1766. Dax.register(:Object, "Dax", 1.3)
  1767. class Object
  1768.   #----------------------------------------------------------------------------
  1769.   # • Requerir um arquivo.
  1770.   #----------------------------------------------------------------------------
  1771.   def require(dll)
  1772.     $LOAD_PATH << "./"
  1773.     p("Carregando...#{dll}")
  1774.     Kernel.send(:require, dll)
  1775.   end
  1776.   #----------------------------------------------------------------------------
  1777.   # • Carregar um arquivo.
  1778.   #----------------------------------------------------------------------------
  1779.   def load(dll)
  1780.     $LOAD_PATH << "./"
  1781.     p "Loading... #{dll}"
  1782.     begin
  1783.       Kernel.send(:load,dll)
  1784.     rescue => error
  1785.       send_error(error)
  1786.     end
  1787.   end
  1788.   #----------------------------------------------------------------------------
  1789.   # • Trigger
  1790.   #----------------------------------------------------------------------------
  1791.   def trigger?(key)
  1792.     return key.is_a?(Symbol) ? Input.trigger?(key) : Key.trigger?(key)
  1793.   end
  1794.   #----------------------------------------------------------------------------
  1795.   # • Press
  1796.   #----------------------------------------------------------------------------
  1797.   def press?(key)
  1798.     return key.is_a?(Symbol) ? Input.press?(key) : Key.press?(key)
  1799.   end
  1800.   #----------------------------------------------------------------------------
  1801.   # • Repeat
  1802.   #----------------------------------------------------------------------------
  1803.   def repeat?(key)
  1804.     return key.is_a?(Symbol) ? Input.repeat?(key) : Key.repeat?(key)
  1805.   end
  1806.   #----------------------------------------------------------------------------
  1807.   # • Chamar a class color.
  1808.   #----------------------------------------------------------------------------
  1809.   def RGB(*args)
  1810.     Color.new(*args)
  1811.   end
  1812. end
  1813. #==============================================================================
  1814. # • ColorBasic
  1815. #==============================================================================
  1816. Dax.register(:ColorBasic, "Dax", 1.2)
  1817. module ColorBasic
  1818.   extend self
  1819.   #----------------------------------------------------------------------------
  1820.   # • Cores em Index
  1821.   #----------------------------------------------------------------------------
  1822.   def [](id)
  1823.     case id
  1824.     when -1 then Color.new(255, 255, 255) # White
  1825.     when 0 then Color.new(240, 248, 255) # Alice Blue
  1826.     when 1 then Color.new(250, 235, 215) # Antique_White
  1827.     when 2 then Color.new(0, 255, 255) # Aqua
  1828.     when 3 then Color.new(127, 255, 255) # Aqua Marine
  1829.     when 4 then Color.new(240, 255, 255) # Azure
  1830.     when 5 then Color.new(245, 245, 220) # Beige
  1831.     when 6 then Color.new(255, 228, 196) # Bisque
  1832.     when 7 then Color.new(0, 0, 0) # Black
  1833.     when 8 then Color.new(255, 235, 205) # Blanchedalmond
  1834.     when 9 then Color.new(0, 0, 255) # Blue
  1835.     when 10 then Color.new(138, 43, 226) # Blue Violet
  1836.     when 11 then Color.new(165, 42, 42) # Brown
  1837.     when 12 then Color.new(222, 184, 135) # Burly Wood
  1838.     when 13 then Color.new(93, 158, 160) # Cadet Blue
  1839.     when 14 then Color.new(127, 255, 0) # Chatreuse
  1840.     when 15 then Color.new(210, 105, 30) # Chocolate
  1841.     when 16 then Color.new(255, 127, 80) # Coral
  1842.     when 17 then Color.new(100, 149, 237) # Corn Flower Blue
  1843.     when 18 then Color.new(255, 248, 220) # CornSilk
  1844.     when 19 then Color.new(220, 20, 60) # Crimson
  1845.     when 20 then Color.new(0, 255, 255) # Cyan
  1846.     when 21 then Color.new(0, 0, 139) # DarkBlue
  1847.     when 22 then Color.new(0, 139, 139) # DarkCyan
  1848.     when 23 then Color.new(184, 134, 11) # DarkGoldEnrod
  1849.     when 24 then Color.new(169, 169, 169) # Dark Gray
  1850.     when 25 then Color.new(0, 100, 0) # Dark Green
  1851.     when 26 then Color.new(189, 183, 107) # Dark Khaki
  1852.     when 27 then Color.new(139, 0, 139) # Dark Magenta
  1853.     when 28 then Color.new(85, 107, 47) # Dark Oliver Green
  1854.     when 29 then Color.new(255, 140, 0) # Dark Orange
  1855.     when 30 then Color.new(153, 50, 204) # Dark orchid
  1856.     when 31 then Color.new(139, 0, 0) # Dark Red
  1857.     when 32 then Color.new(233, 150, 120) # Dark Salmon
  1858.     when 33 then Color.new(143, 188, 143) # Dark Sea Green
  1859.     when 34 then Color.new(72, 61, 139) # Dark Slate Blue
  1860.     when 35 then RGB(255, 255, 0) # Yellow
  1861.     when 36 then RGB(255, 0, 0) # Red
  1862.     when 37 then RGB(0, 255, 0) # Green
  1863.     when 38 then RGB(255, 128, 0) # Orange
  1864.     else
  1865.       Color.new("#FFFFFF") # Cor neutra.
  1866.     end
  1867.   end
  1868. end
  1869. #==============================================================================
  1870. # • Entries
  1871. #==============================================================================
  1872. Dax.register(:entries, 'Dax', 1.0, '02/05/13')
  1873. class Entries
  1874.   #----------------------------------------------------------------------------
  1875.   # • Variável pública da instância.
  1876.   #----------------------------------------------------------------------------
  1877.   attr_accessor :file
  1878.   attr_reader   :get_number
  1879.   attr_reader   :get_file
  1880.   attr_reader   :get_array
  1881.   attr_reader   :name
  1882.   #----------------------------------------------------------------------------
  1883.   # • Inicialização dos objetos.
  1884.   #----------------------------------------------------------------------------
  1885.   def initialize(directory, typefile)
  1886.     return unless FileTest.directory?(directory)
  1887.     @file = Dir.glob(directory + "/*.{" + typefile + "}")
  1888.     @file.each_index { |i| @get_number = i.to_i }
  1889.     @file.each { |i| @get_file = i.to_s }
  1890.     @file.each_with_index { |i| @get_array = i }
  1891.     @name = split @file[0]
  1892.   end
  1893.   #----------------------------------------------------------------------------
  1894.   # • Split | Separar
  1895.   #----------------------------------------------------------------------------
  1896.   def split(file)
  1897.     file.to_s.split('/').last
  1898.   end
  1899.   #----------------------------------------------------------------------------
  1900.   # • Obter nome.
  1901.   #----------------------------------------------------------------------------
  1902.   def name(id)
  1903.     return split(@file[id])
  1904.   end
  1905. end
  1906. #==============================================================================
  1907. # • Window Core
  1908. #==============================================================================
  1909. # Autor: Dax
  1910. # Versão: 1.0
  1911. # Site: www.dax-soft.weebly.com
  1912. # Requerimento: Dax Core
  1913. #==============================================================================
  1914. Dax.register(:Window_Core, "Dax", Dax::Version_WC)
  1915. #==============================================================================
  1916. # • WC
  1917. #==============================================================================
  1918. module WC
  1919.   extend self
  1920.   #----------------------------------------------------------------------------
  1921.   # • Variável e constantes.
  1922.   #----------------------------------------------------------------------------
  1923.   @imported = {} # Importar script.
  1924.   @version_imported = {} # Versão do script importado.
  1925.   @actor_imported = {} # Autor do script importado.
  1926.   #----------------------------------------------------------------------------
  1927.   # • Registrar script.
  1928.   #----------------------------------------------------------------------------
  1929.   def register(name, actor="Dax", version=1.0)
  1930.     @imported[name] = true
  1931.     @version_imported[name] = version
  1932.     @actor_imported[name] = actor
  1933.   end
  1934.   #----------------------------------------------------------------------------
  1935.   # • Cria uma condição de requerimento de script.
  1936.   #----------------------------------------------------------------------------
  1937.   def required(name, actor="Dax", version=1.0)
  1938.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  1939.   end
  1940. end
  1941. #==============================================================================
  1942. # • Letter Input
  1943. #==============================================================================
  1944. WC.register(:Letter_Input, "Dax", 1.0)
  1945. module WC::Letter_Input
  1946.   extend self
  1947.   #----------------------------------------------------------------------------
  1948.   # • Variáveis e constantes.
  1949.   #----------------------------------------------------------------------------
  1950.   $acent = nil
  1951.   $times = [25, 25, 25, 25, 25, 25, 25, 25, 25]
  1952.   #----------------------------------------------------------------------------
  1953.   # • Atualização dos objetos do módulo.
  1954.   #----------------------------------------------------------------------------
  1955.   def update
  1956.     $times[0] = $times[$times.size-1] if $times[0] < $times[$times.size-1] and API::StateKey.call(8) == 0
  1957.     $times[1] = $times[$times.size-1] if $times[1] < $times[$times.size-1] and API::StateKey.call(46) == 0
  1958.     $times[2] = $times[$times.size-1] if $times[2] < $times[$times.size-1] and API::StateKey.call(192) == 0
  1959.     $times[3] = $times[$times.size-1] if $times[3] < $times[$times.size-1] and API::StateKey.call(226) == 0
  1960.     $times[4] = $times[$times.size-1] if $times[4] < $times[$times.size-1] and API::StateKey.call(54) == 0
  1961.     $times[5] = $times[$times.size-1] if $times[5] < $times[$times.size-1] and API::StateKey.call(193) == 0
  1962.     $times[6] = $times[$times.size-1] if $times[6] < $times[$times.size-1] and API::StateKey.call(186) == 0
  1963.     $times[7] = $times[$times.size-1] if $times[7] < $times[$times.size-1] and API::StateKey.call(220) == 0
  1964.   end
  1965.   #----------------------------------------------------------------------------
  1966.   # • Input : Teclas.
  1967.   #----------------------------------------------------------------------------
  1968.   def input
  1969.     acent = get_acent
  1970.     na = false
  1971.     unless acent.nil?
  1972.       if $acent.nil?
  1973.         $acent = acent
  1974.         na = true
  1975.       else
  1976.         r = $acent + acent
  1977.         $acent = nil
  1978.         return r
  1979.       end
  1980.     end
  1981.     unless na
  1982.       r = get_symbol
  1983.       if !r.nil?
  1984.         if !$acent.nil?
  1985.           a = $acent
  1986.           $acent = nil
  1987.           return a + r.to_s
  1988.         else
  1989.           return r
  1990.         end
  1991.       end
  1992.       r = get_number
  1993.       if !r.nil?
  1994.         if !$acent.nil?
  1995.           a = $acent
  1996.           $acent = nil
  1997.           return a + r.to_s
  1998.         else
  1999.           return r
  2000.         end
  2001.       end
  2002.     end
  2003.     m = (get_shift or get_caps_lock)
  2004.     if $acent.nil?
  2005.       r = get_character(m)
  2006.       if r == ""
  2007.         if space?
  2008.           r = " "
  2009.         end
  2010.       end
  2011.     else
  2012.       r = get_character_acent($acent, m)
  2013.       unless r == ""
  2014.         $acent = nil
  2015.       else
  2016.         if space?
  2017.           a = $acent
  2018.           $acent = nil
  2019.           r = a +  " "
  2020.         end
  2021.       end
  2022.     end
  2023.     return r if !r.empty?
  2024.   end
  2025.   #----------------------------------------------------------------------------
  2026.   # • Teclas.
  2027.   #----------------------------------------------------------------------------
  2028.   def space?; trigger?(Key::SPACE); end;
  2029.   def enter?; trigger?(Key::ENTER); end;
  2030.   def back?; trigger?(Key::BACKSPACE); end;
  2031.   def delete?; trigger?(Key::DELETE); end;
  2032.   def asp?; trigger?(Key::F8); end;
  2033.   def tra?; trigger?(226); end;
  2034.   def num6?; trigger?(Key::NUMPAD6); end;
  2035.   def backslash?; trigger?(193); end;
  2036.   def tc?; trigger?(186); end;
  2037.   def t220?; trigger?(220); end;
  2038.   def end?; trigger?(35); end;
  2039.   #----------------------------------------------------------------------------
  2040.   # • Acento.
  2041.   #----------------------------------------------------------------------------
  2042.   def acent
  2043.     if press?(16) and trigger?(19)
  2044.       return "`"
  2045.     elsif trigger?(19)
  2046.       return "´"
  2047.     elsif press?(16) and trigger?(222)
  2048.       return "^"
  2049.     elsif trigger?(222)
  2050.       return "~"
  2051.     elsif trigger?(54)
  2052.       return "¨"
  2053.     end
  2054.     return nil
  2055.   end
  2056.   #----------------------------------------------------------------------------
  2057.   # • Obter Caps Lock
  2058.   #----------------------------------------------------------------------------
  2059.   def get_caps_lock
  2060.     if API::StateKey.call(20) == 1
  2061.       return true
  2062.     else
  2063.       return false
  2064.     end
  2065.   end
  2066.   #----------------------------------------------------------------------------
  2067.   # • Obter Shift
  2068.   #----------------------------------------------------------------------------
  2069.   def get_shift
  2070.     if press?(Key::SHIFT)
  2071.       return true
  2072.     end
  2073.     return false
  2074.   end
  2075.   #----------------------------------------------------------------------------
  2076.   # • Obter Characters
  2077.   #----------------------------------------------------------------------------
  2078.   def get_character(up)
  2079.     c = ""
  2080.     if trigger?(Key::A)
  2081.       c = "a"
  2082.     elsif trigger?(Key::B)
  2083.       c = "b"
  2084.     elsif trigger?(Key::C)
  2085.       c = "c"
  2086.     elsif trigger?(Key::D)
  2087.       c = "d"
  2088.     elsif trigger?(Key::E)
  2089.       c = "e"
  2090.     elsif trigger?(Key::F)
  2091.       c = "f"
  2092.     elsif trigger?(Key::G)
  2093.       c = "g"
  2094.     elsif trigger?(Key::H)
  2095.       c = "h"
  2096.     elsif trigger?(Key::I)
  2097.       c = "i"
  2098.     elsif trigger?(Key::J)
  2099.       c = "j"
  2100.     elsif trigger?(Key::K)
  2101.       c = "k"
  2102.     elsif trigger?(Key::L)
  2103.       c = "l"
  2104.     elsif trigger?(Key::M)
  2105.       c = "m"
  2106.     elsif trigger?(Key::N)
  2107.       c = "n"
  2108.     elsif trigger?(Key::O)
  2109.       c = "o"
  2110.     elsif trigger?(Key::P)
  2111.       c = "p"
  2112.     elsif trigger?(Key::Q)
  2113.       c = "q"
  2114.     elsif trigger?(Key::R)
  2115.       c = "r"
  2116.     elsif trigger?(Key::S)
  2117.       c = "s"
  2118.     elsif trigger?(Key::T)
  2119.       c = "t"
  2120.     elsif trigger?(Key::U)
  2121.       c = "u"
  2122.     elsif trigger?(Key::V)
  2123.       c = "v"
  2124.     elsif trigger?(Key::W)
  2125.       c = "w"
  2126.     elsif trigger?(Key::X)
  2127.       c = "x"
  2128.     elsif trigger?(Key::Y)
  2129.       c = "y"
  2130.     elsif trigger?(Key::Z)
  2131.       c = "z"
  2132.     elsif tc?
  2133.       c = "ç"
  2134.     end
  2135.     if up
  2136.       c = c.upcase
  2137.     end
  2138.     return c
  2139.   end
  2140.   #----------------------------------------------------------------------------
  2141.   # • Obter acentos.
  2142.   #----------------------------------------------------------------------------
  2143.   def get_acent
  2144.     if press?(16) and trigger?(219)
  2145.       return "`"
  2146.     elsif trigger?(219)
  2147.       return "´"
  2148.     elsif press?(16) and trigger?(222)
  2149.       return "^"
  2150.     elsif trigger?(222)
  2151.       return "~"
  2152.     elsif press?(16) and trigger?(Key::N6)
  2153.       return "¨"
  2154.     end
  2155.   end
  2156.   #----------------------------------------------------------------------------
  2157.   # • Obter characters com acentos.
  2158.   #----------------------------------------------------------------------------
  2159.   def get_character_acent(acent, up)
  2160.     c = ""
  2161.     if trigger?(Key::A)
  2162.       if up
  2163.         case acent
  2164.         when "`"
  2165.           c = "À"
  2166.         when "´"
  2167.           c = "Á"
  2168.         when "^"
  2169.           c = "Â"
  2170.         when "~"
  2171.           c = "~A"
  2172.         when "¨"
  2173.           c = "Ä"
  2174.         end
  2175.       else
  2176.         case acent
  2177.         when "`"
  2178.           c = "à"
  2179.         when "´"
  2180.           c = "á"
  2181.         when "^"
  2182.           c = "â"
  2183.         when "~"
  2184.           c = "ã"
  2185.         when "¨"
  2186.           c = "ä"
  2187.         end
  2188.       end
  2189.       return c
  2190.     elsif trigger?(Key::E)
  2191.       if up
  2192.         case acent
  2193.         when "`"
  2194.           c = "È"
  2195.         when "´"
  2196.           c = "É"
  2197.         when "^"
  2198.           c = "Ê"
  2199.         when "~"
  2200.           c = "~E"
  2201.         when "¨"
  2202.           c = "Ë"
  2203.         end
  2204.       else
  2205.         case acent
  2206.         when "`"
  2207.           c = "è"
  2208.         when "´"
  2209.           c = "é"
  2210.         when "^"
  2211.           c = "ê"
  2212.         when "~"
  2213.           c = "~e"
  2214.         when "¨"
  2215.           c = "ë"
  2216.         end
  2217.       end
  2218.       return c
  2219.     elsif trigger?(Key::I)
  2220.       if up
  2221.         case acent
  2222.         when "`"
  2223.           c = "Ì"
  2224.         when "´"
  2225.           c = "Í"
  2226.         when "^"
  2227.           c = "Î"
  2228.         when "~"
  2229.           c = "~I"
  2230.         when "¨"
  2231.           c = "Ï"
  2232.         end
  2233.       else
  2234.         case acent
  2235.         when "`"
  2236.           c = "ì"
  2237.         when "´"
  2238.           c = "í"
  2239.         when "^"
  2240.           c = "î"
  2241.         when "~"
  2242.           c = "~i"
  2243.         when "¨"
  2244.           c = "ï"
  2245.         end
  2246.       end
  2247.       return c
  2248.     elsif trigger?(Key::O)
  2249.       if up
  2250.         case acent
  2251.         when "`"
  2252.           c = "Ò"
  2253.         when "´"
  2254.           c = "Ó"
  2255.         when "^"
  2256.           c = "Ô"
  2257.         when "~"
  2258.           c = "~O"
  2259.         when "¨"
  2260.           c = "Ö"
  2261.         end
  2262.       else
  2263.         case acent
  2264.         when "`"
  2265.           c = "ò"
  2266.         when "´"
  2267.           c = "ó"
  2268.         when "^"
  2269.           c = "ô"
  2270.         when "~"
  2271.           c = "õ"
  2272.         when "¨"
  2273.           c = "ö"
  2274.         end
  2275.       end
  2276.       return c
  2277.     elsif trigger?(Key::U)
  2278.       if up
  2279.         case acent
  2280.         when "`"
  2281.           c = "Ù"
  2282.         when "´"
  2283.           c = "Ú"
  2284.         when "^"
  2285.           c = "Û"
  2286.         when "~"
  2287.           c = "~U"
  2288.         when "¨"
  2289.           c = "Ü"
  2290.         end
  2291.       else
  2292.         case acent
  2293.         when "`"
  2294.           c = "ù"
  2295.         when "´"
  2296.           c = "ú"
  2297.         when "^"
  2298.           c = "û"
  2299.         when "~"
  2300.           c = "~u"
  2301.         when "¨"
  2302.           c = "ü"
  2303.         end
  2304.       end
  2305.       return c
  2306.     elsif trigger?(Key::B)
  2307.       c = acent + "b"
  2308.     elsif trigger?(Key::C)
  2309.       c = acent + "c"
  2310.     elsif trigger?(Key::D)
  2311.       c = acent + "d"
  2312.     elsif trigger?(Key::F)
  2313.       c = acent + "f"
  2314.     elsif trigger?(Key::G)
  2315.       c = acent + "g"
  2316.     elsif trigger?(Key::H)
  2317.       c = acent + "h"
  2318.     elsif trigger?(Key::J)
  2319.       c = acent + "j"
  2320.     elsif trigger?(Key::K)
  2321.       c = acent + "k"
  2322.     elsif trigger?(Key::L)
  2323.       c = acent + "l"
  2324.     elsif trigger?(Key::M)
  2325.       c = acent + "m"
  2326.     elsif trigger?(Key::N)
  2327.       c = acent + "n"
  2328.     elsif trigger?(Key::P)
  2329.       c = acent + "p"
  2330.     elsif trigger?(Key::Q)
  2331.       c = acent + "q"
  2332.     elsif trigger?(Key::R)
  2333.       c = acent + "r"
  2334.     elsif trigger?(Key::S)
  2335.       c = acent + "s"
  2336.     elsif trigger?(Key::T)
  2337.       c = acent + "t"
  2338.     elsif trigger?(Key::V)
  2339.       c = acent + "v"
  2340.     elsif trigger?(Key::W)
  2341.       c = acent + "w"
  2342.     elsif trigger?(Key::X)
  2343.       c = acent + "x"
  2344.     elsif trigger?(Key::Y)
  2345.       c = acent + "y"
  2346.     elsif trigger?(Key::Z)
  2347.       c = acent + "z"
  2348.     elsif tc?
  2349.       c = acent + "ç"
  2350.     end
  2351.     if up and c != ""
  2352.       c = c.upcase
  2353.     end
  2354.     return c
  2355.   end
  2356.   #----------------------------------------------------------------------------
  2357.   # • Obter número.
  2358.   #----------------------------------------------------------------------------
  2359.   def get_number
  2360.     if trigger?(Key::N0)
  2361.       c = 0
  2362.     elsif trigger?(Key::N1)
  2363.       c = 1
  2364.     elsif trigger?(Key::N2)
  2365.       c = 2
  2366.     elsif trigger?(Key::N3)
  2367.       c = 3
  2368.     elsif trigger?(Key::N4)
  2369.       c = 4
  2370.     elsif trigger?(Key::N5)
  2371.       c = 5
  2372.     elsif trigger?(Key::N6)
  2373.       c = 6
  2374.     elsif trigger?(Key::N7)
  2375.       c = 7
  2376.     elsif trigger?(Key::N8)
  2377.       c = 8
  2378.     elsif trigger?(Key::N9)
  2379.       c = 9
  2380.     elsif trigger?(Key::NUMPAD0)
  2381.       c = 0
  2382.     elsif trigger?(Key::NUMPAD1)
  2383.       c = 1
  2384.     elsif trigger?(Key::NUMPAD2)
  2385.       c = 2
  2386.     elsif trigger?(Key::NUMPAD3)
  2387.       c = 3
  2388.     elsif trigger?(Key::NUMPAD4)
  2389.       c = 4
  2390.     elsif trigger?(Key::NUMPAD5)
  2391.       c = 5
  2392.     elsif trigger?(Key::NUMPAD6)
  2393.       c = 6
  2394.     elsif trigger?(Key::NUMPAD7)
  2395.       c = 7
  2396.     elsif trigger?(Key::NUMPAD8)
  2397.       c = 8
  2398.     elsif trigger?(Key::NUMPAD9)
  2399.       c = 9
  2400.     end
  2401.   end
  2402.   #----------------------------------------------------------------------------
  2403.   # • Obter simbolos;
  2404.   #----------------------------------------------------------------------------
  2405.   def get_symbol
  2406.     if press?(16) and trigger?(189)
  2407.       c = "_"
  2408.     elsif trigger?(189)
  2409.       c = "-"
  2410.     elsif press?(17) and press?(18) and trigger?(187)
  2411.       c = "§"
  2412.     elsif press?(16) and trigger?(187)
  2413.       c = "+"
  2414.     elsif trigger?(187)
  2415.       c = "="
  2416.     elsif press?(17) and press?(18) and trigger?(221)
  2417.       c = "ª"
  2418.     elsif press?(16) and trigger?(221)
  2419.       c = "{"
  2420.     elsif trigger?(221)
  2421.       c = "["
  2422.     elsif press?(17) and press?(18) and t220?
  2423.       c = "º"
  2424.     elsif press?(16) and t220?
  2425.       c = "}"
  2426.     elsif t220?
  2427.       c = "]"
  2428.     elsif press?(16) and tra?
  2429.       c = "|"
  2430.     elsif tra?
  2431.       c = "\\"
  2432.     elsif press?(16) and trigger?(188)
  2433.       c = "<"
  2434.     elsif trigger?(188)
  2435.       c = ","
  2436.     elsif press?(16) and trigger?(190)
  2437.       c = ">"
  2438.     elsif trigger?(190)
  2439.       c = "."
  2440.     elsif press?(16) and trigger?(191)
  2441.       c = ":"
  2442.     elsif trigger?(191)
  2443.       c = ";"
  2444.     elsif press?(17) and press?(18) and backslash?
  2445.       c = "°"
  2446.     elsif press?(16) and backslash?
  2447.       c = "?"
  2448.     elsif backslash?
  2449.       c = "/"
  2450.     elsif press?(16) and asp?
  2451.       c = "\""
  2452.     elsif asp?
  2453.       c = "'"
  2454.     elsif trigger?(111)
  2455.       c = "/"
  2456.     elsif trigger?(106)
  2457.       c = "*"
  2458.     elsif trigger?(109)
  2459.       c = "-"
  2460.     elsif trigger?(107)
  2461.       c = "+"
  2462.     elsif trigger?(194)
  2463.       c = "."
  2464.     elsif trigger?(110)
  2465.       c = ","
  2466.     elsif press?(16) and trigger?(Key::N0)
  2467.       c = ")"
  2468.     elsif press?(17) and press?(18) and trigger?(Key::N1)
  2469.       c = "¹"
  2470.     elsif press?(16) and trigger?(Key::N1)
  2471.       c = "!"
  2472.     elsif press?(17) and press?(18) and trigger?(Key::N2)
  2473.       c = "²"
  2474.     elsif press?(16) and trigger?(Key::N3)
  2475.       c = "@"
  2476.     elsif press?(17) and press?(18) and trigger?(Key::N3)
  2477.       c = "³"
  2478.     elsif press?(16) and trigger?(Key::N3)
  2479.       c = "#"
  2480.     elsif press?(17) and press?(18) and trigger?(Key::N4)
  2481.       c = "£"
  2482.     elsif press?(16) and trigger?(Key::N4)
  2483.       c = "$"
  2484.     elsif press?(17) and press?(18) and trigger?(Key::N5)
  2485.       c = "¢"
  2486.     elsif press?(16) and trigger?(Key::N5)
  2487.       c = "%"
  2488.     elsif press?(17) and press?(18) and trigger?(Key::N6)
  2489.       c = "¬"
  2490.     elsif press?(16) and trigger?(Key::N7)
  2491.       c = "&"
  2492.     elsif press?(16) and trigger?(Key::N8)
  2493.       c = "*"
  2494.     elsif press?(16) and trigger?(Key::N9)
  2495.       c = "("
  2496.     end
  2497.   end
  2498. end
  2499.  
  2500. class << Input
  2501.   alias method_letter_input_update update
  2502.   def update
  2503.     method_letter_input_update
  2504.     WC::Letter_Input.update
  2505.   end
  2506. end
  2507. #==============================================================================
  2508. # • Position
  2509. #==============================================================================
  2510. WC.register(:Pos_Size, "Dax", 1.0)
  2511. class WC::Position < Struct.new(:x, :y)
  2512.   #----------------------------------------------------------------------------
  2513.   # • Inicialização dos objetos.
  2514.   #----------------------------------------------------------------------------
  2515.   def initialize(x, y)
  2516.     self.x = x.to_i
  2517.     self.y = y.to_i
  2518.   end
  2519.   #----------------------------------------------------------------------------
  2520.   # • Add.
  2521.   #----------------------------------------------------------------------------
  2522.   def +(add)
  2523.     rst = WC::Position.new(self.x, self.y)
  2524.     rst.x += add.x.to_i
  2525.     rst.y += add.y.to_i
  2526.     rst
  2527.   end
  2528.   #----------------------------------------------------------------------------
  2529.   # • Sub.
  2530.   #----------------------------------------------------------------------------
  2531.   def -(add)
  2532.     rst = WC::Position.new(self.x, self.y)
  2533.     rst.x -= add.x.to_i
  2534.     rst.y -= add.y.to_i
  2535.     rst
  2536.   end
  2537.   #----------------------------------------------------------------------------
  2538.   # • Set
  2539.   #----------------------------------------------------------------------------
  2540.   def set(pos)
  2541.     self.x = pos.x.to_i
  2542.     self.y = pos.y.to_i
  2543.   end
  2544.   #----------------------------------------------------------------------------
  2545.   # • Inspecionar
  2546.   #----------------------------------------------------------------------------
  2547.   def inspects
  2548.     "pos: #{self.to_s}"
  2549.   end
  2550.   #----------------------------------------------------------------------------
  2551.   # • Converter para string.
  2552.   #----------------------------------------------------------------------------
  2553.   def to_s
  2554.     "(#{self.x}, #{self.y})"
  2555.   end
  2556.   #----------------------------------------------------------------------------
  2557.   # • Converter para array.
  2558.   #----------------------------------------------------------------------------
  2559.   def to_a
  2560.     [self.x, self.y]
  2561.   end
  2562.   #----------------------------------------------------------------------------
  2563.   # • Achar o tamanho.
  2564.   #----------------------------------------------------------------------------
  2565.   def to_size
  2566.     WC::Size.new(self.x, self.y)
  2567.   end
  2568.   #----------------------------------------------------------------------------
  2569.   # • Verificar.
  2570.   #----------------------------------------------------------------------------
  2571.   def ==(obj)
  2572.     unless obj.is_a?(WC::Position)
  2573.       return false      
  2574.     end
  2575.     if self.x == obj.x and self.y == obj.y
  2576.       return true
  2577.     end
  2578.     return false
  2579.   end
  2580.   #----------------------------------------------------------------------------
  2581.   # • Converter para um valor bruto.
  2582.   #----------------------------------------------------------------------------
  2583.   def abs
  2584.     WC::Position.new(self.x.abs, self.y.abs)
  2585.   end
  2586. end
  2587. #==============================================================================
  2588. # • Size
  2589. #==============================================================================
  2590. WC.register(:Size, "Dax", 1.0)
  2591. class WC::Size < Struct.new(:width, :height)
  2592.   #----------------------------------------------------------------------------
  2593.   # • Add.
  2594.   #----------------------------------------------------------------------------
  2595.   def +(add)
  2596.     rst = WC::Size.new(self.width, self.height)
  2597.     rst.width += add.width
  2598.     rst.height += add.height
  2599.     rst
  2600.   end
  2601.   #----------------------------------------------------------------------------
  2602.   # • Sub.
  2603.   #----------------------------------------------------------------------------
  2604.   def -(add)
  2605.     rst = WC::Size.new(self.width, self.height)
  2606.     rst.width -= add.width
  2607.     rst.height -= add.height
  2608.     rst
  2609.   end
  2610.   #----------------------------------------------------------------------------
  2611.   # • Set
  2612.   #----------------------------------------------------------------------------
  2613.   def set(size)
  2614.     self.width = size.width
  2615.     self.height = size.height
  2616.   end
  2617.   #----------------------------------------------------------------------------
  2618.   # • Inspecionar
  2619.   #----------------------------------------------------------------------------
  2620.   def inspect
  2621.     "size: #{self.to_s}"
  2622.   end
  2623.   #----------------------------------------------------------------------------
  2624.   # • Converter para string.
  2625.   #----------------------------------------------------------------------------
  2626.   def to_s
  2627.     "(#{self.width}, #{self.height})"
  2628.   end
  2629.   #----------------------------------------------------------------------------
  2630.   # • Converter para array.
  2631.   #----------------------------------------------------------------------------
  2632.   def to_a
  2633.     [self.width, self.height]
  2634.   end
  2635.   #----------------------------------------------------------------------------
  2636.   # • Converter para posição.
  2637.   #----------------------------------------------------------------------------
  2638.   def to_position
  2639.     WC::Position.new(self.width, self.height)
  2640.   end
  2641.   #----------------------------------------------------------------------------
  2642.   # • Igual
  2643.   #----------------------------------------------------------------------------
  2644.   def ==(s)
  2645.     unless s.is_a?(WC::Size)
  2646.       return false      
  2647.     end
  2648.     if self.width == s.width and self.height == s.height
  2649.       return true
  2650.     else
  2651.       return false
  2652.     end
  2653.   end
  2654.   #----------------------------------------------------------------------------
  2655.   # • Converter para valor bruto.
  2656.   #----------------------------------------------------------------------------
  2657.   def abs
  2658.     WC::Size.new(self.width.abs, self.height.abs)
  2659.   end
  2660. end
  2661. #==============================================================================
  2662. # • Kernel
  2663. #==============================================================================
  2664. WC.register(:Kernel, "Dax", 1.0)
  2665. module Kernel
  2666.   #----------------------------------------------------------------------------
  2667.   # • Achar a posição.
  2668.   #----------------------------------------------------------------------------
  2669.   def wc_pos(x, y)
  2670.     WC::Position.new(x, y)
  2671.   end
  2672.   #----------------------------------------------------------------------------
  2673.   # • Achar o tamanho.
  2674.   #----------------------------------------------------------------------------
  2675.   def wc_size(w, h)
  2676.     WC::Size.new(w, h)
  2677.   end
  2678. end
  2679. #==============================================================================
  2680. # • TextBase
  2681. #==============================================================================
  2682. WC.register(:text_base, "Dax", 1.0)
  2683. class TextBase
  2684.   #----------------------------------------------------------------------------
  2685.   # • Inicialização dos objetos.
  2686.   #----------------------------------------------------------------------------
  2687.   def initialize
  2688.     @text = ""
  2689.   end
  2690.   #----------------------------------------------------------------------------
  2691.   # • Adicionar texto.
  2692.   #----------------------------------------------------------------------------
  2693.   def text=(text_add)
  2694.     @text += text_add
  2695.   end
  2696.   #----------------------------------------------------------------------------
  2697.   # • Adicionar uma nova linha.
  2698.   #----------------------------------------------------------------------------
  2699.   def text(text, nspace=0)
  2700.     @text += "\r\n" + (" " * nspace) + text
  2701.   end
  2702.   #----------------------------------------------------------------------------
  2703.   # • Adicionar comentário;
  2704.   #----------------------------------------------------------------------------
  2705.   def comment=(text_add, comment="#")
  2706.     @text += comment + text_add
  2707.   end
  2708.   #----------------------------------------------------------------------------
  2709.   # • Adicionar uma nova linha como comentário.
  2710.   #----------------------------------------------------------------------------
  2711.   def comment(text, nspace=0, comment="#")
  2712.     @text += "\r\n" + (" " * nspace) + comment + text
  2713.   end
  2714.   #----------------------------------------------------------------------------
  2715.   # • Salvar o texto.
  2716.   #----------------------------------------------------------------------------
  2717.   def save(filename="")
  2718.     _file = File.open(filename, "a+").each { |file|
  2719.       file.write(@text.to_s)
  2720.       file.close
  2721.     }
  2722.   end
  2723. end
  2724. #==============================================================================
  2725. # • Psych Core
  2726. #==============================================================================
  2727. # Autor: Dax
  2728. # Versão: 0.1
  2729. # Site: www.dax-soft.weebly.com
  2730. # Requerimento: Dax Core 1.9
  2731. #==============================================================================
  2732. # • Descrição:
  2733. #------------------------------------------------------------------------------
  2734. #  Trata-se de vários scripts para proporcionar uma física simples.
  2735. #==============================================================================
  2736. Dax.register(:Psych_Core, "Dax", Dax::Version_PS)
  2737. module PS
  2738.   extend self
  2739.   #----------------------------------------------------------------------------
  2740.   # • Variável e constantes.
  2741.   #----------------------------------------------------------------------------
  2742.   @imported = {} # Importar script.
  2743.   @version_imported = {} # Versão do script importado.
  2744.   @actor_imported = {} # Autor do script importado.
  2745.   #----------------------------------------------------------------------------
  2746.   # • Registrar script.
  2747.   #----------------------------------------------------------------------------
  2748.   def register(name, actor="Dax", version=Dax::Version_PS)
  2749.     @imported[name] = true
  2750.     @version_imported[name] = version
  2751.     @actor_imported[name] = actor
  2752.   end
  2753.   #----------------------------------------------------------------------------
  2754.   # • Cria uma condição de requerimento de script.
  2755.   #----------------------------------------------------------------------------
  2756.   def required(name, actor="Dax", version=Dax::Version_PS)
  2757.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  2758.   end
  2759. end
  2760. #==============================================================================
  2761. # • LimitScreen | Sisetma que cria uma condição para o objeto não passar os limites da tela.
  2762. #==============================================================================
  2763. PS.register(:LimitScreen, "Dax", 1.0)
  2764. class PS::LimitScreen
  2765.   #----------------------------------------------------------------------------
  2766.   # • Inicialização dos objetos.
  2767.   #----------------------------------------------------------------------------
  2768.   def initialize(object, limit_screen=[Graphics.width, Graphics.height])
  2769.     @object = object
  2770.     @limit_screen = limit_screen
  2771.     up?
  2772.     down?
  2773.     left?
  2774.     right?
  2775.   end
  2776.   #----------------------------------------------------------------------------
  2777.   # • Verificar se o objeto está tentando passar do limite de cima.
  2778.   #----------------------------------------------------------------------------
  2779.   def up?
  2780.     if @object.y <= 0
  2781.       @object.y = 0
  2782.     end
  2783.   end
  2784.   #----------------------------------------------------------------------------
  2785.   # • Verificar se o objeto está tentando passar do limite de baixo.
  2786.   #----------------------------------------------------------------------------
  2787.   def down?
  2788.     if @object.y >= @limit_screen[1] - @object.height
  2789.       @object.y = @limit_screen[1] - @object.height
  2790.     end
  2791.   end
  2792.   #----------------------------------------------------------------------------
  2793.   # • Verificar se o objeto está tentando passar do limite da esquerda.
  2794.   #----------------------------------------------------------------------------
  2795.   def left?
  2796.     if @object.x <= 0
  2797.       @object.x = 0
  2798.     end
  2799.   end
  2800.   #----------------------------------------------------------------------------
  2801.   # • Verificar se o object está tentando passar do limite da direita.
  2802.   #----------------------------------------------------------------------------
  2803.   def right?
  2804.     if @object.x >= @limit_screen[0] - @object.width
  2805.       @object.x = @limit_screen[0] - @object.height
  2806.     end
  2807.   end
  2808. end
  2809. #==============================================================================
  2810. # • DRGSS | Comandos do RGSS...
  2811. #==============================================================================
  2812. Dax.register(:DRGSS, "Dax", Dax::DRGSS)
  2813. module DRGSS
  2814.   extend self
  2815.   #----------------------------------------------------------------------------
  2816.   # • Comandos simples do menu.
  2817.   #----------------------------------------------------------------------------
  2818.   def command_menu(buffer)
  2819.     return if buffer.nil?
  2820.     return "SceneManager.call(Scene_Item)" if buffer =~ /item/
  2821.     return "SceneManager.call(Scene_Skill)" if buffer =~ /skill/
  2822.     return "SceneManager.call(Scene_Equip)" if buffer =~ /equip/
  2823.     return "SceneManager.call(Scene_Status)" if buffer =~ /status/
  2824.     return "SceneManager.call(Scene_Save)" if buffer =~ /save/
  2825.     return "SceneManager.call(Scene_End)" if buffer =~ /end/
  2826.   end
  2827.   #----------------------------------------------------------------------------
  2828.   # • Ações básicas
  2829.   #----------------------------------------------------------------------------
  2830.   def action_base(buffer)
  2831.     return if buffer.nil?
  2832.     if buffer =~ /ani_player: (\d+)/ then $game_player.animation_id = $1.to_i end
  2833.     if buffer =~ /ani_event: (\d+), (\d+)/ then $game_map.events[$1.to_i].animation_id = $2.to_i end  
  2834.     if buffer =~ /clear_vars: (\d+)..(\d+)/ then ($1.to_i...$2.to_i).each { |i| $game_variables[i] = 0 } end
  2835.     if buffer =~ /common_event: (\d+)/ then $game_temp.reserve_common_event($1.to_i) end
  2836.   end
  2837.   #----------------------------------------------------------------------------
  2838.   # • Condições básicas personagem.
  2839.   #----------------------------------------------------------------------------
  2840.   def if_player(buffer)
  2841.     return if buffer.nil?
  2842.     if buffer =~ /skill (\d+), (\d+)/  then return $game_party.members[$1.to_i].skill_learn?($data_skills[$2.to_i]) ? true : false end
  2843.     if buffer =~ /weapon (\d+), (\d+)/ then return $game_party.members[$1.to_i].weapons.include?($data_weapons[$2.to_i]) ? true : false end
  2844.     if buffer =~ /armor (\d+), (\d+)/ then return $game_party.members[$1.to_i].armors.include?($data_armors[$2.to_i]) ? true : false end
  2845.   end
  2846.   #----------------------------------------------------------------------------
  2847.   # • Extrair scripts.
  2848.   #----------------------------------------------------------------------------
  2849.   def extract_scripts(type=".txt",options={})
  2850.     except = options[:except] || []
  2851.     folder = options[:folder] || ""
  2852.     id = 0 #
  2853.     $RGSS_SCRIPTS.each do |script|
  2854.       name = script[1]
  2855.       data = script[3]
  2856.       next if except.include? name or name.empty? or data.empty?
  2857.       filename = sprintf("%03d", id) + "_" + name
  2858.       p "Writing: #{filename}"
  2859.       File.open(folder+filename+"#{type}", "wb") do |file|
  2860.         file.write data
  2861.       end
  2862.       id += 1
  2863.     end
  2864.   end
  2865.   #----------------------------------------------------------------------------
  2866.   # • Carregar scripts.
  2867.   #----------------------------------------------------------------------------
  2868.   def load_scripts(type=".txt",options={})
  2869.     skip = options[:skip] || []
  2870.     folder = options[:folder] || ""
  2871.     begin
  2872.       Dir.foreach(folder) do |file|
  2873.         file_id = file[0,3].to_i
  2874.         break if file_id == options[:limit]
  2875.         next if file == "." or file == ".." or File.extname(file) != "#{type}" or skip.include?(file_id)
  2876.         r = load (folder+"#{file}")
  2877.         p "Loaded: #{r}"
  2878.       end  
  2879.     rescue => error
  2880.       send_error(error)
  2881.     end
  2882.   end
  2883. end
  2884. #==============================================================================
  2885. # • Extension
  2886. #==============================================================================
  2887. # Autor: Dax
  2888. # Versão: 1.0
  2889. # Site: www.dax-soft.weebly.com
  2890. # Requerimento: Dax Core 1.9>
  2891. #==============================================================================
  2892. Dax.register(:Extension, "Dax", Dax::Version_EX)
  2893. #==============================================================================
  2894. # • WC
  2895. #==============================================================================
  2896. module Extension
  2897.   extend self
  2898.   #----------------------------------------------------------------------------
  2899.   # • Variável e constantes.
  2900.   #----------------------------------------------------------------------------
  2901.   @imported = {} # Importar script.
  2902.   @version_imported = {} # Versão do script importado.
  2903.   @actor_imported = {} # Autor do script importado.
  2904.   #----------------------------------------------------------------------------
  2905.   # • Registrar script.
  2906.   #----------------------------------------------------------------------------
  2907.   def register(name, actor="Dax", version=1.0)
  2908.     @imported[name] = true
  2909.     @version_imported[name] = version
  2910.     @actor_imported[name] = actor
  2911.   end
  2912.   #----------------------------------------------------------------------------
  2913.   # • Cria uma condição de requerimento de script.
  2914.   #----------------------------------------------------------------------------
  2915.   def required(name, actor="Dax", version=1.0)
  2916.     @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
  2917.   end
  2918. end
  2919. #==============================================================================
  2920. # • Mouse Extension | Picture Touch
  2921. #==============================================================================
  2922. Extension.register(:Mouse_Extension, "Dax", 1.0)
  2923. class Touch_Picture < Sprite
  2924.   #----------------------------------------------------------------------------
  2925.   # • Inicialização dos objetos.
  2926.   #    name : Nome da picture.
  2927.   #    x : Posição X da picture.
  2928.   #    y : Posição Y da picture.
  2929.   #    z : Altura da picture.
  2930.   #----------------------------------------------------------------------------
  2931.   def initialize(name="",x=0,y=0,z=0,switche_id=nil)
  2932.     super()
  2933.     self.bitmap = Cache.picture(name)
  2934.     self.x, self.y, self.z = x, y, z
  2935.     @clicked = false
  2936.     @switche_id = switche_id
  2937.   end
  2938.   #----------------------------------------------------------------------------
  2939.   # • Renovação dos objetos.
  2940.   #----------------------------------------------------------------------------
  2941.   def dispose
  2942.     self.bitmap.dispose if !self.bitmap.nil?
  2943.     super
  2944.   end
  2945.   #----------------------------------------------------------------------------
  2946.   # • Atualizaçaõ dos objetos.
  2947.   #   action_clicked : Caso seja um nome em formato de String irá chamar uma
  2948.   # scene, caso seja em formato de número irá chamar um evento comum.
  2949.   #----------------------------------------------------------------------------
  2950.   def update
  2951.     self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  2952.     if Mouse.in_area?(self)
  2953.       effect_on_area?
  2954.       @clicked = trigger?(0x01) or repeat?(0x01)
  2955.       action if @clicked && trigger?(0x01) or repeat?(0x01)
  2956.     else
  2957.       effect_off_area?
  2958.       @clicked = false if trigger?(0x01) or repeat?(0x01)
  2959.     end
  2960.   end
  2961.   #----------------------------------------------------------------------------
  2962.   # • Acão após o clique na imagem.
  2963.   #----------------------------------------------------------------------------
  2964.   def action
  2965.   end
  2966.   #----------------------------------------------------------------------------
  2967.   # • Efeito quando estiver na área.
  2968.   #----------------------------------------------------------------------------
  2969.   def effect_on_area?
  2970.     self.opacity = 255
  2971.   end
  2972.   #----------------------------------------------------------------------------
  2973.   # • Efeito quando estiver fora da área.
  2974.   #----------------------------------------------------------------------------
  2975.   def effect_off_area?
  2976.     self.opacity = 128
  2977.   end
  2978. end
  2979. #==============================================================================
  2980. # • Simple Touch Picture | Mouse Extension
  2981. #==============================================================================
  2982. Extension.register(:Simple_Touch_Picture, "Dax", 1.0)
  2983. class Simple_Touch_Picture < Touch_Picture
  2984.   #----------------------------------------------------------------------------
  2985.   # • Inicialização dos objetos.
  2986.   #    name : Nome da picture.
  2987.   #    x : Posição X da picture.
  2988.   #    y : Posição Y da picture.
  2989.   #    z : Altura da picture.
  2990.   #    action : Ação após o clique do Mouse.
  2991.   #----------------------------------------------------------------------------
  2992.   def initialize(action, *args)
  2993.     super(*args)
  2994.     @action = action
  2995.   end
  2996.   #----------------------------------------------------------------------------
  2997.   # • Renovação dos objetos.
  2998.   #----------------------------------------------------------------------------
  2999.   def dispose
  3000.     super
  3001.   end
  3002.   #----------------------------------------------------------------------------
  3003.   # • Atualização dos objetos.
  3004.   #----------------------------------------------------------------------------
  3005.   def update
  3006.     super
  3007.   end
  3008.   #----------------------------------------------------------------------------
  3009.   # • Ação após o clique.
  3010.   #----------------------------------------------------------------------------
  3011.   def action
  3012.     eval(@action.to_s) unless @action.nil?
  3013.   end
  3014.   #----------------------------------------------------------------------------
  3015.   # • Efeito do objeto quando estiver na área.
  3016.   #----------------------------------------------------------------------------
  3017.   def effect_on_area?
  3018.     super
  3019.   end
  3020.   #----------------------------------------------------------------------------
  3021.   # • Efeito do objeto quando estiver fora da área.
  3022.   #----------------------------------------------------------------------------
  3023.   def effect_off_area?
  3024.     super
  3025.   end
  3026.   #----------------------------------------------------------------------------
  3027.   # • Retorna ao conteúdo.
  3028.   #----------------------------------------------------------------------------
  3029.   def contents
  3030.     self
  3031.   end
  3032. end
  3033. #==============================================================================
  3034. # • Mouse Extension | Touch Icon
  3035. #==============================================================================
  3036. Extension.register(:Touch_Icon, "Dax", 1.0)
  3037. class Touch_Icon < Sprite
  3038.   #----------------------------------------------------------------------------
  3039.   # • Inicialização dos objetos.
  3040.   #   id : ID do ícone no database.
  3041.   #   x : Posição X do objeto.
  3042.   #   y : Posição Y do objeto.
  3043.   #   z : Altura do objeto.
  3044.   #----------------------------------------------------------------------------
  3045.   def initialize(id=0, x=0, y=0, z=0, switche_id=nil,effect=:visible,texts=["", ColorBasic[-1], 2],font=["Arial", 16])
  3046.     super()
  3047.     self.x, self.y, self.z = x, y, z
  3048.     self.bitmap = Bitmap.new(24, 24)
  3049.     self.bitmap.draw_icon(id.to_i, 0, 0)
  3050.     @clicked = false
  3051.     @switche_id = switche_id
  3052.     @effect = effect
  3053.     unless texts[0].empty?
  3054.       @text = Sprite.new
  3055.       @text.bitmap = Bitmap.new(100 + texts[0].split(//).size, 24)
  3056.       @text.x, @text.y, @text.z = self.x + (28 + texts[2]), self.y + texts[2], self.z
  3057.       @text.opacity = 0
  3058.       @text.bitmap.draw_text(0, 0, @text.width, @text.height, texts[0].to_s)
  3059.       @text.bitmap.font.name, @text.bitmap.font.size = font
  3060.     end
  3061.   end
  3062.   #----------------------------------------------------------------------------
  3063.   # • Renovação dos objetos.
  3064.   #----------------------------------------------------------------------------
  3065.   def dispose
  3066.     self.bitmap.dispose if !self.bitmap.nil?
  3067.     super
  3068.   end
  3069.   #----------------------------------------------------------------------------
  3070.   # • Atualizaçaõ dos objetos.
  3071.   #   action_clicked : Caso seja um nome em formato de String irá chamar uma
  3072.   # scene, caso seja em formato de número irá chamar um evento comum.
  3073.   #----------------------------------------------------------------------------
  3074.   def update
  3075.     if @effect == :visible then self.visible = !$game_switches[@switche_id] unless @switche_id.nil?  end
  3076.     if @effect == (:visible or :opacity) then @text.visible = self.visible unless @text.nil? end
  3077.     unless @switche_id.nil? then self.opacity = 64 if @effect == :opacity and !$game_switches[@switche_id] end
  3078.     if Mouse.in_area?(self)
  3079.       @text.opacity = 255 unless @text.nil?
  3080.       effect_on_area?
  3081.       @clicked = trigger?(0x01) or repeat?(0x01)
  3082.       action if @clicked && trigger?(0x01) or repeat?(0x01)
  3083.     else
  3084.       @text.opacity = 0 unless @text.nil?
  3085.       effect_off_area?
  3086.       @clicked = false if trigger?(0x01) or repeat?(0x01)
  3087.     end
  3088.   end
  3089.   #----------------------------------------------------------------------------
  3090.   # • Acão após o clique na imagem.
  3091.   #----------------------------------------------------------------------------
  3092.   def action
  3093.     return if self.visible or self.opacity == 64
  3094.     @text.visible = false unless @text.nil?
  3095.   end
  3096.   #----------------------------------------------------------------------------
  3097.   # • Efeito quando estiver na área.
  3098.   #----------------------------------------------------------------------------
  3099.   def effect_on_area?
  3100.     self.opacity = 255
  3101.   end
  3102.   #----------------------------------------------------------------------------
  3103.   # • Efeito quando estiver fora da área.
  3104.   #----------------------------------------------------------------------------
  3105.   def effect_off_area?
  3106.     self.opacity = 128
  3107.   end
  3108. end
  3109. #==============================================================================
  3110. # • Mouse Extension | Simple Touch Icon
  3111. #==============================================================================
  3112. Extension.register(:Simple_Touch_Icon, "Dax", 1.0)
  3113. class Simple_Touch_Icon < Touch_Icon
  3114.   #----------------------------------------------------------------------------
  3115.   # • Inicialização dos objetos.
  3116.   #----------------------------------------------------------------------------
  3117.   def initialize(action, *args)
  3118.     super(*args)
  3119.     self.opacity = 128
  3120.     @action = action
  3121.   end
  3122.   #----------------------------------------------------------------------------
  3123.   # • Renovação dos objetos.
  3124.   #----------------------------------------------------------------------------
  3125.   def dispose
  3126.     super
  3127.   end
  3128.   #----------------------------------------------------------------------------
  3129.   # • Atualização dos objetos.
  3130.   #----------------------------------------------------------------------------
  3131.   def update
  3132.     super
  3133.   end
  3134.   #----------------------------------------------------------------------------
  3135.   # • Ação após o clique.
  3136.   #----------------------------------------------------------------------------
  3137.   def action
  3138.     super
  3139.     eval(@action.to_s) unless @action.nil?
  3140.   end
  3141.   #----------------------------------------------------------------------------
  3142.   # • Efeito do objeto quando estiver na área.
  3143.   #----------------------------------------------------------------------------
  3144.   def effect_on_area?
  3145.     super
  3146.   end
  3147.   #----------------------------------------------------------------------------
  3148.   # • Efeito do objeto quando estiver fora da área.
  3149.   #----------------------------------------------------------------------------
  3150.   def effect_off_area?
  3151.     super
  3152.   end
  3153.   #----------------------------------------------------------------------------
  3154.   # • Retorna ao conteúdo.
  3155.   #----------------------------------------------------------------------------
  3156.   def contents
  3157.     self
  3158.   end
  3159. end
  3160. #==============================================================================
  3161. # • Mouse Extension | Touch Text
  3162. #==============================================================================
  3163. Extension.register(:Touch_Text, "Dax", 1.0)
  3164. class Touch_Text < Sprite
  3165.   #----------------------------------------------------------------------------
  3166.   # • Inicialização dos objetos.
  3167.   #   id : ID do ícone no database.
  3168.   #   x : Posição X do objeto.
  3169.   #   y : Posição Y do objeto.
  3170.   #   z : Altura do objeto.
  3171.   #----------------------------------------------------------------------------
  3172.   def initialize(text="", x=0, y=0, z=0, switche_id=nil,color=[ColorBasic.new(:white), ColorBasic[7]],font=["Arial", 16],align=0)
  3173.     super()
  3174.     self.x, self.y, self.z = x, y, z
  3175.     self.bitmap = Bitmap.new(font[1] + (text.split(//).size ** 2), font[1])
  3176.     self.bitmap.draw_text(0, 0, self.width, self.height, text, align)
  3177.     @clicked = false
  3178.     @switche_id = switche_id
  3179.     @color = color
  3180.     self.bitmap.font.name, self.bitmap.font.size = font
  3181.   end
  3182.   #----------------------------------------------------------------------------
  3183.   # • Renovação dos objetos.
  3184.   #----------------------------------------------------------------------------
  3185.   def dispose
  3186.     self.bitmap.dispose if !self.bitmap.nil?
  3187.     super
  3188.   end
  3189.   #----------------------------------------------------------------------------
  3190.   # • Atualizaçaõ dos objetos.
  3191.   #   action_clicked : Caso seja um nome em formato de String irá chamar uma
  3192.   # scene, caso seja em formato de número irá chamar um evento comum.
  3193.   #----------------------------------------------------------------------------
  3194.   def update
  3195.     self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  3196.     if Mouse.in_area?(self)
  3197.       effect_on_area?
  3198.       @clicked = trigger?(0x01) or repeat?(0x01)
  3199.       action if @clicked && trigger?(0x01) or repeat?(0x01)
  3200.     else
  3201.       effect_off_area?
  3202.       @clicked = false if trigger?(0x01) or repeat?(0x01)
  3203.     end
  3204.   end
  3205.   #----------------------------------------------------------------------------
  3206.   # • Acão após o clique na imagem.
  3207.   #----------------------------------------------------------------------------
  3208.   def action
  3209.    
  3210.   end
  3211.   #----------------------------------------------------------------------------
  3212.   # • Efeito quando estiver na área.
  3213.   #----------------------------------------------------------------------------
  3214.   def effect_on_area?
  3215.     self.color = @color[1]
  3216.   end
  3217.   #----------------------------------------------------------------------------
  3218.   # • Efeito quando estiver fora da área.
  3219.   #----------------------------------------------------------------------------
  3220.   def effect_off_area?
  3221.     self.color = @color[0]
  3222.   end
  3223. end
  3224. #==============================================================================
  3225. # • Mouse Extension | Simple Touch Icon
  3226. #==============================================================================
  3227. Extension.register(:Simple_Touch_Icon, "Dax", 1.0)
  3228. class Simple_Touch_Text < Touch_Text
  3229.   #----------------------------------------------------------------------------
  3230.   # • Inicialização dos objetos.
  3231.   #----------------------------------------------------------------------------
  3232.   def initialize(action, *args)
  3233.     super(*args)
  3234.     @action = action
  3235.   end
  3236.   #----------------------------------------------------------------------------
  3237.   # • Renovação dos objetos.
  3238.   #----------------------------------------------------------------------------
  3239.   def dispose
  3240.     super
  3241.   end
  3242.   #----------------------------------------------------------------------------
  3243.   # • Atualização dos objetos.
  3244.   #----------------------------------------------------------------------------
  3245.   def update
  3246.     super
  3247.   end
  3248.   #----------------------------------------------------------------------------
  3249.   # • Ação após o clique.
  3250.   #----------------------------------------------------------------------------
  3251.   def action
  3252.     eval(@action.to_s) unless @action.nil?
  3253.   end
  3254.   #----------------------------------------------------------------------------
  3255.   # • Efeito do objeto quando estiver na área.
  3256.   #----------------------------------------------------------------------------
  3257.   def effect_on_area?
  3258.     super
  3259.   end
  3260.   #----------------------------------------------------------------------------
  3261.   # • Efeito do objeto quando estiver fora da área.
  3262.   #----------------------------------------------------------------------------
  3263.   def effect_off_area?
  3264.     super
  3265.   end
  3266.   #----------------------------------------------------------------------------
  3267.   # • Retorna ao conteúdo.
  3268.   #----------------------------------------------------------------------------
  3269.   def contents
  3270.     self
  3271.   end
  3272. end
  3273. #==============================================================================
  3274. # • OutlineFillRect
  3275. #==============================================================================
  3276. Dax.register(:outline_fill_rect)
  3277. class OutlineFillRect < Sprite
  3278.   #----------------------------------------------------------------------------
  3279.   # • Variáveis públicas com valor.
  3280.   #----------------------------------------------------------------------------
  3281.   attr_value_accessor :on, "self.visible = true"
  3282.   attr_value_accessor :off, "self.visible = false"
  3283.   #----------------------------------------------------------------------------
  3284.   # • Inicialização dos objetos.
  3285.   #----------------------------------------------------------------------------
  3286.   def initialize(object, max=2, color=ColorBasic[-1])
  3287.     super([object.width, object.height])
  3288.     @object = object
  3289.     self.x, self.y, self.z = object.x, object.y, object.z
  3290.     self.bitmap.fill_rect(0, 0, max, self.height, color)
  3291.     self.bitmap.fill_rect(self.width-max, 0, max, self.height, color)
  3292.     self.bitmap.fill_rect(0, 0, self.width, max, color)
  3293.     self.bitmap.fill_rect(0, self.height-max, self.width, max, color)
  3294.   end
  3295.   #----------------------------------------------------------------------------
  3296.   # • Renovação dos objetos.
  3297.   #----------------------------------------------------------------------------
  3298.   def dispose
  3299.     self.bitmap.dispose unless self.bitmap.disposed?
  3300.     super
  3301.   end
  3302.   #----------------------------------------------------------------------------
  3303.   # • Atualização das coordenadas.
  3304.   #----------------------------------------------------------------------------
  3305.   def update
  3306.     self.x, self.y, self.z = @object.x, @object.y, @object.z
  3307.   end
  3308. end
  3309. #==============================================================================
  3310. # • Send Error
  3311. #==============================================================================
  3312. if $DEBUG or $TEST
  3313.   #-----------------------------------------------------------------------------
  3314.   # Imprimir erro.
  3315.   #-----------------------------------------------------------------------------
  3316.   def send_error(error)
  3317.     puts "Error : " + error
  3318.     puts "TRACE : " + error.backtrace.join("\n")
  3319.     puts " "
  3320.     puts " Going to EXIT - Press Enter to Continue - "
  3321.     gets if $DEBUG or $TEST
  3322.   end
  3323. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement