DaxSoft

Dax Core 1.6

Feb 5th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 120.48 KB | None | 0 0
  1. #==============================================================================
  2. # * Dax Core
  3. #==============================================================================
  4. # Autor : Dax Aquatic X
  5. # Versão : Core i1.6
  6. # Site : www.dax-soft.weebly.com
  7. # Suporte : [email protected]
  8. #==============================================================================
  9. # Um Core com vários módulos e métodos que facilitará na hora de programar os
  10. # seus scripts, bom proveito.
  11. #==============================================================================
  12. # Conteúdo :
  13. #==============================================================================
  14. # i :
  15. # - API
  16. # - String
  17. # - Integer
  18. # - Float
  19. # - Color
  20. # - ColorBasic
  21. # - DMath
  22. # - Key
  23. # - Mouse
  24. # - Entries
  25. # - Rpg Module
  26. # - Read
  27. # - DRGSS
  28. # - Rect
  29. # - Sprite
  30. # - Bitmap : method (save) by Gab!
  31. # - Object
  32. # - Touch_Picture
  33. # - Simple_Touch_Picture
  34. # - Sprite_Text
  35. # - Text_Base
  36. # - Touch_Icon
  37. # - Simple_Touch_Icon
  38. # - Touch_Text
  39. # - Simple_Touch_Text
  40. # - Opacity
  41. # - DString
  42. # - Background
  43. # - Window_Base
  44. # - Map
  45. # - User32
  46. # - VS
  47. # - Sound Base
  48. # - Disable Script
  49. # - Regexp Symbols
  50. #==============================================================================
  51. module Dax
  52. extend self
  53. #----------------------------------------------------------------------------
  54. # Ajuste aqui as configurações básicas da fonte padrão do jogo.
  55. #----------------------------------------------------------------------------
  56. Font.default_name = ["Arial"] # Nome padrão da fonte do jogo.
  57. Font.default_size = 18 # Tamanho padrão da fonte do jogo.
  58. Font.default_bold = true # true - Para usar negrito | false - para não usar.
  59. Font.default_italic = false # true - Para usar italico | false - para não usar.
  60. Font.default_shadow = false # true - Para usar sombra na fonte | false - para não usar.
  61. Font.default_outline = true # true - Para usar borda da fonte | false - para não usar.
  62. Font.default_out_color = Color.new(0, 0, 0) # Cor da fonte padrão da borda da fonte.
  63. Font.default_color = Color.new(255, 255, 255) # Cor da fonte padrão.
  64. #----------------------------------------------------------------------------
  65. # * Constantes e variáveis
  66. #----------------------------------------------------------------------------
  67. @register = {} # Armazena os scripts criados que foram registrados.
  68. @benchmark = "" # Armazena os testes conclusos de benchmark.
  69. # A imagem do ícone do Mouse tem que estar na pasta System. Basta você
  70. # por o nome da imagem dentro das áspas. Caso você queira usar um ícone
  71. # do Rpg Maker no lugar de uma imagem, basta você por o id do ícone no lugar
  72. # das áspas.
  73. Mouse_Name = ""
  74. #----------------------------------------------------------------------------
  75. # * Somente executará o bloco caso estiver registrado o script.
  76. #----------------------------------------------------------------------------
  77. # Exemplo:
  78. # Dax.required_script(:teste) { # Só irá executar caso estiver registrado.
  79. # methods...
  80. # }
  81. #----------------------------------------------------------------------------
  82. def required_script(symbol, &block)
  83. block.call if @register.has_key?(symbol) and block_given?
  84. end
  85. #----------------------------------------------------------------------------
  86. # * Método de registrar scripts :
  87. #----------------------------------------------------------------------------
  88. # ** Este método tem de ser definido alguns valores como :
  89. # symbol - nome do script, que é posto em símbolo : Ex - :arrow
  90. # name - nome do autor do script, que é posto em áspas
  91. # version - versão do script;
  92. # data - data do script;
  93. # Dax.register(symbol, name, version, data)
  94. # ** Você pode usá-lo para somente registrar o nome do script.
  95. # Dax.register(symbol)
  96. # ** Você pode usá-lo para modificar a versão e a data do script.
  97. # --- Mas só funciona caso o script já tenha se registrado.
  98. # Dax.register(symbol, version, data)
  99. #----------------------------------------------------------------------------
  100. def register(*args)
  101. if @register.has_key?(args[0])
  102. @register[args[0]][:version] = args[1]
  103. @register[args[0]][:data] = args[2]
  104. else
  105. @register[args[0]] = {name: args[1], version: args[2], data: args[3], script: nil}
  106. end
  107. end
  108. #----------------------------------------------------------------------------
  109. # * Método de verificar se o objeto existe.
  110. #----------------------------------------------------------------------------
  111. # Dax.required_class("Objeto") { }
  112. # Dentro das chaves você poem o script.
  113. # * Exemplo :
  114. # Dax.required_class("Window_Base") {
  115. # class Window_Base < Window
  116. # def example
  117. # self.x = self.x + self.width
  118. # end
  119. # end
  120. # }
  121. #----------------------------------------------------------------------------
  122. # Executa o bloco se o objeto existir.
  123. #----------------------------------------------------------------------------
  124. def required_class(name, &block)
  125. eval("block.call if defined?(name)")
  126. end
  127. #----------------------------------------------------------------------------
  128. # • Fazer benchmark de um bloco.
  129. #----------------------------------------------------------------------------
  130. # Dax.benchmark(name(opcional)) { BLOCO }
  131. #----------------------------------------------------------------------------
  132. def benchmark(name="", &block)
  133. time = Time.now
  134. block.call
  135. print "Benchmark: #{(time - Time.now).abs.to_f} segundos!\r\n"
  136. @benchmark += "#{name} : #{(time - Time.now).to_f} segundos!\r\n"
  137. end
  138. #----------------------------------------------------------------------------
  139. # • Salva os testes de benchmark.
  140. #----------------------------------------------------------------------------
  141. def benchmark_save
  142. File.open("Benchmark.txt", "a+") do |file|
  143. file.write(@benchmark)
  144. file.close
  145. end
  146. end
  147. #----------------------------------------------------------------------------
  148. # • Requirir um arquivo.
  149. # arquivo : Arquivo...
  150. #----------------------------------------------------------------------------
  151. def require(arquivo)
  152. $: << "./"
  153. Kernel.send(:require, arquivo)
  154. end
  155. #----------------------------------------------------------------------------
  156. # * Somente executa um bloco case existir um arquivo.
  157. #----------------------------------------------------------------------------
  158. # Dax.required_file("arquivo.tipo") { # Exemplo.
  159. # Métodos;
  160. # }
  161. #----------------------------------------------------------------------------
  162. def required_file(filename, &block)
  163. block.call if FileTest.exist?(filename)
  164. end
  165. #----------------------------------------------------------------------------
  166. # * Remove uma [Classe], exemplo: Dax.remove(:Scene_Menu)
  167. #----------------------------------------------------------------------------
  168. def remove(symbol_name)
  169. Object.send(:remove_const, symbol_name)
  170. end
  171. #----------------------------------------------------------------------------
  172. # * Retorna a variável [$RGSS_SCRIPT]
  173. #----------------------------------------------------------------------------
  174. def rgss_script
  175. return $RGSS_SCRIPTS
  176. end
  177. #----------------------------------------------------------------------------
  178. # * Tela chéia
  179. #----------------------------------------------------------------------------
  180. def full_screen
  181. res = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
  182. res.call(18,0,0,0)
  183. res.call(13,0,0,0)
  184. res.call(13,0,2,0)
  185. res.call(18,0,2,0)
  186. end
  187. end
  188. Dax.register(:dax)
  189. #==============================================================================
  190. # * API : Módulo que armazena informações de algumas APIS.
  191. #==============================================================================
  192. Dax.register(:api)
  193. module API
  194. extend self
  195. # Permite acessar as teclas do teclado.
  196. GetKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  197. # Permite ativar/desativar o ícone do mouse.
  198. MouseShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
  199. # Permite achar a posição do mouse.
  200. CursorPosition = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  201. # Permite achar o tamanho da screen.
  202. ScreenToClient = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  203. # Permite fazer a leitura do game.ini.
  204. ReadIni = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  205. # Permite achar o tamando da window.
  206. FindWindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
  207. # API da Message Box.
  208. MessageBoxA = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i')
  209. # Recupera uma string especificada de um arquivo em inicialização.
  210. GetPrivateProfileString = Win32API.new('kernel32', 'GetPrivateProfileStringA',%w(p p p p l p),'l')
  211. # Get Systeme Metrics
  212. GetSystemMetrics = Win32API.new("user32", "GetSystemMetrics", "i", "i")
  213. # Posição da janela.
  214. SetWindowPos = Win32API.new("user32", "SetWindowPos", "lliiiii", "i")
  215. # Obtem o 'Rect' da janela.
  216. GetWindowRect = Win32API.new('user32','GetWindowRect',%w(l p),'i')
  217. # Define a Win32API do comando print
  218. MessageBoxW = Win32API.new("user32", "MessageBoxW", "LPPL", "L")
  219. # Caps Lock
  220. CapsLock = Win32API.new("user32", "GetKeyState", "i", "i").call(20) != 0
  221. # State Key
  222. StateKey = Win32API.new("user32", "GetKeyState", ["i"], "i")
  223. # SetCursorPos
  224. SetCursorPos = Win32API.new("user32", "SetCursorPos", "ll", "i")
  225. SetCursorPos = Win32API.new("user32", "SetCursorPos", "ii", "i")
  226. GetKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  227. GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  228. # Criar uma nova pasta.
  229. CreateDirectory = Win32API.new("kernel32", "CreateDirectory", "p", "lll")
  230. # Remover uma pasta existente.
  231. RemoveDirectory = Win32API.new("kernel32", "RemoveDirectory", "p", "l")
  232. WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  233. MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  234. # retorna para a data do ponteiro.
  235. def copymen(len)
  236. buf = "\0" * len
  237. Win32API.new("kernel32", "RtlMoveMemory", "ppl", "").call(buf, self, len)
  238. buf
  239. end
  240. # Shell
  241. Open = Win32API.new('shell32', 'ShellExecute', 'LPPPPI', 'L')
  242. def open_file(name)
  243. API::Open.call(0, 'open', "#{name}.exe", 0, 0, 1)
  244. end
  245. # Converter texto
  246. def convert_text(text, from, to)
  247. size = MultiByteToWideChar.(from, 0, text, -1, nil, 0)
  248. buffer = [].pack("x#{size*2}")
  249. MultiByteToWideChar.(from, 0, text, -1, buffer, buffer.size/2)
  250. size = WideCharToMultiByte.(to, 0, buffer, -1, nil, 0, nil, nil)
  251. second_buffer = [].pack("x#{size}")
  252. WideCharToMultiByte.(to, 0, buffer, -1, second_buffer, second_buffer.size, nil, nil)
  253. second_buffer.delete!("\000") if to == 65001
  254. second_buffer.delete!("\x00") if to == 0
  255. return second_buffer
  256. end
  257. end
  258. #==============================================================================
  259. # • User32
  260. #==============================================================================
  261. Dax.register(:user32, "Dax", 1.0, "18/05/13")
  262. module User32
  263.  
  264. GSM = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
  265. SetWindowPos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
  266. SetWindowLong = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
  267. Keybd_Event = Win32API.new('user32', 'keybd_event', 'LLLL', '')
  268. FindWindow = Win32API.new('user32', 'FindWindow', 'PP', 'L')
  269. GetDesktopWindow = Win32API.new('user32', 'GetDesktopWindow', '', 'L')
  270. GetWindowInfo = Win32API.new('user32', 'GetWindowInfo', 'LP', 'I')
  271. SetForegroundWindow = Win32API.new('user32', 'SetForegroundWindow', 'L', 'L')
  272. GetCursorPos = Win32API.new('user32', 'GetCursorPos', 'P', 'I')
  273. ShowCursor = Win32API.new('user32', 'ShowCursor', 'L', 'L')
  274. ScreenToClient = Win32API.new('user32', 'ScreenToClient', 'LP', 'I')
  275. GetKeyState = Win32API.new('user32', 'GetKeyState', 'I', 'I')
  276. GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'I', 'I')
  277.  
  278.  
  279. # GSM Constants: Visit the site: microsoft msdn
  280. # http://msdn.microsoft.com/en-us/library/ms724385(VS.85).aspx
  281. SM_CXSCREEN = 0 # Width of the current master screen resolution
  282. SM_CYSCREEN = 1 # Height of the current master screen resolution
  283.  
  284. SM_CXVSCROLL = 2 # Width of a vertical scroll bar
  285. SM_CYHSCROLL = 3 # Height of a horizontal scroll bar
  286.  
  287. SM_CYCAPTION = 4 # Height of a caption area
  288.  
  289. SM_CXBORDER = 5 # Width of a window border
  290. SM_CYBORDER = 6 # Height of a window border
  291.  
  292. SM_CXDLGFRAME = 7
  293. SM_CXFIXEDFRAME = 7 # Width of non-resizable captioned window frame
  294. SM_CYDLGFRAME = 8
  295. SM_CYFIXEDFRAME = 8 # Height of non-resizable captioned window frame
  296.  
  297. SM_CYVTHUMB = 9 # Height of a thumb button on vertical scrollbars
  298. SM_CXHTHUMB = 10 # Width of a thumb button on horizontal scrollbars
  299.  
  300. SM_CXICON = 11 # Default width of an icon
  301. SM_CYICON = 12 # Default height of an icon
  302.  
  303. SM_CXCURSOR = 13 # Width of a cursor
  304. SM_CYCURSOR = 14 # Height of a cursor
  305.  
  306. SM_CYMENU = 15 # Height of a single-line menu bar
  307.  
  308. SM_CXFULLSCREEN = 16 # Width of client rect for a full-screen window
  309. SM_CYFULLSCREEN = 17 # Height of client rect for a full-screen window
  310.  
  311. SM_CYKANJIWINDOW = 18 # Height of kanji window at bottom of screen, if there
  312.  
  313. SM_MOUSEPRESENT = 19 # Non-zero if mouse is present; 0 if not
  314.  
  315. SM_CYVSCROLL = 20 # Height of the arrow bitmap on vertical scrollbars
  316. SM_CXHSCROLL = 21 # Width of the arrow bitmap on horizontal scrollbars
  317.  
  318. SM_DEBUG = 22 # Non-zero if debug User.exe is installed; 0 if not
  319. SM_SWAPBUTTON = 23 # Non-zero if mouse button values are swapped
  320.  
  321. SM_CXMIN = 28 # Minimum width of a window
  322. SM_CYMIN = 29 # Minimum height of a window
  323.  
  324. SM_CXSIZE = 30 # Width of a button in a window caption or title bar
  325. SM_CYSIZE = 31 # Height of a button in a window caption or title bar
  326.  
  327. SM_CXFRAME = 32
  328. SM_CXSIZEFRAME = 32 # Width of the sizing border around a resizable window
  329. SM_CYFRAME = 33
  330. SM_CYSIZEFRAME = 33 # Height of the sizing border around a resizable window
  331.  
  332. SM_CXMINTRACK = 34 # Minimum "tracking" width of a window
  333. SM_CYMINTRACK = 35 # Minimum "tracking" height of a window
  334.  
  335. SM_CXDOUBLECLK = 36 # Width of rect which second click must be in for double
  336. SM_CYDOUBLECLK = 37 # Hght of rect which second click must be in for double
  337.  
  338. SM_CXICONSPACING = 38 # Width of a grid cell for items in large icon view
  339. SM_CYICONSPACING = 39 # Height of a grid cell for items in large icon view
  340.  
  341. SM_MENUDROPALIGNMENT = 40 # 0 if drop-down menus are left-aligned...
  342.  
  343. SM_PENWINDOWS = 41 # Non-zero if Microsoft Windows for Pen computing
  344. # extensions are installed; 0 if not
  345.  
  346. SM_DBCSENABLED = 42 # Non-zero if user32.dll supports DBCS; 0 if not
  347.  
  348. SM_CMOUSEBUTTONS = 43 # Number of available mouse buttons, or 0 for no mouse
  349.  
  350. SM_SECURE = 44 # Always returns 0
  351.  
  352. SM_CXEDGE = 45 # Width of a 3-D style border
  353. SM_CYEDGE = 46 # Height of a 3-D style border
  354.  
  355. SM_CXMINSPACING = 47 # Width of a grid cell for minimized windows
  356. SM_CYMINSPACING = 48 # Height of a grid cell for minimized windows
  357.  
  358. SM_CXSMICON = 49 # Recommended width of a small icon
  359. SM_CYSMICON = 50 # Recommended height of a small icon
  360.  
  361. SM_CYSMCAPTION = 51 # Height of a small caption
  362. SM_CXSMSIZE = 52 # Width of small caption buttons
  363. SM_CYSMSIZE = 53 # Height of small caption buttons
  364. SM_CXMENUSIZE = 54 # Width of menu bar buttons
  365. SM_CYMENUSIZE = 55 # Height of menu bar buttons
  366.  
  367. SM_ARRANGE = 56 # Flags about how system the arranges minimized windows
  368. SM_CXMINIMIZED = 57 # Width of a minimized window
  369. SM_CYMINIMIZED = 58 # Height of a minimized window
  370.  
  371. SM_CXMAXTRACK = 59 # Default maximum width of resizable windows
  372. SM_CYMAXTRACK = 60 # Default maximum height of resizable windows
  373. SM_CXMAXIMIZED = 61 # Default width of maximized top-level window
  374. SM_CYMAXIMIZED = 62 # Default height of maximized top-level window
  375.  
  376. SM_NETWORK = 63 # The least significant bit is set if a network is
  377. # present; otherwise, it is cleared
  378.  
  379. SM_CLEANBOOT = 67 # System boot type; 0:Normal, 1:Safe, 2:Safe w/network
  380.  
  381. SM_CXDRAG = 68
  382. SM_CYDRAG = 69 # Number of pixels mouse can move before initiating drag
  383.  
  384. SM_SHOWSOUNDS = 70 # Non-zero if user requires visible output; 0 if not
  385.  
  386. SM_CXMENUCHECK = 71 # Width of the default menu check-mark bitmap
  387. SM_CYMENUCHECK = 72 # Height of the default menu check-mark bitmap
  388.  
  389. SM_SLOWMACHINE = 73 # Non-zero if system has a slow processor; 0 if not
  390. # No, seriously, that's what Microsoft said!
  391.  
  392. SM_MIDEASTENABLED = 74 # Non-zero if system can use Hebrew, Arabic languages
  393.  
  394. SM_MOUSEWHEELPRESENT = 75 # Nonzero mouse has vertical scroll wheel; 0 if not
  395.  
  396. SM_XVIRTUALSCREEN = 76 # Coordinates of the left side of the virtual screen
  397. SM_YVIRTUALSCREEN = 77 # Coordinates of the top of the virtual screen
  398. SM_CXVIRTUALSCREEN = 78 # Virtual width of all screens put together
  399. SM_CYVIRTUALSCREEN = 79 # Virtual height of all screen put together
  400. SM_CMONITORS = 80 # Numbers of display monitors on a desktop
  401. SM_SAMEDISPLAYFORMAT = 81 # Non-zero if all screen use same color depth...
  402.  
  403. # SetWindowPos constants
  404. HWND_NOTOPMOST = -2 # Make window not always on top (and bring to front)
  405. HWND_TOPMOST = -1 # Put window in front and make it always on top
  406. HWND_TOP = 0 # Put window in front of all non-topmost windows
  407. HWND_BOTTOM = 1 # Put window behind all other windows
  408.  
  409. SWP_NOSIZE = 0x0001 # Keep current size (ignores w and h)
  410. SWP_NOMOVE = 0x0002 # Keep current position (ignores X and Y)
  411. SWP_NOZORDER = 0x0004 # Keep current Z order (ignores hWndInsertAfter)
  412. SWP_NOREDRAW = 0x0008 # Does NOT redraw changes
  413. SWP_NOACTIVATE = 0x0010 # Does NOT automatically activate the window
  414. SWP_FRAMECHANGED = 0x0020 # Applies new frame styles set with SetWindowLong
  415. SWP_SHOWWINDOW = 0x0040 # Displays the window
  416. SWP_HIDEWINDOW = 0x0080 # Hides the window
  417. SWP_NOCOPYBITS = 0x0100 # Discards the entire contents of the client area
  418. SWP_NOOWNERZORDER = 0x0200 # Doesn't change the window display order
  419. SWP_NOSENDCHANGING = 0x0400 # Don't send WM_WINDOWPOSCHANGING
  420. SWP_DEFERERASE = 0x2000 # Prevents generation of the WM_SYNCPAINT message
  421. SWP_ASYNCWINDOWPOS = 0x4000 # Use if calling thread does not own the window
  422.  
  423. # SetWindowLong constants
  424. GWL_USERDATA = -21 # Sets data reserved for use by the application
  425. GWL_EXSTYLE = -20 # Sets a new extended window style
  426. GWL_STYLE = -16 # Sets a new window style
  427. GWL_ID = -12 # Sets a new identifier of the window
  428. GWL_HWNDPARENT = -8 # Sets a new parent hWnd
  429. GWL_HINSTANCE = -6 # Sets a new application instance handle
  430. GWL_WNDPROC = -4 # Sets a new addr for the window calling procedure
  431. # Only available when the hWnd parameter identifies a dialog box:
  432. DWL_MSGRESULT = 0 # Sets the return message of the dialog box proc
  433. DWL_DLGPROC = 4 # Sets the new address of the dialog box proc
  434. DWL_USER = 8 # Sets new extra information private to application
  435.  
  436. # Window Styles (SetWindowLong(hWnd, GWL_STYLE, WS_*))
  437. WS_OVERLAPPED = 0x00000000 # Overlapped window has title and border
  438. WS_TABSTOP = 0x00010000 # Can receive focus from TAB key
  439. WS_GROUP = 0x00020000 # First control of group of controls
  440. WS_MAXIMIZEBOX = 0x00010000 # Has a mazimize button
  441. WS_MINIMIZEBOX = 0x00020000 # Has a minimize button
  442. WS_THICKFRAME = 0x00040000 # Has sizing border
  443. WS_SYSMENU = 0x00080000 # Has buttons on title bar (reqs WS_CAPTION)
  444. WS_HSCROLL = 0x00100000 # Has horizontal scroll bar
  445. WS_VSCROLL = 0x00200000 # Has vertical scroll bar
  446. WS_DLGFRAME = 0x00400000 # Dialog-style border. Cannot have title bar
  447. WS_BORDER = 0x00800000 # Thin border
  448. WS_CAPTION = 0x00C00000 # Has a title bar (implies WS_BORDER)
  449. WS_MAXIMIZE = 0x01000000 # Initially maximized
  450. WS_CLIPCHILDREN = 0x02000000 # Exclude area for children when drawing
  451. WS_CLIPSIBLINGS = 0x04000000 # Exclude sibling client rects when drawing
  452. WS_DISABLED = 0x08000000 # Initially disabled (no input)
  453. WS_VISIBLE = 0x10000000 # Initially visible
  454. WS_MINIMIZE = 0x20000000 # Initially minimized
  455. WS_CHILD = 0x40000000 # Child cannot have menu bar or WS_POPUP
  456. WS_POPUP = 0x80000000 # Popup window
  457. # Window style aliases
  458. WS_OVERLAPPEDWINDOW = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|
  459. WS_MINIMIZEBOX|WS_MAXIMIZEBOX
  460. WS_POPUPWINDOW = WS_POPUP|WS_BORDER|WS_SYSMENU
  461. WS_CHILDWINDOW = WS_CHILD
  462. WS_TILED = WS_OVERLAPPED
  463. WS_ICONIC = WS_MINIMIZE
  464. WS_SIZEBOX = WS_THICKFRAME
  465. WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
  466. end
  467. #==============================================================================
  468. # * String
  469. #==============================================================================
  470. Dax.register(:string)
  471. class String
  472. #----------------------------------------------------------------------------
  473. # * Método com a função de decodificar a base 64.
  474. #----------------------------------------------------------------------------
  475. def decode_base64
  476. self.unpack("m")[0]
  477. end
  478. #----------------------------------------------------------------------------
  479. # * Obtem a palavra do méio de uma frase/palavra
  480. #----------------------------------------------------------------------------
  481. def get_string_between(start_at, end_at)
  482. my_string = " #{self}"
  483. ini = my_string.index(start_at)
  484. return my_string if ini == 0
  485. ini += start_at.length
  486. length = my_string.index(end_at, ini).to_i - ini
  487. return my_string[ini,length]
  488. end
  489. #--------------------------------------------------------------------------
  490. # * retorna self em ASCII-8BIT
  491. #--------------------------------------------------------------------------
  492. def to_ascii
  493. API.convert_text(self, 65001, 0)
  494. end
  495. #--------------------------------------------------------------------------
  496. # * converte self em ASCII-8BIT
  497. #--------------------------------------------------------------------------
  498. def to_ascii!
  499. self.replace(self.to_ascii)
  500. end
  501. #--------------------------------------------------------------------------
  502. # * retorna self para UTF8
  503. #--------------------------------------------------------------------------
  504. def to_utf8
  505. API.convert_text(self, 0, 65001)
  506. end
  507. #--------------------------------------------------------------------------
  508. # * converte self em UTF8
  509. #--------------------------------------------------------------------------
  510. def to_utf8!
  511. self.replace(self.to_utf8)
  512. end
  513. #--------------------------------------------------------------------------
  514. # * Extrai os números.
  515. #--------------------------------------------------------------------------
  516. def extract_numbers
  517. self.scan(/-*\d+/).collect{|n|n.to_i}
  518. end
  519. end
  520. #==============================================================================
  521. # * Integer
  522. #==============================================================================
  523. Dax.register(:integer)
  524. class Integer
  525. #----------------------------------------------------------------------------
  526. # * Transformar o valor em porcentagem : Útil para fazer barras como por exemplo
  527. # barras de HP.
  528. # a : Valor atual.
  529. # b : Valor máximo.
  530. #----------------------------------------------------------------------------
  531. def to_p(a, b)
  532. self * a / b
  533. end
  534. #----------------------------------------------------------------------------
  535. # * Grid On : Multiplica o número pelo tamanho de uma grid.
  536. #----------------------------------------------------------------------------
  537. def grid_on(grid_size=32)
  538. return self * grid_size
  539. end
  540. #----------------------------------------------------------------------------
  541. # * Grid Off : Divide o número pelo tamanho de uma grid.
  542. #----------------------------------------------------------------------------
  543. def grid_off(grid_size=32)
  544. return self / grid_size
  545. end
  546. end
  547. #==============================================================================
  548. # * Float
  549. #==============================================================================
  550. Dax.register(:float)
  551. class Float
  552. #----------------------------------------------------------------------------
  553. # * Transformar em porcentagem :
  554. # a : Valor atual.
  555. # b : Valor máximo.
  556. #----------------------------------------------------------------------------
  557. def to_p(a, b)
  558. self * a / b
  559. end
  560. end
  561. #==============================================================================
  562. # * Color
  563. #==============================================================================
  564. Dax.register(:color)
  565. class Color
  566. #----------------------------------------------------------------------------
  567. # • Diminui a opacidade da cor, deixando-a opaca..
  568. #----------------------------------------------------------------------------
  569. def opacity
  570. self.set(self.red, self.green, self.blue, 128)
  571. end
  572. #----------------------------------------------------------------------------
  573. # • Inverte as cores.
  574. #----------------------------------------------------------------------------
  575. def invert!
  576. self.set(255-self.red, 255-self.green, 255-self.blue, self.alpha)
  577. end
  578. #----------------------------------------------------------------------------
  579. # • Reverter as cores.
  580. #----------------------------------------------------------------------------
  581. def revert
  582. colors = [self.red, self.green, self.blue, self.alpha].reverse!
  583. self.set(*colors)
  584. end
  585. #----------------------------------------------------------------------------
  586. # • Converte para string.
  587. #----------------------------------------------------------------------------
  588. def to_s
  589. "red: #{self.red}\nblue: #{self.blue}\ngreen: #{self.green}\nalpha: #{self.alpha}"
  590. end
  591. #----------------------------------------------------------------------------
  592. # • Comparar cores, retorna a [true] se for igual.. returna a [false] se não
  593. # for igual.
  594. #----------------------------------------------------------------------------
  595. def ==(color)
  596. (self.red == color.red and self.green == color.green and self.blue == color.blue and
  597. self.alpha == color.alpha) ? true : false
  598. end
  599. #----------------------------------------------------------------------------
  600. # • Retorna os valores da classe [COLOR] para hash;;
  601. #----------------------------------------------------------------------------
  602. def to_h
  603. return {
  604. red: self.red, green: self.green, blue: self.blue, alpha: self.alpha,
  605. }
  606. end
  607. #----------------------------------------------------------------------------
  608. # • Retorna os valores da classe [COLOR] para array;;
  609. #----------------------------------------------------------------------------
  610. def to_a
  611. return [self.red, self.green, self.blue, self.alpha]
  612. end
  613. end
  614. #==============================================================================
  615. # * ColorBasic
  616. #==============================================================================
  617. Dax.register(:colorbasic)
  618. module ColorBasic
  619. extend self
  620. #----------------------------------------------------------------------------
  621. # • Cores Hexadécimais
  622. # * ColorBasic.hex("ffffff") #=> 255, 255, 255 | Branco.
  623. #----------------------------------------------------------------------------
  624. def hex(color)
  625. Color.new(*color.scan(/../).map { |color| color.to_i(16)})
  626. end
  627. #----------------------------------------------------------------------------
  628. # • Cores em Index
  629. #----------------------------------------------------------------------------
  630. def [](id)
  631. case id
  632. when -1 then Color.new(255, 255, 255) # White
  633. when 0 then Color.new(240, 248, 255) # Alice Blue
  634. when 1 then Color.new(250, 235, 215) # Antique_White
  635. when 2 then Color.new(0, 255, 255) # Aqua
  636. when 3 then Color.new(127, 255, 255) # Aqua Marine
  637. when 4 then Color.new(240, 255, 255) # Azure
  638. when 5 then Color.new(245, 245, 220) # Beige
  639. when 6 then Color.new(255, 228, 196) # Bisque
  640. when 7 then Color.new(0, 0, 0) # Black
  641. when 8 then Color.new(255, 235, 205) # Blanchedalmond
  642. when 9 then Color.new(0, 0, 255) # Blue
  643. when 10 then Color.new(138, 43, 226) # Blue Violet
  644. when 11 then Color.new(165, 42, 42) # Brown
  645. when 12 then Color.new(222, 184, 135) # Burly Wood
  646. when 13 then Color.new(93, 158, 160) # Cadet Blue
  647. when 14 then Color.new(127, 255, 0) # Chatreuse
  648. when 15 then Color.new(210, 105, 30) # Chocolate
  649. when 16 then Color.new(255, 127, 80) # Coral
  650. when 17 then Color.new(100, 149, 237) # Corn Flower Blue
  651. when 18 then Color.new(255, 248, 220) # CornSilk
  652. when 19 then Color.new(220, 20, 60) # Crimson
  653. when 20 then Color.new(0, 255, 255) # Cyan
  654. when 21 then Color.new(0, 0, 139) # DarkBlue
  655. when 22 then Color.new(0, 139, 139) # DarkCyan
  656. when 23 then Color.new(184, 134, 11) # DarkGoldEnrod
  657. when 24 then Color.new(169, 169, 169) # Dark Gray
  658. when 25 then Color.new(0, 100, 0) # Dark Green
  659. when 26 then Color.new(189, 183, 107) # Dark Khaki
  660. when 27 then Color.new(139, 0, 139) # Dark Magenta
  661. when 28 then Color.new(85, 107, 47) # Dark Oliver Green
  662. when 29 then Color.new(255, 140, 0) # Dark Orange
  663. when 30 then Color.new(153, 50, 204) # Dark orchid
  664. when 31 then Color.new(139, 0, 0) # Dark Red
  665. when 32 then Color.new(233, 150, 120) # Dark Salmon
  666. when 33 then Color.new(143, 188, 143) # Dark Sea Green
  667. when 34 then Color.new(72, 61, 139) # Dark Slate Blue
  668. when 35 then Color.new(255, 255, 0) # Yellow
  669. when 36 then Color.new(255, 0, 0) # Red
  670. when 37 then Color.new(0, 255, 0) # Green
  671. when 38 then Color.new(255, 128, 0) # Orange
  672. end
  673. end
  674. #----------------------------------------------------------------------------
  675. # • Cor padrão.
  676. #----------------------------------------------------------------------------
  677. def default
  678. return self.hex "ffffff"
  679. end
  680. #----------------------------------------------------------------------------
  681. # • * Forma uma cor aleátoria, retornando para um objeto de Cor.
  682. #----------------------------------------------------------------------------
  683. def rand
  684. return Color.new(rand(256), rand(256), rand(256))
  685. end
  686. end
  687. #==============================================================================
  688. # • Rect
  689. #==============================================================================
  690. Dax.register(:rect)
  691. class Rect
  692. #----------------------------------------------------------------------------
  693. # • Verificar se está na área.
  694. #----------------------------------------------------------------------------
  695. def in?(x, y)
  696. x.between?(self.x, self.x + self.width) &&
  697. y.between?(self.y, self.y + self.height)
  698. end
  699. end
  700. #==============================================================================
  701. # • DMath
  702. #==============================================================================
  703. Dax.register(:dmath, 'Dax', 1.5, '04/05/13')
  704. module DMath
  705. extend self
  706. #----------------------------------------------------------------------------
  707. # • Clamp.
  708. #----------------------------------------------------------------------------
  709. def clamp(num, low, high)
  710. return num < low ? low : num > high ? high : low
  711. end
  712. #----------------------------------------------------------------------------
  713. # • Centralizar um objeto n'outro.
  714. #----------------------------------------------------------------------------
  715. def centralize_object(object, object_for_centralize)
  716. x = object.x + (object.width - object_for_centralize.width) / 2
  717. y = object.y + (object.height - object_for_centralize.height) / 2
  718. return x, y
  719. end
  720. #----------------------------------------------------------------------------
  721. # • Centralizar um objeto n'outro.
  722. #----------------------------------------------------------------------------
  723. def centralize_x(objectx, objectwidth, object_for_centralizewidth)
  724. return objectx + (objectwidth - object_for_centralizewidth) / 2
  725. end
  726. #----------------------------------------------------------------------------
  727. # • Centralizar um objeto n'outro.
  728. #----------------------------------------------------------------------------
  729. def centralize_y(objecty=0, objectheight = 0, object_for_centralizeheight=0)
  730. return objecty + (objectheight - object_for_centralizeheight) / 2
  731. end
  732. #----------------------------------------------------------------------------
  733. # • Rotc | Rotacionar.
  734. #----------------------------------------------------------------------------
  735. def rotc(vmn, v, vmx, c = 100)
  736. ((v - vmn) * c) / (vmx - vmn)
  737. end
  738. #----------------------------------------------------------------------------
  739. # • Obter o X do centro da tela para um determinado objeto|sprite,bitmap.
  740. #----------------------------------------------------------------------------
  741. def get_x_center_screen(width)
  742. return (Graphics.width - width) / 2
  743. end
  744. #----------------------------------------------------------------------------
  745. # • Obter o Y do centro da tela para um determinado objeto|sprite,bitmap.
  746. #----------------------------------------------------------------------------
  747. def get_y_center_screen(height)
  748. return (Graphics.height - height) / 2
  749. end
  750. #--------------------------------------------------------------------------
  751. # • Verifica se um objeto está na área. Círculo | Circle
  752. #--------------------------------------------------------------------------
  753. def circle(object, object2, size)
  754. ( (object.x - object2.x) ** 2) + ( (object.y - object2.y) ** 2) <= (size ** 2)
  755. end
  756. #----------------------------------------------------------------------------
  757. # • Converter em graus, multiplique a variável com isto.
  758. #----------------------------------------------------------------------------
  759. def graus
  760. 360 / (2 * Math::PI)
  761. end
  762. #----------------------------------------------------------------------------
  763. # • Radiano
  764. #----------------------------------------------------------------------------
  765. def radian(degree)
  766. return (degree.to_f/180) * Math::PI
  767. end
  768. #----------------------------------------------------------------------------
  769. # • Degree
  770. #----------------------------------------------------------------------------
  771. def degree(radian)
  772. return (radian.to_f/Math::PI) * 180
  773. end
  774. #----------------------------------------------------------------------------
  775. # • Para 4 decimals.
  776. #----------------------------------------------------------------------------
  777. def to_4_dec(n)
  778. ((n * 1000).ceil) / 1000
  779. end
  780. #----------------------------------------------------------------------------
  781. # • Área de um triângulo.
  782. #----------------------------------------------------------------------------
  783. def triangle_area(*args)
  784. x, y, x2, y2, x3, y3 = *args
  785. return (x2 - x) * (y3 - y) - (x3 - x) * (y2 - y)
  786. end
  787. #----------------------------------------------------------------------------
  788. # • Calcular distância para scripts como sensor.
  789. #----------------------------------------------------------------------------
  790. def distance_sensor(target, target2)
  791. return (target.x - target2.x).abs + (target.y - target2.y).abs
  792. end
  793. end
  794. #==============================================================================
  795. # • Keyboard | Método para usar todas as teclas do teclado.
  796. #==============================================================================
  797. Dax.register(:key, "Dax", 1.0)
  798. module Key
  799. extend self
  800. #--------------------------------------------------------------------------
  801. # * Chaves diversos.
  802. #--------------------------------------------------------------------------
  803. CANCEL = 0x03 # Control-Break Processing
  804. BACKSPACE = 0x08 # Backspace Key
  805. TAB = 0x09 # Tab Key
  806. CLEAR = 0x0C # Clear Key
  807. ENTER = 0x0D # Enter Key
  808. SHIFT = 0x10 # Shift Key
  809. CONTROL = 0x11 # Ctrl Key
  810. MENU = 0x12 # Alt Key
  811. PAUSE = 0x13 # Pause Key
  812. ESC = 0x1B # Esc Key
  813. CONVERT = 0x1C # IME Convert Key
  814. NONCONVERT = 0x1D # IME Nonconvert Key
  815. ACCEPT = 0x1E # IME Accept Key
  816. SPACE = 0x20 # Space Bar Key (Space, usually blank)
  817. PRIOR = 0x21 # Page Up Key
  818. NEXT = 0x22 # Page Down Key
  819. ENDS = 0x23 # End Key
  820. HOME = 0x24 # Home Key
  821. LEFT = 0x25 # Left Arrow Key
  822. UP = 0x26 # Up Arrow Key
  823. RIGHT = 0x27 # Right Arrow Key
  824. DOWN = 0x28 # Down Arrow Key
  825. SELECT = 0x29 # Select Key
  826. PRINT = 0x2A # Print Key
  827. EXECUTE = 0x2B # Execute Key
  828. SNAPSHOT = 0x2C # Print Screen Key
  829. DELETE = 0x2E # Delete Key
  830. HELP = 0x2F # Help Key
  831. LSHIFT = 0xA0 # Left Shift Key
  832. RSHIFT = 0xA1 # Right Shift Key
  833. LCONTROL = 0xA2 # Left Control Key (Ctrl)
  834. RCONTROL = 0xA3 # Right Control Key (Ctrl)
  835. LMENU = 0xA4 # Left Menu Key (Alt)
  836. RMENU = 0xA5 # Right Menu Key (Alt)
  837. PACKET = 0xE7 # Used to Pass Unicode Characters as Keystrokes
  838. MOUSE_RIGHT = 0x01 # Button Mouse Right
  839. MOUSE_LEFT = 0x02 # Button Mouse Left
  840. MOUSE_MIDDLE = 0x04 # Button Mouse Middle
  841. #--------------------------------------------------------------------------
  842. # * Chaves de números.
  843. #--------------------------------------------------------------------------
  844. N0 = 0x30 # 0 Key
  845. N1 = 0x31 # 1 Key
  846. N2 = 0x32 # 2 Key
  847. N3 = 0x33 # 3 Key
  848. N4 = 0x34 # 4 Key
  849. N5 = 0x35 # 5 Key
  850. N6 = 0x36 # 6 Key
  851. N7 = 0x37 # 7 Key
  852. N8 = 0x38 # 8 Key
  853. N9 = 0x39 # 9 Key
  854. #--------------------------------------------------------------------------
  855. # * Chaves de letras
  856. #--------------------------------------------------------------------------
  857. A = 0x41 # A Key
  858. B = 0x42 # B Key
  859. C = 0x43 # C Key
  860. D = 0x44 # D Key
  861. E = 0x45 # E Key
  862. F = 0x46 # F Key
  863. G = 0x47 # G Key
  864. H = 0x48 # H Key
  865. I = 0x49 # I Key
  866. J = 0x4A # J Key
  867. K = 0x4B # K Key
  868. L = 0x4C # L Key
  869. M = 0x4D # M Key
  870. N = 0x4E # N Key
  871. O = 0x4F # O Key
  872. P = 0x50 # P Key
  873. Q = 0x51 # Q Key
  874. R = 0x52 # R Key
  875. S = 0x53 # S Key
  876. T = 0x54 # T Key
  877. U = 0x55 # U Key
  878. V = 0x56 # V Key
  879. W = 0x57 # W Key
  880. X = 0x58 # X Key
  881. Y = 0x59 # Y Key
  882. Z = 0x5A # Z Key
  883. #--------------------------------------------------------------------------
  884. # * Chaves de windows
  885. #--------------------------------------------------------------------------
  886. LWIN = 0x5B # Left Windows Key (Natural keyboard)
  887. RWIN = 0x5C # Right Windows Key (Natural Keyboard)
  888. APPS = 0x5D # Applications Key (Natural keyboard)
  889. SLEEP = 0x5F # Computer Sleep Key
  890. BROWSER_BACK = 0xA6 # Browser Back Key
  891. BROWSER_FORWARD = 0xA7 # Browser Forward Key
  892. BROWSER_REFRESH = 0xA8 # Browser Refresh Key
  893. BROWSER_STOP = 0xA9 # Browser Stop Key
  894. BROWSER_SEARCH = 0xAA # Browser Search Key
  895. BROWSER_FAVORITES = 0xAB # Browser Favorites Key
  896. BROWSER_HOME = 0xAC # Browser Start and Home Key
  897. VOLUME_MUTE = 0xAD # Volume Mute Key
  898. VOLUME_DOWN = 0xAE # Volume Down Key
  899. VOLUME_UP = 0xAF # Volume Up Key
  900. MEDIA_NEXT_TRACK = 0xB0 # Next Track Key
  901. MEDIA_PREV_TRACK = 0xB1 # Previous Track Key
  902. MEDIA_STOP = 0xB2 # Stop Media Key
  903. MEDIA_PLAY_PAUSE = 0xB3 # Play/Pause Media Key
  904. LAUNCH_MAIL = 0xB4 # Start Mail Key
  905. LAUNCH_MEDIA_SELECT = 0xB5 # Select Media Key
  906. LAUNCH_APP1 = 0xB6 # Start Application 1 Key
  907. LAUNCH_APP2 = 0xB7 # Start Application 2 Key
  908. PROCESSKEY = 0xE5 # IME Process Key
  909. ATTN = 0xF6 # Attn Key
  910. CRSEL = 0xF7 # CrSel Key
  911. EXSEL = 0xF8 # ExSel Key
  912. EREOF = 0xF9 # Erase EOF Key
  913. PLAY = 0xFA # Play Key
  914. ZOOM = 0xFB # Zoom Key
  915. PA1 = 0xFD # PA1 Key
  916. #--------------------------------------------------------------------------
  917. # * Chaves do Numpad
  918. #--------------------------------------------------------------------------
  919. NUMPAD0 = 0x60 # Numeric Keypad 0 Key
  920. NUMPAD1 = 0x61 # Numeric Keypad 1 Key
  921. NUMPAD2 = 0x62 # Numeric Keypad 2 Key
  922. NUMPAD3 = 0x63 # Numeric Keypad 3 Key
  923. NUMPAD4 = 0x64 # Numeric Keypad 4 Key
  924. NUMPAD5 = 0x65 # Numeric Keypad 5 Key
  925. NUMPAD6 = 0x66 # Numeric Keypad 6 Key
  926. NUMPAD7 = 0x67 # Numeric Keypad 7 Key
  927. NUMPAD8 = 0x68 # Numeric Keypad 8 Key
  928. NUMPAD9 = 0x69 # Numeric Keypad 9 Key
  929. MULTIPLY = 0x6A # Multiply Key (*)
  930. ADD = 0x6B # Add Key (+)
  931. SEPARATOR = 0x6C # Separator Key
  932. SUBTRACT = 0x6D # Subtract Key (-)
  933. DECIMAL = 0x6E # Decimal Key (.)
  934. DIVIDE = 0x6F # Divide Key (/)
  935. #--------------------------------------------------------------------------
  936. # * Chaves de funções
  937. #--------------------------------------------------------------------------
  938. F1 = 0x70 # F1 Key
  939. F2 = 0x71 # F2 Key
  940. F3 = 0x72 # F3 Key
  941. F4 = 0x73 # F4 Key
  942. F5 = 0x74 # F5 Key
  943. F6 = 0x75 # F6 Key
  944. F7 = 0x76 # F7 Key
  945. F8 = 0x77 # F8 Key
  946. F9 = 0x78 # F9 Key
  947. F10 = 0x79 # F10 Key
  948. F11 = 0x7A # F11 Key
  949. F12 = 0x7B # F12 Key
  950. F13 = 0x7C # F13 Key
  951. F14 = 0x7D # F14 Key
  952. F15 = 0x7E # F15 Key
  953. F16 = 0x7F # F16 Key
  954. F17 = 0x80 # F17 Key
  955. F18 = 0x81 # F18 Key
  956. F19 = 0x82 # F19 Key
  957. F20 = 0x83 # F20 Key
  958. F21 = 0x84 # F21 Key
  959. F22 = 0x85 # F22 Key
  960. F23 = 0x86 # F23 Key
  961. F24 = 0x87 # F24 Key
  962. #--------------------------------------------------------------------------
  963. # * Chaves alternativas
  964. #--------------------------------------------------------------------------
  965. CAPITAL = 0x14 # Caps Lock Key
  966. KANA = 0x15 # IME Kana Mode Key
  967. HANGUL = 0x15 # IME Hangul Mode Key
  968. JUNJA = 0x17 # IME Junja Mode Key
  969. FINAL = 0x18 # IME Final Mode Key
  970. HANJA = 0x19 # IME Hanja Mode Key
  971. KANJI = 0x19 # IME Kanji Mode Key
  972. MODECHANGE = 0x1F # IME Mode Change Request Key
  973. INSERT = 0x2D # Insert Key
  974. NUMLOCK = 0x90 # Num Lock Key
  975. SCROLL = 0x91 # Scroll Lock Key
  976. #--------------------------------------------------------------------------
  977. # * Chaves OEM, variadas
  978. #--------------------------------------------------------------------------
  979. OEM_1 = 0xBA # Misc Characters (; : in USA 101/102 Keyboards)
  980. OEM_PLUS = 0xBB # + = Key
  981. OEM_COMMA = 0xBC # , < Key
  982. OEM_MINUS = 0xBD # - _ Key
  983. OEM_PERIOD = 0xBE # . > Key
  984. OEM_2 = 0xBF # Misc Characters (/ ? in USA 101/102 Keyboards)
  985. OEM_3 = 0xC0 # Misc Characters (` ~ in USA 101/102 Keyboards)
  986. OEM_4 = 0xDB # Misc Characters ([ { in USA 101/102 Keyboards)
  987. OEM_5 = 0xDC # Misc Characters (\ | in USA 101/102 Keyboards)
  988. OEM_6 = 0xDD # Misc Characters (] } in USA 101/102 Keyboards)
  989. OEM_7 = 0xDE # Misc Characters (' " in USA 101/102 Keyboards)
  990. OEM_8 = 0xDF # Misc Characters (Varies by Keyboard)
  991. OEM_9 = 0xE1 # OEM Specific
  992. OEM_10 = 0x92 # OEM Specific
  993. OEM_11 = 0x93 # OEM Specific
  994. OEM_12 = 0x94 # OEM Specific
  995. OEM_13 = 0x95 # OEM Specific
  996. OEM_14 = 0x96 # OEM Specific
  997. OEM_15 = 0xE3 # OEM Specific
  998. OEM_16 = 0xE4 # OEM Specific
  999. OEM_17 = 0xE6 # OEM Specific
  1000. OEM_18 = 0xE9 # OEM Specific
  1001. OEM_19 = 0xEA # OEM Specific
  1002. OEM_20 = 0xEB # OEM Specific
  1003. OEM_21 = 0xEC # OEM Specific
  1004. OEM_22 = 0xED # OEM Specific
  1005. OEM_23 = 0xEE # OEM Specific
  1006. OEM_24 = 0xEF # OEM Specific
  1007. OEM_25 = 0xF1 # OEM Specific
  1008. OEM_26 = 0xF2 # OEM Specific
  1009. OEM_27 = 0xF3 # OEM Specific
  1010. OEM_28 = 0xF4 # OEM Specific
  1011. OEM_29 = 0xF5 # OEM Specific
  1012. OEM_102 = 0xE2 # Angle Bracket or Backslash on RT-102 Keyboards
  1013. OEM_CLEAR = 0xFE # Clear Key
  1014. #--------------------------------------------------------------------------
  1015. # * Variáveis do módulo.
  1016. #--------------------------------------------------------------------------
  1017. @unpack_string = 'b'*256
  1018. @last_array = '0'*256
  1019. @press = Array.new(256, false)
  1020. @trigger = Array.new(256, false)
  1021. @repeat = Array.new(256, false)
  1022. @release = Array.new(256, false)
  1023. @repeat_counter = Array.new(256, 0)
  1024. @getKeyboardState = API::GetKeyboardState
  1025. @getAsyncKeyState = API::GetAsyncKeyState
  1026. @getKeyboardState.call(@last_array)
  1027. @last_array = @last_array.unpack(@unpack_string)
  1028. for i in 0...@last_array.size
  1029. @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  1030. end
  1031. #--------------------------------------------------------------------------
  1032. # * Atualização dos objetos do módulo.
  1033. #--------------------------------------------------------------------------
  1034. def update
  1035. @trigger = Array.new(256, false)
  1036. @repeat = Array.new(256, false)
  1037. @release = Array.new(256, false)
  1038. array = '0'*256
  1039. @getKeyboardState.call(array)
  1040. array = array.unpack(@unpack_string)
  1041. for i in 0...array.size
  1042. if array[i] != @last_array[i]
  1043. @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  1044. if @repeat_counter[i] <= 0 && @press[i]
  1045. @repeat[i] = true
  1046. @repeat_counter[i] = 15
  1047. end
  1048. if !@press[i]
  1049. @release[i] = true
  1050. else
  1051. @trigger[i] = true
  1052. end
  1053. else
  1054. if @press[i] == true
  1055. @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  1056. @release[i] = true if !@press[i]
  1057. end
  1058. if @repeat_counter[i] > 0 && @press[i] == true
  1059. @repeat_counter[i] -= 1
  1060. elsif @repeat_counter[i] <= 0 && @press[i] == true
  1061. @repeat[i] = true
  1062. @repeat_counter[i] = 3
  1063. elsif @repeat_counter[i] != 0
  1064. @repeat_counter[i] = 0
  1065. end
  1066. end
  1067. end
  1068. @last_array = array
  1069. end
  1070. #--------------------------------------------------------------------------
  1071. # * Get Key Pressed State
  1072. # key : key index
  1073. #--------------------------------------------------------------------------
  1074. def press?(key)
  1075. return @press[key]
  1076. end
  1077. #--------------------------------------------------------------------------
  1078. # * Get Key Triggered State
  1079. # key : key index
  1080. #--------------------------------------------------------------------------
  1081. def trigger?(key)
  1082. return @trigger[key]
  1083. end
  1084. #--------------------------------------------------------------------------
  1085. # * Get Key Repeated State
  1086. # key : key index
  1087. #--------------------------------------------------------------------------
  1088. def repeat?(key)
  1089. return @repeat[key]
  1090. end
  1091. #--------------------------------------------------------------------------
  1092. # * Get Key Released State
  1093. # key : key index
  1094. #--------------------------------------------------------------------------
  1095. def release?(key)
  1096. return @release[key]
  1097. end
  1098. end
  1099. #==============================================================================
  1100. # • Sprite
  1101. #==============================================================================
  1102. Dax.register(:sprite)
  1103. class Sprite
  1104. #----------------------------------------------------------------------------
  1105. # • Novo método.
  1106. #----------------------------------------------------------------------------
  1107. alias new_initialize initialize
  1108. def initialize(viewport=nil)
  1109. if viewport.is_a?(String)
  1110. new_initialize(nil)
  1111. if viewport.match(/S: ([^>]*)/)
  1112. self.bitmap = Cache.system($1.to_s)
  1113. elsif viewport.match(/P: ([^>]*)/)
  1114. self.bitmap = Cache.picture($1.to_s)
  1115. elsif viewport.match(/G: ([^>]*)/)
  1116. self.bitmap = Bitmap.new("Graphics/#{$1.to_s}")
  1117. else
  1118. self.bitmap = Bitmap.new(viewport)
  1119. end
  1120. elsif viewport.is_a?(Array)
  1121. if viewport.size == 2
  1122. new_initialize(nil)
  1123. self.bitmap = Bitmap.new(viewport[0], viewport[1])
  1124. elsif viewport.size == 5
  1125. new_initialize(nil)
  1126. self.bitmap = Bitmap.new(viewport[0], viewport[1])
  1127. self.x, self.y, self.z = viewport[2], viewport[3], viewport[4]
  1128. end
  1129. elsif viewport.is_a?(Viewport) or viewport.nil?
  1130. new_initialize(viewport)
  1131. end
  1132. end
  1133. #----------------------------------------------------------------------------
  1134. # • Slide pela direita.
  1135. # * speed : Velocidade | point : Ponto da coordenada X que irá chegar.
  1136. #----------------------------------------------------------------------------
  1137. def slide_right(speed, point)
  1138. self.x += speed unless self.x >= point
  1139. end
  1140. #----------------------------------------------------------------------------
  1141. # • Slide pela esquerda.
  1142. # * speed : Velocidade | point : Ponto da coordenada X que irá chegar.
  1143. #----------------------------------------------------------------------------
  1144. def slide_left(speed, point)
  1145. self.x -= speed unless self.x <= point
  1146. end
  1147. #----------------------------------------------------------------------------
  1148. # • Slide por cima.
  1149. # * speed : Velocidade | point : Ponto da coordenada Y que irá chegar.
  1150. #----------------------------------------------------------------------------
  1151. def slide_up(speed, point)
  1152. self.y -= speed unless self.y <= point
  1153. end
  1154. #----------------------------------------------------------------------------
  1155. # • Slide por baixo.
  1156. # * speed : Velocidade | point : Ponto da coordenada Y que irá chegar.
  1157. #----------------------------------------------------------------------------
  1158. def slide_down(speed, point)
  1159. self.y += speed unless self.y >= point
  1160. end
  1161. #----------------------------------------------------------------------------
  1162. # • Define aqui uma posição fixa para um objeto.
  1163. #----------------------------------------------------------------------------
  1164. def position(command=0)
  1165. return if command.nil?
  1166. case command
  1167. when 0 then self.x = 0
  1168. when 1 then self.x = (Graphics.width - self.width) / 2
  1169. when 2 then self.x = Graphics.width - self.width
  1170. when 3 then self.y = 0
  1171. when 4 then self.y = (Graphics.height - self.height) / 2
  1172. when 5 then self.y = Graphics.height - self.height
  1173. when :center
  1174. self.x = (Graphics.width - self.width) / 2
  1175. self.y = Graphics.height / 2 - self.height / 2
  1176. when :center_left
  1177. self.x = 0
  1178. self.y = (Graphics.height - self.height) / 2
  1179. when :center_right
  1180. self.x = Graphics.width - self.height
  1181. self.y = (Graphics.height - self.height) / 2
  1182. end
  1183. end
  1184. #----------------------------------------------------------------------------
  1185. # • Tamanho geral
  1186. #----------------------------------------------------------------------------
  1187. def size
  1188. return self.width + self.height
  1189. end
  1190. #----------------------------------------------------------------------------
  1191. # • Rect
  1192. #----------------------------------------------------------------------------
  1193. def rect
  1194. return self.bitmap.rect
  1195. end
  1196. end
  1197. #==============================================================================
  1198. # • Bitmap
  1199. #==============================================================================
  1200. Dax.register(:bitmap)
  1201. class Bitmap
  1202. #-------------------------------------------------------------------------
  1203. # Desenhar meter... Gradient
  1204. #-------------------------------------------------------------------------
  1205. def draw_meter_line(x, y, min, max, width = 156, height = 4,
  1206. bar_start = Color.new(255, 0, 0, 192), bar_end = Color.new(255, 255, 0, 192),
  1207. background = Color.new(0, 0, 0, 128))
  1208. w = width * min / max
  1209. 4.times do
  1210. fill_rect(x + 8, y + 4, width, height / 4, background)
  1211. draw_gradient_line(x, y, x + w, y, height / 4, bar_start, bar_end)
  1212. x -= 1
  1213. y += height / 4
  1214. end
  1215. end
  1216. #----------------------------------------------------------------------------
  1217. # • Definir gradiente..
  1218. #----------------------------------------------------------------------------
  1219. def gradient_color(colors, width, percentage)
  1220. width_per = ((width * 1.0) * percentage)
  1221. width_per = width_per.round
  1222. if colors.size == 1
  1223. return colors[0]
  1224. elsif colors.size > 1
  1225. i = 0
  1226. sections_per = (1.0 / colors.size)
  1227. equationa = (sections_per * colors.size)
  1228. equationb = (sections_per * (colors.size - 1))
  1229. if equationa >= percentage and equationb < percentage
  1230. i = (colors.size - 1)
  1231. else
  1232. for j in 0..(colors.size - 1)
  1233. equationc = (sections_per * (j + 1))
  1234. equationd = (sections_per * (j + 2))
  1235. if equationc < percentage and equationd > percentage
  1236. i = j + 1
  1237. end
  1238. end
  1239. end
  1240. if i == (colors.size - 1)
  1241. for k in 0..width
  1242. if k == width_per
  1243. r = colors[i - 1].red * (width - k) / width + colors[i].red * k / width
  1244. g = colors[i - 1].green * (width - k) / width + colors[i].green * k / width
  1245. b = colors[i - 1].blue * (width - k) / width + colors[i].blue * k / width
  1246. a = colors[i - 1].alpha * (width - k) / width + colors[i].alpha * k / width
  1247. return Color.new(r,g,b,a)
  1248. end
  1249. end
  1250. else
  1251. for k in 0..width
  1252. if k == width_per
  1253. r = colors[i].red * (width - k) / width + colors[i + 1].red * k / width
  1254. g = colors[i].green * (width - k) / width + colors[i + 1].green * k / width
  1255. b = colors[i].blue * (width - k) / width + colors[i + 1].blue * k / width
  1256. a = colors[i].alpha * (width - k) / width + colors[i + 1].alpha * k / width
  1257. return Color.new(r,g,b,a)
  1258. end
  1259. end
  1260. end
  1261. elsif colors.size < 1
  1262. msgbox 'ERROR : No Colors Were Supplied'
  1263. exit
  1264. end
  1265. end
  1266. #----------------------------------------------------------------------------
  1267. # • Barra.
  1268. #----------------------------------------------------------------------------
  1269. def bar(color, actual, max, borda=1)
  1270. rate = self.width.to_p(actual, max)
  1271. self.fill_rect(borda, borda, rate-(borda*2), self.height-(borda*2),
  1272. color)
  1273. end
  1274. #----------------------------------------------------------------------------
  1275. # • Barra em forma de gradient;.
  1276. #----------------------------------------------------------------------------
  1277. def gradient_bar(color, actual, max, borda=1)
  1278. rate = self.width.to_p(actual, max)
  1279. self.gradient_fill_rect(borda, borda, rate-(borda*2), self.height-(borda*2),
  1280. color[0], color[1], 2)
  1281. end
  1282. #----------------------------------------------------------------------------
  1283. # • Efeito de Shader Sill
  1284. #----------------------------------------------------------------------------
  1285. def shader_sill
  1286. ra = 500
  1287. re = 0 ; gr = 0 ; bl = 0
  1288. for i in 1..(self.height-1)
  1289. for j in 1..(self.width-1)
  1290. for m in -1..1
  1291. for n in -1..1
  1292. if m != 0 and n != 0
  1293. a = self.get_pixel(j+m,i+n)
  1294. re = re + a.red
  1295. gr = gr + a.green
  1296. bl = bl + a.blue
  1297. end
  1298. end
  1299. end
  1300. b = self.get_pixel(j,i)
  1301. re = (b.red-re/8).abs
  1302. gr = (b.green-gr/8).abs
  1303. bl = (b.blue-bl/8).abs
  1304. self.set_pixel(j,i,Color.new(0, 0, 0, b.alpha) )
  1305. end
  1306. end
  1307. end
  1308. #--------------------------------------------------------------------------
  1309. # * Desenho do gráfico do personagem
  1310. # character_name : nome do gráfico do personagem
  1311. # character_index : índice do gráfico de personagem
  1312. # x : coordenada X
  1313. # y : coordenada Y
  1314. #--------------------------------------------------------------------------
  1315. def draw_character(character_name, character_index, x, y)
  1316. return unless character_name
  1317. bitmap = Cache.character(character_name)
  1318. sign = character_name[/^[\!\$]./]
  1319. if sign && sign.include?('$')
  1320. cw = bitmap.width / 3
  1321. ch = bitmap.height / 4
  1322. else
  1323. cw = bitmap.width / 12
  1324. ch = bitmap.height / 8
  1325. end
  1326. n = character_index
  1327. src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  1328. self.blt(x - cw / 2, y - ch, bitmap, src_rect)
  1329. end
  1330. #--------------------------------------------------------------------------
  1331. # * Desenho do gráfico de personagem do herói
  1332. # actor : herói
  1333. # x : coordenada X
  1334. # y : coordenada Y
  1335. #--------------------------------------------------------------------------
  1336. def draw_actor_graphic(actor, x, y)
  1337. draw_character(actor.character_name, actor.character_index, x, y)
  1338. end
  1339. #----------------------------------------------------------------------------
  1340. # • Limpar uma área num formato de círculo.
  1341. #----------------------------------------------------------------------------
  1342. def clear_rect_circle(x, y, r)
  1343. rr = r*r
  1344. for i in 0...r
  1345. adj = Math.sqrt(rr - (i*i)).ceil
  1346. xd = x - adj
  1347. wd = 2 * adj
  1348. self.clear_rect(xd, y-i, wd, 1)
  1349. self.clear_rect(xd, y+i, wd, 1)
  1350. end
  1351. end
  1352. #----------------------------------------------------------------------------
  1353. # • Novo modo de desenhar textos. Configurações já especificadas.
  1354. #----------------------------------------------------------------------------
  1355. def draw_text_rect(*args)
  1356. self.draw_text(self.rect, *args)
  1357. end
  1358. #----------------------------------------------------------------------------
  1359. # • Salvar em png.
  1360. # --- Autor : Gab! ---
  1361. #----------------------------------------------------------------------------
  1362. def save(file_name)
  1363. def chunk(type, data)
  1364. [data.size, type, data, Zlib.crc32(type + data)].pack("NA4A*N")
  1365. end
  1366. img_data = ""
  1367. width, height = self.width, self.height
  1368. for j in 0...(height)
  1369. img_data << "\0"
  1370. for i in 0...(width)
  1371. pos_c = self.get_pixel(i, j)
  1372. img_data << [pos_c.red, pos_c.green, pos_c.blue, pos_c.alpha].pack("C*")
  1373. end
  1374. end
  1375. c = [
  1376. "\x89PNG\r\n\x1a\n",
  1377. chunk("IHDR", [width, height, 8, 6, 0, 0, 0].pack("N2C5")),
  1378. chunk("IDAT", Zlib::Deflate.deflate(img_data)),
  1379. chunk("IEND", "")
  1380. ]
  1381. File.open(file_name, "wb"){|file| c.each{|chunk| file.write(chunk) }}
  1382. end
  1383. #----------------------------------------------------------------------------
  1384. # • Efeito negativo.
  1385. #----------------------------------------------------------------------------
  1386. def negative
  1387. for i in 0...(self.width)
  1388. for j in 0...(self.height)
  1389. pix = self.get_pixel(i, j)
  1390. pix.red = (pix.red - 255) * -1
  1391. pix.blue = (pix.blue - 255) * -1
  1392. pix.green = (pix.green - 255) * -1
  1393. self.set_pixel(i, j, pix)
  1394. end
  1395. end
  1396. end
  1397. #----------------------------------------------------------------------------
  1398. # • Grayscale
  1399. #----------------------------------------------------------------------------
  1400. def grayscale(rect = Rect.new(0, 0, self.width, self.height))
  1401. for i in rect.x...rect.x + rect.width
  1402. for j in rect.y...rect.y + rect.height
  1403. colour = self.get_pixel(i,j)
  1404. grey_pixel = (colour.red*0.3 + colour.green*0.59 + colour.blue*0.11)
  1405. colour.red = colour.green = colour.blue = grey_pixel
  1406. self.set_pixel(i,j,colour)
  1407. end
  1408. end
  1409. end
  1410. #----------------------------------------------------------------------------
  1411. # • Novo fornecedor de pixel.
  1412. #----------------------------------------------------------------------------
  1413. def set_pixel_s(x, y, color, size)
  1414. for i in 0...size
  1415. self.set_pixel(x+i, y, color)
  1416. self.set_pixel(x-i, y, color)
  1417. self.set_pixel(x, y+i, color)
  1418. self.set_pixel(x, y-i, color)
  1419. self.set_pixel(x+i, y+i, color)
  1420. self.set_pixel(x-i, y-i, color)
  1421. self.set_pixel(x+i, y-i, color)
  1422. self.set_pixel(x-i, y+i, color)
  1423. end
  1424. end
  1425. #----------------------------------------------------------------------------
  1426. # • Desenhar uma linha.
  1427. #----------------------------------------------------------------------------
  1428. def draw_line(start_x, start_y, end_x, end_y, color, size=1)
  1429. set_pixel_s(start_x, start_y, color, size)
  1430. distance = (start_x - end_x).abs + (start_y - end_y).abs
  1431. for i in 1..distance
  1432. x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  1433. y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  1434. set_pixel_s(x, y, color, size)
  1435. end
  1436. set_pixel_s(end_x, end_y, color, size)
  1437. end
  1438. #----------------------------------------------------------------------------
  1439. # • draw_bar_gauge(x, y, current, current_max, border, colors)
  1440. # x : Coordenadas X.
  1441. # y : Coordenadas Y.
  1442. # current : Valor atual da barra.
  1443. # current_max : Valor maxímo da barra.
  1444. # border : Expressura da borda.
  1445. # colors : Cores. [0, 1, 2]
  1446. #----------------------------------------------------------------------------
  1447. # Permite adicionar uma barra.
  1448. #----------------------------------------------------------------------------
  1449. def draw_bar_gauge(x, y, current, current_max, colors=[])
  1450. cw = self.width.to_p(current, current_max)
  1451. ch = self.height
  1452. self.gradient_fill_rect(x, y, self.width, self.height, colors[0], colors[1])
  1453. src_rect = Rect.new(0, 0, cw, ch)
  1454. self.blt(x, y, self, src_rect)
  1455. end
  1456. #----------------------------------------------------------------------------
  1457. # • draw_icon(icon_index, x, y, enabled)
  1458. # icon_index : ID do ícone.
  1459. # x : Coordenadas X.
  1460. # y : Coordenadas Y.
  1461. # enabled : Habilitar flag, translucido quando false
  1462. #----------------------------------------------------------------------------
  1463. #----------------------------------------------------------------------------
  1464. def draw_icon(icon_index, x, y, enabled = true)
  1465. icon_index = icon_index.nil? ? 0 : icon_index
  1466. bitmap = Cache.system("Iconset")
  1467. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  1468. self.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  1469. end
  1470. #----------------------------------------------------------------------------
  1471. # • draw_gradation_gauge(x, y, width, height, current, current_max, border, colors, align)
  1472. # x : Coordenadas X.
  1473. # y : Coordenadas Y.
  1474. # width : Largura da barra.
  1475. # height : Altura da barra.
  1476. # current : Valor atual da barra.
  1477. # current_max : Valor maxímo da barra.
  1478. # border : Expressura da borda.
  1479. # colors : Cores. [0, 1, 2]
  1480. # align : Alinhamento.
  1481. #----------------------------------------------------------------------------
  1482. # Permite adicionar uma barra.
  1483. #----------------------------------------------------------------------------
  1484. def draw_gradation_gauge(x, y, current, current_max, border, colors=[])
  1485. cw = self.width.to_p(current, current_max)
  1486. ch = self.height
  1487. self.fill_rect(x, y, self.width, self.height, colors[0])
  1488. self.gradient_fill_rect(x+border, y+border, self.width-(border/2), self.height-(border/2), colors[1], colors[2])
  1489. src_rect = Rect.new(0, 0, cw, ch)
  1490. self.blt(x, y, self, src_rect)
  1491. end
  1492. #--------------------------------------------------------------------------
  1493. # • Desenho do gráfico de rosto
  1494. # face_name : nome do gráfico de face
  1495. # face_index : índice do gráfico de face
  1496. # x : coordenada X
  1497. # y : coordenada Y
  1498. # enabled : habilitar flag, translucido quando false
  1499. #--------------------------------------------------------------------------
  1500. def draw_face(face_name, face_index, x, y, enabled = true)
  1501. bitmap = Cache.face(face_name)
  1502. rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  1503. self.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  1504. end
  1505. #--------------------------------------------------------------------------
  1506. # • Desenho do gráfico de face do herói
  1507. # actor : herói
  1508. # x : coordenada X
  1509. # y : coordenada Y
  1510. # enabled : habilitar flag, translucido quando false
  1511. #--------------------------------------------------------------------------
  1512. def draw_actor_face(actor, x, y, enabled = true)
  1513. draw_face(actor.face_name, actor.face_index, x, y, enabled)
  1514. end
  1515. #--------------------------------------------------------------------------
  1516. # • Desenho do nível
  1517. # actor : herói
  1518. # x : coordenada X
  1519. # y : coordenada Y
  1520. #--------------------------------------------------------------------------
  1521. def draw_actor_level(actor, x, y)
  1522. self.font.name = "Comic Sans MS"
  1523. self.font.color = ColorBasic[35]
  1524. self.font.size = 18
  1525. self.draw_text(x, y, 32, 20, Vocab::level_a)
  1526. self.font.size = 22
  1527. draw_text(x + 16, y, 32, 20, actor.level, 2)
  1528. end
  1529. #----------------------------------------------------------------------------
  1530. # • Desenhar um círuclo preenchido.
  1531. #----------------------------------------------------------------------------
  1532. def fill_circle(x, y, r, c)
  1533. rr = r*r
  1534. for i in 0...r
  1535. adj = Math.sqrt(rr - (i*i)).ceil
  1536. xd = x - adj
  1537. wd = 2 * adj
  1538. self.fill_rect(xd, y-i, wd, 1, c)
  1539. self.fill_rect(xd, y+i, wd, 1, c)
  1540. end
  1541. end
  1542. #----------------------------------------------------------------------------
  1543. # • Desenhar um triângulo preenchido
  1544. #----------------------------------------------------------------------------
  1545. def fill_triangle3(pts, c, pos=[0, 0])
  1546. return if pts.size != 3
  1547. pts.sort! {|a, b| a[1] - b[1]}
  1548. pt1, pt2, pt3 = pts
  1549. dxt = (pt3[0] - pt1[0]) / 2
  1550. dyt = (pt3[1] - pt1[1]) / 2
  1551. dxm = pt2[0] - pt1[0]
  1552. dym = pt2[1] - pt1[1]
  1553. dm = dym.abs
  1554. if dm > 0 and dyt != 0
  1555. for i in 0...(dm+2)
  1556. ix = ((dxm*i) / (dm+1))
  1557. iy = ((dym*i) / (dm+1))
  1558. edx = ix - (dxt * iy / dyt)
  1559. self.fill_rect(ix+pt1[0]-[edx,0].max-2+pos[0], iy+pt1[1]+pos[1], edx.abs+4, 1, c)
  1560. end
  1561. end
  1562. dxm = pt2[0] - pt3[0]
  1563. dym = pt2[1] - pt3[1]
  1564. dm = dym.abs
  1565. if dm > 0 and dyt != 0
  1566. for i in 0...(dm+2)
  1567. ix = ((dxm*i) / (dm+1))
  1568. iy = ((dym*i) / (dm+1))
  1569. edx = ix - (dxt * iy / dyt)
  1570. self.fill_rect(ix+pt3[0]-[edx,0].max-2+pos[0], iy+pt3[1]+pos[1], edx.abs+4, 1, c)
  1571. end
  1572. end
  1573. end
  1574. #----------------------------------------------------------------------------
  1575. # • Desenhar um polígono.
  1576. #----------------------------------------------------------------------------
  1577. def fill_polygon(pts, c, pos=[0, 0])
  1578. return if pts.size <= 2
  1579. n = pts.size - 2
  1580. for i in 0...n
  1581. self.fill_triangle3(pts[i..(i + 2)], c, pos)
  1582. end
  1583. end
  1584. end
  1585. #==============================================================================
  1586. # • Mouse
  1587. #==============================================================================
  1588. Dax.register(:mouse, "Dax", 1.1)
  1589. module Mouse
  1590. extend self
  1591. #--------------------------------------------------------------------------
  1592. # • Inicialização dos objetos.
  1593. #--------------------------------------------------------------------------
  1594. def start
  1595. @cursor = Sprite.new
  1596. @cursor.z = 100000
  1597. @cursor.bitmap = Bitmap.new(1, 1)
  1598. x = Dax::Mouse_Name == "" ? 1 : 0
  1599. API::MouseShowCursor.call(x)
  1600. @dgraphic = Dax::Mouse_Name
  1601. graphic Dax::Mouse_Name
  1602. update
  1603. end
  1604. #--------------------------------------------------------------------------
  1605. # • graphic(graphic_set)
  1606. # graphic_set : Se for número é um ícone; Se for string é uma imagem.
  1607. #--------------------------------------------------------------------------
  1608. def graphic(graphic_set)
  1609. return if graphic_set == "" or graphic_set.nil?
  1610. if graphic_set.is_a?(Fixnum)
  1611. @cursor.bitmap = Bitmap.new(24, 24)
  1612. @cursor.bitmap.draw_icon(graphic_set.to_i, 0, 0)
  1613. else
  1614. @cursor.bitmap = Cache.picture(graphic_set.to_s)
  1615. end
  1616. @dgraphic = graphic_set
  1617. end
  1618. #--------------------------------------------------------------------------
  1619. # • show(visible)
  1620. # visible : True - para mostrar o mouse | False - para esconder o mouse.
  1621. #--------------------------------------------------------------------------
  1622. def show(visible=true)
  1623. @cursor.visible = visible
  1624. end
  1625. #--------------------------------------------------------------------------
  1626. # • update (Atualização das coordenadas)
  1627. #--------------------------------------------------------------------------
  1628. def update
  1629. return if @cursor.nil?
  1630. @cursor.x, @cursor.y = position
  1631. end
  1632. #--------------------------------------------------------------------------
  1633. # • cursor
  1634. #--------------------------------------------------------------------------
  1635. def cursor
  1636. @cursor
  1637. end
  1638. #--------------------------------------------------------------------------
  1639. # • x (Coordenada X do Mouse)
  1640. #--------------------------------------------------------------------------
  1641. def x
  1642. @cursor.x
  1643. end
  1644. #--------------------------------------------------------------------------
  1645. # • y (Coordenada Y do Mouse)
  1646. #--------------------------------------------------------------------------
  1647. def y
  1648. @cursor.y
  1649. end
  1650. #--------------------------------------------------------------------------
  1651. # • position (Posição do Mouse!)
  1652. #--------------------------------------------------------------------------
  1653. def position
  1654. x, y = get_client_position
  1655. return x, y
  1656. end
  1657. #--------------------------------------------------------------------------
  1658. # • get_client_position (Posição original do Mouse!)
  1659. #--------------------------------------------------------------------------
  1660. def get_client_position
  1661. pos = [0, 0].pack('ll')
  1662. API::CursorPosition.call(pos)
  1663. API::ScreenToClient.call(WINDOW, pos)
  1664. return pos.unpack('ll')
  1665. end
  1666. #--------------------------------------------------------------------------
  1667. # • find_window (Tamanho da window)
  1668. #--------------------------------------------------------------------------
  1669. def find_window
  1670. game_name = '\0' * 256
  1671. API::ReadIni.call('Game', 'Title', '', game_name, 255, '.\\Game.ini')
  1672. game_name.delete!('\0') ensure game_name
  1673. return API::FindWindow.call('RGSS Player', game_name)
  1674. end
  1675. #--------------------------------------------------------------------------
  1676. # • Verificação se o mouse está na área de um determinado objeto.
  1677. #--------------------------------------------------------------------------
  1678. def in_area?(object_sprite)
  1679. return @cursor.x.between?(object_sprite.x, object_sprite.x + object_sprite.width) &&
  1680. @cursor.y.between?(object_sprite.y, object_sprite.y + object_sprite.height)
  1681. end
  1682. #----------------------------------------------------------------------------
  1683. # • Mudar posição do cursor.
  1684. #----------------------------------------------------------------------------
  1685. def set_mouse(pos)
  1686. SetCursorPos.call(pos.x, pos.y)
  1687. update
  1688. @cursor.x = @pos.x
  1689. @cursor.y = @pos.y
  1690. end
  1691. WINDOW = find_window
  1692. end
  1693.  
  1694. #==============================================================================
  1695. # • Object
  1696. #==============================================================================
  1697. Dax.register(:object)
  1698. class Object
  1699. #----------------------------------------------------------------------------
  1700. # • Profunda cópia
  1701. #----------------------------------------------------------------------------
  1702. def deep_clone
  1703. Marshal.load(Marshal.dump(self))
  1704. end
  1705. #----------------------------------------------------------------------------
  1706. # * Trigger ou Repeat
  1707. #----------------------------------------------------------------------------
  1708. def trigger_or_repeat?(key)
  1709. trigger?(key) or repeat?(key)
  1710. end
  1711. #----------------------------------------------------------------------------
  1712. # • Trigger
  1713. #----------------------------------------------------------------------------
  1714. def trigger?(key)
  1715. return key.is_a?(Symbol) ? Input.trigger?(key) : Key.trigger?(key)
  1716. end
  1717. #----------------------------------------------------------------------------
  1718. # • Press
  1719. #----------------------------------------------------------------------------
  1720. def press?(key)
  1721. return key.is_a?(Symbol) ? Input.press?(key) : Key.press?(key)
  1722. end
  1723. #----------------------------------------------------------------------------
  1724. # • Repeat
  1725. #----------------------------------------------------------------------------
  1726. def repeat?(key)
  1727. return key.is_a?(Symbol) ? Input.repeat?(key) : Key.repeat?(key)
  1728. end
  1729. end
  1730. #==============================================================================
  1731. # • Entries
  1732. #==============================================================================
  1733. Dax.register(:entries)
  1734. class Entries
  1735. #----------------------------------------------------------------------------
  1736. # • Variável pública da instância.
  1737. #----------------------------------------------------------------------------
  1738. attr_accessor :file
  1739. attr_reader :get_number
  1740. attr_reader :get_file
  1741. attr_reader :get_array
  1742. attr_reader :name
  1743. #----------------------------------------------------------------------------
  1744. # • Inicialização dos objetos.
  1745. #----------------------------------------------------------------------------
  1746. def initialize(directory, typefile)
  1747. return unless FileTest.directory?(directory)
  1748. @file = Dir.glob(directory + "/*.{" + typefile + "}")
  1749. @file.each_index { |i| @get_number = i.to_i }
  1750. @file.each { |i| @get_file = i.to_s }
  1751. @file.each_with_index { |i| @get_array = i }
  1752. @name = split @file[0]
  1753. end
  1754. #----------------------------------------------------------------------------
  1755. # • Split | Separar
  1756. #----------------------------------------------------------------------------
  1757. def split(file)
  1758. file.to_s.split('/').last
  1759. end
  1760. #----------------------------------------------------------------------------
  1761. # • Obter nome.
  1762. #----------------------------------------------------------------------------
  1763. def name(id)
  1764. return split(@file[id])
  1765. end
  1766. end
  1767. #==============================================================================
  1768. # • TextBase
  1769. #==============================================================================
  1770. Dax.register(:text_base)
  1771. class TextBase
  1772. #----------------------------------------------------------------------------
  1773. # • Inicialização dos objetos.
  1774. #----------------------------------------------------------------------------
  1775. def initialize
  1776. @text = ""
  1777. end
  1778. #----------------------------------------------------------------------------
  1779. # • Adicionar texto.
  1780. #----------------------------------------------------------------------------
  1781. def text=(text_add)
  1782. @text += text_add
  1783. end
  1784. #----------------------------------------------------------------------------
  1785. # • Adicionar uma nova linha.
  1786. #----------------------------------------------------------------------------
  1787. def text(text, nspace=0)
  1788. @text += "\r\n" + (" " * nspace) + text
  1789. end
  1790. #----------------------------------------------------------------------------
  1791. # • Adicionar comentário;
  1792. #----------------------------------------------------------------------------
  1793. def comment=(text_add, comment="#")
  1794. @text += comment + text_add
  1795. end
  1796. #----------------------------------------------------------------------------
  1797. # • Adicionar uma nova linha como comentário.
  1798. #----------------------------------------------------------------------------
  1799. def comment(text, nspace=0, comment="#")
  1800. @text += "\r\n" + (" " * nspace) + comment + text
  1801. end
  1802. #----------------------------------------------------------------------------
  1803. # • Salvar o texto.
  1804. #----------------------------------------------------------------------------
  1805. def save(filename="")
  1806. _file = File.open(filename, "a+").each { |file|
  1807. file.write(@text.to_s)
  1808. file.close
  1809. }
  1810. end
  1811. end
  1812. #==============================================================================
  1813. # • DRGSS | Comandos do RGSS...
  1814. #==============================================================================
  1815. Dax.register(:drgss)
  1816. module DRGSS
  1817. extend self
  1818. #----------------------------------------------------------------------------
  1819. # • Deleta a pasta, os arquivos.
  1820. #----------------------------------------------------------------------------
  1821. def recursive_delete(dir)
  1822. files = []
  1823. Dir.foreach(dir) do |fname|
  1824. next if fname == '.' || fname == '..'
  1825. path = dir + '/' + fname
  1826. if File.directory?(path)
  1827. puts "dir #{path}"
  1828. recursive_delete(path)
  1829. else
  1830. puts "file #{path}"
  1831. files << path
  1832. end
  1833. end
  1834. files.each do |path|
  1835. msgbox "delete file #{path}"
  1836. end
  1837. msgbox "delete dir #{dir}"
  1838. Dir.rmdir(dir)
  1839. end
  1840. #----------------------------------------------------------------------------
  1841. # • Deleta tudo.. Só use caso você saiba o que está fazendo
  1842. #----------------------------------------------------------------------------
  1843. def delete(directory)
  1844. if File.directory?(directory)
  1845. Dir.foreach(directory) do |file_or_directory|
  1846. File.delete(directory+"/"+file_or_directory) if file_or_directory != "." and file_or_directory != ".."
  1847. end
  1848. else
  1849. begin
  1850. File.delete(directory) if File.new(directory).stat.size == 0
  1851. rescue
  1852. msgbox "#{$!} Error in deleting zero size file "
  1853. end
  1854. end
  1855. end
  1856. #----------------------------------------------------------------------------
  1857. # • Extrair scripts.
  1858. #----------------------------------------------------------------------------
  1859. def extract_scripts(type=".txt",options={})
  1860. except = options[:except] || []
  1861. folder = options[:folder] || ""
  1862. id = 0 #
  1863. $RGSS_SCRIPTS.each do |script|
  1864. name = script[1]
  1865. data = script[3]
  1866. next if except.include? name or name.empty? or data.empty?
  1867. filename = sprintf("%03d", id) + "_" + name
  1868. p "Writing: #{filename}"
  1869. File.open(folder+filename+"#{type}", "wb") do |file|
  1870. file.write data
  1871. end
  1872. id += 1
  1873. end
  1874. end
  1875. #----------------------------------------------------------------------------
  1876. # • Carregar scripts.
  1877. #----------------------------------------------------------------------------
  1878. def load_scripts(type=".txt",options={})
  1879. skip = options[:skip] || []
  1880. folder = options[:folder] || ""
  1881. begin
  1882. Dir.foreach(folder) do |file|
  1883. file_id = file[0,3].to_i
  1884. break if file_id == options[:limit]
  1885. next if file == "." or file == ".." or File.extname(file) != "#{type}" or skip.include?(file_id)
  1886. r = load (folder+"#{file}")
  1887. p "Loaded: #{r}"
  1888. end
  1889. end
  1890. end
  1891. end
  1892. #==============================================================================
  1893. # • Módulo Touch
  1894. #==============================================================================
  1895. Dax.register(:touch)
  1896. module Touch
  1897. #============================================================================
  1898. # * Picture : Sistema onde você define uma imagem na qual pode ser acessada
  1899. # pelo mouse.
  1900. #============================================================================
  1901. class Picture < Sprite
  1902. #--------------------------------------------------------------------------
  1903. # * Variáveis públicas da instância;
  1904. #--------------------------------------------------------------------------
  1905. attr_accessor :show
  1906. #--------------------------------------------------------------------------
  1907. # ** Inicialização dos objetos **
  1908. #--------------------------------------------------------------------------
  1909. # Argumentos do método *** : ***
  1910. #
  1911. # name/args[0] : Nome do arquivo.
  1912. # x/args[1] : Coordenada X
  1913. # y/args[2] : Coordenada Y
  1914. # switche/args[3] : ID da switche para que quando ela estiver ativada, você não
  1915. # poderá acessar a imagem, caso ela não esteja ativada, você poderá
  1916. # acessar a imagem, agora caso você coloque 'nil' ela poderá ser acessada
  1917. # a qualquer momento.
  1918. # mode/args[4] : 0 - Para identificar se o arquivo está na pasta System
  1919. # 1 - Para identificar se o arquivo está na pasta Picture.
  1920. #--------------------------------------------------------------------------
  1921. def initialize(*args)
  1922. super((args[4] == 0 ? "S: " : "P: ") + args[0])
  1923. [1, 2].each { |number| self.x, self.y = args[number] }
  1924. @clicked, @in_area, @switche_id = false, args[3], false
  1925. self.z = 200
  1926. end
  1927. #--------------------------------------------------------------------------
  1928. # * Verifica se está na área do objeto.
  1929. #--------------------------------------------------------------------------
  1930. def in_area?
  1931. return @in_area
  1932. end
  1933. #--------------------------------------------------------------------------
  1934. # * Renovar os objetos
  1935. #--------------------------------------------------------------------------
  1936. def dispose
  1937. self.bitmap.dispose
  1938. super
  1939. end
  1940. #--------------------------------------------------------------------------
  1941. # * Atualizar os objetos.
  1942. #--------------------------------------------------------------------------
  1943. def update
  1944. self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  1945. if @show
  1946. if Mouse.in_area?(self)
  1947. @in_area = true
  1948. effect_on_area?
  1949. @clicked = trigger_or_repeat?(0x01)
  1950. action if @clicked && trigger_or_repeat?(0x01)
  1951. else
  1952. @in_area = false
  1953. effect_off_area?
  1954. @clicked = false if trigger_or_repeat?(0x01)
  1955. end
  1956. else
  1957. self.opacity = 0
  1958. end
  1959. end
  1960. #--------------------------------------------------------------------------
  1961. # * Ação ao clicar o mouse.
  1962. #--------------------------------------------------------------------------
  1963. def action
  1964. end
  1965. #--------------------------------------------------------------------------
  1966. # * Efeito de quando estiver na área.
  1967. #--------------------------------------------------------------------------
  1968. def effect_on_area?
  1969. self.opacity = 255
  1970. end
  1971. #--------------------------------------------------------------------------
  1972. # * Efeito de quando não estiver na área.
  1973. #--------------------------------------------------------------------------
  1974. def effect_off_area?
  1975. self.opacity = 127.5
  1976. end
  1977. end
  1978. #============================================================================
  1979. # * Simple_Picture : Versão simplificada da Picture
  1980. #============================================================================
  1981. class Simple_Picture < Picture
  1982. #--------------------------------------------------------------------------
  1983. # * Inicialização dos objetos
  1984. #--------------------------------------------------------------------------
  1985. def initialize(action, *args)
  1986. end
  1987. #--------------------------------------------------------------------------
  1988. # * Renovar
  1989. #--------------------------------------------------------------------------
  1990. def dispose
  1991. super
  1992. end
  1993. #--------------------------------------------------------------------------
  1994. # * Atualizar
  1995. #--------------------------------------------------------------------------
  1996. def update
  1997. super
  1998. end
  1999. #--------------------------------------------------------------------------
  2000. # * Ação
  2001. #--------------------------------------------------------------------------
  2002. def action
  2003. unless action.nil?
  2004. eval(action.to_s)
  2005. else
  2006. eval(@action.to_s) unless @action.nil?
  2007. end
  2008. end
  2009. #--------------------------------------------------------------------------
  2010. # * Efeito da área
  2011. #--------------------------------------------------------------------------
  2012. def effect_on_area?; super; end;
  2013. def effect_off_area?; super; end;
  2014. def in_area?; super; end;
  2015. #--------------------------------------------------------------------------
  2016. # * Conteúdo
  2017. #--------------------------------------------------------------------------
  2018. def self; self; end;
  2019. end
  2020. #============================================================================
  2021. # * Icon
  2022. #============================================================================
  2023. class Icon < Sprite
  2024. #--------------------------------------------------------------------------
  2025. # • Inicialização dos objetos.
  2026. # id : ID do ícone no database.
  2027. # x : Posição X do objeto.
  2028. # y : Posição Y do objeto.
  2029. # z : Altura do objeto.
  2030. #--------------------------------------------------------------------------
  2031. def initialize(*args)
  2032. super([24, 24])
  2033. (1..3).each { |number| self.x, self.y, self.z = args[number] }
  2034. self.bitmap.draw_icon(args[0].to_i, 0, 0)
  2035. @clicked = false
  2036. @switche_id = args[4]
  2037. @effect = args[5]
  2038. end
  2039. #--------------------------------------------------------------------------
  2040. # • Renovação dos objetos.
  2041. #--------------------------------------------------------------------------
  2042. def dispose
  2043. self.bitmap.dispose if !self.bitmap.nil?
  2044. super
  2045. end
  2046. #--------------------------------------------------------------------------
  2047. # • Atualizaçaõ dos objetos.
  2048. # action_clicked : Caso seja um nome em formato de String irá chamar uma
  2049. # scene, caso seja em formato de número irá chamar um evento comum.
  2050. #--------------------------------------------------------------------------
  2051. def update
  2052. if @effect == :visible then self.visible = !$game_switches[@switche_id] unless @switche_id.nil? end
  2053. unless @switche_id.nil? then self.opacity = 64 if @effect == :opacity and !$game_switches[@switche_id] end
  2054. if Mouse.in_area?(self)
  2055. effect_on_area?
  2056. @clicked = trigger?(0x01) or repeat?(0x01)
  2057. action if @clicked && trigger?(0x01) or repeat?(0x01)
  2058. else
  2059. effect_off_area?
  2060. @clicked = false if trigger?(0x01) or repeat?(0x01)
  2061. end
  2062. end
  2063. #----------------------------------------------------------------------------
  2064. # • Acão após o clique na imagem.
  2065. #----------------------------------------------------------------------------
  2066. def action
  2067. return if self.visible or self.opacity == 64
  2068. end
  2069. #----------------------------------------------------------------------------
  2070. # • Efeito quando estiver na área.
  2071. #----------------------------------------------------------------------------
  2072. def effect_on_area?
  2073. self.opacity = 255
  2074. end
  2075. #----------------------------------------------------------------------------
  2076. # • Efeito quando estiver fora da área.
  2077. #----------------------------------------------------------------------------
  2078. def effect_off_area?(new=nil)
  2079. self.opacity = new.nil? ? 128 : new
  2080. end
  2081. end
  2082. #==============================================================================
  2083. # • Simple_Icon
  2084. #============================================================================
  2085. class Simple_Icon < Icon
  2086. #----------------------------------------------------------------------------
  2087. # • Inicialização dos objetos.
  2088. #----------------------------------------------------------------------------
  2089. def initialize(action, *args)
  2090. super(*args)
  2091. self.opacity = 128
  2092. @action = action
  2093. end
  2094. #----------------------------------------------------------------------------
  2095. # • Renovação dos objetos.
  2096. #----------------------------------------------------------------------------
  2097. def dispose
  2098. super
  2099. end
  2100. #----------------------------------------------------------------------------
  2101. # • Atualização dos objetos.
  2102. #----------------------------------------------------------------------------
  2103. def update
  2104. super
  2105. end
  2106. #----------------------------------------------------------------------------
  2107. # • Ação após o clique.
  2108. #----------------------------------------------------------------------------
  2109. def action
  2110. super
  2111. eval(@action.to_s) unless @action.nil?
  2112. end
  2113. #----------------------------------------------------------------------------
  2114. # • Efeito do objeto quando estiver na área.
  2115. #----------------------------------------------------------------------------
  2116. def effect_on_area?
  2117. super
  2118. end
  2119. #----------------------------------------------------------------------------
  2120. # • Efeito do objeto quando estiver fora da área.
  2121. #----------------------------------------------------------------------------
  2122. def effect_off_area?(value=nil)
  2123. super(value)
  2124. end
  2125. #----------------------------------------------------------------------------
  2126. # • Retorna ao conteúdo.
  2127. #----------------------------------------------------------------------------
  2128. def contents
  2129. self
  2130. end
  2131. end
  2132. #==============================================================================
  2133. # • Mouse Extension | Touch Text
  2134. #==============================================================================
  2135. class Text < Sprite
  2136. #----------------------------------------------------------------------------
  2137. # • Inicialização dos objetos.
  2138. # id : ID do ícone no database.
  2139. # x : Posição X do objeto.
  2140. # y : Posição Y do objeto.
  2141. # z : Altura do objeto.
  2142. #----------------------------------------------------------------------------
  2143. def initialize(text="", x=0, y=0, z=0, switche_id=nil,color=[ColorBasic[-1], ColorBasic[7]],font=["Arial", 16],align=0)
  2144. super([font[1] + (text.split(//).size ** 2), args[6][1]])
  2145. (1..3).each { |xyz| self.x, self.y, self.z = args[xyz] }
  2146. self.bitmap.draw_text(0, 0, self.width, self.height, args[0], args[7])
  2147. @clicked = false
  2148. @switche_id = args[4]
  2149. @color = args[5]
  2150. self.bitmap.font.name, self.bitmap.font.size = args[6]
  2151. end
  2152. #----------------------------------------------------------------------------
  2153. # • Renovação dos objetos.
  2154. #----------------------------------------------------------------------------
  2155. def dispose
  2156. self.bitmap.dispose if !self.bitmap.nil?
  2157. super
  2158. end
  2159. #----------------------------------------------------------------------------
  2160. # • Atualizaçaõ dos objetos.
  2161. # action_clicked : Caso seja um nome em formato de String irá chamar uma
  2162. # scene, caso seja em formato de número irá chamar um evento comum.
  2163. #----------------------------------------------------------------------------
  2164. def update
  2165. self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
  2166. if Mouse.in_area?(self)
  2167. effect_on_area?
  2168. @clicked = trigger?(0x01) or repeat?(0x01)
  2169. action if @clicked && trigger?(0x01) or repeat?(0x01)
  2170. else
  2171. effect_off_area?
  2172. @clicked = false if trigger?(0x01) or repeat?(0x01)
  2173. end
  2174. end
  2175. #----------------------------------------------------------------------------
  2176. # • Acão após o clique na imagem.
  2177. #----------------------------------------------------------------------------
  2178. def action
  2179.  
  2180. end
  2181. #----------------------------------------------------------------------------
  2182. # • Efeito quando estiver na área.
  2183. #----------------------------------------------------------------------------
  2184. def effect_on_area?
  2185. self.color = @color[1]
  2186. end
  2187. #----------------------------------------------------------------------------
  2188. # • Efeito quando estiver fora da área.
  2189. #----------------------------------------------------------------------------
  2190. def effect_off_area?
  2191. self.color = @color[0]
  2192. end
  2193. end
  2194. #============================================================================
  2195. # Simple Touch Icon
  2196. #============================================================================
  2197. class Simple_Text < Text
  2198. #----------------------------------------------------------------------------
  2199. # • Inicialização dos objetos.
  2200. #----------------------------------------------------------------------------
  2201. def initialize(action, *args)
  2202. super(*args)
  2203. @action = action
  2204. end
  2205. #----------------------------------------------------------------------------
  2206. # • Renovação dos objetos.
  2207. #----------------------------------------------------------------------------
  2208. def dispose
  2209. super
  2210. end
  2211. #----------------------------------------------------------------------------
  2212. # • Atualização dos objetos.
  2213. #----------------------------------------------------------------------------
  2214. def update
  2215. super
  2216. end
  2217. #----------------------------------------------------------------------------
  2218. # • Ação após o clique.
  2219. #----------------------------------------------------------------------------
  2220. def action
  2221. eval(@action.to_s) unless @action.nil?
  2222. end
  2223. #----------------------------------------------------------------------------
  2224. # • Efeito do objeto quando estiver na área.
  2225. #----------------------------------------------------------------------------
  2226. def effect_on_area?
  2227. super
  2228. end
  2229. #----------------------------------------------------------------------------
  2230. # • Efeito do objeto quando estiver fora da área.
  2231. #----------------------------------------------------------------------------
  2232. def effect_off_area?
  2233. super
  2234. end
  2235. #----------------------------------------------------------------------------
  2236. # • Retorna ao conteúdo.
  2237. #----------------------------------------------------------------------------
  2238. def contents
  2239. self
  2240. end
  2241. end
  2242. end
  2243. #==============================================================================
  2244. # • OutlineFillRect
  2245. #==============================================================================
  2246. Dax.register(:outline_fill_rect)
  2247. class OutlineFillRect < Sprite
  2248. #----------------------------------------------------------------------------
  2249. # • Inicialização dos objetos.
  2250. #----------------------------------------------------------------------------
  2251. def initialize(object, max=2, color=ColorBasic[-1])
  2252. super([object.width, object.height])
  2253. @object = object
  2254. self.x, self.y, self.z = object.x, object.y, object.z
  2255. self.bitmap.fill_rect(0, 0, max, self.height, color)
  2256. self.bitmap.fill_rect(self.width-max, 0, max, self.height, color)
  2257. self.bitmap.fill_rect(0, 0, self.width, max, color)
  2258. self.bitmap.fill_rect(0, self.height-max, self.width, max, color)
  2259. end
  2260. #----------------------------------------------------------------------------
  2261. # • Renovação dos objetos.
  2262. #----------------------------------------------------------------------------
  2263. def dispose
  2264. self.bitmap.dispose unless self.bitmap.disposed?
  2265. super
  2266. end
  2267. #----------------------------------------------------------------------------
  2268. # • Atualização das coordenadas.
  2269. #----------------------------------------------------------------------------
  2270. def update
  2271. self.x, self.y, self.z = @object.x, @object.y, @object.z
  2272. end
  2273. end
  2274.  
  2275. #==============================================================================
  2276. # • BackupSystem
  2277. #==============================================================================
  2278. Dax.register :backupsystem
  2279. $BACKUP = <<_SCRIPT_
  2280. if $TEST
  2281. time = Time.now
  2282. Dir.mkdir('Backup') unless File.directory?('Backup')
  2283. ftype = 'rvdata2'
  2284. flist = Dir.glob('./Data/*.{' + ftype + '}')
  2285. flist.each_index do |i|
  2286. flist[i] = flist[i].split('/').last
  2287. save_data(load_data('Data/' + flist[i]), 'Backup' + '/' + flist[i])
  2288. end
  2289. print("Backup em:" + (Time.now - time).to_s + ' segundos')
  2290. end
  2291. _SCRIPT_
  2292. def backup; eval($BACKUP); end;
  2293. #==============================================================================
  2294. # • BackString
  2295. #==============================================================================
  2296. Dax.register :dstring
  2297. module DString
  2298. extend self
  2299. #----------------------------------------------------------------------------
  2300. # • Deletar a útlima letra de uma string..
  2301. #----------------------------------------------------------------------------
  2302. def backslash(text)
  2303. text2 = ""
  2304. text = text.to_s.split(//)
  2305. text[text.size-1] = "" unless text[0].to_s.empty?
  2306. for i in 0..text.size-1
  2307. text2 += text[i].to_s
  2308. end
  2309. return text2
  2310. end
  2311. end
  2312. #==============================================================================
  2313. # * SceneManager
  2314. #==============================================================================
  2315. Dax.register :scenemanager
  2316. class << SceneManager
  2317. #----------------------------------------------------------------------------
  2318. # • Chama uma scene através de uma palavra.;
  2319. #----------------------------------------------------------------------------
  2320. def symbol(scene_symbol)
  2321. eval("self.call(#{scene_symbol.to_s})")
  2322. end
  2323. end
  2324. #==============================================================================
  2325. # • Sprite_Text
  2326. #==============================================================================
  2327. Dax.register(:sprite_text)
  2328. class Sprite_Text < Sprite
  2329. #----------------------------------------------------------------------------
  2330. # • Variáveis públicas da instância.
  2331. #----------------------------------------------------------------------------
  2332. attr_accessor :text # Mudar de texto...
  2333. #----------------------------------------------------------------------------
  2334. # • Inicialização dos objetos.
  2335. #----------------------------------------------------------------------------
  2336. def initialize(x, y, width, height, text, align=0)
  2337. super([width, height])
  2338. self.x, self.y = x, y
  2339. @text = text
  2340. self.bitmap.draw_text_rect(@text, align)
  2341. end
  2342. #----------------------------------------------------------------------------
  2343. # • Renovação dos objetos.
  2344. #----------------------------------------------------------------------------
  2345. def dispose
  2346. self.bitmap.dispose
  2347. super
  2348. end
  2349. #----------------------------------------------------------------------------
  2350. # • Atualização dos objetos.
  2351. #----------------------------------------------------------------------------
  2352. def update
  2353. self.bitmap.clear
  2354. super
  2355. self.bitmap.draw_text_rect(@text)
  2356. end
  2357. end
  2358. #==============================================================================
  2359. # • Opacity
  2360. #==============================================================================
  2361. Dax.register(:opacity)
  2362. module Opacity
  2363. extend self
  2364. @key ||= {}
  2365. #----------------------------------------------------------------------------
  2366. # • Efeito de opacidade + e -.
  2367. #----------------------------------------------------------------------------
  2368. def sprite_opacity(sprite, speed, max, min, hash=nil)
  2369. unless @key[hash]
  2370. sprite.opacity += speed unless sprite.opacity >= max
  2371. @key[hash] = sprite.opacity >= max
  2372. else
  2373. sprite.opacity -= speed unless sprite.opacity <= min
  2374. @key[hash] = false if sprite.opacity <= min
  2375. end
  2376. end
  2377. #----------------------------------------------------------------------------
  2378. # • Efeito de opacidade por fora.
  2379. #----------------------------------------------------------------------------
  2380. def sprite_opacity_out(sprite, speed, max)
  2381. sprite.opacity += speed unless sprite.opacity >= max
  2382. end
  2383. #----------------------------------------------------------------------------
  2384. # • Efeito de opacidade por dentro.
  2385. #----------------------------------------------------------------------------
  2386. def sprite_opacity_in(sprite, speed, min)
  2387. sprite.opacity -= speed unless sprite.opacity <= min
  2388. end
  2389. #--------------------------------------------------------------------------
  2390. # • Efeito de fade out em massa
  2391. # time : duração (em milesegundo)
  2392. #--------------------------------------------------------------------------
  2393. def fadeout_all(time = 1000)
  2394. RPG::BGM.fade(time)
  2395. RPG::BGS.fade(time)
  2396. RPG::ME.fade(time)
  2397. Graphics.fadeout(time * Graphics.frame_rate / 1000)
  2398. RPG::BGM.stop
  2399. RPG::BGS.stop
  2400. RPG::ME.stop
  2401. end
  2402. end
  2403. #==============================================================================
  2404. # • Rpg
  2405. #==============================================================================
  2406. Dax.register(:rpg)
  2407. module Rpg
  2408. def self.data_manager
  2409. end
  2410. #============================================================================
  2411. # • Hud
  2412. #============================================================================
  2413. module Hud
  2414.  
  2415. end
  2416. #============================================================================
  2417. # • Menu
  2418. #============================================================================
  2419. module Menu
  2420. extend self
  2421. def include_item?(item)
  2422. item.is_a?(RPG::Item) && !item.key_item?
  2423. end
  2424. #--------------------------------------------------------------------------
  2425. # • Cursor...
  2426. #--------------------------------------------------------------------------
  2427. def cursor_up(variable, max)
  2428. variable += 1 unless variable > max
  2429. variable = 0 if variable > max
  2430. return variable
  2431. end
  2432. #--------------------------------------------------------------------------
  2433. # • Cursor...
  2434. #--------------------------------------------------------------------------
  2435. def cursor_down(variable, max)
  2436. variable -= 1 unless variable < 0
  2437. variable = max if variable < 0
  2438. return variable
  2439. end
  2440. end
  2441. #============================================================================
  2442. # • Battle
  2443. #============================================================================
  2444. module Battle
  2445. end
  2446. #============================================================================
  2447. # • Title
  2448. #============================================================================
  2449. module Title
  2450. end
  2451. end
  2452. #==============================================================================
  2453. # • String
  2454. #==============================================================================
  2455. class String
  2456. #----------------------------------------------------------------------------
  2457. # • Comandos.
  2458. #----------------------------------------------------------------------------
  2459. def script
  2460. if self.match(/sprite: ([^>]*)/)
  2461. return Sprite.new($1)
  2462. elsif self.match(/cb|CB: (\d+)/)
  2463. return ColorBasic[$1.to_i]
  2464. elsif self.match(/window: x: (\d+) y: (\d+) width: (\d+) height: (\d+)/)
  2465. return Window_Base.new($1.to_i, $2.to_i, $3.to_i, $4.to_i)
  2466. elsif self.match(/G: ([^>]*)/)
  2467. return "Graphics/#{$1}"
  2468. elsif self.match(/C:(\w+):([^>]*)/)
  2469. case $1
  2470. when "S"
  2471. return Cache.system($2.to_s)
  2472. when "P"
  2473. return Cache.picture($2.to_s)
  2474. when "Pl"
  2475. return Cache.parallax($2.to_s)
  2476. when "C"
  2477. return Cache.character($2.to_s)
  2478. when "A"
  2479. return Cache.animation($2.to_s)
  2480. when "B1"
  2481. return Cache.battleback1($2.to_s)
  2482. when "B2"
  2483. return Cache.battleback2($2.to_s)
  2484. when "B"
  2485. return Cache.battler($2.to_s)
  2486. when "F"
  2487. return Cache.face($2.to_s)
  2488. when "T1"
  2489. return Cache.title1($2.to_s)
  2490. when "T2"
  2491. return Cache.title2($2.to_s)
  2492. when "T"
  2493. return Cache.tileset($2.to_s)
  2494. end
  2495. elsif self.match(/scall: (\w+)/)
  2496. return eval("SceneManager.call(#{$1})")
  2497. elsif self.match(/sgoto: (\w+)/)
  2498. return eval("SceneManager.goto(#{$1})")
  2499. elsif self.match(/text: x: (\d+) y: (\d+) width: (\d+) height: (\d+) text: ([^>]*)/)
  2500. return Sprite_Text.new($1.to_f, $2.to_f, $3.to_f, $4.to_f, $5.to_s)
  2501. elsif self.match(/r(\d+) g(\d+) b(\d+) a(\d+)/)
  2502. return Color.new($1.to_f, $2.to_f, $3.to_f, $4.to_f)
  2503. end
  2504. end
  2505. end
  2506. #==============================================================================
  2507. # • Txt
  2508. #==============================================================================
  2509. Dax.register(:read, "Dax")
  2510. module Read
  2511. extend self
  2512. #----------------------------------------------------------------------------
  2513. # • Verificar valor numérico após uma palavra em um arquivo.
  2514. #----------------------------------------------------------------------------
  2515. def numeric(file, tag)
  2516. IO.readlines(file).each do |line|
  2517. return $1.to_i if line.match(/#{tag} (\d+)/)
  2518. end
  2519. end
  2520. #----------------------------------------------------------------------------
  2521. # • Verificar valor de uma palavra(string única) após uma palavra em um arquivo
  2522. #----------------------------------------------------------------------------
  2523. def string(file, tag)
  2524. IO.readlines(file).each do |line|
  2525. return $1.to_s if line.match(/#{tag} (\w+)/)
  2526. end
  2527. end
  2528. #----------------------------------------------------------------------------
  2529. # • Verificar um conteúdo após uma palavra de um arquivo.
  2530. #----------------------------------------------------------------------------
  2531. def content(file, tag)
  2532. IO.readlines(file).each do |line|
  2533. return $1 if line.match(/#{tag} ([^>]*)/)
  2534. end
  2535. end
  2536. #----------------------------------------------------------------------------
  2537. # • Multiplo número..
  2538. #----------------------------------------------------------------------------
  2539. def multiple_numeric(file, tag)
  2540. IO.readlines(file).each do |line|
  2541. return [$1.to_i, $2.to_i] if line.match(/#{tag} (\d+), (\d+)/)
  2542. end
  2543. end
  2544. #----------------------------------------------------------------------------
  2545. # • Multiplo string..
  2546. #----------------------------------------------------------------------------
  2547. def multiple_string(file, tag)
  2548. IO.readlines(file).each do |line|
  2549. return [$1.to_s, $2.to_s] if line.match(/#{tag} (\w+), (\w+)/)
  2550. end
  2551. end
  2552. #----------------------------------------------------------------------------
  2553. # • Triplo número.
  2554. #----------------------------------------------------------------------------
  2555. def triple_numeric(file, tag)
  2556. IO.readlines(file).each do |line|
  2557. return [$1.to_i, $2.to_i, $3.to_i] if line.match(/#{tag} (\d+), (\d+), (\d+)/)
  2558. end
  2559. end
  2560. #----------------------------------------------------------------------------
  2561. # • Triplo string.
  2562. #----------------------------------------------------------------------------
  2563. def triple_string(file, tag)
  2564. IO.readlines(file).each do |line|
  2565. return [$1.to_s, $2.to_s, $3.to_s] if line.match(/#{tag} (\w+), (\w+), (\w+)/)
  2566. end
  2567. end
  2568. # true or false
  2569. def of(file, tag)
  2570. IO.readlines(file).each do |line|
  2571. return $1.to_s == "true" ? true : false if line.match(/#{tag} ([^>]*)/)
  2572. end
  2573. end
  2574. end
  2575.  
  2576. #==============================================================================
  2577. # • Background
  2578. #==============================================================================
  2579. Dax.register :background
  2580. module Background
  2581. extend self
  2582. #----------------------------------------------------------------------------
  2583. # • Plano de fundo padrão...
  2584. #----------------------------------------------------------------------------
  2585. def default(alpha=128)
  2586. @background = Sprite.new
  2587. @background.bitmap = SceneManager.background_bitmap
  2588. @background.color.set(16, 16, 16, alpha)
  2589. end
  2590. #----------------------------------------------------------------------------
  2591. # • Plano de fundo padrão renovado.
  2592. #----------------------------------------------------------------------------
  2593. def default_dispose
  2594. return if @background.nil?
  2595. @background.dispose
  2596. end
  2597. end
  2598. #==============================================================================
  2599. # * Window_Base
  2600. #==============================================================================
  2601. Dax.register(:window_base)
  2602. Dax.required_class("Window_Base") {
  2603. class Window_Base < Window
  2604. #----------------------------------------------------------------------------
  2605. # • Slide pela direita.
  2606. # * speed : Velocidade | point : Ponto da coordenada X que irá chegar.
  2607. #----------------------------------------------------------------------------
  2608. def slide_right(speed, point)
  2609. self.x += speed unless self.x >= point
  2610. end
  2611. #----------------------------------------------------------------------------
  2612. # • Slide pela esquerda.
  2613. # * speed : Velocidade | point : Ponto da coordenada X que irá chegar.
  2614. #----------------------------------------------------------------------------
  2615. def slide_left(speed, point)
  2616. self.x -= speed unless self.x <= point
  2617. end
  2618. #----------------------------------------------------------------------------
  2619. # • Slide por cima.
  2620. # * speed : Velocidade | point : Ponto da coordenada Y que irá chegar.
  2621. #----------------------------------------------------------------------------
  2622. def slide_up(speed, point)
  2623. self.y -= speed unless self.y <= point
  2624. end
  2625. #----------------------------------------------------------------------------
  2626. # • Slide por baixo.
  2627. # * speed : Velocidade | point : Ponto da coordenada Y que irá chegar.
  2628. #----------------------------------------------------------------------------
  2629. def slide_down(speed, point)
  2630. self.y += speed unless self.y >= point
  2631. end
  2632. end
  2633. }
  2634. #==============================================================================
  2635. # • Map
  2636. #==============================================================================
  2637. Dax.register(:map)
  2638. module Map
  2639. extend self
  2640. #----------------------------------------------------------------------------
  2641. # • Mapeiar área.
  2642. # map : Objeto [SPRITE].. que será escaniado..
  2643. # scan_sprite : Objeto [SPRITE].. que irá projetar o scan.
  2644. # color : Cor do scan.
  2645. #----------------------------------------------------------------------------
  2646. def char_area(map, scan_sprite, color=ColorBasic[-1])
  2647. _table = Table.new(map.width, map.height)
  2648. for x in 0..._table.xsize
  2649. for y in 0..._table.ysize
  2650. next if map.bitmap.get_pixel(x, y).alpha == 0
  2651. scan_sprite.bitmap.set_pixel(x, y, color)
  2652. end
  2653. end
  2654. end
  2655. #----------------------------------------------------------------------------
  2656. # • Colidir com determinada cor de um objeto sprite.
  2657. # ar : [largura, altura, bloqueio da esquerda, bloqueio de cima]
  2658. # object : Objeto a colidir. [SPRITE]
  2659. # map : Mapa. [SPRITE]
  2660. # color : Cor, na qual quando o objeto colidir com está cor.. ativa.
  2661. #---------------------------------------------------------------------------
  2662. def collide_with_color(object, map, color, ar=[28,30,30,30])
  2663. (ar[0]...object.width).each { |w| (ar[1]...object.height).each { |h|
  2664. _r = map.bitmap.get_pixel(object.x+w, object.y+h) == color[:right]
  2665. _l = map.bitmap.get_pixel(object.x+ar[2]-w, object.y+h) == color[:left]
  2666. _d = map.bitmap.get_pixel(object.x+w, object.y+h) == color[:down]
  2667. _u = map.bitmap.get_pixel(object.x+w, object.y+ar[3]-h) == color[:up]
  2668. return {right: _r, left: _l, down: _d, up: _u}
  2669. }}
  2670. end
  2671. end
  2672. #==============================================================================
  2673. # • VS | Variables & Switches
  2674. #==============================================================================
  2675. Dax.register(:vs)
  2676. module VS
  2677. #----------------------------------------------------------------------------
  2678. # • Função do módulo.
  2679. #----------------------------------------------------------------------------
  2680. module_function
  2681. #----------------------------------------------------------------------------
  2682. # • Desligar a quantia predestinada de switches...
  2683. #----------------------------------------------------------------------------
  2684. def off_switche(value=9999)
  2685. Dax.required_class("$game_switches"){value.times { |index| $game_switches[index] = false }
  2686. $game_switches.on_change}
  2687. end
  2688. #----------------------------------------------------------------------------
  2689. # • Ativar a quantia predestinada de switches...
  2690. #----------------------------------------------------------------------------
  2691. def on_switche(value=9999)
  2692. Dax.required_class("$game_switches"){value.times { |index| $game_switches[index] = true }
  2693. $game_switches.on_change}
  2694. end
  2695. #----------------------------------------------------------------------------
  2696. # • Salvar as variáveis do jogo em um arquivo
  2697. # *args : IDs delas.. exemplo: 1, 2, 3, 4
  2698. #----------------------------------------------------------------------------
  2699. def save_game_variable(*args)
  2700. Dax.required_class("$game_variables"){
  2701. Dax.required_file("savedGameVariables.rvdata2"){File.delete("savedGameVariables.rvdata2")}
  2702. i = [*args]
  2703. sgv = [{}]
  2704. (0...i.size-1).each { |index| sgv[0][index] = $game_variables[index] }
  2705. save_data(sgv, "savedGameVariables.rvdata2")
  2706. }
  2707. end
  2708. #----------------------------------------------------------------------------
  2709. # • Carregar as variáveis do jogo dum arquivo
  2710. # *args : IDs delas.. exemplo: 1, 2, 3, 4
  2711. #----------------------------------------------------------------------------
  2712. def load_game_variable(*args)
  2713. Dax.required_class("$game_variables"){
  2714. Dax.required_file("savedGameVariables.rvdata2"){
  2715. i = [*args]
  2716. sgv = load_data("savedGameVariables.rvdata2")
  2717. (0...i.size-1).each { |index| $game_variables[index] = sgv[0][index]}
  2718.  
  2719. }}
  2720. end
  2721. #----------------------------------------------------------------------------
  2722. # • Salvar as switches do jogo em um arquivo
  2723. # *args : IDs delas.. exemplo: 1, 2, 3, 4
  2724. #----------------------------------------------------------------------------
  2725. def save_switches_variable(*args)
  2726. Dax.required_class("$game_switches"){
  2727. Dax.required_file("savedGameSwitches.rvdata2"){File.delete("savedGameSwitches.rvdata2")}
  2728. i = [*args]
  2729. sgs= [{}]
  2730. (0...i.size-1).each { |index| sgs[0][index] = $game_switches[index] }
  2731. save_data(sgs, "savedGameSwitches.rvdata2")
  2732. }
  2733. end
  2734. #----------------------------------------------------------------------------
  2735. # • Carregar as variáveis do jogo dum arquivo
  2736. # *args : IDs delas.. exemplo: 1, 2, 3, 4
  2737. #----------------------------------------------------------------------------
  2738. def load_game_variable(*args)
  2739. Dax.required_class("$game_switches"){
  2740. Dax.required_file("savedGameSwitches.rvdata2"){
  2741. i = [*args]
  2742. sgs = load_data("savedGameSwitches.rvdata2")
  2743. (0...i.size-1).each { |index| $game_switches[index] = sgs[0][index]}
  2744.  
  2745. }}
  2746. end
  2747. end
  2748. #==============================================================================
  2749. # • Sound Base
  2750. #==============================================================================
  2751. Dax.register(:sound_base)
  2752. module Sound_Base
  2753. #----------------------------------------------------------------------------
  2754. # • Função do módulo.
  2755. #----------------------------------------------------------------------------
  2756. module_function
  2757. #----------------------------------------------------------------------------
  2758. # • Executar um som.
  2759. #----------------------------------------------------------------------------
  2760. def play(name, volume, pitch, type = :se)
  2761. case type
  2762. when :se ; RPG::SE.new(name, volume, pitch).play rescue valid?(name)
  2763. when :me ; RPG::ME.new(name, volume, pitch).play rescue valid?(name)
  2764. when :bgm ; RPG::BGM.new(name, volume, pitch).play rescue valid?(name)
  2765. when :bgs ; RPG::BGS.new(name, volume, pitch).play rescue valid?(name)
  2766. end
  2767. end
  2768. #----------------------------------------------------------------------------
  2769. # • Validar som.
  2770. #----------------------------------------------------------------------------
  2771. def valid?(name)
  2772. raise("Arquivo de som não encontrado: #{name}")
  2773. exit
  2774. end
  2775. end
  2776. #==============================================================================
  2777. # • Desativar scripts : Para fazer, basta por no nome do script da lista,
  2778. # [D].
  2779. #==============================================================================
  2780. Dax.register(:disable_script)
  2781. Dax.rgss_script.each_with_index { |data, index|
  2782. $RGSS_SCRIPTS.at(index)[2] = $RGSS_SCRIPTS.at(index)[3] = "" if data.at(1).include?("[D]")
  2783. }
  2784. #==============================================================================
  2785. # * DataManager
  2786. #==============================================================================
  2787. class << DataManager
  2788. alias :new_init :init
  2789. def init
  2790. Rpg.data_manager
  2791. Mouse.start
  2792. new_init
  2793. end
  2794. end
  2795. #==============================================================================
  2796. # * Input
  2797. #==============================================================================
  2798. class << Input
  2799. alias :upft :update
  2800. def update
  2801. upft
  2802. Key.update
  2803. end
  2804. end
  2805.  
  2806. class << Graphics
  2807. alias :uptf :update
  2808. def update
  2809. uptf
  2810. Mouse.update
  2811. end
  2812. end
  2813.  
  2814. __END__
  2815. :regexp_symbol
  2816. #==============================================================================
  2817. # • Regexp Symbol
  2818. #==============================================================================
  2819.  
  2820. Símbolos:
  2821.  
  2822. [x]|[abc] : Um único caractér de: a, b ou c
  2823. [^x]|[^abc] : Qualquer caractér exceto: a, b, ou c
  2824. [a-z] : Um único caractér no intervalo de a...z
  2825. [a-zA-Z] : Um único caractér no intervalo de a...z ou A...Z
  2826. ^ : Começo da linha.
  2827. $ : Fim da linha.
  2828. \A : Começo da string.
  2829. \z : Fim da string.
  2830. . : Um único caractér
  2831. \s : Qualquer carácter com espaço
  2832. \S : Qualquer carácter sem espaço
  2833. \d : Qualquer dígito
  2834. \D : Qualquer um que não seja um dígito
  2835. \w : Qualquer palavra
  2836. \W : Qualquer um que não seja uma palavra.
  2837. \b : Qualquer limite de palavra.
  2838. (...) : Capturar tudo fechado.
  2839. (x|y)|(a|b) : A(X) ou B(Y)
  2840. x? : Zero ou um de x.
  2841. x* : Zero ou mais de x.
  2842. x+ : Um ou mais de x.
  2843. x{3} : Exatamente 3 de x.
  2844. x{3,} : Exatamente 3 ou mais de um de x.
  2845. x{3,6} : Entre 3 e 6 de x.
  2846.  
  2847. Opções:
  2848.  
  2849. /i : Sem case sensitive
  2850. /m : Para mais de uma linha
  2851. /x : Ingnorar espaços brancos
  2852. /o : Executar o #{...}, alterações apenas uma vez.
Add Comment
Please, Sign In to add comment