#============================================================================== # Scene KeyConfig [XP] #------------------------------------------------------------------------------ # Cria uma tela no jogo onde é possível configurar os botões do RPG Maker XP. #------------------------------------------------------------------------------ # Autor: Kyo Panda (http://www.mundorpgmaker.com.br/) # Autor do módulo Input: AWorks # Versão: 1.0 # Lançado em: 21/05/2010 #============================================================================== #============================================================================== # Agradecimentos: #------------------------------------------------------------------------------ # * AWorks: Pelo módulo completo Input. Sem isso, a criação do script se # tornaria impossível. #============================================================================== #============================================================================== # Como usar: #------------------------------------------------------------------------------ # # #-------------------------------------------------------------------------- # # Instalação # #-------------------------------------------------------------------------- # # Cole o arquivo "AWorks.dll" na pasta do seu projeto. # # Cole o script do menu acima "Main" e abaixo das "Scene_" no Editor de # Scripts do RPG Maker XP. # # Configure o script como desejar no guia "Configuração" logo abaixo. # # #-------------------------------------------------------------------------- # # Utilização # #-------------------------------------------------------------------------- # # Simplesmente utilize o seguinte código no "Comando de Evento" # "Chamar Script" em um evento qualquer: # # KeyConfig.call # * Para chamar as configurações de botões. # #============================================================================== #============================================================================== # KeyConfig_Set #------------------------------------------------------------------------------ # Módulo do configuração do script Scene KeyConfig. #============================================================================== module KeyConfig_Set #-------------------------------------------------------------------------- # Configurações avançadas #-------------------------------------------------------------------------- # Defina aqui o nome da fonte utilizada no menu. # A fonte será lida por ordem de index na array, se a primeira fonte não # existir ele procurará a segunda e assim em diante. MENU_FONT = ["UmePlus Gothic", "Calibri", "Verdana"] # Aqui você pode definir se algumas janelas serão ativadas ou não. # Defina true para ativada e false para desativada. MNWA = true # Janela com o nome do menu # Se definiu utilizar a janela com o nome do menu, defina aqui qual nome # ela deve conter. # Lembre-se que o nome deve estar contido entre aspas ("") ou # apóstrofes para serem considerado textos pelo RPG Maker XP. MENU_NAME = "Configuração de botões" # Defina aqui as strings (textos) exibidos pelo script. # Lembre-se que elas devem estar contidas entre aspas ("") ou apóstrofes # ('') para que sejam compreendidas como texto pelo RPG Maker XP. ACTION = "Funções" # Funções FIRST = "1º" # Primeiro botão SECOND = "2º" # Segundo botão THIRD = "3º" # Terceiro botão ACTION_CONFIRM = "Confirmar/Ação" # Confirmar ACTION_CANCEL = "Cancelar/Menu" # Cancelar ACTION_PAGE_UP = "Próximo Página" # Próxima página ACTION_PAGE_DOWN = "Página anterior" # Página anterior ACTION_DEFAULT = "Padrão" # Padrão DEFINE_KEYS = "Pressione a tecla desejada" # Pergunta sobre a tecla RETURN_DEFAULT = "Deseja retornar as teclas ao padrão?" # Pergunta padrão ANSWER_A = "Sim" # Resposta afirmativa ANSWER_B = "Não" # Resposta negativa # Defina aqui a opacidade das janelas do script. # Esta opção é útil caso você queira inserir uma imagem de fundo no menu # ao invés de utilizar janelas. # 0 : Transparente, 255 : Opaco. MENU_OPACITY = 255 # Defina aqui o posicionamento de cada janela do script. # Defina os valores de X (posicionamento horizontal), Y (posicionamento # vertical), largura e altura das janelas respectivamente. # [ X , Y , Lar, Alt] MNWV = [ 0, 80, 640, 64] # Janela com o nome do menu MKWV = [ 0, 144, 640, 264] # Janela de configuração de botões #-------------------------------------------------------------------------- # Fim da configuração #-------------------------------------------------------------------------- end #-------------------------------------------------------------------------- # Insere a string "Scene_KeyConfig" na hash $kpanda_scripts #-------------------------------------------------------------------------- $kpanda_scripts = {} if $kpanda_scripts.nil? $kpanda_scripts["Scene_KeyConfig"] = true #============================================================================== # KeyConfig #------------------------------------------------------------------------------ # Módulo que facilita a chamada do Scene KeyConfig. #============================================================================== module KeyConfig #-------------------------------------------------------------------------- # Chama a Scene KeyConfig #-------------------------------------------------------------------------- def self.call $scene = Scene_KeyConfig.new end end #============================================================================== # AWorks Library (ALibrary) [XP] [VX] #------------------------------------------------------------------------------ # Este script é uma compilação de ferramentas úteis criadas e desenhadas para # serem usados em conjunto com os scripts do AWorks. No entanto, algumas # funções podem ser úteis para outros propósitos e scripts. #------------------------------------------------------------------------------ # Autor: AWorks # Versão: 1.03 # Atualização: 26/01/2009 # Tradução PT: Kyo Panda (http://www.mundorpgmaker.com.br/) #============================================================================== #============================================================================== # Agradecimentos: #------------------------------------------------------------------------------ # * Ruby 1.8 # - Classe Win32::Registry, base do AWorks::Registry # * Nishikawa, Yasuhiro # - APIs para AWorks::Clipboard #============================================================================== #============================================================================== # Requerimentos: #------------------------------------------------------------------------------ # * AWorks.dll (Coloque-a na pasta do seu projeto) # - Versão: 1.00 #============================================================================== #============================================================================== # Funções: #------------------------------------------------------------------------------ # * AWorks::Ini.get_string(id[, tag[, arquivo]]) # Adquire a string do campo id da seção tag do arquivo .ini. # # * AWorks::Ini.set_string(string, id, [, tag[, arquivo]]) # Define a string no campo id da seção tag do arquivo .ini. # # * AWorks::Clipboard.read # Adquire os dados da área de transferência. # # * AWorks::Clipboard.write(string) # Define uma string à área de transferência # # * AWorks::Clipboard.empty # Apaga os dados da área de transferência # # * AWorks::Registry.read_value(chave, entrada) # Lê o valor da entrada do registro sob determinada chave. # # * AWorks::Registry.enum_keys(chave) # Enumera todas as sub-chaves de determinada chave. # # * AWorks::Registry.enum_values(chave) # Enumera todas as entradas de determinada chave. # # * AWorks::Registry.create_key(chave) # Cria uma sub-chave em determinada chave. # # * AWorks::Registry.set_value(chave, valor[, tipo]) # Define (ou cria) o valor. # # * AWorks::Registry.delete_key(chave[, recursiva]) # Deleta a sub-chave. # # * AWorks::Registry.delete_value(chave) # Deleta o valor. # # * AWorks.get_fonts_names # Retorna o nome das fontes da pasta de fontes do Windows. # # * AWorks.get_hwnd # Retorna o index do HWND do jogador. # # * AWorks.get_rgssdll # Retorna o nome da dll RGSS. # # * AWorks.get_rtp_path([id]) # Retorna o caminho do rtp de determinado id. # # * AWorks.get_mouse_swap_buttons_flag # Retorna os valores dos botões do mouse. # # * Array.recursive_clone # Clona a Array e todos os seus sub-elementos. # # * Array.to_hash # Converte a Array em Hash. # # * Array.rindexes(*valores) # Adquire os indexes dos valores. # # * Array.deep # Adquire o fim da array. O fim é definido como o máximo de subconteiners # (Arrays e Hashes) dentro da Array. # # * Array.recursive_flatten # Chama o método flatten à Array e todos os seus sub-elementos. # # * Array.recursive_flatten! # Chama o método flatten! à Array e todos os seus sub-elementos. # # * Array.insert(i, objeto) # Insere o objeto na Array no index i. # # * Hash.recursive_clone # Clona a hash e todos os seus sub-elementos. # # * Hash.deep(máximo = -1) # Adquire o fim da hash. O fim é definido como o máximo de subconteiners # (Arrays e Hashes) dentro da Hash. # # * Hash.fusion # Faz uma array da hash combinando cada chave e valor. # # * NilClass.clone # Método vazio permitindo clonar objetos nulos. # # * Math.radian2degree(r) # Converte o valor radiano para graus. # # * Math.degree2radian(g) # Converte o valor em graus para radiano. # # * Math.quick_cos(i) # Calcula o valor do cosseno do Integer. Mais rápido do que Math.cos. # # * Math.quick_sin(i) # Calcula o valor do seno do Integer. Mais rápido do que Math.sin. # # * String.pixel_width(fonte) # Calcula a largura da string da fonte dada em pixels. # # * String.pixel_width(fonte, tamanho, negrito) # Calcula a largura da string da fonte dada em pixels. # # * String.pixel_height(fonte) # Calcula a altura da string da fonte dada em pixels. # # * String.pixel_height(fonte, tamanho, negrito) # Calcula a altura da string da fonte dada em pixels. # # * String.width_slice(largura, fonte) # Retorna uma array com a string dividida em peças que caibam com a largura # dada com a fonte dada. # # * String.width_slice(largura, fonte, tamanho, negrito) # Retorna uma array com a string dividida em peças que caibam com a largura # dada com a fonte dada. # # * String.font_size_width(largura, fonte) # Adquire o tamanho máximo da fonte para a string caber em dada largura com # a mesma fonte. O tamanho da fonte não importa. # # * String.font_size_width(largura, fonte, negrito) # Adquire o tamanho máximo da fonte para a string caber em dada largura com # a mesma fonte. O tamanho da fonte não importa. # # * String.font_size_height(altura, fonte) # Adquire o tamanho máximo da fonte para a string caber em dada altura com # a mesma fonte. O tamanho da fonte não importa. # # * String.font_size_height(altura, fonte, negrito) # Adquire o tamanho máximo da fonte para a string caber em dada altura com # a mesma fonte. O tamanho da fonte não importa. # # * String.font_size(largura, altura, fonte) # Adquire o tamanho máximo da fonte para a string caber em dada largura e # com altura com a mesma fonte. O tamanho da fonte não importa. # # * String.font_size(width, height, name, bold) # Adquire o tamanho máximo da fonte para a string caber em dada largura e # com altura com a mesma fonte. O tamanho da fonte não importa. # # * Bitmap.adraw_text(*args) # Desenha um bitmap como Bitmap.draw_text, mas com algumas funções # especiais. # # * Graphics.auto_update (Propriedade) # Uma array. Atualiza os objetos e métodos contidos em cada frame. Para # adicionar um objeto de ser auto-atualizado, adicione uma Array para o # Graphics.auto_update com o seguinte formato: # [objeto, método, frames] # O objeto deve ser uma classe e o método um símbolo. Se frames for nil, a # auto-atualizaçãp ececutará com frames indeterminados (pode ser removida # com .delete(método)). # Se isto for um Integer, isto irá agir num efeito decrescente para cada # frame, e a auto-atualização se findará quando for 0. #============================================================================== #============================================================================== # AWorks #------------------------------------------------------------------------------ # Módulo que armazena as configurações para os scripts do AWorks. #============================================================================== module AWorks module_function #============================================================================== # API #------------------------------------------------------------------------------ # Módulo que armazena os recursos API. #============================================================================== module_function module API #-------------------------------------------------------------------------- # Declaração API da dll AWorks #-------------------------------------------------------------------------- Initialize = Win32API.new('AWorks', 'Initialize', 'L', '') InputIni = Win32API.new('AWorks', 'InputInitialize', 'LLLLLL', '') InputUpdate = Win32API.new('AWorks', 'InputUpdate', '', '') InputMouseIni = Win32API.new('AWorks', 'InputMouseInitialize', 'LLL', '') InputMouseConfig = Win32API.new('AWorks', 'InputMouseConfig', 'LLLL', '') BitmapRotate = Win32API.new('AWorks', 'BitmapRotate', 'LLL', '') #--------------------------------------------------------------------------- # Declaração API #--------------------------------------------------------------------------- BlockInput = Win32API.new('user32', 'BlockInput', 'L', 'L') ClientToScreen = Win32API.new('user32', 'ClientToScreen', 'LP', 'L') CloseClipboard = Win32API.new('user32', 'CloseClipboard', '', 'L') ClipCursor = Win32API.new('user32', 'ClipCursor', 'P', 'L') EmptyClipboard = Win32API.new('user32', 'EmptyClipboard', '', 'L') FindWindowA = Win32API.new('user32', 'FindWindowA', 'pp', 'l') GetActiveWindow = Win32API.new('user32', 'GetActiveWindow', '', 'L') GetAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'L') GetClientRect = Win32API.new('user32', 'GetClientRect', 'LP', 'L') GetClipboardData = Win32API.new('user32', 'GetClipboardData', 'L', 'L') GetCursorPos = Win32API.new('user32', 'GetCursorPos', 'P', 'L') GetDoubleClickTime = Win32API.new('user32', 'GetDoubleClickTime', '', 'L') GetKeyboardLayout = Win32API.new('user32', 'GetKeyboardLayout','L', 'L') GetKeyboardLayoutName =Win32API.new('user32','GetKeyboardLayoutName','P','L') GetKeyboardState = Win32API.new('user32', 'GetKeyboardState', 'P', 'L') GetKeyState = Win32API.new('user32', 'GetKeyState', 'L', 'L') GetSystemMetrics = Win32API.new('user32', 'GetSystemMetrics', 'L', 'L') GetWindowPlacement = Win32API.new('user32', 'GetWindowPlacement', 'LP', 'L') Keybd_Event = Win32API.new('user32', 'keybd_event', 'LLLL', '') OpenClipboard = Win32API.new('user32', 'OpenClipboard', 'L', 'L') ScreenToClient = Win32API.new('user32', 'ScreenToClient', 'LP', 'L') SetClipboardData = Win32API.new('user32', 'SetClipboardData', 'LL', 'L') ShowCursor = Win32API.new('user32', 'ShowCursor', 'L', 'L') SwapMouseButton = Win32API.new('user32', 'SwapMouseButton', 'L', 'L') ToAsciiEx = Win32API.new('user32', 'ToAsciiEx', 'LLPPLL', 'L') GetCurrentProcessId = Win32API.new('kernel32','GetCurrentProcessId', '','L') GPPSA = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L') WPPSA = Win32API.new('kernel32', 'WritePrivateProfileStringA', 'PPPP', 'L') GlobalAlloc = Win32API.new('kernel32', 'GlobalAlloc', 'LL', 'L') GlobalLock = Win32API.new('kernel32', 'GlobalLock', 'L', 'L') GlobalSize = Win32API.new('kernel32', 'GlobalSize', 'L', 'L') GlobalUnlock = Win32API.new('kernel32', 'GlobalUnlock', 'L', '') RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L') RegEnumKeyExA = Win32API.new('advapi32', 'RegEnumKeyExA', 'LLPPLLLP', 'L') RegEnumValueA = Win32API.new('advapi32', 'RegEnumValueA', 'LLPPPPPP', 'L') RegOpenKeyExA = Win32API.new('advapi32', 'RegOpenKeyExA', 'LPLLP', 'L') RegQueryValueExA = Win32API.new('advapi32', 'RegQueryValueExA','LPLPPP', 'L') RegDeleteValue = Win32API.new('advapi32', 'RegDeleteValue','LP', 'L') RegDeleteKey = Win32API.new('advapi32', 'RegDeleteKey','LP', 'L') begin Memcpy = Win32API.new('ntdll', 'memcpy', 'PPL', 'L') rescue Memcpy = Win32API.new('crtdll', 'memcpy', 'PPL', 'L') end dll = "\0" * 255 GPPSA.call('Game', 'Library', '', dll, 255, '.\\Game.ini') dll.delete!("\0") RGSSGetRTPPath = Win32API.new(dll, 'RGSSGetRTPPath', 'L', 'L') RGSSGetPathWithRTP = Win32API.new(dll, 'RGSSGetPathWithRTP', 'L', 'P') end #============================================================================== # Ini #------------------------------------------------------------------------------ # Módulo que domina o arquivo .ini do RPG Maker VX. #============================================================================== module Ini module_function #-------------------------------------------------------------------------- # Adquire a string do arquivo .ini #-------------------------------------------------------------------------- def get_string(id, tag = 'Game', file = '.\\Game.ini') buffer = "\0" * 255 API::GPPSA.call(tag, id, '', buffer, 255, file) buffer.delete!("\0") end #------------------------------------------------------------------------- # Escreve a string no arquivo .ini #------------------------------------------------------------------------- def set_string(string, id, tag = 'Game', file = '.\\Game.ini') API::WPPSA.call(tag, id, string, file) end end #============================================================================== # Clipboard #------------------------------------------------------------------------------ # Módulo que gerencia as informações da área de transferência do Windows. #============================================================================== module Clipboard module_function #-------------------------------------------------------------------------- # Lê os dados da área de transferência #-------------------------------------------------------------------------- def read API::OpenClipboard.call(0) data = API::GetClipboardData.call(7) API::CloseClipboard.call return '' if data == 0 lp = API::GlobalLock.call(data) len = API::GlobalSize.call(data) data2 = ' ' * (len - 1) API::Memcpy.call(data2, lp, len) API::GlobalUnlock.call(data) data2 end #-------------------------------------------------------------------------- # Escreve dados na área de transferência #-------------------------------------------------------------------------- def write(data) API::OpenClipboard.call(0) API::EmptyClipboard.call set_data = API::GlobalAlloc.call(66, data.length + 1) len = [data.size + 1, API::GlobalSize.call(set_data)].min lp = API::GlobalLock.call(set_data) API::Memcpy.call(lp, "#{data}", len) API::GlobalUnlock.call(set_data) API::SetClipboardData.call(7, set_data) API::CloseClipboard.call end #------------------------------------------------------------------------- # Apaga os dados da área de transferência #------------------------------------------------------------------------- def empty API::EmptyClipboard.call end end #============================================================================== # Registry #------------------------------------------------------------------------------ # Módulo que comanda os registros inseridos pelo RPG Maker VX. #============================================================================== module Registry module_function T_AUTO = -1 T_SZ = 1 T_BINARY = 3 T_DWORD = 4 HKEYS = {'HKEY_CLASSES_ROOT' => 0x80000000,'HKEY_CURRENT_USER' =>0x80000001, 'HKEY_LOCAL_MACHINE' => 0x80000002, 'HKEY_USERS' => 0x80000003, 'HKEY_CURRENT_CONFIG' => 0x80000005} #-------------------------------------------------------------------------- # Lê um valor #-------------------------------------------------------------------------- def read_value(key, entry) key.sub!(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end opened, type, size = [0].pack('V'), [0].pack('V'), [0].pack('V') API::RegOpenKeyExA.call(hkey, key, 0, 131097, opened) opened = (opened + [0].pack('V')).unpack('V')[0] API::RegQueryValueExA.call(opened, entry, 0, type, 0, size) data = ' ' * (size + [0].pack('V')).unpack('V')[0] API::RegQueryValueExA.call(opened, entry, 0, type, data, size) API::RegCloseKey.call(opened) data = data[0, (size + [0].pack('V')).unpack('V')[0]] type = (type += [0].pack('V')).unpack('V')[0] case type when 1 data.chop when 2 data.chop.gsub(/%([^%]+)%/) { ENV[$1] || $& } when 3 data when 4 (data += [0].pack('V')).unpack('V')[0] when 5 data.unpack('N')[0] when 7 data.split(/\0/) when 11 (data.unpack('VV')[1] << 32) | data[0] else nil end end #-------------------------------------------------------------------------- # Enumera chaves #-------------------------------------------------------------------------- def enum_keys(key) key.sub!(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end index, keys, opened = 0, [], [0].pack('V') API::RegOpenKeyExA.call(hkey, key, 0, 131097, opened) opened = (opened + [0].pack('V')).unpack('V')[0] loop do name = ' ' * 514 size = [514].pack('V') result = API::RegEnumKeyExA.call(opened, index, name, size, 0, 0, 0, 0) if result == 0 keys.push(name[0, (size += [0].pack('V')).unpack('V')[0]]) index += 1 else break end end API::RegCloseKey.call(opened) keys end #-------------------------------------------------------------------------- # Enumera valores #-------------------------------------------------------------------------- def enum_values(key) key.sub!(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end index, entries, opened = 0, [], [0].pack('V') API::RegOpenKeyExA.call(hkey, key, 0, 131097, opened) opened = (opened + [0].pack('V')).unpack('V')[0] loop do name = ' ' * 514 size = [514].pack('V') result = API::RegEnumValueA.call(opened, index, name, size, 0, 0, 0, 0) if result == 0 entries.push(name[0, (size += [0].pack('V')).unpack('V')[0]]) index += 1 else break end end API::RegCloseKey.call(opened) entries end #-------------------------------------------------------------------------- # Cria uma chave #-------------------------------------------------------------------------- def create_key(key) key.sub!(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end result = [0].pack('V') disp = [0].pack('V') API::RegCreateKeyExA.call(hkey, key, 0, 0, 0, 131135, 0, result, disp) if [disp + [0].pack('V')].unpack('V')[0] == 2 API::RegCloseKey.call(result) end end #-------------------------------------------------------------------------- # Define um valor #-------------------------------------------------------------------------- def set_value(key, value, type = T_AUTO) key.sub!(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end if type == T_AUTO if value.is_a?(Numeric) type = T_DWORD else type = T_SZ value = value.to_s end end case type when 1, 2 value = value.to_s + "\0" when 7 value = value.to_a.join("\0") + "\0\0" when 3 value = value.to_s when 4 value = [value.to_i].pack('V') when 5 value = [value.to_i].pack('N') when 11 value = [value.to_i & 0xFFFFFFFF, value.to_i >> 32 ].pack('VV') end API::RegSetValueExA.call(hkey, key, 0, type, value, value.length) end #-------------------------------------------------------------------------- # Deleta uma chave #-------------------------------------------------------------------------- def delete_key(key, recursive = false) skey = key.sub(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end if recursive else API::RegDeleteKey.call(hkey, key) end end #-------------------------------------------------------------------------- # Deleta um valor #-------------------------------------------------------------------------- def delete_value(key) key.sub!(/(.*?)\\/, '') if !HKEYS[$1].nil? hkey = HKEYS[$1] else return nil end API::RegDeleteValue.call(hkey, key) end end #-------------------------------------------------------------------------- # Declaração das variáveis #-------------------------------------------------------------------------- ASCII_TABLE = {1=>'☺',2=>'☻',3=>'♥',4=>'♦',5=>'♣',6=>'♠',7=>'•',8=>'◘',9=>'○', 10=>'◙',11=>'♂',12=>'♀',13=>'♪',14=>'♫',15=>'¤',16=>'►',17=>'◄',18=>'↕', 19=>'‼',20=>'¶',21=>'§',22=>'▬',23=>'↨',24=>'↑',25=>'↓',26=>'→',27=>'←', 28=>'∟',29=>'↔',30=>'▲',31=>'▼',32=>' ',33=>'!',34=>'"',35=>'#',36=>'$', 37=>'%',38=>'&',39=>"'",40=>'(',41=>')',42=>'*',43=>'+',44=>',',45=>'-', 46=>'.',47=>'/',48=>'0',49=>'1',50=>'2',51=>'3',52=>'4',53=>'5',54=>'6', 55=>'7',56=>'8',57=>'9',58=>':',59=>';',60=>'<',61=>'=',62=>'>',63=>'?', 64=>'@',65=>'A',66=>'B',67=>'C',68=>'D',69=>'E',70=>'F',71=>'G',72=>'H', 73=>'I',74=>'J',75=>'K',76=>'L',77=>'M',78=>'N',79=>'O',80=>'P',81=>'Q', 82=>'R',83=>'S',84=>'T',85=>'U',86=>'V',87=>'W',88=>'X',89=>'Y',90=>'Z', 91=>'[',92=>'\\',93=>']',94=>'^',95=>'_',96=>'`',97=>'a',98=>'b',99=>'c', 100=>'d',101=>'e',102=>'f',103=>'g',104=>'h',105=>'i',106=>'j',107=>'k', 108=>'l',109=>'m',110=>'n',111=>'o',112=>'p',113=>'q',114=>'r',115=>'s', 116=>'t',117=>'u',118=>'v',119=>'w',120=>'x',121=>'y',122=>'z',123=>'{', 124=>'|',125=>'}',126=>'~',127=>'¦',128=>'Ç',129=>'ü',130=>'é',131=>'â', 132=>'ä',133=>'à',134=>'å',135=>'ç',136=>'ê',137=>'ë',138=>'è',139=>'ï', 140=>'î',141=>'ì',142=>'Ä',143=>'Å',144=>'É',145=>'æ',146=>'Æ',147=>'ô', 148=>'ö',149=>'ò',150=>'û',151=>'ù',152=>'ÿ',153=>'Ö',154=>'Ü',155=>'ø', 156=>'£',157=>'Ø',158=>'×',159=>'ƒ',160=>'á',161=>'í',162=>'ó',163=>'ú', 164=>'ñ',165=>'Ñ',166=>'ª',167=>'º',168=>'¿',169=>'®',170=>'¬',171=>'½', 172=>'¼',173=>'¡',174=>'«',175=>'»',176=>'¦',177=>'¦',178=>'¦',179=>'¦', 180=>'¦',181=>'Á',182=>'Â',183=>'À',184=>'©',185=>'¦',186=>'¦',187=>'+', 188=>'+',189=>'¢',190=>'¥',191=>'+',192=>'+',193=>'-',194=>'-',195=>'+', 196=>'-',197=>'+',198=>'ã',199=>'Ã',200=>'+',201=>'+',202=>'-',203=>'-', 204=>'¦',205=>'-',206=>'+',207=>'¤',208=>'ð',209=>'Ð',210=>'Ê',211=>'Ë', 212=>'È',213=>'i',214=>'Í',215=>'Î',216=>'Ï',217=>'+',218=>'+',219=>'¦', 220=>'_',221=>'¦',222=>'Ì',223=>'¯',224=>'Ó',225=>'ß',226=>'Ô',227=>'Ò', 228=>'õ',229=>'Õ',230=>'µ',231=>'þ',232=>'Þ',233=>'Ú',234=>'Û',235=>'Ù', 236=>'ý',237=>'Ý',238=>'¯',239=>'´',240=>'­',241=>'±',242=>'=',243=>'¾', 244=>'¶',245=>'§',246=>'÷',247=>'¸',248=>'°',249=>'¨',250=>'·',251=>'¹', 252=>'³',253=>'²',254=>'¦',255=>' '} TRANSLATE_TABLE ={"\225"=>'•',"\244"=>'¤',"\266"=>'¶',"\247"=>'§',"\307"=>'Ç', "\374"=>'ü',"\351"=>'é',"\342"=>'â',"\344"=>'ä',"\340"=>'à',"\345"=>'å', "\347"=>'ç',"\352"=>'ê',"\353"=>'ë',"\350"=>'è',"\357"=>'ï',"\356"=>'î', "\354"=>'ì',"\304"=>'Ä',"\305"=>'Å',"\311"=>'É',"\346"=>'æ',"\306"=>'Æ', "\364"=>'ô',"\366"=>'ö',"\362"=>'ò',"\373"=>'û',"\371"=>'ù',"\377"=>'ÿ', "\326"=>'Ö',"\334"=>'Ü',"\370"=>'ø',"\243"=>'£',"\330"=>'Ø',"\327"=>'×', "\203"=>'ƒ',"\341"=>'á',"\355"=>'í',"\363"=>'ó',"\372"=>'ú',"\361"=>'ñ', "\321"=>'Ñ',"\252"=>'ª',"\272"=>'º',"\277"=>'¿',"\256"=>'®',"\254"=>'¬', "\275"=>'½',"\274"=>'¼',"\241"=>'¡',"\253"=>'«',"\273"=>'»',"\301"=>'Á', "\302"=>'Â',"\300"=>'À',"\251"=>'©',"\242"=>'¢',"\245"=>'¥',"\343"=>'ã', "\303"=>'Ã',"\244"=>'¤',"\360"=>'ð',"\320"=>'Ð',"\312"=>'Ê',"\313"=>'Ë', "\310"=>'È',"\315"=>'Í',"\316"=>'Î',"\317"=>'Ï',"\314"=>'Ì',"\257"=>'¯', "\323"=>'Ó',"\337"=>'ß',"\324"=>'Ô',"\322"=>'Ò',"\365"=>'õ',"\325"=>'Õ', "\265"=>'µ',"\376"=>'þ',"\336"=>'Þ',"\332"=>'Ú',"\333"=>'Û',"\331"=>'Ù', "\375"=>'ý',"\335"=>'Ý',"\257"=>'¯',"\264"=>'´',"\255"=>'­',"\261"=>'±', "\276"=>'¾',"\266"=>'¶',"\247"=>'§',"\367"=>'÷',"\270"=>'¸',"\260"=>'°', "\250"=>'¨',"\267"=>'·',"\271"=>'¹',"\263"=>'³',"\262"=>'²',"\240"=>' ', "\t"=>' ',"\200"=>'€'} #-------------------------------------------------------------------------- # Adquire o nome das fontes #-------------------------------------------------------------------------- def get_fonts_names key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\#{ENV['OS'].sub(/_/,' ')}\\" fonts = Registry.enum_values(key + 'CurrentVersion\\Fonts') fonts.each_index {|f| fonts[f].sub!(' (TrueType)', '') fonts[f] = nil if !Font.exist?(fonts[f]) }.delete(nil) fonts end #-------------------------------------------------------------------------- # Adquire o index HWND do Player RGSS #-------------------------------------------------------------------------- def get_hwnd if @hwnd.nil? @hwnd = API::FindWindowA.call('RGSS Player', Ini.get_string('Title')) else @hwnd end end #-------------------------------------------------------------------------- # Adquire a dll RGSS #-------------------------------------------------------------------------- def get_rgssdll Ini.get_string('Library') end #-------------------------------------------------------------------------- # Adquire o caminho do RTP #-------------------------------------------------------------------------- def get_rtp_path(rtp = 0) API::RGSSGetPathWithRTP.call(API::RGSSGetRTPPath.cal(rtp)) end #-------------------------------------------------------------------------- # Adquire a troca dos botões do mouse #-------------------------------------------------------------------------- def get_mouse_swap_buttons_flag result = API::SwapMouseButton.call(0) if result == 0 API::SwapMouseButton.call(0) 0 else API::SwapMouseButton.call(1) 1 end end #-------------------------------------------------------------------------- # Inicialização da livraria AWorks #-------------------------------------------------------------------------- API::Initialize.call(self.get_hwnd) end #============================================================================== # Array #------------------------------------------------------------------------------ # Classe das arrays. #============================================================================== class Array #-------------------------------------------------------------------------- # Clone recursivo #-------------------------------------------------------------------------- def recursive_clone clon = self.clone clon.each_index do |i| clon[i] = clon[i].recursive_clone rescue clon[i].clone rescue clon[i] end clon end alias_method(:rclone, :recursive_clone) #-------------------------------------------------------------------------- # Para Hash #-------------------------------------------------------------------------- def to_hash hash = Hash.new self.each_index {|i| hash[i] = self[i]} hash end #-------------------------------------------------------------------------- # Indexes reservados #-------------------------------------------------------------------------- def rindexes(*values) array = Array.new self.each_index {|i| array.push(i) if values.include?(self[i])} array end #-------------------------------------------------------------------------- # Máximo #-------------------------------------------------------------------------- def deep(deep = -1) tmp_deep = deep + 1 deep = tmp_deep self.each do |i| deep = i.deep(tmp_deep) if deep < i.deep(tmp_deep) rescue nil end deep end #-------------------------------------------------------------------------- # Flatten Recursivo #-------------------------------------------------------------------------- def recursive_flatten array = self.recursive_clone array.each_index do |i| array[i] = array[i].to_a if array[i].is_a?(Hash) array[i] = array[i].recursive_flatten rescue array[i] end array.flatten! array end alias_method(:rflatten, :recursive_flatten) #-------------------------------------------------------------------------- # Flatten Recursivo Destrutivo #-------------------------------------------------------------------------- def recursive_flatten! self.each_index do |i| self[i] = self[i].to_a if self[i].is_a?(Hash) self[i] = self[i].recursive_flatten! rescue self[i] end self.flatten! self end alias_method(:rflatten!, :recursive_flatten!) =begin #-------------------------------------------------------------------------- # Inserir #-------------------------------------------------------------------------- def insert(i, obj) if i == 0 obj + self elsif i == self.size self + obj elsif self.size < i self + Array.new(i - self.size) + obj else self[0, i - 1] + obj + self[i, self.size] end end =end end #============================================================================== # Hash #------------------------------------------------------------------------------ # Classe que gerencia as hashs. #============================================================================== class Hash #-------------------------------------------------------------------------- # Clone recursivo #-------------------------------------------------------------------------- def recursive_clone clon = self.clone clon.each_key do |i| clon[i] = clon[i].recursive_clone rescue clon[i].clone rescue clon[i] end clon end alias_method(:rclone, :recursive_clone) #-------------------------------------------------------------------------- # Máximo #-------------------------------------------------------------------------- def deep(deep = -1) tmp_deep = deep + 1 key_deep = tmp_deep value_deep = tmp_deep self.each do |k, v| key_deep = k.deep(tmp_deep) if key_deep < k.deep(tmp_deep) rescue nil value_deep = v.deep(tmp_deep) if value_deep < v.deep(tmp_deep) rescue nil end if key_deep > value_deep key_deep else value_deep end end #-------------------------------------------------------------------------- # Para Array, combinando chave e valor #-------------------------------------------------------------------------- def fusion array = self.sort array.each_index do|i| array[i] = array[i][0] + array[i][1] rescue array[i] end array end end #============================================================================== # NilClass #------------------------------------------------------------------------------ # Classe que comanda todo e qualquer objeto nulo. #============================================================================== class NilClass #-------------------------------------------------------------------------- # Clonar #-------------------------------------------------------------------------- def clone;end end #============================================================================== # Math #------------------------------------------------------------------------------ # Classe que opera as equações matemáticas. #============================================================================== module Math #-------------------------------------------------------------------------- # Radiano para graus #-------------------------------------------------------------------------- def Math.radian2degree(r) r * 180 / Math::PI end #-------------------------------------------------------------------------- # Graus para radiano #-------------------------------------------------------------------------- def Math.degree2radian(g) g * Math::PI / 180 end #-------------------------------------------------------------------------- # Cosseno e seno rápido #-------------------------------------------------------------------------- @cos = {} @sin = {} for i in 0..360 @cos[i] = Math.cos(Math.degree2radian(i - 90)) @sin[i] = Math.sin(Math.degree2radian(i - 90)) end def Math.quick_cos(i) @cos[i.round % 360] end def Math.quick_sin(i) @sin[i.round % 360] end end #============================================================================== # String #------------------------------------------------------------------------------ # Classe que opera os textos exibidos pelo programa. #============================================================================== class String #-------------------------------------------------------------------------- # Largura em pixel da string #-------------------------------------------------------------------------- def pixel_width(*args) bitmap = Bitmap.new(1, 1) if args[0].is_a?(Font) bitmap.font.size = args[0].size bitmap.font.name = args[0].name bitmap.font.bold = args[0].bold else bitmap.font.size = args[0].nil? ? Font.default_size : args[0] bitmap.font.name = args[1].nil? ? Font.default_name : args[1] bitmap.font.bold = args[2].nil? ? Font.default_bold : args[2] end pix = bitmap.text_size(self).width bitmap.dispose pix end #-------------------------------------------------------------------------- # Altura em pixel da string #-------------------------------------------------------------------------- def pixel_height(*args) bitmap = Bitmap.new(1, 1) if args[0].is_a?(Font) bitmap.font.size = args[0].size bitmap.font.name = args[0].name bitmap.font.bold = args[0].bold else bitmap.font.size = args[0].nil? ? Font.default_size : args[0] bitmap.font.name = args[1].nil? ? Font.default_name : args[1] bitmap.font.bold = args[2].nil? ? Font.default_bold : args[2] end pix = bitmap.text_size(self).height bitmap.dispose pix end #-------------------------------------------------------------------------- # Corta as strings com tamanho menor ou igual à largura dada #-------------------------------------------------------------------------- def width_slice(width, *args) bitmap = Bitmap.new(1, 1) if args[0].is_a?(Font) bitmap.font.size = args[0].size bitmap.font.name = args[0].name bitmap.font.bold = args[0].bold else bitmap.font.size = args[0].nil? ? Font.default_size : args[0] bitmap.font.name = args[1].nil? ? Font.default_name : args[1] bitmap.font.bold = args[2].nil? ? Font.default_bold : args[2] end result = [''] txt = self.clone.scan(/./) txt.each_index do |i| if txt[i].is_a?(String) txt[i] = [txt[i], bitmap.text_size(txt[i]).width] if txt.include?(txt[i][0]) txt.collect! do |e| e == txt[i][0] ? txt[i] : e end end end end bitmap.dispose act_width = 0 loop do if txt.size > 0 tmp_width = act_width + txt[0][1] tmp_width += txt[1][1] if txt.size > 1 if width >= act_width + txt[0][1] result[result.size - 1] += txt[0][0] act_width += txt[0][1] txt.delete_at(0) else result.push('') act_width = 0 end else break end end result end #-------------------------------------------------------------------------- # Tamanho máximo da fonte com a largura definida #-------------------------------------------------------------------------- def font_size_width(width, *args) bitmap = Bitmap.new(1, 1) if args[0].is_a?(Font) bitmap.font.name = args[0].name bitmap.font.bold = args[0].bold else bitmap.font.name = args[0].nil? ? Font.default_name : args[0] bitmap.font.bold = args[1].nil? ? Font.default_bold : args[1] end size = 6 for i in 6..96 bitmap.font.size = i size = i if bitmap.text_size(self).width <= width end bitmap.dispose size end #-------------------------------------------------------------------------- # Tamanho máximo da fonte com a altura definida #-------------------------------------------------------------------------- def font_size_height(height, *args) bitmap = Bitmap.new(1, 1) if args[0].is_a?(Font) bitmap.font.name = args[0].name bitmap.font.bold = args[0].bold else bitmap.font.name = args[0].nil? ? Font.default_name : args[0] bitmap.font.bold = args[1].nil? ? Font.default_bold : args[1] end size = 6 for i in 6..96 bitmap.font.size = i size = i if bitmap.text_size(self).height <= height end bitmap.dispose size end #-------------------------------------------------------------------------- # Tamanho máximo da fonte com a largura e altura definida #-------------------------------------------------------------------------- def font_size(width, height, *args) bitmap = Bitmap.new(1, 1) if args[0].is_a?(Font) bitmap.font.name = args[0].name bitmap.font.bold = args[0].bold else bitmap.font.name = args[0].nil? ? Font.default_name : args[0] bitmap.font.bold = args[1].nil? ? Font.default_bold : args[1] end size = 6 for i in 6..96 bitmap.font.size = i if bitmap.text_size(self).width <= width and bitmap.text_size(self).height <= height size = i end end bitmap.dispose size end #-------------------------------------------------------------------------- # Tranformar caracteres não desenháveis #-------------------------------------------------------------------------- def trans_undrawable_chr(font = Font.new, chr = '?') bmp = Bitmap.new(1, 1) bmp.font = font txt = '' scan(/./).each {|c| txt += (bmp.text_size(c).width == 0) ? chr : c} txt end end #============================================================================== # Bitmap #------------------------------------------------------------------------------ # Classe que domina as imagens exibidas. #============================================================================== class Bitmap #-------------------------------------------------------------------------- # Desenhar texto AWorks #-------------------------------------------------------------------------- def adraw_text(*args) if args.size.between?(2,3) args[2] = 0 if args.size == 2 args[4] = args[1] args[5] = args[2] args[1] = args[0].y args[2] = args[0].width args[3] = args[0].height args[0] = args[0].x elsif args.size == 5 args[5] = 0 end if args[4].is_a?(Array) args[4] = args[4].rflatten args[4].each do |t| t = t.nil? ? 'nil' : "#{t}" width = args[2].nil? ? self.text_size(t).width : args[2] height = args[3].nil? ? self.text_size('0').height : args[3] self.draw_text(args[0], args[1], width, height, t, args[5]) args[1] += height end return elsif args[4].is_a?(Hash) args[4] = args[4].fusion args[4] = args[4].rflatten args[4].each do |t| t = t.nil? ? 'nil' : "#{t}" width = args[2].nil? ? self.text_size(t).width : args[2] height = args[3].nil? ? self.text_size('0').height : args[3] self.draw_text(args[0], args[1], width, height, t, args[5]) args[1] += height end return elsif !args[4].is_a?(String) if args[4].to_s == '' args[4] = args[4].inspect else args[4] = args[4].to_s end end args[2] = args[2].nil? ? self.text_size(args[4]).width + 2 : args[2] args[3] = args[3].nil? ? self.text_size('0').height + 2 : args[3] draw_text(*args) end end #============================================================================== # Graphics #------------------------------------------------------------------------------ # Classe que domina os gráficos do jogo. #============================================================================== module Graphics @auto_update = [] class << self #-------------------------------------------------------------------------- # Auto-chamar objeto #-------------------------------------------------------------------------- unless self.method_defined?(:alibrary_update) alias_method(:alibrary_update, :update) end attr_accessor(:auto_update) def update alibrary_update @auto_update.each do |k| k[0].method(k[1]).call if !k[2].nil? k[2] -= 1 k = nil if k[2] <= 0 end end @auto_update.delete_if {|x| if !x[2].nil? : x[2] <= 0 else false end} end end end #============================================================================== # AWorks Input Module (AIM) [XP] [VX] #------------------------------------------------------------------------------ # Este script simula o módulo Input do RGSS/2. Não é o módulo original, mas # possue todas as funções originais e algumas novas. #------------------------------------------------------------------------------ # Autor: AWorks # Versão: 3.00 # Atualização: 26/01/2009 # Tradução PT: Kyo Panda (http://www.mundorpgmaker.com.br/) #============================================================================== #============================================================================== # Requerimentos: #------------------------------------------------------------------------------ # * ALibrary (AWorks Library) # - Versão: 1.03 # * AKM (AWorks Keys Module) # - Opcional, mas recomendado #============================================================================== #============================================================================== # Histórico de versões: #------------------------------------------------------------------------------ # * Versão 3.00 # - Script completamente reescrito, agora utiliza a AWorks.dll para a # atualização de input. #============================================================================== #============================================================================== # Funções: #------------------------------------------------------------------------------ # * Todas as teclas de teclado/mouse # - Quando chamando um dos métodos de estado de tecla (press?, trigger?, ...) # você pode usar o script AKM para obter os identificadores das teclas. # Ao invés de: (Como no Input original) # Input.press?(Input::[NOME DA TECLA AQUI]) # Utilize: # Input.press?(Keys::[NOME DA TECLA AQUI]) # Exemplo para a tecla F3: # Input.press?(Keys::F3) # Examplo para a tecla H: # Input.press?(Keys::H) # Examplo para a tecla Y: # Input.press?(Keys::Y) # # * Input.release?(vk) # - Determina se a tecla vk está sendo solta. Isto pode ser considerado o # oposto da função Input.trigger? # # * Input.pressed # - Retorna todas as teclas que estão sendo pressionadas. # # * Input.triggered # - Retorna todas as teclas que são pressionadas. # # * Input.repeated # - Retorna todas as teclas que estão sendo repetidas. # # * Input.released # - Retorna todas as teclas que estão sendo soltas. #============================================================================== #============================================================================== # Notas: #------------------------------------------------------------------------------ # * Para mais informações sobre os métodos Input.press?, Input.trigger?, # Input.repeat?, Input.dir4, Input.dir8 e Input.update veja os arquivos de # ajuda do RMXP/RMVX. # # * Não confunda as teclas do módulo Input (A, B, C, X, Y, Z, L, R) com as # teclas do teclado, sendo que as do módulo Input só reconhecem as teclas # de configuração do usuário (acessível pelo menu F1) e não as verdadeiras # do teclado. # # * O sistema Input funciona com teclas virtuais (VK) para indentificar todas # as teclas do mouse e teclado, e elas consistem nos números entre 0 .. 255. # Cada tecla no teclado possue sua própria tecla virtual que são lisatadas # no AKM para fácil uso. # # * Note que nem todos os computadores possuem o mesmo teclado e configuração # de teclado (Layout), especialmente teclas de símbolos e caracteres. # Geralemente, teclados possuem teclas OEM variadas (veja no AKM), mas # alguns teclasdos possuem algumas teclas extras que outros não possuem. # (O mesmo se aplica à mouses) # # * Este script não detecta as mudanças de configuração de teclas do menu F1 # até que o jogo seja fechado e a configuração salva no registro. Então, # você deve reiniciar o jogo para que as configurações surtem efeito. # # * As condições "Tecla sendo pressionada" e "Se pressionar tecla" são # incompatíveis com este novo sistema de Input. No entanto, você pode # utilizar o patch AIM:PXP para RMXP ou AIM:PVX para RMVX para corrigir esta # incompatibilidade. #============================================================================== #============================================================================== # Avisos: #------------------------------------------------------------------------------ # * Você pode checar os estado da tecla em um evento utilizando o comando # "Script" da "Condição" apenas escrevendo o método do Input e a tecla # verificada. # Exemplo para a letra "O", apenas coloque: # Input.press?(Keys::O) #============================================================================== #============================================================================== # Input #------------------------------------------------------------------------------ # Módulo que comanda as teclas pressionadas no jogo. #============================================================================== module Input #-------------------------------------------------------------------------- # Declaração das variáveis #-------------------------------------------------------------------------- @time = Array.new(256, 0) @press = Array.new(256, false) @trigger = Array.new(256, false) @repeat = Array.new(256, false) @release = Array.new(256, false) @dirs = [0, 0] #-------------------------------------------------------------------------- # Conversão de teclas (método interno) #-------------------------------------------------------------------------- REG_KVALUES = { 0 => 32, 1 => 13, 2 => 27, 3 => 96, 4 => 16, 5 => 90, 6 => 88, 7 => 67, 8 => 86, 9 => 66, 10 => 65, 11 => 83, 12 => 68, 13 => 81, 14 => 87} DEFAULT_KEYS = {11 => [16], 12 => [27, 88, 96], 13 => [13, 32, 90], 14 => [65], 15 => [83], 16 => [68], 17 => [81], 18 => [87]} def convert_keys(key) begin keys = [] rkey = 'HKEY_CURRENT_USER\\Software\\Enterbrain\\RGSS' data = AWorks::Registry.read_entry(rkey, 'ButtonAssign')[10, 25].scan(/./) 15.times {|i| keys.push(REG_KVALUES[i]) if key == data[i].unpack('C')[0]} keys rescue DEFAULT_KEYS[key] rescue [] end end module_function :convert_keys #-------------------------------------------------------------------------- # Declaração das constantes das teclas #-------------------------------------------------------------------------- LOWER_LEFT = 97 LOWER_RIGHT = 99 UPPER_LEFT = 103 UPPER_RIGHT = 105 DOWN = [98, 40] LEFT = [100, 37] RIGHT = [ 102, 39] UP = [104, 38] A = convert_keys(11) B = [45] + convert_keys(12) C = convert_keys(13) X = convert_keys(14) Y = convert_keys(15) Z = convert_keys(16) L = [33] + convert_keys(17) R = [34] + convert_keys(18) SHIFT = 16 CTRL = 17 ALT = 18 F5 = 116 F6 = 117 F7 = 118 F8 = 119 F9 = 120 #-------------------------------------------------------------------------- # Inicialização do Input #-------------------------------------------------------------------------- AWorks::API::InputIni.call(@time.object_id, @press.object_id, @trigger.object_id, @repeat.object_id, @release.object_id, @dirs.object_id) #-------------------------------------------------------------------------- # Atualização dos estados das teclas #-------------------------------------------------------------------------- def Input.update AWorks::API::InputUpdate.call end #-------------------------------------------------------------------------- # Pressionando? #-------------------------------------------------------------------------- def Input.press?(vk) @press.indexes(*vk).include?(true) end #-------------------------------------------------------------------------- # Pressionados #-------------------------------------------------------------------------- def Input.pressed array = Array.new @press.each_index {|i| array.push(i) if @press[i]} array end #-------------------------------------------------------------------------- # Apertado? #-------------------------------------------------------------------------- def Input.trigger?(vk) @trigger.indexes(*vk).include?(true) end #-------------------------------------------------------------------------- # Apertados #-------------------------------------------------------------------------- def Input.triggered array = Array.new @trigger.each_index {|i| array.push(i) if @trigger[i]} array end #-------------------------------------------------------------------------- # Repetido? #-------------------------------------------------------------------------- def Input.repeat?(vk) @repeat.indexes(*vk).include?(true) end #-------------------------------------------------------------------------- # Repetidos #-------------------------------------------------------------------------- def Input.repeated array = Array.new @repeat.each_index {|i| array.push(i) if @repeat[i]} array end #-------------------------------------------------------------------------- # Solto? #-------------------------------------------------------------------------- def Input.release?(vk) @release.indexes(*vk).include?(true) end #-------------------------------------------------------------------------- # Soltos #-------------------------------------------------------------------------- def Input.released array = Array.new @release.each_index {|i| array.push(i) if @release[i]} array end #-------------------------------------------------------------------------- # 4 Direções #-------------------------------------------------------------------------- def Input.dir4 @dirs[0] end #-------------------------------------------------------------------------- # 8 Direções #-------------------------------------------------------------------------- def Input.dir8 @dirs[1] end end #============================================================================== # AWorks Keys Module (AKM) [XP] [VX] #------------------------------------------------------------------------------ # Este módulo é um complemento para o AIM (AWorks Input Module). Isto lista # todas as chaves virtuais do teclado e mouse. #------------------------------------------------------------------------------ # Autor: AWorks # Versão: 1.12 # Atualização: 26/01/2009 # Tradução PT: Kyo Panda (http://www.mundorpgmaker.com.br/) #============================================================================== #============================================================================== # Histórico de versões: #------------------------------------------------------------------------------ # * Versão 1.10 # - Adicionado todas as chaves virtuais do teclado e mouse. (74 adicionadas) # - Método Keys.name? melhorado. # - Novos métodos: Keys.var_name?, Keys.vk? e Keys.var_vk? # * Versão 1.11 # - Consertado o bug entre os códigos virtuais Enter e Clear. # * Versão 1.12 # - Excluídos métodos var_name? e var_vk? # - Adicionados nomes de constantes alternativos #============================================================================== #============================================================================== # Instruções: #------------------------------------------------------------------------------ # Para usar uma chave virtual: Keys::CHAVE_VIRTUAL, onde CHAVE_VIRTUAL é o # nome da tecla que você deseja utilizar. Por exemplo: Keys::A retornará 65, a # chave virtual para a tecla A, e Keys::ALT retornará 18, a chave virtual para # a tecla ALT. #============================================================================== #============================================================================== # Funções: #------------------------------------------------------------------------------ # * Keys.name?(vk) # Retorna o nome da chave virtual. # * Keys.vk?(nome) # Retorna a chave virtual para o nome da tecla. #============================================================================== #============================================================================== # Keys #------------------------------------------------------------------------------ # Módulo que armazena os valores de todas as chaves virtuais das teclas do # teclado e mouse. #============================================================================== module Keys #-------------------------------------------------------------------------- # Botões do mouse #-------------------------------------------------------------------------- MOUSE_LEFT = 1 # Botão primário do mouse (normalmente o botão esquerdo) MOUSE_RIGHT = 2 # Botão secundário do mouse (normalmente o botão direito) MOUSE_MIDDLE = 4 # Botão central do mouse MOUSE_4TH = 5 # 4º botão do mouse MOUSE_5TH = 6 # 5º botão do mouse #-------------------------------------------------------------------------- # Teclas funcionais #-------------------------------------------------------------------------- CANCEL = 3 # Tecla Cancel BACKSPACE = 8 # Tecla Backspace TAB = 9 # Tecla Tab CLEAR = 12 # Tecla Clear RETURN = 13 # Tecla Enter SHIFT = 16 # Tecla Shift CTRL = 17 # Tecla Control ALT = 18 # Tecla Alt PAUSE = 19 # Tecla Pause ESCAPE = 27 # Tecla Escape SPACE = 32 # Tecla Barra de Espaço PGUP = 33 # Tecla Page Up PGDN = 34 # Tecla Page Down ENDS = 35 # Tecla End HOME = 36 # Tecla Home LEFT = 37 # Tecla Seta Esquerda UP = 38 # Tecla Seta Acima RIGHT = 39 # Tecla Seta Direita DOWN = 40 # Tecla Seta Abaixo SNAPSHOT = 44 # Tecla Print Screen SELECT = 41 # Tecla Select PRINT = 42 # Tecla Print EXECUTE = 43 # Tecla Execute INSERT = 45 # Tecla Insert DELETE = 46 # Tecla Delete HELP = 47 # Tecla Help LEFT_SHIFT = 160 # Tecla Shift Esquerdo RIGHT_SHIFT = 161 # Tecla Shift Direito LEFT_CONTROL = 162 # Tecla Control Esquerdo RIGHT_CONTROL = 163 # Tecla Control Direito LEFT_ALT = 164 # Tecla Alt Esquerdo RIGHT_ALT = 165 # Tecla Alt Direito #-------------------------------------------------------------------------- # Teclas de números #-------------------------------------------------------------------------- N0 = 48 # Tecla 0 N1 = 49 # Tecla 1 N2 = 50 # Tecla 2 N3 = 51 # Tecla 3 N4 = 52 # Tecla 4 N5 = 53 # Tecla 5 N6 = 54 # Tecla 6 N7 = 55 # Tecla 7 N8 = 56 # Tecla 8 N9 = 57 # Tecla 9 #-------------------------------------------------------------------------- # Teclas de letras #-------------------------------------------------------------------------- A = 65 # Tecla A B = 66 # Tecla B C = 67 # Tecla C D = 68 # Tecla D E = 69 # Tecla E F = 70 # Tecla F G = 71 # Tecla G H = 72 # Tecla H I = 73 # Tecla I J = 74 # Tecla J K = 75 # Tecla K L = 76 # Tecla L M = 77 # Tecla M N = 78 # Tecla N O = 79 # Tecla O P = 80 # Tecla P Q = 81 # Tecla Q R = 82 # Tecla R S = 83 # Tecla S T = 84 # Tecla T U = 85 # Tecla U V = 86 # Tecla V W = 87 # Tecla W X = 88 # Tecla X Y = 89 # Tecla Y Z = 90 # Tecla Z #-------------------------------------------------------------------------- # Teclas do Windows #-------------------------------------------------------------------------- LWIN = 91 # Tecla Esquerda Windows (Teclado Normal Microsoft) RWIN = 92 # Tecla Direita Window (Teclado Normal) APPS = 93 # Tecla Aplicativos (Teclado Normal) SLEEP = 95 # Tecla Modo Stand-by BROWSER_BAK = 166 # Tecla Navegador Anterior BROWSER_FORWARD = 167 # Tecla Navegador Posterior BROWSER_REFRESH = 168 # Tecla Navegador Atualização BROWSER_STOP = 169 # Tecla Navegador Parar BROWSER_SEARCH = 170 # Tecla Navegador Procura BROWSER_FAVORITES = 171 # Tecla Navegador Favoritos BROWSER_HOME = 172 # Tecla Navegador Iniciar e Home VOLUME_MUTE = 173 # Tecla Volume Mudo VOLUME_DOWN = 174 # Tecla Volume Abaixo VOLUME_UP = 175 # Tecla Volume Acima MEDIA_NEXT_TRACK = 176 # Tecla Próxima Faixa MEDIA_PREV_TRACK = 177 # Tecla Faixa Anterior MEDIA_STOP = 178 # Tecla Parar Media MEDIA_PLAY_PAUSE = 179 # Tecla Tocar/Pausar Media LAUNCH_MAIL = 180 # Tecla Iniciar E-Mail LAUNCH_MEDIA_SELECT = 181 # Tecla Definir Media LAUNCH_APP1 = 182 # Tecla Iniciar Aplicativo 1 LAUNCH_APP2 = 183 # Tecla Iniciar aplicativo 2 PROCESS = 229 # Tecla Processar ATTN = 246 # Tecla Attn CRSEL = 247 # Tecla CrSel EXSEL = 248 # Tecla ExSel EREOF = 249 # Tecla Apagar EOF PLAY = 250 # Tecla Tocar ZOOM = 251 # Tecla Zoom PA1 = 253 # Tecla PA1 #-------------------------------------------------------------------------- # Teclas Pad Matemático #-------------------------------------------------------------------------- NUMPAD0 = 96 # Tecla Pad 0 NUMPAD1 = 97 # Tecla Pad 1 NUMPAD2 = 98 # Tecla Pad 2 NUMPAD3 = 99 # Tecla Pad 3 NUMPAD4 = 100 # Tecla Pad 4 NUMPAD5 = 101 # Tecla Pad 5 NUMPAD6 = 102 # Tecla Pad 6 NUMPAD7 = 103 # Tecla Pad 7 NUMPAD8 = 104 # Tecla Pad 8 NUMPAD9 = 105 # Tecla Pad 9 MULTIPLY = 106 # Tecla Multiplicação (*) ADD = 107 # Tecla Adição (+) SEPARATOR = 108 # Tecla Separadora (,) SUBTRACT = 109 # Tecla Subtração (-) DECIMAL = 110 # Tecla Decimal (.) DIVIDE = 111 # Tecla Divisão (/) #-------------------------------------------------------------------------- # Teclas F #-------------------------------------------------------------------------- F1 = 112 # Tecla F1 F2 = 113 # Tecla F2 F3 = 114 # Tecla F3 F4 = 115 # Tecla F4 F5 = 116 # Tecla F5 F6 = 117 # Tecla F6 F7 = 118 # Tecla F7 F8 = 119 # Tecla F8 F9 = 120 # Tecla F9 F10 = 121 # Tecla F10 F11 = 122 # Tecla F11 F12 = 123 # Tecla F12 F13 = 124 # Tecla F13 F14 = 125 # Tecla F14 F15 = 126 # Tecla F15 F16 = 127 # Tecla F16 F17 = 128 # Tecla F17 F18 = 129 # Tecla F18 F19 = 130 # Tecla F19 F20 = 131 # Tecla F20 F21 = 132 # Tecla F21 F22 = 133 # Tecla F22 F23 = 134 # Tecla F23 F24 = 135 # Tecla F24 #-------------------------------------------------------------------------- # Teclas de Modos #-------------------------------------------------------------------------- CAPS_LOCK = 20 # Tecla Capitals Lock NUM_LOCK = 144 # Tecla Number Lock SCROLL_LOCK = 145 # Tecla Scroll Lock KANA = 21 # Tecla Kana JUNJA = 23 # Tecla Junja FINAL = 24 # Tecla Final KANJI = 25 # Tecla Kanji CONVERT = 28 # Tecla Convert NONCONVERT = 29 # Tecla Non Convert ACCEPT = 30 # Tecla Accept MODECHANGE = 31 # Tecla Mode Change Request #-------------------------------------------------------------------------- # Teclas OEM # - Teclas usadas pars caracters alternativos; variam por teclado #-------------------------------------------------------------------------- OEM_1 = 186 # Nos Teclados Americanos 101/102 (; :) OEM_2 = 187 # Nos Teclados Americanos 101/102 (= +) OEM_3 = 188 # Nos Teclados Americanos 101/102 (, <) OEM_4 = 189 # Nos Teclados Americanos 101/102 (- _) OEM_5 = 190 # Nos Teclados Americanos 101/102 (. >) OEM_6 = 191 # Nos Teclados Americanos 101/102 (/ ?) OEM_7 = 192 # Nos Teclados Americanos 101/102 (` ~) OEM_8 = 219 # Nos Teclados Americanos 101/102 ([ {) OEM_9 = 220 # Nos Teclados Americanos 101/102 (\ |) OEM_10 = 221 # Nos Teclados Americanos 101/102 (] }) OEM_11 = 222 # Nos Teclados Americanos 101/102 (' ") OEM_13 = 223 # Tecla OEM OEM_14 = 226 # Tecla OEM OEM_15 = 146 # Tecla OEM OEM_16 = 147 # Tecla OEM OEM_17 = 148 # Tecla OEM OEM_18 = 149 # Tecla OEM OEM_19 = 150 # Tecla OEM OEM_20 = 225 # Tecla OEM OEM_21 = 227 # Tecla OEM OEM_22 = 228 # Tecla OEM OEM_23 = 230 # Tecla OEM OEM_24 = 232 # Tecla OEM OEM_25 = 240 # Tecla OEM OEM_26 = 241 # Tecla OEM OEM_27 = 242 # Tecla OEM OEM_28 = 243 # Tecla OEM OEM_29 = 244 # Tecla OEM OEM_30 = 245 # Tecla OEM OEM_CLEAR = 254 # Tecla OEM Clear #-------------------------------------------------------------------------- # Nomes Alternativos #-------------------------------------------------------------------------- MOUSE_1 = 1 # Botão primário do mouse (normalmente o botão esquerdo) MOUSE_2 = 2 # Botão secundário do mouse (normalmente o botão direito) MOUSE_3 = 4 # Botão central do mouse MOUSE_4 = 5 # 4º botão do mouse MOUSE_5 = 6 # 5º botão do mouse TABULAR = 9 # Tecla Tab ENTER = 13 # Tecla Enter CONTROL = 17 # Tecla Control ALTERNATIVE = 18 # Tecla Alt ESC = 27 # Tecla Escape SPACEBAR = 32 # Tecla Barra de Espaço PAGE_UP = 33 # Tecla Page Up PAGE_DOWN = 34 # Tecla Page Down INS = 45 # Tecla Insert DEL = 46 # Tecla Delete LSHIFT = 160 # Tecla Shift Esquerdo RSHIFT = 161 # Tecla Shift Direito LCTRL = 162 # Tecla Control Esquerdo RCTRL = 163 # Tecla Control Direito LALT = 164 # Tecla Alt Esquerdo RALT = 165 # Tecla Alt Direito Pad NP0 = 96 # Tecla Pad 0 NP1 = 97 # Tecla Pad 1 NP2 = 98 # Tecla Pad 2 NP3 = 99 # Tecla Pad 3 NP4 = 100 # Tecla Pad 4 NP5 = 101 # Tecla Pad 5 NP6 = 102 # Tecla Pad 6 NP7 = 103 # Tecla Pad 7 NP8 = 104 # Tecla Pad 8 NP9 = 105 # Tecla Pad 9 MULT = 106 # Tecla Multiplicação (*) PLUS = 107 # Tecla Adição (+) SEP = 108 # Tecla Separador (,) MINUS = 109 # Tecla Subtração (-) POINT = 110 # Tecla Decimal (.) DIV = 111 # Tecla Divisão (/) #-------------------------------------------------------------------------- # Nome das teclas #-------------------------------------------------------------------------- KEYS_NAMES = {1=>'Mouse Pri.',2=>'Mouse Sec.',3=>'Cancel', 4=>'Mouse Meio',5=>'Mouse 4º',6=>'Mouse 5º',8=>'Backspace',9=>'Tab', 12=>'Clear',13=>'Enter',16=>'Shift',17=>'Control',18=>'Alt',19=>'Pause', 20=>'Capitals Lock',21=>'Kana',23=>'Junja',24=>'Final',25=>'Kanji', 27=>'Escape',28=>'Convert',29=>'Non Convert',30=>'Accept',31=>'Mode Change', 32=>'Espaço',33=>'Page Up',34=>'Page Down',35=>'End',36=>'Home',37=>'Esquerda', 38=>'Acima',39=>'Direita',40=>'Abaixo',41=>'Select',42=>'Print',43=>'Execute', 44=>'Snapshot',45=>'Insert',46=>'Delete',47=>'Help',48=>'0',49=>'1',50=>'2', 51=>'3',52=>'4',53=>'5',54=>'6',55=>'7',56=>'8',57=>'9',65=>'A',66=>'B', 67=>'C',68=>'D',69=>'E',70=>'F',71=>'G',72=>'H',73=>'I',74=>'J',75=>'K', 76=>'L',77=>'M',78=>'N',79=>'O',80=>'P',81=>'Q',82=>'R',83=>'S',84=>'T', 85=>'U',86=>'V',87=>'W',88=>'X',89=>'Y',90=>'Z',91=>'Windows', 92=>'Windows Dir.',93=>'Application',95=>'Sleep',96=>'PAD 0',97=>'PAD 1', 98=>'PAD 2',99=>'PAD 3',100=>'PAD 4',101=>'PAD 5',102=>'PAD 6',103=>'PAD 7', 104=>'PAD 8',105=>'PAD 9',106=>'*',107=>'+',108=>'Separator',109=>'-',110=>'.', 111=>'/',112=>'F1',113=>'F2',114=>'F3',115=>'F4',116=>'F5',117=>'F6',118=>'F7', 119=>'F8',120=>'F9',121=>'F10',122=>'F11',123=>'F12',124=>'F13',125=>'F14', 126=>'F15',127=>'F16',128=>'F17',129=>'F18',130=>'F19',131=>'F20',132=>'F21', 133=>'F22',134=>'F23',135=>'F24',144=>'Number Lock',145=>'Scroll Lock', 146=>'OEM 15',147=>'OEM 16',148=>'OEM 17',149=>'OEM 18',150=>'OEM 19', 160=>'Shift Esq.',161=>'Shift Dir.',162=>'Control Esq.',163=>'Control Dir.', 164=>'Alt Esq.',165=>'Alt Dir.',166=>'Browser Back',167=>'Browser Forward', 168=>'Browser Refresh',169=>'Browser Stop',170=>'Browser Search', 171=>'Browser Favorites',172=>'Browser Home',173=>'Volume Mute', 174=>'Volume Down',175=>'Volume Up',176=>'Media Next Track', 177=>'Media Previous Track',178=>'Media Stop',179=>'Media Play Pause', 180=>'Launch Mail',181=>'Launch Media Select',182=>'Launch Application', 183=>'Launch Application',186=>'OEM 1',187=>'OEM 2',188=>'OEM 3',189=>'OEM 4', 190=>'OEM 5',191=>'OEM 6',192=>'OEM 7',219=>'OEM 8',220=>'OEM 9',221=>'OEM 10', 222=>'OEM 11',223=>'OEM 13',225=>'OEM 20',226=>'OEM 14',227=>'OEM 21', 228=>'OEM 22',229=>'Proccess',230=>'OEM 23',232=>'OEM 24',240=>'OEM 25', 241=>'OEM 26',242=>'OEM 27',243=>'OEM 28',244=>'OEM 29',245=>'OEM 30', 246=>'ATTN',247=>'CRSEL',248=>'EXSEL',249=>'EREOF',250=>'Play',251=>'Zoom', 253=>'PA1',254=>'OEM Clear'} #-------------------------------------------------------------------------- # Retorna o nome da tecla com determinada chave virtual #-------------------------------------------------------------------------- def Keys.name?(vk) KEYS_NAMES[vk].nil? ? '???' : KEYS_NAMES[vk] end #-------------------------------------------------------------------------- # Retorna a chave virtual com determinado nome da tecla #-------------------------------------------------------------------------- def Keys.vk?(name) KEYS_NAMES.invert[name].nil? ? 0 : KEYS_NAMES.invert[name] end end #============================================================================== # AWorks Input Module: Mouse Plugin (AIM:M) [XP] [VX] #------------------------------------------------------------------------------ # Este script adiciona o processo de detecção do mouse pelo módulo Input. #------------------------------------------------------------------------------ # Autor: AWorks # Versão: 1.00 # Atualização: 26/01/2009 # Tradução PT: Kyo Panda (http://www.mundorpgmaker.com.br/) #============================================================================== #============================================================================== # Requerimentos: #------------------------------------------------------------------------------ # * ALibrary (AWorks Library) # - Versão: 1.03 # * AIM (AWorks Input Module) # - Versão: 3.00 #============================================================================== #============================================================================== # Histórico de versões: #------------------------------------------------------------------------------ # * Versão 1.00 # - Criação do script #============================================================================== #============================================================================== # Funções: #------------------------------------------------------------------------------ # * Configuração # - @mouse_double_click_time # Define o máximo de frames que devem se passar entre o primeiro e o # segundo clique. Se nil, será o usado por padrão pelo computador. # - @mouse_double_click_pix # Defina a área máxima de pixels que o cursor pode se mover entre o # primeiro e o segundo clique. O padrão é 4. # - @mouse_drag_pix # Defina o total de pixels que o cursor deve se mover para o processo de # arrastar inicie-se. O padrão é 4. # # * Input.mouse_doubleclick?([vk]) # - Determina se a chave virtual da tecla esta recebendo o clique duplo. # Só funciona com as teclas do mouse. Se a chave virtual (vk) não for # dada, será interpretado como o botão direito do mouse. # # * Input.mouse_in_screen? # - Retorna verdadeiro (true) se o cursor do mouse estiver na tela do jogo. # # * Input.mouse_pos # - Retorna a coordenada X e Y do cursor em uma Array. Se o cursor não está # sobre a tela do jogo, os dois valores retornam nil. # # * Input.mouse_x? # - Retorna a coordenada X do cursor. Se o cursor não está sobre a tela do # jogo, retorna nil. # # * Input.mouse_y? # - Retorna a coordenada Y do cursor. Se o cursor não está sobre a tela do # jogo, retorna nil. # # * Input.mouse_dragging? # - Retorna verdadeiro (true) se está arrastando. # # * Input.mouse_drag_rect? # - Retorna o retângulo formado ao arrastar num objeto Rect. # # * Input.mouse_drag_coor? # - Retorna as coordenadas do retângulo ao arrastar em uma Array. # # * Input.mouse_in_area?(x, y, largura, altura) # - Retorna verdadeiro se o cursor está sobre a área dada. # # * Input.mouse_in_area?(rect) # - Retorna verdadeiro se o cursor está sobre a área dada. # # * Input.mouse_visible=(flag) # - Mostra ou oculta o cursor do mouse. # # * Input.mouse_visible? # - Retorna verdadeiro (true) se o cursor está visível. #============================================================================== #============================================================================== # Notas: #------------------------------------------------------------------------------ # * Há uma diferença entre os botões esquerdo e direito do mouse e os botões # primário e secundário. O primeiro sempre se refere aos botões esquerdos e # direitos do mouse, mas o segundo varia de acordo com a definição do # usuário. Se o Swap Buttons Flag (modo canhoto) estiver ativado, os botões # primário e secundário são trocados, mas os esquerda e direita permanecem o # mesmo. Este script detecta o modo canhoto, e define os seus valores # verdadeiros para as constantes MOUSE_PRIMARY e MOUSE_SECUNDARY, às quais # pertencem ao módulo Input. Logo, ao invés de usar Keys::MOUSE_LEFT e # Keys::MOUSE_RIGHT, utilize Input::MOUSE_PRIMARY e Input::MOUSE_SECONDARY # respectivamente. #============================================================================== #============================================================================== # Input #------------------------------------------------------------------------------ # Módulo que comanda as teclas pressionadas no jogo. #============================================================================== module Input #-------------------------------------------------------------------------- # Configuração #-------------------------------------------------------------------------- @mouse_double_click_time = nil @mouse_double_click_pix = 4 @mouse_drag_pix = 4 #-------------------------------------------------------------------------- # Declaração das variáveis #-------------------------------------------------------------------------- MOUSE_SWAP_BUTTONS = AWorks.get_mouse_swap_buttons_flag MOUSE_PRIMARY = 1 + MOUSE_SWAP_BUTTONS MOUSE_SECONDARY = 2 - MOUSE_SWAP_BUTTONS @mouse_pos = [0, 0] @mouse_drag = [false, 0, 0, 0, 0, 0, 0] @mouse_doubleclick = [nil, false, false, false, false, false] if @mouse_double_click_time.nil? @mouse_double_click_time = Graphics.frame_rate * (AWorks::API::GetDoubleClickTime.call / 10) / 100 end #-------------------------------------------------------------------------- # Inicialização do Input do mouse #-------------------------------------------------------------------------- AWorks::API::InputMouseIni.call(@mouse_pos.object_id, @mouse_drag.object_id, @mouse_doubleclick.object_id) AWorks::API::InputMouseConfig.call(MOUSE_SWAP_BUTTONS, @mouse_drag_pix, @mouse_double_click_time, @mouse_double_click_pix) #-------------------------------------------------------------------------- # Atualiza as configurações do mouse #-------------------------------------------------------------------------- def Input.update_mouse_configuration @mouse_double_click_time = Graphics.frame_rate * (AWorks::API::GetDoubleClickTime.call / 10) / 100 AWorks::API::InputMouseConfig.call(MOUSE_SWAP_BUTTONS, @mouse_drag_pix, @mouse_double_click_time, @mouse_double_click_pix) end #-------------------------------------------------------------------------- # Clique duplo? #-------------------------------------------------------------------------- def Input.mouse_doubleclick?(vk = MOUSE_PRIMARY) @mouse_doubleclick[vk] end #-------------------------------------------------------------------------- # Mouse na tela? #-------------------------------------------------------------------------- def Input.mouse_in_screen? !@mouse_pos[0].nil? end #-------------------------------------------------------------------------- # Adquire a posição do mouse #-------------------------------------------------------------------------- def Input.mouse_pos @mouse_pos end #-------------------------------------------------------------------------- # Adquire a coordenada X do mouse #-------------------------------------------------------------------------- def Input.mouse_x? @mouse_pos[0] end #-------------------------------------------------------------------------- # Adquire a coordenada Y do mouse #-------------------------------------------------------------------------- def Input.mouse_y? @mouse_pos[1] end #-------------------------------------------------------------------------- # Mouse arrastando? #-------------------------------------------------------------------------- def Input.mouse_dragging? @mouse_drag[0].nil? ? false : @mouse_drag[0] end #-------------------------------------------------------------------------- # Retângulo do arrasto do mouse #-------------------------------------------------------------------------- def Input.mouse_drag_rect? Rect.new(*@mouse_drag[3, 4]) if @mouse_drag[0] end #-------------------------------------------------------------------------- # Coordenadas do retângulo do arrasto do mouse #-------------------------------------------------------------------------- def Input.mouse_drag_coor? @mouse_drag[3, 4] if @mouse_drag[0] end #-------------------------------------------------------------------------- # Mouse na área? #-------------------------------------------------------------------------- def Input.mouse_in_area?(*args) return false if @mouse_pos[0].nil? if args[0].is_a?(Rect) @mouse_pos[0] >= args[0].x and @mouse_pos[1] >= args[0].y and @mouse_pos[0] <= args[0].x + args[0].width and @mouse_pos[1] <= args[0].y + args[0].height else @mouse_pos[0] >= args[0] and @mouse_pos[1] >= args[1] and @mouse_pos[0] <= args[0] + args[2] and @mouse_pos[1] <= args[1] + args[3] end end #-------------------------------------------------------------------------- # Mudança da visibilidade do mouse #-------------------------------------------------------------------------- def Input.mouse_visible=(flag) val, result = flag ? 1 : 0, nil until result == (val - 1) result = AWorks::API::ShowCursor.call(val) end end #-------------------------------------------------------------------------- # Mouse visível? #-------------------------------------------------------------------------- def Input.mouse_visible? AWorks::API::ShowCursor.call(1) AWorks::API::ShowCursor.call(0) >= 0 end end #============================================================================== # AWorks Input Module Patch (AIM:PXP) [XP] #------------------------------------------------------------------------------ # Este patch faz com que o AIM seja compatível com o interpreter padrão do # RPG Maker XP quando utilizado as opções de Condição pelo pressionamento de # teclas. #------------------------------------------------------------------------------ # Autor: AWorks # Versão: 1.00 # Atualização: 26/01/2009 # Tradução PT: Kyo Panda (http://www.mundorpgmaker.com.br/) #============================================================================== #============================================================================== # Requerimentos: #------------------------------------------------------------------------------ # * RPG Maker XP # * AIM (AWorks Input Module) # - Versão: 3.00 #============================================================================== #============================================================================== # Interpreter #------------------------------------------------------------------------------ # É a classe que interpreta os comandos de eventos do jogo. # É usada dentro da classe Game_Event e Game_System. #============================================================================== class Interpreter #-------------------------------------------------------------------------- # Pressionamento de teclas #-------------------------------------------------------------------------- def input_button n = 1 if Input.trigger?(Input::LOWER_LEFT) n = 3 if Input.trigger?(Input::LOWER_RIGHT) n = 7 if Input.trigger?(Input::UPPER_LEFT) n = 9 if Input.trigger?(Input::UPPER_RIGHT) n = 2 if Input.trigger?(Input::DOWN) n = 4 if Input.trigger?(Input::LEFT) n = 6 if Input.trigger?(Input::RIGHT) n = 8 if Input.trigger?(Input::UP) n = 11 if Input.trigger?(Input::A) n = 12 if Input.trigger?(Input::B) n = 13 if Input.trigger?(Input::C) n = 14 if Input.trigger?(Input::X) n = 15 if Input.trigger?(Input::Y) n = 16 if Input.trigger?(Input::Z) n = 17 if Input.trigger?(Input::L) n = 18 if Input.trigger?(Input::R) if !n.nil? $game_variables[@button_input_variable_id] = n $game_map.need_refresh = true @button_input_variable_id = 0 end end #-------------------------------------------------------------------------- # Condição #-------------------------------------------------------------------------- def command_111 result = false case @parameters[0] when 0 result = ($game_switches[@parameters[1]] == (@parameters[2] == 0)) when 1 value1 = $game_variables[@parameters[1]] if @parameters[2] == 0 value2 = @parameters[3] else value2 = $game_variables[@parameters[3]] end case @parameters[4] when 0 result = (value1 == value2) when 1 result = (value1 >= value2) when 2 result = (value1 <= value2) when 3 result = (value1 > value2) when 4 result = (value1 < value2) when 5 result = (value1 != value2) end when 2 if @event_id > 0 key = [$game_map.map_id, @event_id, @parameters[1]] if @parameters[2] == 0 result = ($game_self_switches[key] == true) else result = ($game_self_switches[key] != true) end end when 3 if $game_system.timer_working sec = $game_system.timer / Graphics.frame_rate if @parameters[2] == 0 result = (sec >= @parameters[1]) else result = (sec <= @parameters[1]) end end when 4 actor = $game_actors[@parameters[1]] if actor != nil case @parameters[2] when 0 result = ($game_party.actors.include?(actor)) when 1 result = (actor.name == @parameters[3]) when 2 result = (actor.skill_learn?(@parameters[3])) when 3 result = (actor.weapon_id == @parameters[3]) when 4 result = (actor.armor1_id == @parameters[3] or actor.armor2_id == @parameters[3] or actor.armor3_id == @parameters[3] or actor.armor4_id == @parameters[3]) when 5 result = (actor.state?(@parameters[3])) end end when 5 enemy = $game_troop.enemies[@parameters[1]] if enemy != nil case @parameters[2] when 0 result = (enemy.exist?) when 1 result = (enemy.state?(@parameters[3])) end end when 6 character = get_character(@parameters[1]) if character != nil result = (character.direction == @parameters[2]) end when 7 if @parameters[2] == 0 result = ($game_party.gold >= @parameters[1]) else result = ($game_party.gold <= @parameters[1]) end when 8 result = ($game_party.item_number(@parameters[1]) > 0) when 9 result = ($game_party.weapon_number(@parameters[1]) > 0) when 10 result = ($game_party.armor_number(@parameters[1]) > 0) when 11 case @parameters[1] when 2 n = Input::DOWN when 4 n = Input::LEFT when 6 n = Input::RIGHT when 8 n = Input::UP when 11 n = Input::A when 12 n = Input::B when 13 n = Input::C when 14 n = Input::X when 15 n = Input::Y when 16 n = Input::Z when 17 n = Input::L when 18 n = Input::R end result = Input.press?(n) when 12 result = eval(@parameters[1]) end @branch[@list[@index].indent] = result if @branch[@list[@index].indent] == true @branch.delete(@list[@index].indent) return true end return command_skip end end #============================================================================== # Scene_Base #------------------------------------------------------------------------------ # Classe superior à todas as classes Scene_. #============================================================================== class Scene_Base #-------------------------------------------------------------------------- # Processo principal #-------------------------------------------------------------------------- def main start # Inicia o processo perform_transition # Executa a transição post_start # Processo pós-inicialização Input.update # Atualiza as informações inseridas loop do Graphics.update # Atualiza os gráficos Input.update # Atualiza as informações inseridas update # Atualização break if $scene != self # Descontinuação do loop end Graphics.update pre_terminate # Preparação para finalização Graphics.freeze # Congelamento dos gráficos terminate # Fim end #-------------------------------------------------------------------------- # Inicialização do processo #-------------------------------------------------------------------------- def start end #-------------------------------------------------------------------------- # Execução da transição #-------------------------------------------------------------------------- def perform_transition Graphics.transition(10) end #-------------------------------------------------------------------------- # Processo pós-inicialização #-------------------------------------------------------------------------- def post_start end #-------------------------------------------------------------------------- # Atualização da tela #-------------------------------------------------------------------------- def update end #-------------------------------------------------------------------------- # Preparação para finalização #-------------------------------------------------------------------------- def pre_terminate end #-------------------------------------------------------------------------- # Fim do processo #-------------------------------------------------------------------------- def terminate end end #============================================================================== # Window_Base #------------------------------------------------------------------------------ # Esta classe é para todos as janelas do jogo #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # Alias da inicialização dos Objetos #-------------------------------------------------------------------------- alias kc_initialize initialize #-------------------------------------------------------------------------- # Inicialização dos Objetos # # x : coordenada x da janela # y : coordenada y da janela # width : largura da janela # height : altura da janela #-------------------------------------------------------------------------- def initialize(x, y, width, height) kc_initialize(x, y, width, height) self.contents = Bitmap.new(width - 32, height - 32) end end #============================================================================== # Window_KeyConfig #------------------------------------------------------------------------------ # Janela que exibe os botões definidos para cada função. #============================================================================== class Window_KeyConfig < Window_Selectable #-------------------------------------------------------------------------- # Inclusão das constantes do módulo KeyConfig_Set #-------------------------------------------------------------------------- include KeyConfig_Set #-------------------------------------------------------------------------- # Inicialização do objeto #-------------------------------------------------------------------------- def initialize super(MKWV[0], MKWV[1], MKWV[2], MKWV[3]) self.contents = Bitmap.new(width - 32, height - 32) @item_max = 5 @index = 0 refresh end #-------------------------------------------------------------------------- # Atualização #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.name = MENU_FONT @cell_size = (self.contents.width / 2) / 3 @half_size = (self.contents.width / 2) # Cria os textos de ajuda sobre o campos self.contents.font.color = system_color self.contents.draw_text(0, 0, @half_size, 32, ACTION) self.contents.draw_text(@half_size + 2, 0, @cell_size - 2, 32, FIRST, 1) self.contents.draw_text(@half_size + 3 + @cell_size, 0, @cell_size - 2, 32, SECOND, 1) self.contents.draw_text(@half_size + 4 + @cell_size * 2, 0, @cell_size - 2, 32, THIRD, 1) # Cria os retângulos dos campos self.contents.font.color = normal_color for i in 0 .. 3 rect = Rect.new(@half_size + 1, (32 * (i + 1)) + 1, @cell_size - 2, 32 - 2) self.contents.fill_rect(rect, Color.new(0, 0, 0, 128)) rect = Rect.new(@half_size + @cell_size + 2, 32 * (i + 1) + 1, @cell_size - 2, 32 - 2) self.contents.fill_rect(rect, Color.new(0, 0, 0, 128)) rect = Rect.new(@half_size + (@cell_size * 2) + 3, 32 * (i + 1) + 1, @cell_size - 2, 32 - 2) self.contents.fill_rect(rect, Color.new(0, 0, 0, 128)) end rect = Rect.new(@half_size + 3 + @cell_size, 32 * 6 + 1, @half_size - 2 - @cell_size, 32 - 2) self.contents.fill_rect(rect, Color.new(0, 0, 0, 128)) # Cria os campos com as teclas if $scene.key_index != nil self.contents.font.color.alpha = $scene.key_index == 0 ? 255 : 128 end self.contents.draw_text(0, 32 * 1, @half_size, 32, ACTION_CONFIRM) for i in 0 .. Input::C.size - 1 self.contents.draw_text(@half_size + (i + 1) + (@cell_size * i), 32 * 1, @cell_size - 2, 32, Keys.name?(Input::C[i]), 1) end if $scene.key_index != nil self.contents.font.color.alpha = $scene.key_index == 1 ? 255 : 128 end self.contents.draw_text(0, 32 * 2, @half_size, 32, ACTION_CANCEL) for i in 0 .. Input::B.size - 1 self.contents.draw_text(@half_size + (i + 1) + (@cell_size * i), 32 * 2, @cell_size - 2, 32, Keys.name?(Input::B[i]), 1) end if $scene.key_index != nil self.contents.font.color.alpha = $scene.key_index == 2 ? 255 : 128 end =begin self.contents.draw_text(0, 32 * 3, @half_size, 32, ACTION_RUN) for i in 0 .. Input::A.size - 1 self.contents.draw_text(@half_size + (i + 1) + (@cell_size * i), 32 * 3, @cell_size - 2, 32, Keys.name?(Input::A[i]), 1) end if $scene.key_index != nil self.contents.font.color.alpha = $scene.key_index == 3 ? 255 : 128 end =end self.contents.draw_text(0, 32 * 3, @half_size, 32, ACTION_PAGE_UP) for i in 0 .. Input::L.size - 1 self.contents.draw_text(@half_size + (i + 1) + (@cell_size * i), 32 * 3, @cell_size - 2, 32, Keys.name?(Input::L[i]), 1) end if $scene.key_index != nil self.contents.font.color.alpha = $scene.key_index == 3 ? 255 : 128 end self.contents.draw_text(0, 32 * 4, @half_size, 32, ACTION_PAGE_DOWN) for i in 0 .. Input::R.size - 1 self.contents.draw_text(@half_size + (i + 1) + (@cell_size * i), 32 * 4, @cell_size - 2, 32, Keys.name?(Input::R[i]), 1) end if $scene.key_index != nil self.contents.font.color.alpha = $scene.key_index == 4 ? 255 : 128 end self.contents.draw_text(@half_size + 2 + @cell_size, 32 * 6, @half_size - 1 - @cell_size, 32, ACTION_DEFAULT, 1) end #-------------------------------------------------------------------------- # Atualização do cursor #-------------------------------------------------------------------------- def update_cursor_rect cursor_rect.set(0, 32 * (@index + 1), self.contents.width, 32) if @index == 4 cursor_rect.set(@half_size + 2 + @cell_size, 32 * (@index + 2), @half_size - 1 - @cell_size, 32) end end end #============================================================================== # Window_Ask #------------------------------------------------------------------------------ # Janela que exibe uma pergunta de reposta afirmativa ou negativa. #============================================================================== class Window_Ask < Window_Selectable #-------------------------------------------------------------------------- # Inicialização do objeto #-------------------------------------------------------------------------- def initialize(x, y, width, height, question, answer1, answer2) super(x, y, width, height) self.contents = Bitmap.new(width - 32, height - 32) self.z = 200 self.back_opacity = 255 self.opacity = 255 @question = question @answer1 = answer1 @answer2 = answer2 @item_max = 2 refresh end #-------------------------------------------------------------------------- # Atualização #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.draw_text(0, 32 * 0, self.contents.width, 32, @question, 1) self.contents.draw_text(0, 32 * 1, self.contents.width, 32, @answer1, 1) self.contents.draw_text(0, 32 * 2, self.contents.width, 32, @answer2, 1) end #-------------------------------------------------------------------------- # Atualização do cursor #-------------------------------------------------------------------------- def update_cursor_rect cursor_rect.set(0, @index * 32 + 32, self.contents.width, 32) end end #============================================================================== # Game_KeyConfig #------------------------------------------------------------------------------ # Classe que armazena as configurações de teclas. #============================================================================== class Game_KeyConfig #-------------------------------------------------------------------------- # Inicialização do objeto #-------------------------------------------------------------------------- def initialize @data = [] if @data[0] == nil @data[0] = Input::C end if @data[1] == nil @data[1] = Input::B end =begin if @data[2] == nil @data[2] = Input::A end =end if @data[2] == nil @data[2] = Input::L end if @data[3] == nil @data[3] = Input::R end end #-------------------------------------------------------------------------- # Retorna os valores das teclas #-------------------------------------------------------------------------- def keys return @data end #-------------------------------------------------------------------------- # Definição dos novos valores # value : valor das teclas #-------------------------------------------------------------------------- def keys=(value) return @data = value end end #============================================================================== # Scene_Title #------------------------------------------------------------------------------ # Classe das operações na tela de título. #============================================================================== class Scene_Title #-------------------------------------------------------------------------- # Alias do processo principal #-------------------------------------------------------------------------- alias kc_main main #-------------------------------------------------------------------------- # Processo principal #-------------------------------------------------------------------------- def main $default_keys = [] $default_keys.push(Input::C.clone) $default_keys.push(Input::B.clone) # $default_keys.push(Input::A.clone) $default_keys.push(Input::L.clone) $default_keys.push(Input::R.clone) $game_keys = Game_KeyConfig.new kc_main end end #============================================================================== # Scene_Save #------------------------------------------------------------------------------ # Esta classe processa o Save #============================================================================== class Scene_Save < Scene_File #-------------------------------------------------------------------------- # Alias do lê dados do save #-------------------------------------------------------------------------- alias kg_write_save_data write_save_data #-------------------------------------------------------------------------- # Escreve dados de save # file : arquivo onde será salvo #-------------------------------------------------------------------------- def write_save_data(file) kg_write_save_data(file) Marshal.dump($game_keys, file) end end #============================================================================== # Scene_Load #------------------------------------------------------------------------------ # Esta classe processa a tela de Continuar #============================================================================== class Scene_Load < Scene_File #-------------------------------------------------------------------------- # Alias do lê dados de save #-------------------------------------------------------------------------- alias kg_read_save_data read_save_data #-------------------------------------------------------------------------- # Lê dados de save # file : arquivo onde está salvo #-------------------------------------------------------------------------- def read_save_data(file) kg_read_save_data(file) $game_keys = Marshal.load(file) @actual_keys = [] @actual_keys.push(Input::C) @actual_keys.push(Input::B) # @actual_keys.push(Input::A) @actual_keys.push(Input::L) @actual_keys.push(Input::R) for i in 0 .. $game_keys.keys.size - 1 for j in 0 .. $game_keys.keys[i].size - 1 if @actual_keys[i][j].nil? @actual_keys[i].push($game_keys.keys[i][j]) else @actual_keys[i][j] = $game_keys.keys[i][j] end end end end end #============================================================================== # Scene_KeyConfig #------------------------------------------------------------------------------ # Classe de operações da tela de configuração de botões. #============================================================================== class Scene_KeyConfig < Scene_Base #-------------------------------------------------------------------------- # Inclusão das constantes do módulo KeyConfig_Set #-------------------------------------------------------------------------- include KeyConfig_Set #-------------------------------------------------------------------------- # Inicialização do processo #-------------------------------------------------------------------------- def start super $game_keys = Game_KeyConfig.new if $game_keys.nil? @key_config_window = Window_KeyConfig.new @key_config_window.opacity = MENU_OPACITY @message_window = Window_Base.new(0, 208, 640, 64) @message_window.z = 200 @message_window.back_opacity = 255 @message_window.opacity = 255 question = DEFINE_KEYS @message_window.contents.draw_text(0, 0, 640 - 32, 24, question, 1) @message_window.visible = false @input_selection = false @input_decision = false @input_index = 0 if MNWA @menu_name_window = Window_Base.new(MNWV[0], MNWV[1], MNWV[2], MNWV[3]) @menu_name_window.opacity = MENU_OPACITY @menu_name_window.contents.font.color = @menu_name_window.system_color @menu_name_window.contents.draw_text(0, 0, @menu_name_window.contents.width, 24, MENU_NAME, 1) end @ask_window = nil @key_index = nil end #-------------------------------------------------------------------------- # Atualização da tela #-------------------------------------------------------------------------- def update super @menu_name_window.update if MNWA if @ask_window != nil update_ask_selection elsif @key_config_window.active and not @input_selection and not @input_decision update_command_selection elsif @input_selection update_input_selection elsif @input_decision update_input_decision end end #-------------------------------------------------------------------------- # Fim do processo #-------------------------------------------------------------------------- def terminate super @menu_name_window.dispose if MNWA @key_config_window.dispose end #-------------------------------------------------------------------------- # Index da tecla #-------------------------------------------------------------------------- def key_index return @key_index end #-------------------------------------------------------------------------- # Atualização da seleção do comando #-------------------------------------------------------------------------- def update_command_selection @key_config_window.update if Input::trigger?(Input::C) $game_system.se_play($data_system.decision_se) if @key_config_window.index == 4 question = RETURN_DEFAULT answer1 = ANSWER_A answer2 = ANSWER_B @ask_window = Window_Ask.new(0, 224, 640, 128, question, answer1, answer2) @ask_window.index = 0 @ask_window.contents.font.name = MENU_FONT @ask_window.refresh @update_ask = true @key_config_window.refresh else @key_index = @key_config_window.index @memo_index = @key_config_window.index @input_index = 0 @key_config_window.refresh @input_selection = true end elsif Input::trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new end end #-------------------------------------------------------------------------- # Atualização da janela de pergunta #-------------------------------------------------------------------------- def update_ask_selection @ask_window.update if @update_ask if Input.trigger?(Input::C) case @ask_window.index when 0 $game_system.se_play($data_system.decision_se) @keys = [] @keys.push(Input::C) @keys.push(Input::B) # @keys.push(Input::A) @keys.push(Input::L) @keys.push(Input::R) for i in 0 .. @keys.size - 1 for j in 0 .. @keys[i].size - 1 if $default_keys[i][j].nil? @keys[i].delete_at(j) else @keys[i][j] = $default_keys[i][j] end end end @update_ask = false @ask_window.dispose @ask_window = nil @key_index = nil @key_config_window.refresh when 1 $game_system.se_play($data_system.cancel_se) @update_ask = false @ask_window.dispose @ask_window = nil @key_index = nil @key_config_window.refresh end elsif Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @update_ask = false @ask_window.dispose @ask_window = nil @key_index = nil @key_config_window.refresh end end #-------------------------------------------------------------------------- # Atualização da seleção das teclas #-------------------------------------------------------------------------- def update_input_selection @key_config_window.update @key_config_window.index = @memo_index @cell_size = (@key_config_window.contents.width / 2) / 3 @half_size = (@key_config_window.contents.width / 2) @key_config_window.cursor_rect.set(@half_size + (@input_index + 1) + (@cell_size * @input_index), 32 * (@key_config_window.index + 1), @cell_size - 2, 32) if Input.trigger?(Input::RIGHT) @input_index += 1 if @input_index > 2 @input_index = 0 end elsif Input.trigger?(Input::LEFT) @input_index -= 1 if @input_index < 0 @input_index = 2 end end if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @key_index = nil @key_config_window.refresh @input_selection = false elsif Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @temptrigger = {} @input_selection = false @input_decision = true @keys = [] @keys.push(Input::C) @keys.push(Input::B) # @keys.push(Input::A) @keys.push(Input::L) @keys.push(Input::R) end end #-------------------------------------------------------------------------- # Teclas não permitidas #-------------------------------------------------------------------------- def not_allowed_keys(k) keys = [] true_count = 0 for i in 1 .. 2 keys.push(i) end for i in 4 .. 6 keys.push(i) end for i in 37 .. 40 keys.push(i) end for i in 112 .. 135 keys.push(i) end for i in 0 .. keys.size - 1 if keys[i] != k true_count += 1 end end if true_count != keys.size - 1 return true else return false end end #-------------------------------------------------------------------------- # Atualização da decisão de teclas #-------------------------------------------------------------------------- def update_input_decision @message_window.visible = true case @key_config_window.index when 0 @action = Input::C when 1 @action = Input::B # when 2 # @action = Input::A when 2 @action = Input::L when 3 @action = Input::R end actual_key = @action[@input_index] Input.triggered.each do |i| @temptrigger[i] = 5 end @temptrigger.each do |k, v| if not_allowed_keys(k) for i in 0 .. @keys.size - 1 for j in 0 .. @keys[i].size - 1 if @keys[i][j] == k if actual_key.nil? @keys[i].delete_at(j) else @keys[i][j] = actual_key end end end end if @input_index > 0 and @action[@input_index - 1].nil? @action[@input_index - 1] = k else @action[@input_index] = k end end if @temptrigger[k] != nil and not_allowed_keys(k) $game_system.se_play($data_system.decision_se) @input_decision = false @input_selection = true @message_window.visible = false @key_config_window.refresh end $game_keys.keys = @keys end end end