Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # • Dax Core
- #==============================================================================
- # Autor: Dax
- # Versão: 2.5
- # Site: www.dax-soft.weebly.com
- # Requerimento: N/A
- #==============================================================================
- # • Descrição:
- #------------------------------------------------------------------------------
- # Adiciona alguns requesitos necessarios para executar alguns script Dax.
- #==============================================================================
- # • Versões:
- #------------------------------------------------------------------------------
- # 1.0 :
- # - ColorBasic : Módulo com informação de algumas cores.
- # - API : Módulo com informação de algumas APIs.
- # - Input : Módulo que permite você utilizar as várias teclas do teclado.
- # - Zone : Calcular a zona de um objeto no outro.
- # - Bitmap : Add-ons para está classe.
- # - Mouse : Sistema do mouse.
- # - Sprite_Picture : Correção de falhas.
- # - Window_Base : Correção de falhas.
- # - Game_Event : Add-ons para está classe.
- # - String : Add-ons para está clasee.
- # 1.1 :
- # - Bitmap : Add-ons para está classe.
- # - Sprite : Add-ons para está classe.
- # - String : Add-ons para está classe.
- # - Integer : Add-ons para está classe.
- # 1.2 :
- # - ColorBasic : Modificação e add-ons.
- # - Sprite : Add-ons...
- # - Bitmap : Modificações..
- # - Mouse : Modificação..
- # - Game_Event : Modificação..Add-ons.
- # 1.3 :
- # - MessageBox : Sistema da caixa de mensage...
- # - API : Add-ons...
- # - ScreenWindow : Sistema que permite redimensionar a tela do jogo.
- # - Game_Event : Modificações...
- # 1.4 :
- # - Sprite : Add-ons..
- # - Input : Módulo do Raizen884
- # - Download : Sistema que permite baixar coisas da net.
- # 1.5 :
- # - Sprite : Add-ons...
- # - Game_Event : Add-ons...
- # - API : Add-ons
- # 1.6 :
- # - Variable : Módulo para guardar informações de variávels.
- # - Switche : Módulo para guardar informações das switches.
- # - Game_Event : Add-ons..
- # 1.7 :
- # - Dax : Add-ons.
- # - Object : Add-ons.
- # 1.8 :
- # - ColorBasic : Novo método.
- # - Object : Add-ons.
- # 1.9 :
- # - API : Add-ons.
- # - Object : Add-ons.
- # - Window Core : Criado | 1.0
- # - Window Core : Criado.
- # - LetterInput : Criado.
- # - Position and Size : Criado.
- # - Psych : | 0.1
- # - Psych Core: Criado.
- # - LimitScreen : Criado.
- # 2.0 :
- # - API : Add-ons.
- # - Mouse : Add-ons.
- # - Drag : Modificado.
- # - Sprite : Add-ons.
- # - Key : Novo módulo de usar todas as teclas do teclado.
- # - Class Games : Add-ons e modificações :
- # - Game_CommonEvent
- # - Window Core : Modificado é atualizado | 1.2
- # - Letter_Input : Modificado.
- # - Object : Modificado.
- # - Psych : Atualizado | 0.2
- # - Path : Criado.
- # - DRGSS | Criado | 0.1
- # - Extension : Criado | 1.0
- # - Mouse : Extensão para o mouse.
- # - Touch_Picture | Criado.
- # - Simple_Touch_Picture | Criado.
- # - Touch_Icon | Criado.
- # - Simple_Touch_Icon | Criado.
- # 2.1 :
- # - MessageBox : Removida.
- # - Extension : Atualizado | 1.1
- # - Touch_Text : Criado.
- # - Simple_Touch_Text : Criado.
- # 2.5 :
- # - API : Add-ons.
- # - Color : Add-ons.
- # - ColorBasic : Add-ons;
- # - Window Core : Atualizado | 1.3
- # - DesignMenu : Criado.
- # - SampleMenuStrip | Criado
- # - MenuStrip : Criado.
- # - Exension >> Mouse | Add-ons.
- #==============================================================================
- module Dax
- extend self
- #----------------------------------------------------------------------------
- # • Font
- # Ajuste aqui as configurações básicas da fonte padrão do jogo.
- #----------------------------------------------------------------------------
- Font.default_name = ["VL Gothic"] # Nome padrão da fonte do jogo.
- Font.default_size = 18 # Tamanho padrão da fonte do jogo.
- Font.default_bold = false # true - Para usar negrito | false - para não usar.
- Font.default_italic = false # true - Para usar italico | false - para não usar.
- Font.default_shadow = false # true - Para usar sombra na fonte | false - para não usar.
- Font.default_outline = true # true - Para usar borda da fonte | false - para não usar.
- Font.default_out_color = Color.new(0, 0, 0) # Cor da fonte padrão da borda da fonte.
- Font.default_color = Color.new(255, 255, 255) # Cor da fonte padrão.
- #----------------------------------------------------------------------------
- # • Variável e constantes.
- #----------------------------------------------------------------------------
- @imported = {} # Importar script.
- @version_imported = {} # Versão do script importado.
- @actor_imported = {} # Autor do script importado.
- Core = true # Chave do módulo.
- Version_PS = 0.2 # Versão do Psych.
- Version_WC = 1.2 # Versão do Window Core.
- Version_EX = 1.1 # Versão do Extension.
- #----------------------------------------------------------------------------
- # • Mouse
- # Configure aqui, algumas coisas do mouse.
- #----------------------------------------------------------------------------
- # Caso você queira, que não aparece nenhuma imagem ou ícone, representando o
- # cursor do mouse, apenas deixe vázio as áspas. Caso você queira uma imagem,
- # representando o mouse, ponha entre as áspas o nome da imagem, que deve de estar
- # na pasta de Pictures. Caso você queira que um ícone represente o cursor do mouse
- # ponha o ID do ícone no lugar das áspas.
- Mouse_Name = ""
- #----------------------------------------------------------------------------
- # • Registrar script.
- #----------------------------------------------------------------------------
- def register(name, actor="Dax", version=2.5)
- @imported[name] = true
- @version_imported[name] = version
- @actor_imported[name] = actor
- end
- #----------------------------------------------------------------------------
- # • Cria uma condição de requerimento de script.
- #----------------------------------------------------------------------------
- def required(name, actor="Dax", version=2.5)
- @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
- end
- #----------------------------------------------------------------------------
- # • Remover um script existente.
- #----------------------------------------------------------------------------
- def remove(name_symbol)
- Object.send(:remove_const, name_symbol)
- end
- register(:Core)
- end
- #==============================================================================
- # • API
- #==============================================================================
- Dax.register(:API, 'Dax', 1.0)
- module API
- extend self
- #----------------------------------------------------------------------------
- # • Constantes de APIs.
- #----------------------------------------------------------------------------
- # Permite acessar as teclas do teclado.
- GetKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
- # Permite ativar/desativar o ícone do mouse.
- MouseShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
- # Permite achar a posição do mouse.
- CursorPosition = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
- # Permite achar o tamanho da screen.
- ScreenToClient = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
- # Permite fazer a leitura do game.ini.
- ReadIni = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
- # Permite achar o tamando da window.
- FindWindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
- # API da Message Box.
- MessageBoxA = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i')
- # Recupera uma string especificada de um arquivo em inicialização.
- GetPrivateProfileString = Win32API.new('kernel32', 'GetPrivateProfileStringA',%w(p p p p l p),'l')
- # Get Systeme Metrics
- GetSystemMetrics = Win32API.new("user32", "GetSystemMetrics", "i", "i")
- #Set Windows Pos
- SetWindowPos = Win32API.new("user32", "SetWindowPos", "lliiiii", "i")
- #Get Windows Rect
- GetWindowRect = Win32API.new('user32','GetWindowRect',%w(l p),'i')
- # Define a Win32API do comando print
- MessageBoxW = Win32API.new("user32", "MessageBoxW", "LPPL", "L")
- # Caps Lock
- CapsLock = Win32API.new("user32", "GetKeyState", "i", "i").call(20) != 0
- # State Key
- StateKey = Win32API.new("user32", "GetKeyState", ["i"], "i")
- # SetCursorPos
- SetCursorPos = Win32API.new("user32", "SetCursorPos", "ll", "i")
- SetCursorPos = Win32API.new("user32", "SetCursorPos", "ii", "i")
- GetKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
- GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
- # Criar uma nova pasta.
- CreateDirectory = Win32API.new("kernel32", "CreateDirectory", "p", "lll")
- # Remover uma pasta existente.
- RemoveDirectory = Win32API.new("kernel32", "RemoveDirectory", "p", "l")
- #----------------------------------------------------------------------------
- # • createDirectory(name)
- # name : Nome.
- # Função de criar uma nova pasta...
- #----------------------------------------------------------------------------
- def createDirectory(name)
- CreateDirectory.call(name.to_s)
- end
- #----------------------------------------------------------------------------
- # • removeDirectory(name)
- # name : Nome.
- # Função de remover uma pasta existente.
- #----------------------------------------------------------------------------
- def removeDirectory(name)
- RemoveDirectory.call(name.to_s)
- end
- end
- #==============================================================================
- # • Color
- #==============================================================================
- Dax.register(:Color, "Dax", 0.5)
- class Color
- #----------------------------------------------------------------------------
- # • Efeito de cor opaca.
- #----------------------------------------------------------------------------
- def opacity
- self.set(self.red, self.green, self.blue, 128)
- end
- #----------------------------------------------------------------------------
- # • Inverter as cores.
- #----------------------------------------------------------------------------
- def invert
- self.set(255-self.red, 255-self.green, 255-self.blue, self.alpha)
- end
- #----------------------------------------------------------------------------
- # • Reverter as cores.
- #----------------------------------------------------------------------------
- def revert
- colors = [self.red, self.green, self.blue, self.alpha].reverse!
- self.set(*colors)
- end
- end
- #==============================================================================
- # • Keyboard | Método para usar todas as teclas do teclado.
- #==============================================================================
- Dax.register(:Key, "Dax", 1.0)
- module Key
- extend self
- #--------------------------------------------------------------------------
- # * Chaves diversos.
- #--------------------------------------------------------------------------
- CANCEL = 0x03 # Control-Break Processing
- BACKSPACE = 0x08 # Backspace Key
- TAB = 0x09 # Tab Key
- CLEAR = 0x0C # Clear Key
- RETURN = 0x0D # Enter Key
- SHIFT = 0x10 # Shift Key
- CONTROL = 0x11 # Ctrl Key
- MENU = 0x12 # Alt Key
- PAUSE = 0x13 # Pause Key
- ESCAPE = 0x1B # Esc Key
- CONVERT = 0x1C # IME Convert Key
- NONCONVERT = 0x1D # IME Nonconvert Key
- ACCEPT = 0x1E # IME Accept Key
- SPACE = 0x20 # Space Bar Key (Space, usually blank)
- PRIOR = 0x21 # Page Up Key
- NEXT = 0x22 # Page Down Key
- ENDS = 0x23 # End Key
- HOME = 0x24 # Home Key
- LEFT = 0x25 # Left Arrow Key
- UP = 0x26 # Up Arrow Key
- RIGHT = 0x27 # Right Arrow Key
- DOWN = 0x28 # Down Arrow Key
- SELECT = 0x29 # Select Key
- PRINT = 0x2A # Print Key
- EXECUTE = 0x2B # Execute Key
- SNAPSHOT = 0x2C # Print Screen Key
- DELETE = 0x2E # Delete Key
- HELP = 0x2F # Help Key
- LSHIFT = 0xA0 # Left Shift Key
- RSHIFT = 0xA1 # Right Shift Key
- LCONTROL = 0xA2 # Left Control Key (Ctrl)
- RCONTROL = 0xA3 # Right Control Key (Ctrl)
- LMENU = 0xA4 # Left Menu Key (Alt)
- RMENU = 0xA5 # Right Menu Key (Alt)
- PACKET = 0xE7 # Used to Pass Unicode Characters as Keystrokes
- MOUSE_RIGHT = 0x01 # Button Mouse Right
- MOUSE_LEFT = 0x02 # Button Mouse Left
- MOUSE_MIDDLE = 0x04 # Button Mouse Middle
- #--------------------------------------------------------------------------
- # * Chaves de números.
- #--------------------------------------------------------------------------
- N0 = 0x30 # 0 Key
- N1 = 0x31 # 1 Key
- N2 = 0x32 # 2 Key
- N3 = 0x33 # 3 Key
- N4 = 0x34 # 4 Key
- N5 = 0x35 # 5 Key
- N6 = 0x36 # 6 Key
- N7 = 0x37 # 7 Key
- N8 = 0x38 # 8 Key
- N9 = 0x39 # 9 Key
- #--------------------------------------------------------------------------
- # * Chaves de letras
- #--------------------------------------------------------------------------
- A = 0x41 # A Key
- B = 0x42 # B Key
- C = 0x43 # C Key
- D = 0x44 # D Key
- E = 0x45 # E Key
- F = 0x46 # F Key
- G = 0x47 # G Key
- H = 0x48 # H Key
- I = 0x49 # I Key
- J = 0x4A # J Key
- K = 0x4B # K Key
- L = 0x4C # L Key
- M = 0x4D # M Key
- N = 0x4E # N Key
- O = 0x4F # O Key
- P = 0x50 # P Key
- Q = 0x51 # Q Key
- R = 0x52 # R Key
- S = 0x53 # S Key
- T = 0x54 # T Key
- U = 0x55 # U Key
- V = 0x56 # V Key
- W = 0x57 # W Key
- X = 0x58 # X Key
- Y = 0x59 # Y Key
- Z = 0x5A # Z Key
- #--------------------------------------------------------------------------
- # * Chaves de windows
- #--------------------------------------------------------------------------
- LWIN = 0x5B # Left Windows Key (Natural keyboard)
- RWIN = 0x5C # Right Windows Key (Natural Keyboard)
- APPS = 0x5D # Applications Key (Natural keyboard)
- SLEEP = 0x5F # Computer Sleep Key
- BROWSER_BACK = 0xA6 # Browser Back Key
- BROWSER_FORWARD = 0xA7 # Browser Forward Key
- BROWSER_REFRESH = 0xA8 # Browser Refresh Key
- BROWSER_STOP = 0xA9 # Browser Stop Key
- BROWSER_SEARCH = 0xAA # Browser Search Key
- BROWSER_FAVORITES = 0xAB # Browser Favorites Key
- BROWSER_HOME = 0xAC # Browser Start and Home Key
- VOLUME_MUTE = 0xAD # Volume Mute Key
- VOLUME_DOWN = 0xAE # Volume Down Key
- VOLUME_UP = 0xAF # Volume Up Key
- MEDIA_NEXT_TRACK = 0xB0 # Next Track Key
- MEDIA_PREV_TRACK = 0xB1 # Previous Track Key
- MEDIA_STOP = 0xB2 # Stop Media Key
- MEDIA_PLAY_PAUSE = 0xB3 # Play/Pause Media Key
- LAUNCH_MAIL = 0xB4 # Start Mail Key
- LAUNCH_MEDIA_SELECT = 0xB5 # Select Media Key
- LAUNCH_APP1 = 0xB6 # Start Application 1 Key
- LAUNCH_APP2 = 0xB7 # Start Application 2 Key
- PROCESSKEY = 0xE5 # IME Process Key
- ATTN = 0xF6 # Attn Key
- CRSEL = 0xF7 # CrSel Key
- EXSEL = 0xF8 # ExSel Key
- EREOF = 0xF9 # Erase EOF Key
- PLAY = 0xFA # Play Key
- ZOOM = 0xFB # Zoom Key
- PA1 = 0xFD # PA1 Key
- #--------------------------------------------------------------------------
- # * Chaves do Numpad
- #--------------------------------------------------------------------------
- NUMPAD0 = 0x60 # Numeric Keypad 0 Key
- NUMPAD1 = 0x61 # Numeric Keypad 1 Key
- NUMPAD2 = 0x62 # Numeric Keypad 2 Key
- NUMPAD3 = 0x63 # Numeric Keypad 3 Key
- NUMPAD4 = 0x64 # Numeric Keypad 4 Key
- NUMPAD5 = 0x65 # Numeric Keypad 5 Key
- NUMPAD6 = 0x66 # Numeric Keypad 6 Key
- NUMPAD7 = 0x67 # Numeric Keypad 7 Key
- NUMPAD8 = 0x68 # Numeric Keypad 8 Key
- NUMPAD9 = 0x69 # Numeric Keypad 9 Key
- MULTIPLY = 0x6A # Multiply Key (*)
- ADD = 0x6B # Add Key (+)
- SEPARATOR = 0x6C # Separator Key
- SUBTRACT = 0x6D # Subtract Key (-)
- DECIMAL = 0x6E # Decimal Key (.)
- DIVIDE = 0x6F # Divide Key (/)
- #--------------------------------------------------------------------------
- # * Chaves de funções
- #--------------------------------------------------------------------------
- F1 = 0x70 # F1 Key
- F2 = 0x71 # F2 Key
- F3 = 0x72 # F3 Key
- F4 = 0x73 # F4 Key
- F5 = 0x74 # F5 Key
- F6 = 0x75 # F6 Key
- F7 = 0x76 # F7 Key
- F8 = 0x77 # F8 Key
- F9 = 0x78 # F9 Key
- F10 = 0x79 # F10 Key
- F11 = 0x7A # F11 Key
- F12 = 0x7B # F12 Key
- F13 = 0x7C # F13 Key
- F14 = 0x7D # F14 Key
- F15 = 0x7E # F15 Key
- F16 = 0x7F # F16 Key
- F17 = 0x80 # F17 Key
- F18 = 0x81 # F18 Key
- F19 = 0x82 # F19 Key
- F20 = 0x83 # F20 Key
- F21 = 0x84 # F21 Key
- F22 = 0x85 # F22 Key
- F23 = 0x86 # F23 Key
- F24 = 0x87 # F24 Key
- #--------------------------------------------------------------------------
- # * Chaves alternativas
- #--------------------------------------------------------------------------
- CAPITAL = 0x14 # Caps Lock Key
- KANA = 0x15 # IME Kana Mode Key
- HANGUL = 0x15 # IME Hangul Mode Key
- JUNJA = 0x17 # IME Junja Mode Key
- FINAL = 0x18 # IME Final Mode Key
- HANJA = 0x19 # IME Hanja Mode Key
- KANJI = 0x19 # IME Kanji Mode Key
- MODECHANGE = 0x1F # IME Mode Change Request Key
- INSERT = 0x2D # Insert Key
- NUMLOCK = 0x90 # Num Lock Key
- SCROLL = 0x91 # Scroll Lock Key
- #--------------------------------------------------------------------------
- # * Chaves OEM, variadas
- #--------------------------------------------------------------------------
- OEM_1 = 0xBA # Misc Characters (; : in USA 101/102 Keyboards)
- OEM_PLUS = 0xBB # + = Key
- OEM_COMMA = 0xBC # , < Key
- OEM_MINUS = 0xBD # - _ Key
- OEM_PERIOD = 0xBE # . > Key
- OEM_2 = 0xBF # Misc Characters (/ ? in USA 101/102 Keyboards)
- OEM_3 = 0xC0 # Misc Characters (` ~ in USA 101/102 Keyboards)
- OEM_4 = 0xDB # Misc Characters ([ { in USA 101/102 Keyboards)
- OEM_5 = 0xDC # Misc Characters (\ | in USA 101/102 Keyboards)
- OEM_6 = 0xDD # Misc Characters (] } in USA 101/102 Keyboards)
- OEM_7 = 0xDE # Misc Characters (' " in USA 101/102 Keyboards)
- OEM_8 = 0xDF # Misc Characters (Varies by Keyboard)
- OEM_9 = 0xE1 # OEM Specific
- OEM_10 = 0x92 # OEM Specific
- OEM_11 = 0x93 # OEM Specific
- OEM_12 = 0x94 # OEM Specific
- OEM_13 = 0x95 # OEM Specific
- OEM_14 = 0x96 # OEM Specific
- OEM_15 = 0xE3 # OEM Specific
- OEM_16 = 0xE4 # OEM Specific
- OEM_17 = 0xE6 # OEM Specific
- OEM_18 = 0xE9 # OEM Specific
- OEM_19 = 0xEA # OEM Specific
- OEM_20 = 0xEB # OEM Specific
- OEM_21 = 0xEC # OEM Specific
- OEM_22 = 0xED # OEM Specific
- OEM_23 = 0xEE # OEM Specific
- OEM_24 = 0xEF # OEM Specific
- OEM_25 = 0xF1 # OEM Specific
- OEM_26 = 0xF2 # OEM Specific
- OEM_27 = 0xF3 # OEM Specific
- OEM_28 = 0xF4 # OEM Specific
- OEM_29 = 0xF5 # OEM Specific
- OEM_102 = 0xE2 # Angle Bracket or Backslash on RT-102 Keyboards
- OEM_CLEAR = 0xFE # Clear Key
- #--------------------------------------------------------------------------
- # * Variáveis do módulo.
- #--------------------------------------------------------------------------
- @unpack_string = 'b'*256
- @last_array = '0'*256
- @press = Array.new(256, false)
- @trigger = Array.new(256, false)
- @repeat = Array.new(256, false)
- @release = Array.new(256, false)
- @repeat_counter = Array.new(256, 0)
- @getKeyboardState = API::GetKeyboardState
- @getAsyncKeyState = API::GetAsyncKeyState
- @getKeyboardState.call(@last_array)
- @last_array = @last_array.unpack(@unpack_string)
- for i in 0...@last_array.size
- @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
- end
- #--------------------------------------------------------------------------
- # * Atualização dos objetos do módulo.
- #--------------------------------------------------------------------------
- def self.update
- @trigger = Array.new(256, false)
- @repeat = Array.new(256, false)
- @release = Array.new(256, false)
- array = '0'*256
- @getKeyboardState.call(array)
- array = array.unpack(@unpack_string)
- for i in 0...array.size
- if array[i] != @last_array[i]
- @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
- if @repeat_counter[i] <= 0 && @press[i]
- @repeat[i] = true
- @repeat_counter[i] = 15
- end
- if !@press[i]
- @release[i] = true
- else
- @trigger[i] = true
- end
- else
- if @press[i] == true
- @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
- @release[i] = true if !@press[i]
- end
- if @repeat_counter[i] > 0 && @press[i] == true
- @repeat_counter[i] -= 1
- elsif @repeat_counter[i] <= 0 && @press[i] == true
- @repeat[i] = true
- @repeat_counter[i] = 3
- elsif @repeat_counter[i] != 0
- @repeat_counter[i] = 0
- end
- end
- end
- @last_array = array
- end
- #--------------------------------------------------------------------------
- # * Get Key Pressed State
- # key : key index
- #--------------------------------------------------------------------------
- def press?(key)
- return @press[key]
- end
- #--------------------------------------------------------------------------
- # * Get Key Triggered State
- # key : key index
- #--------------------------------------------------------------------------
- def trigger?(key)
- return @trigger[key]
- end
- #--------------------------------------------------------------------------
- # * Get Key Repeated State
- # key : key index
- #--------------------------------------------------------------------------
- def repeat?(key)
- return @repeat[key]
- end
- #--------------------------------------------------------------------------
- # * Get Key Released State
- # key : key index
- #--------------------------------------------------------------------------
- def release?(key)
- return @release[key]
- end
- end
- #==============================================================================
- # • Input | Atualização do Key
- #==============================================================================
- class << Input
- alias key_update update
- def update
- key_update
- Key.update
- end
- end
- #============================================================================
- # • Zone
- #============================================================================
- Dax.register(:Zone, "Dax", 1.3)
- module Zone
- extend self
- #--------------------------------------------------------------------------
- # • Verifica se um objeto está na área. Normal | Rect
- #--------------------------------------------------------------------------
- def rect(object, object2)
- object.x >= object2.x && object.x <= object2.bitmap.width && object.y >= object2.y && object.y <= object2.bitmap.height
- end
- #--------------------------------------------------------------------------
- # • Verifica se um objeto está na área. Círculo | Circle
- #--------------------------------------------------------------------------
- def circle(o, o2, size)
- ( (o.x - o2.x) ** 2) + ( (o.y - o2.y) ** 2) <= (size ** 2)
- end
- #--------------------------------------------------------------------------
- # • Verifica se um objeto está na área. Eclipse | Eclipse
- #--------------------------------------------------------------------------
- def eclipse(o, o2)
- rate_x = ((o.x.to_f - o2.x.to_f) ** 2.0 / (o2.src_rect.width / 2.0))
- rate_y = ((o.y.to_f - o2.y.to_f) ** 2.0 / (o2.src_rect.height / 2.0))
- rate_x + rate_y <= 1
- end
- #----------------------------------------------------------------------------
- # • object_in_area?(object, x, y, width, height)
- # object : Objeto.
- # x : Coordenadas X.
- # y : Coordenadas Y.
- # width : Largura.
- # heigt : Altura.
- #----------------------------------------------------------------------------
- # Verifica se algum objeto está na área do object.
- #----------------------------------------------------------------------------
- def object_in_area?(object, x, y, width, height)
- return object.x.between?(x, x + width) && object.y.between?(y, y + height)
- end
- #--------------------------------------------------------------------------
- # • Verifica se um objeto está na área. All | All
- #--------------------------------------------------------------------------
- def full(object, object2, size=0)
- return rect(object, object2) || circle(object, object2, size) || eclipse(object, object2)
- end
- end
- #==============================================================================
- # • Sprite
- #==============================================================================
- Dax.register(:Sprite, "Dax", 0.2)
- class Sprite
- #----------------------------------------------------------------------------
- # • Define aqui uma posição fixa para um objeto.
- #----------------------------------------------------------------------------
- def position(command=0)
- return if command.nil?
- case command
- when 0 then self.x = 0
- when 1 then self.x = Graphics.width / 2 - self.width / 2
- when 2 then self.x = Graphics.width - self.width
- when 3 then self.y = 0
- when 4 then self.y = Graphics.height / 2 - self.height / 2
- when 5 then self.y = Graphics.height - self.height
- when :center
- self.x = Graphics.width / 2 - self.width / 2
- self.y = Graphics.height / 2 - self.height / 2
- when :center_left
- self.x = 0 + add_x
- self.y = Graphics.height / 2 - self.height / 2
- when :center_right
- self.x = Graphics.width - self.height
- self.y = Graphics.height / 2 - self.height / 2
- end
- end
- #----------------------------------------------------------------------------
- # • Se esta no alcance?
- #----------------------------------------------------------------------------
- def range?(pos, margin=0)
- rect = self.src_rect
- if pos.x >= rect.x + margin and pos.y >= rect.y + margin and
- pos.x < rect.x + rect.width - margin and
- pos.y < rect.y + rect.height - margin
- return true
- end
- return false
- end
- #----------------------------------------------------------------------------
- # • Se esta no alcance X?
- #----------------------------------------------------------------------------
- def range_x?(pos, margin=0)
- rect = self.src_rect
- if pos.x >= rect.x + margin and
- pos.x < rect.x + rect.width - margin
- return true
- end
- return false
- end
- #----------------------------------------------------------------------------
- # • Se esta no alcance Y?
- #----------------------------------------------------------------------------
- def range_y?(pos, margin=0)
- rect = self.src_rect
- if pos.y >= rect.y + margin and
- pos.y < rect.y + rect.height - margin
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # • Se esta no alcance na borda?
- #--------------------------------------------------------------------------
- def range_border?(pos, bs)
- rect = self.rect(true)
- arect = self.src_rect
- dx = (rect.x - arect.x).abs == 0
- dy = (rect.y - arect.y).abs == 0
- dw = (rect.width - arect.width).abs == 0
- dh = (rect.height - arect.height).abs == 0
- sx = (!dx and pos.x < arect.x)
- sy = (!dy and pos.y < arect.y)
- sw = (!dw and pos.x > arect.x + arect.width)
- sh = (!dh and pos.y > arect.y + arect.height)
- if sx or sy or sw or sh
- return
- end
- border_x = (((pos.x >= (rect.x - bs)) and (pos.x < (rect.x + bs))) or
- ((pos.x >= (rect.x + rect.width - bs)) and (pos.x < (rect.x + rect.width + bs))))
- border_y = (((pos.y >= (rect.y - bs)) and (pos.y < (rect.y + bs))) or
- ((pos.y >= (rect.y + rect.height - bs)) and (pos.y < (rect.y + rect.height + bs))))
- in_x = ((pos.x >= (rect.x - bs)) and (pos.x < (rect.x + rect.width + bs)))
- in_y = ((pos.y >= (rect.y - bs)) and (pos.y < (rect.y + rect.height + bs)))
- if ((border_x and in_y) or (border_y and in_x)) and
- return true
- end
- return false
- end
- end
- #==============================================================================
- # • Bitmap
- #==============================================================================
- Dax.register(:Bitmap, "Dax", 1.2)
- class Bitmap
- #----------------------------------------------------------------------------
- # • draw_bar(x, y, current, current_max, file)
- # x : Coordenadas X.
- # y : Coordenadas Y.
- # current : Valor atual da barra.
- # current_max : Valor maxímo da barra.
- # file : Imagem da barra.
- #----------------------------------------------------------------------------
- # Permite adicionar uma barra.
- #----------------------------------------------------------------------------
- def draw_bar(x, y, current, current_max, file, folder=0)
- bitmap = folder == 0 ? Cache.picture(file) : Cache.system(file)
- cw = self.width * current / current_max
- ch = self.height
- src_rect = Rect.new(0, 0, cw, ch)
- self.blt(x, y, bitmap, src_rect)
- end
- #----------------------------------------------------------------------------
- # • draw_bar_gauge(x, y, current, current_max, border, colors)
- # x : Coordenadas X.
- # y : Coordenadas Y.
- # current : Valor atual da barra.
- # current_max : Valor maxímo da barra.
- # border : Expressura da borda.
- # colors : Cores. [0, 1, 2]
- #----------------------------------------------------------------------------
- # Permite adicionar uma barra.
- #----------------------------------------------------------------------------
- def draw_bar_gauge(x, y, current, current_max, border, colors=[])
- cw = self.width * current / current_max
- ch = self.height
- self._fill(x, y, self.width, self.height, colors[0], colors[0])
- self.gradient_fill_rect(x+border, y+border, self.width-(border/2), self.height-(border/2), colors[1], colors[2])
- src_rect = Rect.new(0, 0, cw, ch)
- self.blt(x, y, self, src_rect)
- end
- #----------------------------------------------------------------------------
- # • draw_icon(icon_index, x, y, enabled)
- # icon_index : ID do ícone.
- # x : Coordenadas X.
- # y : Coordenadas Y.
- # enabled : Habilitar flag, translucido quando false
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- def draw_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- self.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- end
- #----------------------------------------------------------------------------
- # • _fill(x, y, width, height, color1, color2)
- # x : Coordenada X.
- # y : Coordenada Y.
- # width : Largura da barra.
- # height : Altura da barra.
- # color1 : Cor da borda.
- # color2 : Cor da barra.
- #----------------------------------------------------------------------------
- # Permite criar uma barra em fill_rect simples.
- #----------------------------------------------------------------------------
- def _fill(x, y, width, height, color1, color2)
- self.fill_rect(x, y, width, height, color1)
- self.fill_rect(x+1, y+1, width-2, height-2, color2)
- end
- #----------------------------------------------------------------------------
- # • gradation_fill_rect(*args)
- # x : Posição X.
- # y : Posição Y.
- # width : Largura da barra.
- # height : Altura da barra.
- # color1 : Primeira cor.
- # color2 : Segunda cor.
- # aling : 0 - Gradiação normal, 1 - Gradiação na Vertical, 2 - Gradiação concetrada
- #----------------------------------------------------------------------------
- # Faz uma gradiação;
- #----------------------------------------------------------------------------
- def gradation_fill_rect(x, y, width, height, color1, color2, align=0)
- case align
- when 0
- for ix in x...x + width
- red = color1.red + (color2.red - color1.red) * (ix - x) / (width - 1)
- green = color1.green + (color2.green - color1.green) * (ix - x) / (width - 1)
- blue = color1.blue + (color2.blue - color1.blue) * (i - x) / (width - 1)
- alpha = color1.alpha + (color2.alpha - color1.alpha) * (i - x) / (width - 1)
- color = Color.new(red, green, blue, alpha)
- self.fill_rect(ix, y, 1, height, color)
- end
- when 1
- for iy in y...y + height
- red = color1.red + (color2.red - color1.red) * (iy - y) / (height - 1)
- green = color1.green + (color2.green - color1.green) * (iy - y) / (height - 1)
- blue = color1.blue + (color2.blue - color1.blue) * (iy - y) / (height - 1)
- alpha = color1.alpha + (color2.alpha - color1.alpha) * (iy - y) / (height - 1)
- color = Color.new(red, green, blue, alpha)
- fill_rect(x, iy, width, 1, color)
- end
- when 2
- for ix in x...x + width
- for ij in y...y + height
- red = color1.red + (color2.red - color1.red) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
- green = color1.green + (color2.green - color1.green) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
- blue = color1.blue + (color2.blue - color1.blue) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
- alpha = color1.alpha + (color2.alpha - color1.alpha) * ((ix - x) / (width - 1.0) + (ij - y) / (height - 1.0)) / 2
- color = Color.new(red, green, blue, alpha)
- set_pixel(ix, ij, color)
- end
- end
- end
- end
- #----------------------------------------------------------------------------
- # • draw_gradation_gauge(x, y, width, height, current, current_max, border, colors, align)
- # x : Coordenadas X.
- # y : Coordenadas Y.
- # width : Largura da barra.
- # height : Altura da barra.
- # current : Valor atual da barra.
- # current_max : Valor maxímo da barra.
- # border : Expressura da borda.
- # colors : Cores. [0, 1, 2]
- # align : Alinhamento.
- #----------------------------------------------------------------------------
- # Permite adicionar uma barra.
- #----------------------------------------------------------------------------
- def draw_gradation_gauge(x, y, current, current_max, border, colors=[], align=2)
- cw = self.width * current / current_max
- ch = self.height
- self._fill(x, y, self.width, self.height, colors[0], colors[0])
- self.gradation_fill_rect(x+border, y+border, self.width-(border/2), self.height-(border/2), colors[1], colors[2], align)
- src_rect = Rect.new(0, 0, cw, ch)
- self.blt(x, y, self, src_rect)
- end
- #--------------------------------------------------------------------------
- # • Desenho do gráfico de rosto
- # face_name : nome do gráfico de face
- # face_index : índice do gráfico de face
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- #--------------------------------------------------------------------------
- def draw_face(face_name, face_index, x, y, enabled = true)
- bitmaps = Cache.face(face_name)
- rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
- self.blt(x, y, bitmaps, rect, enabled ? 255 : translucent_alpha)
- end
- #--------------------------------------------------------------------------
- # • Desenho do gráfico de face do herói
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- #--------------------------------------------------------------------------
- def draw_actor_face(actor, x, y, enabled = true)
- draw_face(actor.face_name, actor.face_index, x, y, enabled)
- end
- #--------------------------------------------------------------------------
- # • Desenho do nível
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_actor_level(actor, x, y)
- self.font.name = "Comic Sans MS"
- self.font.color = ColorBasic.yellow
- self.font.size = 18
- self.draw_text(x, y, 32, 20, Vocab::level_a)
- self.font.size = 22
- draw_text(x + 16, y, 32, 20, actor.level, 2)
- end
- #----------------------------------------------------------------------------
- # • Pegar a largura.
- #----------------------------------------------------------------------------
- def get_the_width(lstring)
- string_rect = self.text_size(lstring)
- width = string_rect.width
- return width
- end
- #----------------------------------------------------------------------------
- # • Desenhar um círuclo.
- #----------------------------------------------------------------------------
- def fill_circle(x, y, r, c)
- rr = r*r
- for i in 0...r
- adj = Math.sqrt(rr - (i*i)).ceil
- xd = x - adj
- wd = 2 * adj
- self.fill_rect(xd, y-i, wd, 1, c)
- self.fill_rect(xd, y+i, wd, 1, c)
- end
- end
- end
- #==============================================================================
- # • Mouse
- #==============================================================================
- Dax.register(:Mouse, "Dax", 1.1)
- module Mouse
- extend self
- #--------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #--------------------------------------------------------------------------
- def start
- @cursor = Sprite.new
- @cursor.z = 100000
- x = Dax::Mouse_Name.empty? ? 1 : 0
- API::MouseShowCursor.call(x)
- graphic(Dax::Mouse_Name)
- update
- end
- #--------------------------------------------------------------------------
- # • graphic(graphic_set)
- # graphic_set : Se for número é um ícone; Se for string é uma imagem.
- #--------------------------------------------------------------------------
- def graphic(graphic_set)
- return if graphic_set.empty? or graphic_set.nil?
- if graphic_set.is_a?(Fixnum)
- @cursor.bitmap = Bitmap.new(24, 24)
- @cursor.bitmap.draw_icon(graphic_set.to_i, 0, 0)
- else
- @cursor.bitmap = Cache.picture(graphic_set.to_s)
- end
- end
- #--------------------------------------------------------------------------
- # • show(visible)
- # visible : True - para mostrar o mouse | False - para esconder o mouse.
- #--------------------------------------------------------------------------
- def show(visible=true)
- @cursor.visible = visible
- end
- #--------------------------------------------------------------------------
- # • update (Atualização das coordenadas)
- #--------------------------------------------------------------------------
- def update
- return if @cursor.nil?
- @cursor.x, @cursor.y = position
- end
- #--------------------------------------------------------------------------
- # • cursor
- #--------------------------------------------------------------------------
- def cursor
- @cursor
- end
- #--------------------------------------------------------------------------
- # • x (Coordenada X do Mouse)
- #--------------------------------------------------------------------------
- def x
- @cursor.x
- end
- #--------------------------------------------------------------------------
- # • y (Coordenada Y do Mouse)
- #--------------------------------------------------------------------------
- def y
- @cursor.y
- end
- #--------------------------------------------------------------------------
- # • position (Posição do Mouse!)
- #--------------------------------------------------------------------------
- def position
- x, y = get_client_position
- return x, y
- end
- #--------------------------------------------------------------------------
- # • get_client_position (Posição original do Mouse!)
- #--------------------------------------------------------------------------
- def get_client_position
- pos = [0, 0].pack('ll')
- API::CursorPosition.call(pos)
- API::ScreenToClient.call(WINDOW, pos)
- return pos.unpack('ll')
- end
- #--------------------------------------------------------------------------
- # • find_window (Tamanho da window)
- #--------------------------------------------------------------------------
- def find_window
- game_name = '\0' * 256
- API::ReadIni.call('Game', 'Title', '', game_name, 255, '.\\Game.ini')
- game_name.delete!('\0')
- return API::FindWindow.call('RGSS Player', game_name)
- end
- #--------------------------------------------------------------------------
- # • Verificação se o mouse está na área de um determinado objeto.
- #--------------------------------------------------------------------------
- def in_area?(object_sprite)
- return @cursor.x.between?(object_sprite.x, object_sprite.x + object_sprite.width) &&
- @cursor.y.between?(object_sprite.y, object_sprite.y + object_sprite.height)
- end
- #--------------------------------------------------------------------------
- # • Verificação um objeto está na área do mouse.
- #--------------------------------------------------------------------------
- def object_area?(x, y, xy, yx)
- return Zone.object_in_area?(@cursor, x, y, xy, yx)
- end
- #----------------------------------------------------------------------------
- # • Mudar posição do cursor.
- #----------------------------------------------------------------------------
- def set_mouse(pos)
- SetCursorPos.call(pos.x, pos.y)
- update
- @cursor.x = @pos.x
- @cursor.y = @pos.y
- end
- #--------------------------------------------------------------------------
- # • Verificando se o mouse está na zona de um determinado objeto.
- #--------------------------------------------------------------------------
- def in_zone?(object, circled=0)
- Zone.full(self, object, circled)
- end
- WINDOW = find_window
- end
- class << DataManager
- alias init_mouse init
- def init
- Mouse.start
- init_mouse
- end
- end
- class << Input
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- alias ds_core_engine_update update
- def update
- ds_core_engine_update
- Mouse.update
- end
- end
- #==============================================================================
- # • Sprite_Picture
- #==============================================================================
- Dax.register(:Sprite_Picture, "Dax", 1.0)
- class Sprite_Picture
- #--------------------------------------------------------------------------
- # • Atualização da tela
- #--------------------------------------------------------------------------
- def update
- super
- [update_bitmap, update_origin, update_position, update_zoom, update_other].each { |i|
- if @picture.name != ""
- i
- else
- self.bitmap.dispose unless self.bitmap.nil?
- end
- }
- end
- end
- #==============================================================================
- # • Window_Base
- #==============================================================================
- Dax.register(:Window_Base, "Dax", 1.0)
- class Window_Base < Window
- #----------------------------------------------------------------------------
- # • Fixa o lag, gerado pela draw_face.
- #----------------------------------------------------------------------------
- def draw_face(face_name, face_index, x, y, enabled = true)
- bitmap = Cache.face(face_name)
- rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
- contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- end
- end
- #==============================================================================
- # • Game_Event
- #==============================================================================
- Dax.register(:Game_Event, "Dax", 1.3)
- class Game_Event < Game_Character
- #----------------------------------------------------------------------------
- # • check_comment(comment)
- # comment : Comentário.
- #----------------------------------------------------------------------------
- # Permite checar o comentário.
- #----------------------------------------------------------------------------
- def check_comment(comment, command=:integer)
- for item in @list
- if item.code == 108 or item.code == 408
- case command
- when :include?
- if item.parameters[0].include?(comment)
- return true
- else
- return false
- end
- when :integer
- if item.parameters[0] =~ /#{comment} (\d+)/
- return $1.to_i
- end
- return 0
- when :string
- if item.parameters[0] =~ /#{comment} ([^>]*)/
- return $1
- end
- return ""
- when :word
- if item.parameters[0] =~ /#{comment} (\w+)/
- return $1.nil? ? "" : $1.to_s
- end
- end
- end
- end
- end
- #----------------------------------------------------------------------------
- # • check_name(comment)
- #----------------------------------------------------------------------------
- def check_name(comment, command)
- case command
- when :include?
- if event.name.include?(comment)
- return true
- end
- return false
- when :integer
- if event.name =~ /#{comment} (\d+)/
- return $1.to_i
- end
- when :word
- if event.name =~ /#{comment} (\w+))/
- return $1.to_s
- end
- end
- end
- end
- #==============================================================================
- # • String
- #==============================================================================
- Dax.register(:String, "Dax", 1.0)
- class String
- #--------------------------------------------------------------------------
- # • Quebra de linha
- #--------------------------------------------------------------------------
- def n
- expanded = []
- self.each_line do |line|
- line.gsub!(/^(.{8}*?)([^\t\r\n]{0,7})\t/) do
- "#{$1}#{$2}#{' ' * (8 - $2.size)}"
- end until line !~ /\t/
- expanded << line
- end
- expanded.join
- end
- #----------------------------------------------------------------------------
- # • Transformar em Integer.
- #----------------------------------------------------------------------------
- def i
- return self.to_i(36)
- end
- end
- #==============================================================================
- # • Integer
- #==============================================================================
- Dax.register(:Integer, "Dax", 0.1)
- class Integer
- #----------------------------------------------------------------------------
- # • Transformar em String.
- #----------------------------------------------------------------------------
- def s
- return self.to_s(36)
- end
- end
- #==============================================================================
- # • Download Module;
- #==============================================================================
- Dax.register(:Download, "Dax & Berka", 1.0)
- module Download
- #--------------------------------------------------------------------------
- # » Mensagens de erros.
- #--------------------------------------------------------------------------
- module DowError
- ConIn = "Não foi possível se conectar á Internet."
- ConFtp = "Não foi possível se conectar ao FTP."
- DownFtp = "Download ftp falhou."
- NoFFtpEx = "O arquivo de download não existe."
- Mkdir = "Não é possível criar um novo diretório."
- NoFile = "Não existe o arquivo."
- ConHttp = "Não foi possível conectar ao servidor."
- end
- #--------------------------------------------------------------------------
- # » Net(Principal¹)
- #--------------------------------------------------------------------------
- module Net
- W = 'wininet'
- SPC = Win32API.new('kernel32', 'SetPriorityClass', 'pi', 'i').call(-1, 128)
- IOA = Win32API.new(W, 'InternetOpenA', 'plppl', 'i').call('',0,'','',0)
- IC = Win32API.new(W, 'InternetConnectA', 'lplpplll', 'l')
- msgbox(DowError::ConIn) if IOA == 0
- #--------------------------------------------------------------------------
- # » FTP
- #--------------------------------------------------------------------------
- module FTP
- FSCD = Win32API.new(W, 'FtpSetCurrentDirectoryA', 'lp', 'l')
- FGF = Win32API.new(W,'FtpGetFileA','lppllll','l')
- FPF = Win32API.new(W,'FtpPutFile','lppll','l')
- FCD = Win32API.new(W,'FtpCreateDirectoryA','lp','l')
- #------------------------------------------------------------------------
- # » Executa a etapa principal
- #------------------------------------------------------------------------
- def self.new
- ftp = "ftp.server.com"
- port = 21
- indentifiant = "user"
- motdepasse = "password"
- @fb = IC.call(IOA,ftp,port,identifiant,motdepasse,1,0,0)
- ftp, port, identifiant, motdepasse = [nil] * 4
- (msgbox(DowError::ConFtp)) if @fb == 0
- end
- #------------------------------------------------------------------------
- # » Download
- #------------------------------------------------------------------------
- def self.download(ext, int = './')
- self.new if @fb.nil?
- c = ext.split('/').pop
- if FSCD.call(@fb,ext)&&File.exist?(int)
- msgbox(DowError::NoFFtpEx)if FPF.call(@fb,int,ext,2,0)==0
- else
- msgbox(DowError::NoFFtpEx)
- end
- end
- #------------------------------------------------------------------------
- # » Diretório
- #------------------------------------------------------------------------
- def self.mkdir(rep)
- self.new if @fb.nil?
- msgbox(DowError::Mkdir) if FCD.call(@fb, rep) == 0
- end
- end
- #--------------------------------------------------------------------------
- # » HTTP
- #--------------------------------------------------------------------------
- module HTTP
- IOU = Win32API.new(W, 'InternetOpenUrl', 'lppllp', 'l')
- IRF = Win32API.new(W, 'InternetReadFile', 'lpip', 'l')
- ICH = Win32API.new(W, 'InternetCloseHandle', 'l', 'l')
- HQI = Win32API.new(W, 'HttpQueryInfo', 'llppp', 'i')
- #------------------------------------------------------------------------
- # » Tamanho do load.
- #------------------------------------------------------------------------
- def self.sizeloaded(i='')
- @read[i]
- end
- #------------------------------------------------------------------------
- # » Transferência confirmada
- #------------------------------------------------------------------------
- def self.transfered
- @dloaded
- end
- #------------------------------------------------------------------------
- # » Transferências
- #------------------------------------------------------------------------
- def self.transfers
- @dls
- end
- #------------------------------------------------------------------------
- # » Progresso
- #------------------------------------------------------------------------
- def self.progress(i='')
- (@read[i].to_f / @size[i] * 100)
- end
- #------------------------------------------------------------------------
- # » Carregar
- #------------------------------------------------------------------------
- def self.loaded?(i='')
- @read[i] >= @size[i] rescue nil
- end
- #------------------------------------------------------------------------
- # » Temps
- #------------------------------------------------------------------------
- def self.temps(i='')
- @tps[i] if self.loaded?(i)
- end
- #------------------------------------------------------------------------
- # » Tamanho
- #------------------------------------------------------------------------
- def self.size(i='')
- @size[i]
- end
- #------------------------------------------------------------------------
- # » Download
- #------------------------------------------------------------------------
- def self.download(url, int='./')
- @dloaded ||= 0
- @dls ||={}
- @i ||= -1
- @size ||={}
- @read ||={}
- @tps={}
- a = url.split('/')
- serv, root, fich =a[2], a[3..a.size].join('/'), a[-1]
- msgbox(DowError::NoFile) if fich.nil?
- @dls[fich] = Thread.start(url,int) {|url,int| txt = ''
- t = Time.now
- DowError::ConHttp if (e = IC.call(IOA, serv, 80, '', '', 3, 1, 0)) == 0
- f = IOU.call(IOA, url, nil, 0, 0, 0)
- HQI.call(f, 5, k = "\0" * 1024, [k.size-1].pack('l'), nil)
- @read[fich], @size[fich] = 0, k.delete!("\0").to_i
- loop do
- buf, n= ' ' * 1024, 0
- r = IRF.call(f, buf, 1024, o = [n].pack('i!'))
- n = o.unpack('i!')[0]
- break if r&&n == 0
- txt << buf[0, n]
- @read[fich]= txt.size
- end
- (File.open(int+fich,'wb')<<txt).close
- @dloaded+=@read[fich]
- ICH.call(f);sleep(0.01)
- @tps[fich]=Time.now-t}
- end
- end
- end
- #--------------------------------------------------------------------------
- # » Baixa um arquivo de um site.
- #--------------------------------------------------------------------------
- def self.url(url)
- Download::Net::HTTP.download(url)
- end
- end
- #==============================================================================
- # • Variable
- #==============================================================================
- Dax.register(:Variable)
- class Variables
- #----------------------------------------------------------------------------
- # • Iniciar
- #----------------------------------------------------------------------------
- def initialize
- @variable = []
- end
- #----------------------------------------------------------------------------
- # • ID da variável.
- #----------------------------------------------------------------------------
- def [](id)
- @variable[id] || 0
- end
- #----------------------------------------------------------------------------
- # • ID mais valor da variável.
- #----------------------------------------------------------------------------
- def []=(id, value)
- @variable[id] = value
- end
- end
- #==============================================================================
- # • Switche
- #==============================================================================
- Dax.register(:Switche)
- class Switches
- #----------------------------------------------------------------------------
- # • Iniciar
- #----------------------------------------------------------------------------
- def initialize
- @switche = []
- end
- #----------------------------------------------------------------------------
- # • ID da variável.
- #----------------------------------------------------------------------------
- def [](id)
- @switche[id] || false
- end
- #----------------------------------------------------------------------------
- # • ID mais valor da variável.
- #----------------------------------------------------------------------------
- def []=(id, value)
- @switche[id] = value
- end
- end
- #==============================================================================
- # • DataManager
- #==============================================================================
- class << DataManager
- #--------------------------------------------------------------------------
- # • Criação dos objetos do jogo
- #--------------------------------------------------------------------------
- alias dax_create_game_objects create_game_objects
- def create_game_objects
- dax_create_game_objects
- $variables = Variables.new
- $switches = Switches.new
- end
- end
- #==============================================================================
- # • Object
- #==============================================================================
- Dax.register(:Object)
- class Object
- #----------------------------------------------------------------------------
- # • Checar..
- #----------------------------------------------------------------------------
- def check(regexp)
- self.each_line { |check| return true if check =~ /#{regexp}/i }
- return false
- end
- #----------------------------------------------------------------------------
- # • Trigger
- #----------------------------------------------------------------------------
- def trigger?(key)
- return key.is_a?(Symbol) ? Input.trigger?(key) : Key.trigger?(key)
- end
- #----------------------------------------------------------------------------
- # • Press
- #----------------------------------------------------------------------------
- def press?(key)
- return key.is_a?(Symbol) ? Input.press?(key) : Key.press?(key)
- end
- #----------------------------------------------------------------------------
- # • Repeat
- #----------------------------------------------------------------------------
- def repeat?(key)
- return key.is_a?(Symbol) ? Input.repeat?(key) : Key.repeat?(key)
- end
- #----------------------------------------------------------------------------
- # • Checar Regexp.
- #----------------------------------------------------------------------------
- def check_regexp(comment, type=:integer)
- return /<(?:#{comment.upcase!}|#{comment}):[ ]*(\d+)>/i if type == :integer
- return /<(?:#{comment.upcase!}|#{comment.downcase!}):[ ]*(\w+)>/i if type == :string
- return /<(?:#{comment.upcase!}|#{comment.downcase!})>/i if type == :include?
- end
- #----------------------------------------------------------------------------
- # • Chamar a class color.
- #----------------------------------------------------------------------------
- def RGB(*args)
- Color.new(*args)
- end
- end
- #==============================================================================
- # • ColorBasic
- #==============================================================================
- Dax.register(:ColorBasic, "Dax", 1.2)
- module ColorBasic
- extend self
- #----------------------------------------------------------------------------
- # • Cores básica.
- #----------------------------------------------------------------------------
- def new(basic=:white)
- case basic
- when :white && -1 then RGB(255, 255, 255)
- when :black && 7 then RGB(0, 0, 0)
- when :red && 36 then RGB(255, 0, 0)
- when :blue && 9 then RGB(0, 0, 255)
- when :green && 37 then RGB(0, 255, 0)
- when :yellow && 35 then RGB(255, 255, 0)
- when :orange && 38 then RGB(255, 128, 0)
- end
- end
- #----------------------------------------------------------------------------
- # • Cores em Index
- #----------------------------------------------------------------------------
- def [](id)
- case id
- when -1 then Color.new(255, 255, 255) # White
- when 0 then Color.new(240, 248, 255) # Alice Blue
- when 1 then Color.new(250, 235, 215) # Antique_White
- when 2 then Color.new(0, 255, 255) # Aqua
- when 3 then Color.new(127, 255, 255) # Aqua Marine
- when 4 then Color.new(240, 255, 255) # Azure
- when 5 then Color.new(245, 245, 220) # Beige
- when 6 then Color.new(255, 228, 196) # Bisque
- when 7 then Color.new(0, 0, 0) # Black
- when 8 then Color.new(255, 235, 205) # Blanchedalmond
- when 9 then Color.new(0, 0, 255) # Blue
- when 10 then Color.new(138, 43, 226) # Blue Violet
- when 11 then Color.new(165, 42, 42) # Brown
- when 12 then Color.new(222, 184, 135) # Burly Wood
- when 13 then Color.new(93, 158, 160) # Cadet Blue
- when 14 then Color.new(127, 255, 0) # Chatreuse
- when 15 then Color.new(210, 105, 30) # Chocolate
- when 16 then Color.new(255, 127, 80) # Coral
- when 17 then Color.new(100, 149, 237) # Corn Flower Blue
- when 18 then Color.new(255, 248, 220) # CornSilk
- when 19 then Color.new(220, 20, 60) # Crimson
- when 20 then Color.new(0, 255, 255) # Cyan
- when 21 then Color.new(0, 0, 139) # DarkBlue
- when 22 then Color.new(0, 139, 139) # DarkCyan
- when 23 then Color.new(184, 134, 11) # DarkGoldEnrod
- when 24 then Color.new(169, 169, 169) # Dark Gray
- when 25 then Color.new(0, 100, 0) # Dark Green
- when 26 then Color.new(189, 183, 107) # Dark Khaki
- when 27 then Color.new(139, 0, 139) # Dark Magenta
- when 28 then Color.new(85, 107, 47) # Dark Oliver Green
- when 29 then Color.new(255, 140, 0) # Dark Orange
- when 30 then Color.new(153, 50, 204) # Dark orchid
- when 31 then Color.new(139, 0, 0) # Dark Red
- when 32 then Color.new(233, 150, 120) # Dark Salmon
- when 33 then Color.new(143, 188, 143) # Dark Sea Green
- when 34 then Color.new(72, 61, 139) # Dark Slate Blue
- when 35 then RGB(255, 255, 0) # Yellow
- when 36 then RGB(255, 0, 0) # Red
- when 37 then RGB(0, 255, 0) # Green
- when 38 then RGB(255, 128, 0) # Orange
- end
- end
- #----------------------------------------------------------------------------
- # • Index das cores usadas para o Design de Windows.
- #----------------------------------------------------------------------------
- def window(index)
- case index.to_i
- when 0 then RGB(238, 238, 238) # Cinza | Barra de opções
- when 1 then RGB(165, 172, 178) # Cinza escuro | Barra de opções | Borda
- when 2 then RGB(255, 148, 40) # Laranja escuro | Barra de opções | Selecionada
- when 3 then RGB(245, 121, 0) # Laranja escuro ² | Barra de opções | Selecionada | Borda
- end
- end
- end
- #==============================================================================
- # • Game_CommonEvent
- #==============================================================================
- Dax.register(:Game_CommonEvent, "Dax", 1.0)
- class Game_CommonEvent
- #----------------------------------------------------------------------------
- # • Nova variável.
- #----------------------------------------------------------------------------
- alias dax_core_new_variable initialize
- def initialize(common_event_id)
- @common_event_id = common_event_id.to_i
- dax_core_new_variable(common_event_id)
- end
- #----------------------------------------------------------------------------
- # • Achar o nome do evento comum chamado.
- #----------------------------------------------------------------------------
- def name
- return $data_common_events[@common_event_id].name.to_s
- end
- #----------------------------------------------------------------------------
- # • Obter trigger.
- #----------------------------------------------------------------------------
- def trigger
- return $data_common_events[@common_event_id].trigger
- end
- #----------------------------------------------------------------------------
- # • Obter ID da Switche.
- #----------------------------------------------------------------------------
- def switche_id
- return $data_common_events[@common_event_id].switche_id.to_i
- end
- #----------------------------------------------------------------------------
- # • Obter a lista dos comandos.
- #----------------------------------------------------------------------------
- def list
- return $data_common_events[@common_event_id].list
- end
- end
- #==============================================================================
- # • Window Core
- #==============================================================================
- # Autor: Dax
- # Versão: 1.0
- # Site: www.dax-soft.weebly.com
- # Requerimento: Dax Core 1.9>
- #==============================================================================
- Dax.register(:Window_Core, "Dax", Dax::Version_WC)
- #==============================================================================
- # • WC
- #==============================================================================
- module WC
- extend self
- #----------------------------------------------------------------------------
- # • Variável e constantes.
- #----------------------------------------------------------------------------
- @imported = {} # Importar script.
- @version_imported = {} # Versão do script importado.
- @actor_imported = {} # Autor do script importado.
- #----------------------------------------------------------------------------
- # • Registrar script.
- #----------------------------------------------------------------------------
- def register(name, actor="Dax", version=1.0)
- @imported[name] = true
- @version_imported[name] = version
- @actor_imported[name] = actor
- end
- #----------------------------------------------------------------------------
- # • Cria uma condição de requerimento de script.
- #----------------------------------------------------------------------------
- def required(name, actor="Dax", version=1.0)
- @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
- end
- end
- #==============================================================================
- # • Letter Input
- #==============================================================================
- WC.register(:Letter_Input, "Dax", 1.0)
- module WC::Letter_Input
- extend self
- #----------------------------------------------------------------------------
- # • Variáveis e constantes.
- #----------------------------------------------------------------------------
- $acent = nil
- $times = [25, 25, 25, 25, 25, 25, 25, 25, 25]
- #----------------------------------------------------------------------------
- # • Atualização dos objetos do módulo.
- #----------------------------------------------------------------------------
- def update
- $times[0] = $times[$times.size-1] if $times[0] < $times[$times.size-1] and API::StateKey.call(8) == 0
- $times[1] = $times[$times.size-1] if $times[1] < $times[$times.size-1] and API::StateKey.call(46) == 0
- $times[2] = $times[$times.size-1] if $times[2] < $times[$times.size-1] and API::StateKey.call(192) == 0
- $times[3] = $times[$times.size-1] if $times[3] < $times[$times.size-1] and API::StateKey.call(226) == 0
- $times[4] = $times[$times.size-1] if $times[4] < $times[$times.size-1] and API::StateKey.call(54) == 0
- $times[5] = $times[$times.size-1] if $times[5] < $times[$times.size-1] and API::StateKey.call(193) == 0
- $times[6] = $times[$times.size-1] if $times[6] < $times[$times.size-1] and API::StateKey.call(186) == 0
- $times[7] = $times[$times.size-1] if $times[7] < $times[$times.size-1] and API::StateKey.call(220) == 0
- end
- #----------------------------------------------------------------------------
- # • Input : Teclas.
- #----------------------------------------------------------------------------
- def input
- acent = get_acent
- na = false
- if !acent.nil?
- if $acent.nil?
- $acent = acent
- na = true
- else
- r = $acent + acent
- $acent = nil
- return r
- end
- end
- unless na
- r = get_symbol
- if !r.nil?
- if !$acent.nil?
- a = $acent
- $acent = nil
- return a + r.to_s
- else
- return r
- end
- end
- r = get_number
- if !r.nil?
- if !$acent.nil?
- a = $acent
- $acent = nil
- return a + r.to_s
- else
- return r
- end
- end
- end
- m = (get_shift or get_caps_lock)
- if $acent.nil?
- r = get_character(m)
- if r == ""
- if space?
- r = " "
- end
- end
- else
- r = get_character_acent($acent, m)
- if r != ""
- $acent = nil
- else
- if space?
- a = $acent
- $acent = nil
- r = a + " "
- end
- end
- end
- return r if !r.empty?
- end
- #----------------------------------------------------------------------------
- # • Teclas.
- #----------------------------------------------------------------------------
- def space?; trigger?(Key::SPACE); end;
- def enter?; trigger?(Key::ENTER); end;
- def back?; trigger?(Key::BACKSPACE); end;
- def delete?; trigger?(Key::DELETE); end;
- def asp?; trigger?(Key::F8); end;
- def tra?; trigger?(226); end;
- def num6?; trigger?(Key::NUMPAD6); end;
- def backslash?; trigger?(193); end;
- def tc?; trigger?(186); end;
- def t220?; trigger?(220); end;
- def end?; trigger?(35); end;
- #----------------------------------------------------------------------------
- # • Acento.
- #----------------------------------------------------------------------------
- def acent
- if press?(16) and trigger?(19)
- return "`"
- elsif trigger?(19)
- return "´"
- elsif press?(16) and trigger?(222)
- return "^"
- elsif trigger?(222)
- return "~"
- elsif trigger?(54)
- return "¨"
- end
- return nil
- end
- #----------------------------------------------------------------------------
- # • Obter Caps Lock
- #----------------------------------------------------------------------------
- def get_caps_lock
- if API::StateKey.call(20) == 1
- return true
- else
- return false
- end
- end
- #----------------------------------------------------------------------------
- # • Obter Shift
- #----------------------------------------------------------------------------
- def get_shift
- if press?(Key::Shift)
- return true
- end
- return false
- end
- #----------------------------------------------------------------------------
- # • Obter Characters
- #----------------------------------------------------------------------------
- def get_character(up)
- c = ""
- if trigger?(Key::A)
- c = "a"
- elsif trigger?(Key::B)
- c = "b"
- elsif trigger?(Key::C)
- c = "c"
- elsif trigger?(Key::D)
- c = "d"
- elsif trigger?(Key::E)
- c = "e"
- elsif trigger?(Key::F)
- c = "f"
- elsif trigger?(Key::G)
- c = "g"
- elsif trigger?(Key::H)
- c = "h"
- elsif trigger?(Key::I)
- c = "i"
- elsif trigger?(Key::J)
- c = "j"
- elsif trigger?(Key::K)
- c = "k"
- elsif trigger?(Key::L)
- c = "l"
- elsif trigger?(Key::M)
- c = "m"
- elsif trigger?(Key::N)
- c = "n"
- elsif trigger?(Key::O)
- c = "o"
- elsif trigger?(Key::P)
- c = "p"
- elsif trigger?(Key::Q)
- c = "q"
- elsif trigger?(Key::R)
- c = "r"
- elsif trigger?(Key::S)
- c = "s"
- elsif trigger?(Key::T)
- c = "t"
- elsif trigger?(Key::U)
- c = "u"
- elsif trigger?(Key::V)
- c = "v"
- elsif trigger?(Key::W)
- c = "w"
- elsif trigger?(Key::X)
- c = "x"
- elsif trigger?(Key::Y)
- c = "y"
- elsif trigger?(Key::Z)
- c = "z"
- elsif tc?
- c = "ç"
- end
- if up
- c = c.upcase
- end
- return c
- end
- #----------------------------------------------------------------------------
- # • Obter acentos.
- #----------------------------------------------------------------------------
- def get_acent
- if press?(16) and trigger?(219)
- return "`"
- elsif trigger?(219)
- return "´"
- elsif press?(16) and trigger?(222)
- return "^"
- elsif trigger?(222)
- return "~"
- elsif press?(16) and trigger?(Key::N6)
- return "¨"
- end
- end
- #----------------------------------------------------------------------------
- # • Obter characters com acentos.
- #----------------------------------------------------------------------------
- def get_character_acent(acent, up)
- c = ""
- if trigger?(Key::A)
- if up
- case acent
- when "`"
- c = "À"
- when "´"
- c = "Á"
- when "^"
- c = "Â"
- when "~"
- c = "~A"
- when "¨"
- c = "Ä"
- end
- else
- case acent
- when "`"
- c = "à"
- when "´"
- c = "á"
- when "^"
- c = "â"
- when "~"
- c = "ã"
- when "¨"
- c = "ä"
- end
- end
- return c
- elsif trigger?(Key::E)
- if up
- case acent
- when "`"
- c = "È"
- when "´"
- c = "É"
- when "^"
- c = "Ê"
- when "~"
- c = "~E"
- when "¨"
- c = "Ë"
- end
- else
- case acent
- when "`"
- c = "è"
- when "´"
- c = "é"
- when "^"
- c = "ê"
- when "~"
- c = "~e"
- when "¨"
- c = "ë"
- end
- end
- return c
- elsif trigger?(Key::I)
- if up
- case acent
- when "`"
- c = "Ì"
- when "´"
- c = "Í"
- when "^"
- c = "Î"
- when "~"
- c = "~I"
- when "¨"
- c = "Ï"
- end
- else
- case acent
- when "`"
- c = "ì"
- when "´"
- c = "í"
- when "^"
- c = "î"
- when "~"
- c = "~i"
- when "¨"
- c = "ï"
- end
- end
- return c
- elsif trigger?(Key::O)
- if up
- case acent
- when "`"
- c = "Ò"
- when "´"
- c = "Ó"
- when "^"
- c = "Ô"
- when "~"
- c = "~O"
- when "¨"
- c = "Ö"
- end
- else
- case acent
- when "`"
- c = "ò"
- when "´"
- c = "ó"
- when "^"
- c = "ô"
- when "~"
- c = "õ"
- when "¨"
- c = "ö"
- end
- end
- return c
- elsif trigger?(Key::U)
- if up
- case acent
- when "`"
- c = "Ù"
- when "´"
- c = "Ú"
- when "^"
- c = "Û"
- when "~"
- c = "~U"
- when "¨"
- c = "Ü"
- end
- else
- case acent
- when "`"
- c = "ù"
- when "´"
- c = "ú"
- when "^"
- c = "û"
- when "~"
- c = "~u"
- when "¨"
- c = "ü"
- end
- end
- return c
- elsif trigger?(Key::B)
- c = acent + "b"
- elsif trigger?(Key::C)
- c = acent + "c"
- elsif trigger?(Key::D)
- c = acent + "d"
- elsif trigger?(Key::F)
- c = acent + "f"
- elsif trigger?(Key::G)
- c = acent + "g"
- elsif trigger?(Key::H)
- c = acent + "h"
- elsif trigger?(Key::J)
- c = acent + "j"
- elsif trigger?(Key::K)
- c = acent + "k"
- elsif trigger?(Key::L)
- c = acent + "l"
- elsif trigger?(Key::M)
- c = acent + "m"
- elsif trigger?(Key::N)
- c = acent + "n"
- elsif trigger?(Key::P)
- c = acent + "p"
- elsif trigger?(Key::Q)
- c = acent + "q"
- elsif trigger?(Key::R)
- c = acent + "r"
- elsif trigger?(Key::S)
- c = acent + "s"
- elsif trigger?(Key::T)
- c = acent + "t"
- elsif trigger?(Key::V)
- c = acent + "v"
- elsif trigger?(Key::W)
- c = acent + "w"
- elsif trigger?(Key::X)
- c = acent + "x"
- elsif trigger?(Key::Y)
- c = acent + "y"
- elsif trigger?(Key::Z)
- c = acent + "z"
- elsif tc?
- c = acent + "ç"
- end
- if up and c != ""
- c = c.upcase
- end
- return c
- end
- #----------------------------------------------------------------------------
- # • Obter número.
- #----------------------------------------------------------------------------
- def get_number
- if trigger?(Key::N0)
- c = 0
- elsif trigger?(Key::N1)
- c = 1
- elsif trigger?(Key::N2)
- c = 2
- elsif trigger?(Key::N3)
- c = 3
- elsif trigger?(Key::N4)
- c = 4
- elsif trigger?(Key::N5)
- c = 5
- elsif trigger?(Key::N6)
- c = 6
- elsif trigger?(Key::N7)
- c = 7
- elsif trigger?(Key::N8)
- c = 8
- elsif trigger?(Key::N9)
- c = 9
- elsif trigger?(Key::NUMPAD0)
- c = 0
- elsif trigger?(Key::NUMPAD1)
- c = 1
- elsif trigger?(Key::NUMPAD2)
- c = 2
- elsif trigger?(Key::NUMPAD3)
- c = 3
- elsif trigger?(Key::NUMPAD4)
- c = 4
- elsif trigger?(Key::NUMPAD5)
- c = 5
- elsif trigger?(Key::NUMPAD6)
- c = 6
- elsif trigger?(Key::NUMPAD7)
- c = 7
- elsif trigger?(Key::NUMPAD8)
- c = 8
- elsif trigger?(Key::NUMPAD9)
- c = 9
- end
- end
- #----------------------------------------------------------------------------
- # • Obter simbolos;
- #----------------------------------------------------------------------------
- def get_symbol
- if press?(16) and trigger?(189)
- c = "_"
- elsif trigger?(189)
- c = "-"
- elsif press?(17) and press?(18) and trigger?(187)
- c = "§"
- elsif press?(16) and trigger?(187)
- c = "+"
- elsif trigger?(187)
- c = "="
- elsif press?(17) and press?(18) and trigger?(221)
- c = "ª"
- elsif press?(16) and trigger?(221)
- c = "{"
- elsif trigger?(221)
- c = "["
- elsif press?(17) and press?(18) and t220?
- c = "º"
- elsif press?(16) and t220?
- c = "}"
- elsif t220?
- c = "]"
- elsif press?(16) and tra?
- c = "|"
- elsif tra?
- c = "\\"
- elsif press?(16) and trigger?(188)
- c = "<"
- elsif trigger?(188)
- c = ","
- elsif press?(16) and trigger?(190)
- c = ">"
- elsif trigger?(190)
- c = "."
- elsif press?(16) and trigger?(191)
- c = ":"
- elsif trigger?(191)
- c = ";"
- elsif press?(17) and press?(18) and backslash?
- c = "°"
- elsif press?(16) and backslash?
- c = "?"
- elsif backslash?
- c = "/"
- elsif press?(16) and asp?
- c = "\""
- elsif asp?
- c = "'"
- elsif trigger?(111)
- c = "/"
- elsif trigger?(106)
- c = "*"
- elsif trigger?(109)
- c = "-"
- elsif trigger?(107)
- c = "+"
- elsif trigger?(194)
- c = "."
- elsif trigger?(110)
- c = ","
- elsif press?(16) and trigger?(Key::N0)
- c = ")"
- elsif press?(17) and press?(18) and trigger?(Key::N1)
- c = "¹"
- elsif press?(16) and trigger?(Key::N1)
- c = "!"
- elsif press?(17) and press?(18) and trigger?(Key::N2)
- c = "²"
- elsif press?(16) and trigger?(Key::N3)
- c = "@"
- elsif press?(17) and press?(18) and trigger?(Key::N3)
- c = "³"
- elsif press?(16) and trigger?(Key::N3)
- c = "#"
- elsif press?(17) and press?(18) and trigger?(Key::N4)
- c = "£"
- elsif press?(16) and trigger?(Key::N4)
- c = "$"
- elsif press?(17) and press?(18) and trigger?(Key::N5)
- c = "¢"
- elsif press?(16) and trigger?(Key::N5)
- c = "%"
- elsif press?(17) and press?(18) and trigger?(Key::N6)
- c = "¬"
- elsif press?(16) and trigger?(Key::N7)
- c = "&"
- elsif press?(16) and trigger?(Key::N8)
- c = "*"
- elsif press?(16) and trigger?(Key::N9)
- c = "("
- end
- end
- end
- class << Input
- alias method_letter_input_update update
- def update
- method_letter_input_update
- WC::Letter_Input.update
- end
- end
- #==============================================================================
- # • Position
- #==============================================================================
- WC.register(:Pos_Size, "Dax", 1.0)
- class WC::Position < Struct.new(:x, :y)
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize(x, y)
- self.x = x.to_i
- self.y = y.to_i
- end
- #----------------------------------------------------------------------------
- # • Add.
- #----------------------------------------------------------------------------
- def +(add)
- rst = WC::Position.new(self.x, self.y)
- rst.x += add.x.to_i
- rst.y += add.y.to_i
- rst
- end
- #----------------------------------------------------------------------------
- # • Sub.
- #----------------------------------------------------------------------------
- def -(add)
- rst = WC::Position.new(self.x, self.y)
- rst.x -= add.x.to_i
- rst.y -= add.y.to_i
- rst
- end
- #----------------------------------------------------------------------------
- # • Set
- #----------------------------------------------------------------------------
- def set(pos)
- self.x = pos.x.to_i
- self.y = pos.y.to_i
- end
- #----------------------------------------------------------------------------
- # • Inspecionar
- #----------------------------------------------------------------------------
- def inspects
- "WC_Position#{self.to_s}"
- end
- #----------------------------------------------------------------------------
- # • Converter para string.
- #----------------------------------------------------------------------------
- def to_s
- "(#{self.x}, #{self.y})"
- end
- #----------------------------------------------------------------------------
- # • Converter para array.
- #----------------------------------------------------------------------------
- def to_a
- [self.x, self.y]
- end
- #----------------------------------------------------------------------------
- # • Achar o tamanho.
- #----------------------------------------------------------------------------
- def to_size
- WC::Size.new(self.x, self.y)
- end
- #----------------------------------------------------------------------------
- # • Verificar.
- #----------------------------------------------------------------------------
- def ==(obj)
- unless obj.is_a?(WC::Position)
- return false
- end
- if self.x == obj.x and self.y == obj.y
- return true
- end
- return false
- end
- #----------------------------------------------------------------------------
- # • Converter para um valor bruto.
- #----------------------------------------------------------------------------
- def abs
- WC::Position.new(self.x.abs, self.y.abs)
- end
- end
- #==============================================================================
- # • Size
- #==============================================================================
- WC.register(:Size, "Dax", 1.0)
- class WC::Size < Struct.new(:width, :height)
- #----------------------------------------------------------------------------
- # • Add.
- #----------------------------------------------------------------------------
- def +(add)
- rst = WC::Size.new(self.width, self.height)
- rst.width += add.width
- rst.height += add.height
- rst
- end
- #----------------------------------------------------------------------------
- # • Sub.
- #----------------------------------------------------------------------------
- def -(add)
- rst = WC::Size.new(self.width, self.height)
- rst.width -= add.width
- rst.height -= add.height
- rst
- end
- #----------------------------------------------------------------------------
- # • Set
- #----------------------------------------------------------------------------
- def set(size)
- self.width = size.width
- self.height = size.height
- end
- #----------------------------------------------------------------------------
- # • Inspecionar
- #----------------------------------------------------------------------------
- def inspect
- "WC_Size#{self.to_s}"
- end
- #----------------------------------------------------------------------------
- # • Converter para string.
- #----------------------------------------------------------------------------
- def to_s
- "(#{self.width}, #{self.height})"
- end
- #----------------------------------------------------------------------------
- # • Converter para array.
- #----------------------------------------------------------------------------
- def to_a
- [self.width, self.height]
- end
- #----------------------------------------------------------------------------
- # • Converter para posição.
- #----------------------------------------------------------------------------
- def to_position
- WC::Position.new(self.width, self.height)
- end
- #----------------------------------------------------------------------------
- # • Igual
- #----------------------------------------------------------------------------
- def ==(s)
- unless s.is_a?(WC::Size)
- return false
- end
- if self.width == s.width and self.height == s.height
- return true
- else
- return false
- end
- end
- #----------------------------------------------------------------------------
- # • Converter para valor bruto.
- #----------------------------------------------------------------------------
- def abs
- WC::Size.new(self.width.abs, self.height.abs)
- end
- end
- #==============================================================================
- # • Kernel
- #==============================================================================
- WC.register(:Kernel, "Dax", 1.0)
- module Kernel
- #----------------------------------------------------------------------------
- # • Achar a posição.
- #----------------------------------------------------------------------------
- def wc_pos(x, y)
- WC::Position.new(x, y)
- end
- #----------------------------------------------------------------------------
- # • Achar o tamanho.
- #----------------------------------------------------------------------------
- def wc_size(w, h)
- WC::Size.new(w, h)
- end
- end
- #==============================================================================
- # • DesignMenu
- #==============================================================================
- WC.register(:DesignMenu, "Dax", 1.0)
- module WC::DesignMenu
- #============================================================================
- # • SampleMenuStripButton |
- #============================================================================
- class SampleMenuStripButton < Sprite
- #--------------------------------------------------------------------------
- # • Variáveis públicas da instância.
- #--------------------------------------------------------------------------
- attr_reader :area
- #--------------------------------------------------------------------------
- # • Inicialização dos objetos.
- # title : Título do comando.
- # action : Ação do comando.
- # x : Posição X.
- # y : Posição Y.
- # z : Altura.
- #--------------------------------------------------------------------------
- def initialize(action, x, y, z)
- super()
- self.x, self.y, self.z = x, y, z
- self.bitmap = Bitmap.new(64, 20)
- @action = action.to_s
- self.bitmap.clear
- self.bitmap.fill_rect(0, 0, self.width, self.height, ColorBasic.window(1))
- self.bitmap.fill_rect(0, 0, self.width, self.height-1, ColorBasic[-1])
- self.bitmap.fill_rect(0, 0, self.width, self.height-2, ColorBasic.window(0))
- @clicked = false
- @area = false
- end
- #--------------------------------------------------------------------------
- # • Renovar os objetos.
- #--------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose unless self.bitmap.disposed?
- super
- end
- #--------------------------------------------------------------------------
- # • Atualização dos objetos.
- #--------------------------------------------------------------------------
- def update(switche)
- if Mouse.in_area?(self)
- if switche
- on_area
- @clicked = trigger?(0x01) or repeat?(0x01)
- action if @clicked && trigger?(0x01) && repeat?(0x01)
- end
- else
- off_area
- @clicked = false if trigger?(0x01) or repeat?(0x01)
- end
- end
- #--------------------------------------------------------------------------
- # • Ação do comando.
- #--------------------------------------------------------------------------
- def action
- end
- #--------------------------------------------------------------------------
- # • Efeito fora da área.
- #--------------------------------------------------------------------------
- def off_area
- @area = false
- self.bitmap.fill_rect(0, 0, self.width, self.height-2, ColorBasic.window(0))
- end
- #--------------------------------------------------------------------------
- # • Efeito dentro da área.
- #--------------------------------------------------------------------------
- def on_area
- @area = true
- self.bitmap.fill_rect(0, 0, self.width, self.height-2, ColorBasic.window(2))
- end
- end
- #============================================================================
- # • MenuStrip
- #============================================================================
- class MenuStrip
- #--------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #--------------------------------------------------------------------------
- def initialize(number,x,y,z,titles,actions,switche)
- @number = number rescue 0
- @titles = titles
- @actions = actions
- @x, @y, @z = x, y, z
- @sample = []
- @text = []
- @switche = switche
- (0..@number).each do |i|
- @sample[i] = SampleMenuStripButton.new(@actions[i], @x + (64 * i+1), @y, @z)
- @text[i] = Sprite.new
- @text[i].x, @text[i].y, @text[i].z = @x + (64 * i+1), @y, @z+1
- @text[i].bitmap = Bitmap.new(64, 22)
- @text[i].bitmap.font.name = "Arial"
- @text[i].bitmap.font.size = 14
- @text[i].bitmap.font.outline = false
- @text[i].color = ColorBasic[7]
- @text[i].bitmap.draw_text(0, -2, 64, 22, @titles[i], 1)
- end
- end
- #--------------------------------------------------------------------------
- # • Renovação dos objetos.
- #--------------------------------------------------------------------------
- def dispose
- @sample.each { |i| i.dispose }
- @text.each { |i| i.dispose }
- end
- #--------------------------------------------------------------------------
- # • Atualização dos objetos.
- #--------------------------------------------------------------------------
- def update
- (0..@number).each { |i|
- @sample[i].update(@switche[i])
- if @sample[i].area
- @text[i].color = ColorBasic[-1]
- else
- @text[i].color = ColorBasic[7]
- end
- }
- end
- end
- end
- #==============================================================================
- # • Psych Core
- #==============================================================================
- # Autor: Dax
- # Versão: 0.1
- # Site: www.dax-soft.weebly.com
- # Requerimento: Dax Core 1.9
- #==============================================================================
- # • Descrição:
- #------------------------------------------------------------------------------
- # Trata-se de vários scripts para proporcionar uma física simples.
- #==============================================================================
- Dax.register(:Psych_Core, "Dax", Dax::Version_PS)
- module PS
- extend self
- #----------------------------------------------------------------------------
- # • Variável e constantes.
- #----------------------------------------------------------------------------
- @imported = {} # Importar script.
- @version_imported = {} # Versão do script importado.
- @actor_imported = {} # Autor do script importado.
- #----------------------------------------------------------------------------
- # • Registrar script.
- #----------------------------------------------------------------------------
- def register(name, actor="Dax", version=Dax::Version_PS)
- @imported[name] = true
- @version_imported[name] = version
- @actor_imported[name] = actor
- end
- #----------------------------------------------------------------------------
- # • Cria uma condição de requerimento de script.
- #----------------------------------------------------------------------------
- def required(name, actor="Dax", version=Dax::Version_PS)
- @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
- end
- end
- #==============================================================================
- # • LimitScreen | Sisetma que cria uma condição para o objeto não passar os limites da tela.
- #==============================================================================
- PS.register(:LimitScreen, "Dax", 1.0)
- class PS::LimitScreen
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize(object, limit_screen=[Graphics.width, Graphics.height])
- @object = object
- @limit_screen = limit_screen
- up?
- down?
- left?
- right?
- end
- #----------------------------------------------------------------------------
- # • Verificar se o objeto está tentando passar do limite de cima.
- #----------------------------------------------------------------------------
- def up?
- if @object.y <= 0
- @object.y = 0
- end
- end
- #----------------------------------------------------------------------------
- # • Verificar se o objeto está tentando passar do limite de baixo.
- #----------------------------------------------------------------------------
- def down?
- if @object.y >= @limit_screen[1] - @object.height
- @object.y = @limit_screen[1] - @object.height
- end
- end
- #----------------------------------------------------------------------------
- # • Verificar se o objeto está tentando passar do limite da esquerda.
- #----------------------------------------------------------------------------
- def left?
- if @object.x <= 0
- @object.x = 0
- end
- end
- #----------------------------------------------------------------------------
- # • Verificar se o object está tentando passar do limite da direita.
- #----------------------------------------------------------------------------
- def right?
- if @object.x >= @limit_screen[0] - @object.width
- @object.x = @limit_screen[0] - @object.height
- end
- end
- end
- #==============================================================================
- # • Path
- #==============================================================================
- PS.register(:Path, "Dax", 1.0)
- module Path
- extend self
- #----------------------------------------------------------------------------
- # • Checar a distância de um objeto com outro.
- #----------------------------------------------------------------------------
- def distance(x, x², y, y²)
- rise = x² - y²
- rub = x - y
- hypo_math = Math.hypot(rise, rub)
- return hypo_math
- end
- #----------------------------------------------------------------------------
- # • Verificar o caminho "a pé" até o alvo.
- #----------------------------------------------------------------------------
- def check_path(init_x, init_y, term_x, term_y, exclude=false)
- quadrant = term_y > init_y ? term_x > init_x ? 3 : 1 : term_x > init_x ? 9 : 7
- vert = ((term_x - init_x).abs < (term_y - init_y).abs)
- cardinal = vert ? (term_y > init_y ? 2 : 8) : (term_x > init_x ? 6 : 4)
- for test in 1..2
- jog = 0
- loop do
- pablo_x = init_x
- pablo_y = init_y
- steps = 0
- check = false
- loop do
- case test
- when 1
- if steps >= jog
- move_along = (pablo_x == term_x or pablo_y == term_y) ? 'card' : 'quad'
- else
- move_along = 'card'
- end
- when 2
- if steps >= jog
- move_along = ((pablo_x - term_x).abs == (pablo_y - term_y).abs) ? 'quad' : 'card'
- else
- move_along = 'quad'
- end
- end
- check_x = pablo_x
- check_y = pablo_y
- check_dir = move_along == 'quad' ? quadrant : cardinal
- exclude_coords = exclude ? [term_x, term_y] : nil
- if !@map.path_pass?(check_x, check_y, check_dir, exclude_coords)
- check = false
- break
- end
- d = move_along == 'quad' ? quadrant : cardinal
- pablo_x += (d%3==0) ? 1 : (d%3==1) ? -1 : 0
- pablo_y += ((d-1)/3==0) ? 1 : ((d-1)/3==2) ? -1 : 0
- steps += 1
- if pablo_x == term_x and pablo_y == term_y
- check = true
- break
- end
- end
- return [test, jog] if check
- jog += 1
- stop = ((init_x - term_x).abs - (init_y - term_y).abs).abs
- if test == 1
- break if jog > (vert ? (init_y-term_y).abs : (init_x-term_x).abs) - stop
- else
- break if jog > stop
- end
- end
- end
- return nil
- end
- #----------------------------------------------------------------------------
- # • Obter alcance
- #----------------------------------------------------------------------------
- def get_range(x, y)
- points = []
- graphics_counter = 0
- for check_x in 6...20
- for check_y in 1..15
- next if check_x == start_x and check_y == start_y
- if !check_path(start_x, start_y, check_x, check_y).nil?
- points.push([check_x, check_y])
- end
- graphics_counter += 1
- if graphics_counter == 50
- graphics_counter = 0
- Graphics.update
- end
- end
- end
- return points
- end
- #----------------------------------------------------------------------------
- # • Encontrar o lado mais próximo;
- #----------------------------------------------------------------------------
- def find_closest_side(start_x, start_y, target_x, target_y)
- possibles = []
- distances = []
- for i in 0..3
- check_x = target_x
- check_y = target_y
- check_x += (i == 1) ? -1 : (i == 2) ? 1 : 0
- check_y += (i == 3) ? -1 : (i == 0) ? 1 : 0
- blockage = check_path(start_x, start_y, check_x, check_y)
- if !blockage.nil?
- possibles.push([check_x, check_y])
- distances.push(distance(start_x, start_y, check_x, check_y))
- end
- end
- return nil if possibles.empty?
- return possibles[distances.index(distances.min)]
- end
- #----------------------------------------------------------------------------
- # • Escolha o lugar de destino com base numa restrição.
- #----------------------------------------------------------------------------
- def apply_restriction(init_x, init_y, term_x, term_y, restriction)
- if restriction.nil?
- return find_closest_side(init_x, init_y, term_x, term_y)
- end
- return [term_x, term_y]
- end
- #----------------------------------------------------------------------------
- # • Criar um caminho para o alvo.
- #----------------------------------------------------------------------------
- def get_nodes(pablo_x, pablo_y, target_x, target_y, restriction=nil, dir=nil)
- nodes = []
- goto = apply_restriction(pablo_x, pablo_y, target_x, target_y, restriction)
- goto = [target_x, target_y] if goto.nil?
- goto_x = goto[0]
- goto_y = goto[1]
- path = check_path(pablo_x, pablo_y, goto_x, goto_y, !restriction.nil?)
- if !path.nil?
- node = [goto_x, goto_y] + path
- nodes.push(node)
- return nodes
- else
- @save_info = true
- range = get_range(pablo_x, pablo_y)
- stones = []
- stones_steps = []
- for i in range
- if restriction.nil?
- point = apply_restriction(i[0], i[1], target_x, target_y, restriction)
- next if point.nil?
- else
- next if check_path(i[0], i[1], target_x, target_y, true).nil?
- end
- stones.push(i)
- steps = distance(pablo_x, pablo_y, i[0], i[1]) +
- distance(goto_x, goto_y, i[0], i[1])
- stones_steps.push(steps)
- end
- if stones.empty?
- msgbox 'Falha no calculo da rota...'
- else
- best_stone = stones[stones_steps.index(stones_steps.min)]
- best_path = check_path(pablo_x, pablo_y, best_stone[0], best_stone[1])
- if restriction.nil?
- final_place = find_closest_side(best_stone[0], best_stone[1], goto_x, goto_y)
- else
- final_place = [goto_x, goto_y]
- end
- final_path = check_path(best_stone[0], best_stone[1], final_place[0], final_place[1], !restriction.nil?)
- nodes.push(best_stone+best_path, final_place+final_path)
- return nodes
- end
- end
- end
- #----------------------------------------------------------------------------
- # • Criar um caminho para o alvo.
- #----------------------------------------------------------------------------
- def create_path(mover_ev, target_ev, restriction=nil, dir=nil)
- @map = $game_map
- mover = @map.map.events[mover_ev.id]
- target = @map.map.events[target_ev.id]
- target_x = target.x
- target_y = target.y
- if !restriction.nil?
- if restriction == 'path_object'
- target_x += (dir == 6) ? -1 : (dir == 4) ? 1 : 0
- target_y += (dir == 8) ? 1 : (dir == 2) ? -2 : -1
- elsif restriction == 'exit'
- target_y += (dir == 4 or dir == 6) ? -1 : 0
- elsif restriction == 'force_dir'
- target_x += (dir == 4) ? -1 : (dir == 6) ? 1 : 0
- target_y += (dir == 8) ? -1 : (dir == 2) ? 1 : 0
- end
- end
- pablo_x = mover.x
- pablo_y = mover.y
- nodes = get_nodes(pablo_x, pablo_y, target_x, target_y, restriction, dir)
- route_nums = []
- for node in nodes
- target_x = node[0]
- target_y = node[1]
- pattern = node[2]
- jog_at = node[3]
- quadrant = target_y > pablo_y ? target_x > pablo_x ? 6 : 5 : target_x > pablo_x ? 8 : 7
- vert = ((target_x - pablo_x).abs < (target_y - pablo_y).abs)
- cardinal = vert ? (target_y > pablo_y ? 1 : 4) : (target_x > pablo_x ? 3 : 2)
- steps = [(target_x - pablo_x).abs, (target_y - pablo_y).abs].max
- if pattern == 1
- jog_length = [(target_x - pablo_x).abs, (target_y - pablo_y).abs].min
- else
- jog_length = ((target_x - pablo_x).abs - (target_y - pablo_y).abs).abs
- end
- nums = pattern == 1 ? [cardinal, quadrant] : [quadrant, cardinal]
- for i in 0...steps
- face_num = cardinal + 15
- if i == jog_at + jog_length
- route_nums.push(face_num) if pattern == 2
- elsif i == jog_at
- route_nums.push(face_num) if pattern == 1
- elsif i == 0
- route_nums.push(face_num) if pattern == 2
- end
- if i >= jog_at
- if i < jog_at + jog_length
- route_nums.push(nums[1])
- else
- route_nums.push(nums[0])
- end
- else
- route_nums.push(nums[0])
- end
- end
- pablo_x = target_x
- pablo_y = target_y
- end
- approach_route = RPG::MoveRoute.new
- approach_route.list = []
- for step in route_nums
- new_step = RPG::MoveCommand.new
- new_step.code = step
- approach_route.list.push(new_step)
- end
- return_nums = []
- for i in route_nums.reverse
- return_step = {1=>4,2=>3,3=>2,4=>1,5=>8,6=>7,7=>6,8=>5,
- 16=>nil,17=>nil,18=>nil,19=>nil}[i]
- return_nums.push(return_step) if !return_step.nil?
- end
- return_route = RPG::MoveRoute.new
- return_route.list = []
- for step in return_nums
- new_step = RPG::MoveCommand.new(step)
- return_route.list.push(new_step)
- end
- approach_route.list.push(RPG::MoveCommand.new)
- return_route.list.push(RPG::MoveCommand.new)
- speed = 3
- approach_route.list.insert(0, RPG::MoveCommand.new(29, [speed]))
- return_route.list.insert(0, RPG::MoveCommand.new(29, [speed]))
- approach_route.repeat = false
- return_route.repeat = false
- @a_route = approach_route
- @r_route = return_route
- end
- #----------------------------------------------------------------------------
- # • Retorna a rota de aproximação.
- #----------------------------------------------------------------------------
- def route_approach
- route = RPG::MoveRoute.new
- route.list = @a_route.list.dup
- route.repeat = false
- return route
- end
- #----------------------------------------------------------------------------
- # • Retorna a rota de retorno do passado.
- #----------------------------------------------------------------------------
- def route_return
- route = RPG::MoveRoute.new
- route.list = @r_route.list.dup
- route.repeat = false
- return route
- end
- end
- #==============================================================================
- # • DRGSS | Comandos do RGSS...
- #==============================================================================
- Dax.register(:DRGSS, "Dax", 0.1)
- module DRGSS
- extend self
- #----------------------------------------------------------------------------
- # • Executar ações...
- #----------------------------------------------------------------------------
- def eval(buffer)
- if (buffer =~ /event_call (\d+)/) # Chamar um evento comum.
- return $game_temp.reserve_common_event($1.to_i)
- end
- eval(buffer)
- end
- #----------------------------------------------------------------------------
- # • Executar ações das variáveis.
- #----------------------------------------------------------------------------
- def var(buffer)
- if buffer =~ /var\[(\d+)\] = (\d+)/ # Igualar valor
- return $game_variables[$1] = $2
- elsif buffer =~ /var\[(\d+)\] += (\d+)/ # Aumentar o valor
- return $game_variables[$1] += $2
- elsif buffer =~ /var\[(\d+)\] *= (\d+)/ # Diminuir o valor
- return $game_variables[$1] -= $2
- elsif buffer =~ /variable\[(\d+)\] = (\d+)/ # Igualar valor
- return $variables[$1] = $2
- elsif buffer =~ /variable\[(\d+)\] += (\d+)/ # Aumentar o valor
- return $variables[$1] += $2
- elsif buffer =~ /variable\[(\d+)\] *= (\d+)/ # Diminuir o valor
- return $variables[$1] -= $2
- end
- return
- end
- #----------------------------------------------------------------------------
- # • Executar ações das switches
- #----------------------------------------------------------------------------
- def switche(buffer)
- end
- #----------------------------------------------------------------------------
- # • Executar as várias funções.
- #----------------------------------------------------------------------------
- def call(buffer)
- var(buffer)
- switche(buffer)
- eval(buffer)
- end
- end
- #==============================================================================
- # • Extension
- #==============================================================================
- # Autor: Dax
- # Versão: 1.0
- # Site: www.dax-soft.weebly.com
- # Requerimento: Dax Core 1.9>
- #==============================================================================
- Dax.register(:Extension, "Dax", Dax::Version_EX)
- #==============================================================================
- # • WC
- #==============================================================================
- module Extension
- extend self
- #----------------------------------------------------------------------------
- # • Variável e constantes.
- #----------------------------------------------------------------------------
- @imported = {} # Importar script.
- @version_imported = {} # Versão do script importado.
- @actor_imported = {} # Autor do script importado.
- #----------------------------------------------------------------------------
- # • Registrar script.
- #----------------------------------------------------------------------------
- def register(name, actor="Dax", version=1.0)
- @imported[name] = true
- @version_imported[name] = version
- @actor_imported[name] = actor
- end
- #----------------------------------------------------------------------------
- # • Cria uma condição de requerimento de script.
- #----------------------------------------------------------------------------
- def required(name, actor="Dax", version=1.0)
- @imported[name] && @version_imported[name] >= version && @actor_imported[name] == name
- end
- end
- #==============================================================================
- # • Mouse Extension | Picture Touch
- #==============================================================================
- Extension.register(:Mouse_Extension, "Dax", 1.0)
- class Touch_Picture < Sprite
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- # name : Nome da picture.
- # x : Posição X da picture.
- # y : Posição Y da picture.
- # z : Altura da picture.
- #----------------------------------------------------------------------------
- def initialize(name="",x=0,y=0,z=0,switche_id=nil)
- super()
- self.bitmap = Cache.picture(name)
- self.x, self.y, self.z = x, y, z
- @clicked = false
- @switche_id = switche_id
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose if !self.bitmap.nil?
- super
- end
- #----------------------------------------------------------------------------
- # • Atualizaçaõ dos objetos.
- # action_clicked : Caso seja um nome em formato de String irá chamar uma
- # scene, caso seja em formato de número irá chamar um evento comum.
- #----------------------------------------------------------------------------
- def update
- self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
- if Mouse.in_area?(self)
- effect_on_area?
- @clicked = trigger?(0x01) or repeat?(0x01)
- action if @clicked && trigger?(0x01) or repeat?(0x01)
- else
- effect_off_area?
- @clicked = false if trigger?(0x01) or repeat?(0x01)
- end
- end
- #----------------------------------------------------------------------------
- # • Acão após o clique na imagem.
- #----------------------------------------------------------------------------
- def action
- end
- #----------------------------------------------------------------------------
- # • Efeito quando estiver na área.
- #----------------------------------------------------------------------------
- def effect_on_area?
- self.opacity = 255
- end
- #----------------------------------------------------------------------------
- # • Efeito quando estiver fora da área.
- #----------------------------------------------------------------------------
- def effect_off_area?
- self.opacity = 128
- end
- end
- #==============================================================================
- # • Simple Touch Picture | Mouse Extension
- #==============================================================================
- Extension.register(:Simple_Touch_Picture, "Dax", 1.0)
- class Simple_Touch_Picture < Touch_Picture
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- # name : Nome da picture.
- # x : Posição X da picture.
- # y : Posição Y da picture.
- # z : Altura da picture.
- # action : Ação após o clique do Mouse.
- #----------------------------------------------------------------------------
- def initialize(action, *args)
- super(*args)
- @action = action
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- super
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- super
- end
- #----------------------------------------------------------------------------
- # • Ação após o clique.
- #----------------------------------------------------------------------------
- def action
- eval(@action.to_s) unless @action.nil?
- end
- #----------------------------------------------------------------------------
- # • Efeito do objeto quando estiver na área.
- #----------------------------------------------------------------------------
- def effect_on_area?
- super
- end
- #----------------------------------------------------------------------------
- # • Efeito do objeto quando estiver fora da área.
- #----------------------------------------------------------------------------
- def effect_off_area?
- super
- end
- #----------------------------------------------------------------------------
- # • Retorna ao conteúdo.
- #----------------------------------------------------------------------------
- def contents
- self
- end
- end
- #==============================================================================
- # • Mouse Extension | Touch Icon
- #==============================================================================
- Extension.register(:Touch_Icon, "Dax", 1.0)
- class Touch_Icon < Sprite
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- # id : ID do ícone no database.
- # x : Posição X do objeto.
- # y : Posição Y do objeto.
- # z : Altura do objeto.
- #----------------------------------------------------------------------------
- def initialize(id=0, x=0, y=0, z=0, switche_id=nil,texts=["", ColorBasic.new(:white), 2],font=["Arial", 16])
- super()
- self.x, self.y, self.z = x, y, z
- self.bitmap = Bitmap.new(24, 24)
- self.bitmap.draw_icon(id.to_i, 0, 0)
- @clicked = false
- @switche_id = switche_id
- unless texts[0].empty?
- @text = Sprite.new
- @text.bitmap = Bitmap.new(100 + texts[0].split(//).size, 24)
- @text.x, @text.y, @text.z = self.x + (28 + texts[2]), self.y + texts[2], self.z
- @text.opacity = 0
- @text.bitmap.draw_text(0, 0, @text.width, @text.height, texts[0].to_s)
- @text.bitmap.font.name, @text.bitmap.font.size = font
- end
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose if !self.bitmap.nil?
- super
- end
- #----------------------------------------------------------------------------
- # • Atualizaçaõ dos objetos.
- # action_clicked : Caso seja um nome em formato de String irá chamar uma
- # scene, caso seja em formato de número irá chamar um evento comum.
- #----------------------------------------------------------------------------
- def update
- self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
- @text.visible = self.visible unless @text.nil?
- if Mouse.in_area?(self)
- @text.opacity = 255 unless @text.nil?
- effect_on_area?
- @clicked = trigger?(0x01) or repeat?(0x01)
- action if @clicked && trigger?(0x01) or repeat?(0x01)
- else
- @text.opacity = 0 unless @text.nil?
- effect_off_area?
- @clicked = false if trigger?(0x01) or repeat?(0x01)
- end
- end
- #----------------------------------------------------------------------------
- # • Acão após o clique na imagem.
- #----------------------------------------------------------------------------
- def action
- @text.visible = false unless @text.nil?
- end
- #----------------------------------------------------------------------------
- # • Efeito quando estiver na área.
- #----------------------------------------------------------------------------
- def effect_on_area?
- self.opacity = 255
- end
- #----------------------------------------------------------------------------
- # • Efeito quando estiver fora da área.
- #----------------------------------------------------------------------------
- def effect_off_area?
- self.opacity = 128
- end
- end
- #==============================================================================
- # • Mouse Extension | Simple Touch Icon
- #==============================================================================
- Extension.register(:Simple_Touch_Icon, "Dax", 1.0)
- class Simple_Touch_Icon < Touch_Icon
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize(action, *args)
- super(*args)
- self.opacity = 128
- @action = action
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- super
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- super
- end
- #----------------------------------------------------------------------------
- # • Ação após o clique.
- #----------------------------------------------------------------------------
- def action
- super
- eval(@action.to_s) unless @action.nil?
- end
- #----------------------------------------------------------------------------
- # • Efeito do objeto quando estiver na área.
- #----------------------------------------------------------------------------
- def effect_on_area?
- super
- end
- #----------------------------------------------------------------------------
- # • Efeito do objeto quando estiver fora da área.
- #----------------------------------------------------------------------------
- def effect_off_area?
- super
- end
- #----------------------------------------------------------------------------
- # • Retorna ao conteúdo.
- #----------------------------------------------------------------------------
- def contents
- self
- end
- end
- #==============================================================================
- # • Mouse Extension | Touch Text
- #==============================================================================
- Extension.register(:Touch_Text, "Dax", 1.0)
- class Touch_Text < Sprite
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- # id : ID do ícone no database.
- # x : Posição X do objeto.
- # y : Posição Y do objeto.
- # z : Altura do objeto.
- #----------------------------------------------------------------------------
- def initialize(text="", x=0, y=0, z=0, switche_id=nil,color=[ColorBasic.new(:white), ColorBasic[7]],font=["Arial", 16],align=0)
- super()
- self.x, self.y, self.z = x, y, z
- self.bitmap = Bitmap.new(font[1] + (text.split(//).size ** 2), font[1])
- self.bitmap.draw_text(0, 0, self.width, self.height, text, align)
- @clicked = false
- @switche_id = switche_id
- @color = color
- self.bitmap.font.name, self.bitmap.font.size = font
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- self.bitmap.dispose if !self.bitmap.nil?
- super
- end
- #----------------------------------------------------------------------------
- # • Atualizaçaõ dos objetos.
- # action_clicked : Caso seja um nome em formato de String irá chamar uma
- # scene, caso seja em formato de número irá chamar um evento comum.
- #----------------------------------------------------------------------------
- def update
- self.visible = !$game_switches[@switche_id] unless @switche_id.nil?
- if Mouse.in_area?(self)
- effect_on_area?
- @clicked = trigger?(0x01) or repeat?(0x01)
- action if @clicked && trigger?(0x01) or repeat?(0x01)
- else
- effect_off_area?
- @clicked = false if trigger?(0x01) or repeat?(0x01)
- end
- end
- #----------------------------------------------------------------------------
- # • Acão após o clique na imagem.
- #----------------------------------------------------------------------------
- def action
- end
- #----------------------------------------------------------------------------
- # • Efeito quando estiver na área.
- #----------------------------------------------------------------------------
- def effect_on_area?
- self.color = @color[1]
- end
- #----------------------------------------------------------------------------
- # • Efeito quando estiver fora da área.
- #----------------------------------------------------------------------------
- def effect_off_area?
- self.color = @color[0]
- end
- end
- #==============================================================================
- # • Mouse Extension | Simple Touch Icon
- #==============================================================================
- Extension.register(:Simple_Touch_Icon, "Dax", 1.0)
- class Simple_Touch_Text < Touch_Text
- #----------------------------------------------------------------------------
- # • Inicialização dos objetos.
- #----------------------------------------------------------------------------
- def initialize(action, *args)
- super(*args)
- @action = action
- end
- #----------------------------------------------------------------------------
- # • Renovação dos objetos.
- #----------------------------------------------------------------------------
- def dispose
- super
- end
- #----------------------------------------------------------------------------
- # • Atualização dos objetos.
- #----------------------------------------------------------------------------
- def update
- super
- end
- #----------------------------------------------------------------------------
- # • Ação após o clique.
- #----------------------------------------------------------------------------
- def action
- eval(@action.to_s) unless @action.nil?
- end
- #----------------------------------------------------------------------------
- # • Efeito do objeto quando estiver na área.
- #----------------------------------------------------------------------------
- def effect_on_area?
- super
- end
- #----------------------------------------------------------------------------
- # • Efeito do objeto quando estiver fora da área.
- #----------------------------------------------------------------------------
- def effect_off_area?
- super
- end
- #----------------------------------------------------------------------------
- # • Retorna ao conteúdo.
- #----------------------------------------------------------------------------
- def contents
- self
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement