Gabz

Extreme Menu

Nov 26th, 2013
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 206.72 KB | None | 0 0
  1. #=============================================================================
  2. # * Mundo RPG Maker Extreme Menu
  3. #---------------------------------------------------------------------------
  4. # Autor: Gab!
  5. # Data:  22/12/12 ~ 20/01/13
  6. #---------------------------------------------------------------------------
  7. # Créditos:
  8. #   * Tweening:
  9. #     - Robert Penner
  10. #     - UziMonkey
  11. #   * CogWheel Bars:
  12. #     - Syvkal
  13. #   * Base da classe StaticMiniMap:
  14. #     - SheolShade
  15. #   * Janela de descrição de itens/equipamentos:
  16. #     - Yanfly
  17. #--------------------------------------------------------------------------
  18. # Instruções de instalação:
  19. #   - Cole acima do script 'Main', preferencialmente abaixo do indicador
  20. #     "Scripts Adicionais"
  21. #
  22. #   - Leia as instruções de uso
  23. #
  24. #   - Configure abaixo
  25. #
  26. #--------------------------------------------------------------------------
  27. # Instruções de uso:
  28. #
  29. #   * Para remover uma opção do menu, use o comando seguinte em 'chamar script':
  30. #     MRM::ExtremeMenu.disable(opção)
  31. #
  32. #     'opção' é o ícone que será desativado, deve ser um do termos abaixo:
  33. #     - :Items     # Itens
  34. #     - :Equips    # Equipamentos
  35. #     - :Skills    # Habilidades
  36. #     - :Formation # Formação
  37. #     - :Status    # Estado
  38. #     - :Bestiary  # Bestiário
  39. #     - :PDist     # Distribuição de pontos
  40. #     - :MiniMap   # Mini-Mapa
  41. #     - :Options   # Opções
  42. #     - :Save      # Salvar jogo
  43. #     - :Exit      # Sair do jogo
  44. #
  45. #   #=====================================================================#
  46. #
  47. #   * Para adicionar novamente uma opção removida, basta chamar o comando:
  48. #     MRM::ExtremeMenu.enable(opção)
  49. #
  50. #     'opção' se refere ao ícone que será adicionado novamente.
  51. #
  52. #   #=====================================================================#
  53. #
  54. #   * Para verificar se uma opção está ativa no menu, pela opção de scripts
  55. #     das condições nos eventos, use:
  56. #     MRM::ExtremeMenu.enabled?(opção)
  57. #
  58. #     'opção' novamente se refere ao ícone que será checado.
  59. #
  60. #   #=====================================================================#
  61. #
  62. #   * Os personagens ganham pontos automaticamente ao passar de nível, porém
  63. #     se houver necessidade de adicionar ou retirar pontos, usa-se:
  64. #
  65. #     Adicionar: MRM::ExtremeMenu.giveActorPoints(ator, qt)
  66. #     Remover:   MRM::ExtremeMenu.removeActorPoints(ator, qt)
  67. #    
  68. #     Em ambos 'ator' se refere ao ID do ator *na database* e 'qt' será a
  69. #     quantidade de pontos adicionados ou removidos.
  70. #
  71. #   #=====================================================================#
  72. #
  73. #   * Para adicionar ou remover monstros do bestiário:
  74. #
  75. #     Adicionar: MRM::ExtremeMenu.bestiaryAddMonster(id)
  76. #     Remover:   MRM::ExtremeMenu.bestiaryRemoveMonster(id)
  77. #
  78. #     Nos dois casos 'id' indica o ID do monstro na database.
  79. #
  80. #=============================================================================
  81.  
  82. module (MRM ||= Module.new)::ExtremeMenu
  83.   #===========================================================================
  84.   # ** CONFIGURAÇÃO
  85.   #===========================================================================
  86.  
  87.   Use = { # Marque com true as opções que deve ser ativas no início do jogo
  88.           # false caso contrário.
  89.     Items:     true, # Itens
  90.     Equips:    true, # Equipamentos
  91.     Skills:    true, # Habilidades
  92.     Formation: true, # Formação
  93.     Status:    true, # Estado
  94.     Bestiary:  true, # Bestiário
  95.     PDist:     true, # Distribuição de pontos
  96.     MiniMap:   true, # Mini-Mapa
  97.     Options:   true, # Opções (Som)
  98.     Save:      true, # Salvar Jogo
  99.     Exit:      true, # Sair do Jogo
  100.   }
  101.    
  102.   Vocab = { # Vocabulário
  103.     Items:       "Itens",                # Itens
  104.     Equips:      "Equipamentos",         # Equipamentos
  105.     Skills:      "Habilidades",          # Habilidades
  106.     Status:      "Estado",               # Estado
  107.     Formation:   "Formação",             # Formação
  108.     Bestiary:    "Bestiário",            # Bestiário
  109.     PDist:       "Pontos",               # Distribuição de pontos
  110.     MiniMap:     "Mini-Mapa",            # Mini-Mapa
  111.     Options:     "Opções",               # Opções
  112.     Save:        "Salvar",               # Salvar jogo
  113.     Exit:        "Sair",                 # Deixar jogo
  114.     #==========================
  115.     NoItemUser:  "Nenhum usuário para o item!", #
  116.     Item:        "Item Comum",           # Item Comum
  117.     Weapon:      "Arma",                 # Armas
  118.     Armor:       "Armadura",             # Armaduras
  119.     KeyItem:     "Item Chave",           # Itens chave
  120.     Empty:       "---",                  # Quando nada é mostrado
  121.     HPRecover:   "Recup. de HP",         # Recuperação de HP
  122.     MPRecover:   "Recup. de MP",         # Recuperação de MP
  123.     TPRecover:   "Recup. de TP",         # Recuperação de TP
  124.     TPGain:      "Ganho de TP",          # Ganho de TP
  125.     Applies:     "Provoca",              # Estados provacados
  126.     Removes:     "Remove",               # Estados removidos
  127.     #==========================
  128.     FixEquip:    "Equipamento fixo!",    # Equipamento fixo
  129.     Optimize:    "Melhor Equipamento",   # Otimizar equipamentos e selecionar
  130.                                          # os melhores
  131.     #==========================
  132.     InsufActs:   "Apenas um membro no grupo!", # Membros insuficientes para abrir
  133.                                                # o menu de formação
  134.    
  135.     #==========================
  136.     ZeroMonster: "Bestiário vazio!",     # Não existem monstros no bestiário
  137.     BComplete:   "Progresso: {c}%",      # Progresso. ({c} será substituido pela
  138.                                          # porcentagem de progresso.)
  139.     Experience:  "Experiência",          # Experiência
  140.     Loot:        "Recompensas",          # Recompensas
  141.    
  142.     #==========================
  143.     InsufPts:    "Pontos insuficientes", # Pontos insuficientes
  144.    
  145.     #==========================
  146.     OptionsSFX:  "Efeitos Sonoros",      # Efeitos sonoros
  147.     OptionsMsc:  "Música",               # Música (BGM, ME)
  148.     OptionsSnd:  "Som",                  # Som (BGS, SE)
  149.    
  150.     #==========================
  151.     SaveBlock:   "Save Bloqueado",       # Salvar desabilitado
  152.     FreeSlot:    "Slot vazio",           # Slot de save vazio
  153.     NewSave:     "Novo save",            # Criar novo save
  154.     PlayTime:    "Tempo de Jogo:",       # Tempo de jogo
  155.     Party:       "Grupo",                # Grupo
  156.     SaveOver:    "Sobrescrever?",        # Confirmação de sobresctrita
  157.     SaveYes:     "Sim",                  # Confirmação de Sobrescrita (Sim)
  158.     SaveNo:      "Não",                  # Confirmação de Sobrescrita (Não)
  159.     Saved:       "Jogo salvo!",          # Jogo salvo
  160.    
  161.     #==========================
  162.     ExitTitle:   "Tela de Título",       # Voltar ao título
  163.     ExitGame:    "Deixar Jogo",          # Sair do jogo
  164.     ExitCanc:    "Cancelar",             # Cancelar Saída
  165.   }
  166.  
  167.   Font = { # Definições de fonte
  168.     Name:    "Trebuchet MS",       # Nome
  169.     Size:    18,                   # Tamanho
  170.     Color:   [255, 255, 255, 255], # Cor (R, G, B, A)
  171.     Shadow:  true,                 # Usar sombra?
  172.     Outline: false,                # Usar outline?
  173.   }
  174.  
  175.   Icon = { # ID dos ícones
  176.     Items:      194, # Itens
  177.     Equips:     115, # Equipamentos
  178.     Skills:     116, # Skills
  179.     Status:      10, # Estado
  180.     Formation:   11, # Formação
  181.     Bestiary:     9, # Bestiário
  182.     PDist:      125, # Distribuição de pontos
  183.     MiniMap:    231, # Mini-Mapa
  184.     Options:    185, # Opções (Som)
  185.     Save:       230, # Salvar jogo
  186.     Exit:       121, # Sair
  187.     #=============================
  188.     Item:       197, # Itens comuns
  189.     Weapon:     148, # Armas
  190.     Armor:      169, # Armadura
  191.     KeyItem:    243, # Item Chave
  192.     #=============================
  193.     SaveYes:    113, # Confirmação de Sobrescrita (Sim)
  194.     SaveNo:     114, # Confirmação de Sobrescrita (Não)
  195.     #=============================
  196.     ExitTitle:   16, # Voltar ao título
  197.     ExitGame:     1, # Sair do jogo
  198.     ExitCanc:   114, # Cancelar Saída
  199.     #=============================
  200.     Gold:       361, # Ouro
  201.   }
  202.  
  203.   DisabledIcon = {  # Ícones desabilitados
  204.                     # Use -1 para usar o mesmo ícone porém escurecido
  205.                    
  206.     Formation:  -1, # Ícone de formação quando não é possível modificá-la
  207.     Bestiary:   -1, # Ícone do bestiário quando não existem monstros novos
  208.     PDist:     126, # Ícone de distribuição de pontos quando não existem
  209.                     # pontos para ser distribuidos
  210.     Save:      368, # Ícone de save desabilitado
  211.   }
  212.  
  213.   # Velocidade de atualização dos sprites dos atores
  214.   ActorsSpeed = 25
  215.  
  216.   # Confirmar sobreescrita em slot de save?
  217.   ConfirmOverwrite = true
  218.  
  219.   # Adicionar monstros ao bestiário automaticamente após as batalhas ganhas?
  220.   # (Pode não funcionar quando utilizando um sistema de batalha diferente)
  221.   AutoBestiaryAdd  = true
  222.  
  223.   # Número máximo de efeitos adicionados/removidos que são mostrados nos
  224.   # itens do inventário
  225.   MaxIconsDrawn = 5
  226.  
  227.   # Barras de HP e MP
  228.   BarColor1 = [  0,   0,   0, 192] # Borda exterior
  229.   BarColor2 = [255, 255, 192, 192] # Borda interior
  230.   BarColor3 = [  0,   0,   0,  12] # Metade do sombreamento
  231.   BarColor4 = [ 64,   0,   0,  92] # Metade do sombreamento
  232.  
  233.   # Cores de mensagens
  234.   MsgOk    = [204, 255,   0, 230] # Mensagem Ok
  235.   MsgInfo  = [  0, 204, 255, 230] # Mensagem de informação/pergunta
  236.   MsgError = [255,   0,  68, 250] # Mensagem de erro
  237.  
  238.   #-------------------------------------------------------------------------
  239.   # DISTRIBUIÇÃO DE PONTOS
  240.   #-------------------------------------------------------------------------
  241.   # É possível determinar, para cada classe, quantos pontos serão ganhos por
  242.   # nível e quantos serão requeridos para cada atributo.
  243.   #
  244.   # Existe uma notação [X,Y] que indica o seguinte:
  245.   #   X é a quantidade de pontos que serão necessário para aumentar em Y
  246.   #   o atributo indicado.
  247.   #
  248.   # A quantidade de pontos ganhos por nível PODE ser um valor decimal. Porém
  249.   # só será considerado um valor inteiro. Logo, se PPN = 3.5, o ator ganhará
  250.   # 3 pontos no primeiro e no segundo nível, porém no terceiro ganhará 4.
  251.   #-------------------------------------------------------------------------
  252.   PDistPoints = {
  253.     # Siga este padrão, caso existam mais classes:
  254.     # ID DA CLASSE => {
  255.     #   PPN: Pontos ganhos por nível,
  256.     #   HPM: [X, Y], # HP Máximo
  257.     #   MPM: [X, Y], # MP Máximo
  258.     #   ATK: [X, Y], # Ataque
  259.     #   DEF: [X, Y], # Defesa
  260.     #   ATM: [X, Y], # Ataque Mágico (Inteligência)
  261.     #   DEM: [X, Y], # Defesa Mágica (Resistência)
  262.     #   AGI: [X, Y], # Agilidade
  263.     #   SOR: [X, Y], # Sorte
  264.     # },
  265.    
  266.     1 => { # Guerreiro
  267.       PPN: 4,
  268.       HPM: [1, 10], # HP Máximo
  269.       MPM: [1, 10], # MP Máximo
  270.       ATK: [1,  5], # Ataque
  271.       DEF: [1,  5], # Defesa
  272.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  273.       DEM: [3,  5], # Defesa Mágica (Resistência)
  274.       AGI: [1,  3], # Agilidade
  275.       SOR: [3,  1], # Sorte
  276.     },
  277.      
  278.     2 => { # Monge
  279.       PPN: 4,
  280.       HPM: [1, 10], # HP Máximo
  281.       MPM: [1, 10], # MP Máximo
  282.       ATK: [2, 10], # Ataque
  283.       DEF: [1,  8], # Defesa
  284.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  285.       DEM: [2,  5], # Defesa Mágica (Resistência)
  286.       AGI: [1,  5], # Agilidade
  287.       SOR: [3,  1], # Sorte
  288.     },
  289.    
  290.     3 => { # Cavaleiro
  291.       PPN: 4,
  292.       HPM: [1, 10], # HP Máximo
  293.       MPM: [1, 10], # MP Máximo
  294.       ATK: [1,  8], # Ataque
  295.       DEF: [1,  7], # Defesa
  296.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  297.       DEM: [3,  5], # Defesa Mágica (Resistência)
  298.       AGI: [1,  3], # Agilidade
  299.       SOR: [3,  1], # Sorte
  300.     },
  301.    
  302.     4 => { # Espadachim
  303.       PPN: 5,
  304.       HPM: [1, 15], # HP Máximo
  305.       MPM: [2, 15], # MP Máximo
  306.       ATK: [1,  8], # Ataque
  307.       DEF: [1,  7], # Defesa
  308.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  309.       DEM: [3,  5], # Defesa Mágica (Resistência)
  310.       AGI: [1,  3], # Agilidade
  311.       SOR: [3,  1], # Sorte
  312.     },
  313.    
  314.     5 => { # Samurai
  315.       PPN: 4,
  316.       HPM: [1, 10], # HP Máximo
  317.       MPM: [1, 10], # MP Máximo
  318.       ATK: [1,  5], # Ataque
  319.       DEF: [1,  5], # Defesa
  320.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  321.       DEM: [3,  5], # Defesa Mágica (Resistência)
  322.       AGI: [1,  7], # Agilidade
  323.       SOR: [3,  1], # Sorte
  324.     },
  325.    
  326.     6 => { # Arqueiro
  327.       PPN: 4,
  328.       HPM: [1, 10], # HP Máximo
  329.       MPM: [1, 10], # MP Máximo
  330.       ATK: [1,  5], # Ataque
  331.       DEF: [1,  5], # Defesa
  332.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  333.       DEM: [3,  5], # Defesa Mágica (Resistência)
  334.       AGI: [1,  3], # Agilidade
  335.       SOR: [3,  1], # Sorte
  336.     },
  337.    
  338.     7 => { # Ladino
  339.       PPN: 4,
  340.       HPM: [1, 10], # HP Máximo
  341.       MPM: [1, 10], # MP Máximo
  342.       ATK: [1,  5], # Ataque
  343.       DEF: [1,  5], # Defesa
  344.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  345.       DEM: [3,  5], # Defesa Mágica (Resistência)
  346.       AGI: [1,  3], # Agilidade
  347.       SOR: [3,  1], # Sorte
  348.     },
  349.    
  350.     8 => { # Sacerdote
  351.       PPN: 4,
  352.       HPM: [1, 10], # HP Máximo
  353.       MPM: [1, 10], # MP Máximo
  354.       ATK: [1,  5], # Ataque
  355.       DEF: [1,  5], # Defesa
  356.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  357.       DEM: [3,  5], # Defesa Mágica (Resistência)
  358.       AGI: [1,  3], # Agilidade
  359.       SOR: [3,  1], # Sorte
  360.     },
  361.    
  362.     9 => { # Mago
  363.       PPN: 4,
  364.       HPM: [1,  7], # HP Máximo
  365.       MPM: [1, 20], # MP Máximo
  366.       ATK: [2,  5], # Ataque
  367.       DEF: [2,  5], # Defesa
  368.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  369.       DEM: [1,  5], # Defesa Mágica (Resistência)
  370.       AGI: [1,  3], # Agilidade
  371.       SOR: [3,  1], # Sorte
  372.     },
  373.    
  374.     10 => { # Sábio
  375.       PPN: 6,
  376.       HPM: [1, 10], # HP Máximo
  377.       MPM: [1, 10], # MP Máximo
  378.       ATK: [1,  5], # Ataque
  379.       DEF: [1,  5], # Defesa
  380.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  381.       DEM: [3,  5], # Defesa Mágica
  382.       AGI: [1,  3], # Agilidade
  383.       SOR: [3,  1], # Sorte
  384.     },
  385.   }
  386.  
  387.   #------------------------------------------------------------------------
  388.   # Diálogo que alerta o jogador sobre a quantidade de pontos necessários
  389.   # para aprimorar determinado atributo.
  390.   #
  391.   # Separe as linhas por vírgula.
  392.   #
  393.   # As mudanças de cor, substituições de variáveis, nomes de personagens
  394.   # da equipe, etc, serão serão aceitas. Certifique-se de usar barras duplas
  395.   # para que possa funcionar.
  396.   #
  397.   # Existem substituições que o sistema fará:
  398.   # {actorName}   será substituido pelo nome do ator.
  399.   # {actorPoints} será substituido pela quantidade de pontos que o ator tem.
  400.   # {attrName}    será substituido pelo nome do atributo.
  401.   # {attrNPoints} será substituido pela quantidade de pontos que o atributo
  402.   #               precisa para ser aprimorado.
  403.   # {attrGPoints} será substituido pela quantia que o ator ganhará no
  404.   #               atributo selecionado.
  405.   #-------------------------------------------------------------------------
  406.  
  407.   PDistDiag = [
  408.     "\\c[1]Pontos de {actorName}: \\c[0]{actorPoints}",
  409.     "\\c[1]Pontos necessários: \\c[0]{attrNPoints}",
  410.     "\\c[1]Ganhos: \\c[0]{attrGPoints} de {attrName}",
  411.     "",
  412.     "Pressione \\c[10][Enter]\\c[0] para confirmar."
  413.   ]
  414.    
  415.   #-------------------------------------------------------------------------
  416.   # MINI-MAPA
  417.   #-------------------------------------------------------------------------
  418.   # O principal foco aqui são as cores. Perceba que estão todas no formato
  419.   # RGBA, ou seja, você terá quatro campos para preencher: [R, G, B, A]
  420.   # Onde:
  421.   #   R = Vermelho
  422.   #   G = Verde
  423.   #   B = Azul
  424.   #   A = Opacidade
  425.   # Cada um pode ir de 0 até 255.
  426.   #-------------------------------------------------------------------------
  427.  
  428.   # Tamanho dos tiles
  429.   TileSize    = 8
  430.  
  431.   # Dependendo do tamanho dos tiles, pode exister necessidade de fazer um
  432.   # ajuste de posições.
  433.   MapOffset   = -4
  434.  
  435.   # Cor do player
  436.   PlayerColor = [255, 0, 0, 255]
  437.    
  438.   # Cor dos eventos
  439.   ObjectColor = {
  440.    
  441.     # Esta configuração permite que você adicione
  442.     # diferentes cores para cada tipo de evento.
  443.     #
  444.     # Para que um evento apareça no mini-map você
  445.     # deve colocar um comentário com uma das
  446.     # opções abaixo.
  447.     #
  448.     # Utilize este padrão:
  449.     # "comentário" => [R, G, B, A],
  450.    
  451.     "npc"   => [  0, 255,   0, 255],
  452.     "door"  => [  0,   0, 255, 255],
  453.     "chest" => [100, 100, 100, 255],
  454.   }
  455.  
  456.   # Cor da borda dos eventos e do player
  457.   BorderColor        = [  0,   0,   0, 255]  
  458.  
  459.   # Cor dos obstáculos
  460.   MapColor           = [  0,   0,   0, 255]
  461.  
  462.   # Cor da borda dos obstáculos
  463.   MapBorderColor     = [ 50,  50,  50, 255]
  464.  
  465.   # Opacidade da camada de eventos
  466.   ObjectLayerOpacity = 255
  467.  
  468.   #-------------------------------------------------------------------------
  469.   # ANIMAÇÕES
  470.   #-------------------------------------------------------------------------
  471.   # O menu permite a configuração das animações, deve-se usar um número de 0
  472.   # até 29 para selecionar a animação que você quer. Sendo que:
  473.   #
  474.   #  0 = Linear                     | 15 = Cúbica (Entrada e Saída)
  475.   #  1 = Senoidal (Entrada)         | 16 = Exponencial (Entrada)
  476.   #  2 = Senoidal (Saída)           | 17 = Exponencial (Saída)
  477.   #  3 = Senoidal (Entrada e Saída) | 18 = Exponencial (Entrada e Saída)
  478.   #  4 = Circular (Entrada)         | 19 = Quadrática (Entrada)
  479.   #  5 = Circular (Saída)           | 20 = Quadrática (Saída)
  480.   #  6 = Circular (Entrada e Saída) | 21 = Quadrática (Entrada e Saída)
  481.   #  7 = Mola (Entrada)             | 22 = Quártica (Entrada)
  482.   #  8 = Mola (Saída)               | 23 = Quártica (Saída)
  483.   #  9 = Mola (Entrada e Saída)     | 24 = Quártica (Entrada e Saída)
  484.   # 10 = Retorno (Entrada)          | 25 = Quíntica (Entrada)
  485.   # 11 = Retorno (Saída)            | 26 = Quíntica (Saída)
  486.   # 12 = Retorno (Entrada e Saída)  | 27 = Quíntica (Entrada e Saída)
  487.   # 13 = Cúbico (Entrada)           | 28 = Elástica (Entrada)
  488.   # 14 = Cúbica (Saída)             | 29 = Elástica (Saída)
  489.   #
  490.   # Todos os campos "Duração" são referentes ao tempo da animação em segundos
  491.   # Todos os campos "Atraso" são referentes ao atraso da animação em centésimos
  492.   #-------------------------------------------------------------------------
  493.   Animation = {
  494.     # Animação de entrada dos ícones
  495.     IconsEnter: [
  496.       9, # ID da animação
  497.       1, # Duração
  498.       5, # Atraso
  499.     ],
  500.    
  501.     # Animação de movimendo dos ícones
  502.     IconsMove: [
  503.        12, # ID da animação
  504.       0.5, # Duração
  505.     ],
  506.    
  507.     # Animação de entrada do Cursor
  508.     CursorEnter: [
  509.       13, # ID da animação
  510.        1, # Duração
  511.     ],
  512.    
  513.     # Animação de movimento do Cursor
  514.     CursorMove: [
  515.        29, # ID da animação
  516.       0.5, # Duração
  517.     ],
  518.    
  519.     # Animação de entrada da janela de ouro
  520.     GoldEnter: [
  521.        18, # ID da animação
  522.         2, # Duração
  523.     ],
  524.    
  525.     # Animação da mensagem
  526.     Message: [
  527.       21, # ID da animação
  528.        1, # Duração
  529.     ],
  530.    
  531.     # Animação de entrada das informações (básicas) dos atores
  532.     WindowsEnter: [
  533.       27, # ID da animação
  534.        2, # Duração
  535.        5, # Atraso
  536.     ],
  537.    
  538.     # Animação de movimento das informações (básicas) dos atores
  539.     WindowsMove: [
  540.        16, # ID da animação
  541.         1, # Duração
  542.         1, # Atraso
  543.     ],
  544.    
  545.     # Animação de entrada da janela de seleção de atores
  546.     ActorSelEnter: [
  547.       4, # ID da animação
  548.       1, # Duração
  549.     ],
  550.    
  551.     # Animação de movimento da janela de seleção de atores
  552.     ActorSelMove: [
  553.        24, # ID da animação
  554.       0.5, # Duração
  555.     ],
  556.    
  557.     # Animação de entrada das janelas de itens
  558.     ItemsEnter: [
  559.       9, # ID da animação
  560.       1, # Duração
  561.     ],
  562.    
  563.     # Animação de movimento das janelas de itens
  564.     ItemsMove: [
  565.        12, # ID da animação
  566.       0.5, # Duração
  567.     ],
  568.    
  569.     # Animação de entrada das janelas de equipamentos
  570.     EquipsEnter: [
  571.       9, # ID da animação
  572.       1, # Duração
  573.     ],
  574.    
  575.     # Animação de movimento das janelas de equipamentos
  576.     EquipsMove: [
  577.        12, # ID da animação
  578.       0.5, # Duração
  579.     ],
  580.    
  581.     # Animação de entrada das janelas de habilidades
  582.     SkillsEnter: [
  583.      12, # ID da animação
  584.       1, # Duração
  585.     ],
  586.    
  587.     # Animação de movimento das janelas de habilidades
  588.     SkillsMove: [
  589.        15, # ID da animação
  590.       0.5, # Duração
  591.     ],
  592.    
  593.     # Animação de entrada das janelas de formação
  594.     FormationEnter: [
  595.        29, # ID da animação
  596.       1.5, # Duração
  597.         1, # Atraso
  598.     ],
  599.    
  600.     # Animação de movimento das janelas de formação
  601.     FormationMove: [
  602.        12, # ID da animação
  603.       1.5, # Duração
  604.     ],
  605.    
  606.     # Animação de entrada das janelas de informações completas
  607.     StatusEnter: [
  608.       29, # ID da animação
  609.        2, # Duração
  610.     ],
  611.    
  612.     # Animação de movimento das janelas de informações completas
  613.     StatusMove: [
  614.        3, # ID da animação
  615.      0.5, # Duração
  616.     ],
  617.    
  618.     # Animação de entrada das janelas de monstros do bestiário
  619.     BestiaryEnter: [
  620.       22, # ID da animação
  621.        1, # Duração
  622.        1, # Atraso
  623.     ],
  624.    
  625.     # Animação de movimento das janelas de monstros do bestiário
  626.     BestiaryMove: [
  627.       15, # ID da animação
  628.      0.3, # Duração
  629.     ],
  630.    
  631.     # Animação de entrada das janelas de informações completas
  632.     PDistEnter: [
  633.       29, # ID da animação
  634.        2, # Duração
  635.     ],
  636.    
  637.     # Animação de movimento das janelas de informações completas
  638.     PDistMove: [
  639.        3, # ID da animação
  640.      0.5, # Duração
  641.     ],
  642.    
  643.     # Animação de entrada do mini-mapa
  644.     MiniMapEnter: [
  645.        9, # ID da animação
  646.        1, # Duração
  647.     ],
  648.    
  649.     # Animação de movimento do mini-mapa
  650.     MiniMapMove: [
  651.        9, # ID da animação
  652.        1, # Duração
  653.     ],
  654.    
  655.     # Animação de entrada da janela de opções
  656.     OptionEnter: [
  657.       29, # ID da animação
  658.        2, # Duração
  659.     ],
  660.        
  661.     # Animação de entrada das janelas de save
  662.     SaveEnter: [
  663.        27, # ID da animação
  664.       1.5, # Duração
  665.         1, # Atraso
  666.     ],
  667.    
  668.     # Animação de movimento das janelas de save
  669.     SaveMove: [
  670.          1, # ID da animação
  671.       0.25, # Duração
  672.     ],
  673.   }
  674.  
  675.   #===========================================================================
  676.   # ** FIM DA CONFIGURAÇÃO
  677.   #===========================================================================
  678.  
  679.   ColorOk    = Color.new(*MsgOk   )
  680.   ColorInfo  = Color.new(*MsgInfo )
  681.   ColorError = Color.new(*MsgError)
  682.  
  683.   #---
  684.  
  685.   @enabled = []
  686.   @cache   = false
  687.  
  688.   Use.each_pair{|key, value| @enabled << key if value}
  689.  
  690.   module_function
  691.  
  692.   #-------------------------------------------------------------------------
  693.   # * Ativa uma opção do menu durante o jogo (Chamada por eventos)
  694.   #     option : Chave que identifica o comando
  695.   #-------------------------------------------------------------------------
  696.   def enable(option)
  697.     if Use.keys.include?(option) and not @enabled.include?(option)
  698.       @enabled.push(option)
  699.     end
  700.   end
  701.  
  702.   #-------------------------------------------------------------------------
  703.   # * Desativa uma opção do menu durante o jogo (Chamada por eventos)
  704.   #     option : Chave que identifica o comando
  705.   #-------------------------------------------------------------------------
  706.   def disable(option)
  707.     @enabled.delete(option) if Use.keys.include?(option)
  708.   end
  709.  
  710.   #-------------------------------------------------------------------------
  711.   # * Verifica se um comando está ativado
  712.   #     option : Chave que identifica o comando
  713.   #-------------------------------------------------------------------------
  714.   def enabled?(option)
  715.     return @enabled.include?(option)
  716.   end
  717.  
  718.   #-------------------------------------------------------------------------
  719.   # * Dá pontos de atributo à um ator
  720.   #     id : ID do ator na database
  721.   #     qt : Quantidade de pontos
  722.   #-------------------------------------------------------------------------
  723.   def giveActorPoints(id, qt)
  724.     members = $game_party.members
  725.     index   = members.map{|actor| actor.id}.index(id)
  726.     return unless index
  727.     members[index].attrPoints += qt
  728.     members[index].attrPoints  = 0 if members[index].attrPoints < 0
  729.   end
  730.  
  731.   #-------------------------------------------------------------------------
  732.   # * Dá pontos de atributo de um ator
  733.   #     id : ID do ator na database
  734.   #     qt : Quantidade de pontos
  735.   #-------------------------------------------------------------------------
  736.   def removeActorPoints(id, qt)
  737.     giveActorsPoints(id, -qt)
  738.   end
  739.  
  740.   #-------------------------------------------------------------------------
  741.   # * Adiciona monstro ao bestiário
  742.   #     id : ID do monstro na database
  743.   #-------------------------------------------------------------------------
  744.   def bestiaryAddMonster(id)
  745.     $game_system.bestiaryAddMonster(id)
  746.   end
  747.  
  748.   #-------------------------------------------------------------------------
  749.   # * Remove monstro do bestiário
  750.   #     id : ID do monstro na database
  751.   #-------------------------------------------------------------------------
  752.   def bestiaryRemoveMonster(id)
  753.     $game_system.bestiaryRemoveMonster(id)
  754.   end
  755.  
  756.   #================
  757.  
  758.   #-------------------------------------------------------------------------
  759.   # * Retorna todas as opções ativas
  760.   #-------------------------------------------------------------------------
  761.   def enabled
  762.     return @enabled
  763.   end
  764.   #-------------------------------------------------------------------------
  765.   # * Retorna todas as opções ativas
  766.   #-------------------------------------------------------------------------
  767.   def enabledOptions(ret = :none)
  768.     options = @enabled.dup
  769.     return options if ret == :none
  770.    
  771.     case ret
  772.     when :icon
  773.       options.map!{|key|
  774.         base = Icon[key]
  775.      
  776.         if (key == :Formation) and ($game_party.members.size < 2)
  777.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  778.         end
  779.        
  780.         if (key == :Bestiary) and (!$game_system.new_monsters)
  781.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  782.         end
  783.        
  784.         if (key == :PDist) and ($game_party.members.all?{|ac| ac.attrPoints == 0})
  785.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  786.         end
  787.        
  788.         if (key == :Save) and ($game_system.save_disabled)
  789.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  790.         end
  791.        
  792.         base      
  793.       }
  794.      
  795.     when :name
  796.       options.map!{|key| Vocab[key]}
  797.      
  798.     end
  799.   end
  800.   #-------------------------------------------------------------------------
  801.   # * Retorna todas as subopções ativas
  802.   #-------------------------------------------------------------------------
  803.   def enabledSubOption(option = :none, type = :none)
  804.     case option
  805.     when :Items
  806.       keys = [:Item, :Weapon, :Armor, :KeyItem]
  807.     when :Save
  808.       keys = [:SaveYes, :SaveNo]
  809.     when :Exit
  810.       keys = [:ExitTitle, :ExitGame, :ExitCanc]
  811.     end
  812.    
  813.     return keys if type == :none
  814.     return keys.map{|key| type == :Names ? Vocab[key] : Icon[key] }
  815.   end
  816. end
  817.  
  818. #==============================================================================
  819. # ** Numeric
  820. #------------------------------------------------------------------------------
  821. # Classe que rege as instâncias numéricas
  822. #==============================================================================
  823. class Numeric
  824.   #-------------------------------------------------------------------------
  825.   # * Converte o numérico para string
  826.   #-------------------------------------------------------------------------
  827.   def group
  828.     self.to_s
  829.   end
  830. end
  831.  
  832. #==============================================================================
  833. # ** String
  834. #------------------------------------------------------------------------------
  835. # Classe que rege todas as instâncias de strings
  836. #==============================================================================
  837. class String
  838.   UPCASE_ISOTAB   = 'ÀÁÂÃÄÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÇÑÝŸ'
  839.   DOWNCASE_ISOTAB = 'àáâãäèéêëÍíîïòóôõöùúûüçñýÿ'
  840.  
  841.   #-------------------------------------------------------------------------
  842.   # * Faz com que caracteres especiais também sejam colocado em caixa-alta
  843.   #-------------------------------------------------------------------------
  844.   def isoUpcase
  845.     return upcase.tr(DOWNCASE_ISOTAB, UPCASE_ISOTAB)
  846.   end
  847. end
  848.  
  849. #==============================================================================
  850. # ** Audio
  851. #------------------------------------------------------------------------------
  852. # Módulo que coordena toda operação sonora do jogo
  853. #==============================================================================
  854. class << Audio
  855.   alias mrm_extrememenu_bgm_play bgm_play
  856.   alias mrm_extrememenu_me_play  me_play
  857.   alias mrm_extrememenu_bgs_play bgs_play
  858.   alias mrm_extrememenu_se_play  se_play
  859.  
  860.   def bgm_play(name, volume, pitch, pos)
  861.     volume *= $game_system.musicRate if defined?($game_system)
  862.     mrm_extrememenu_bgm_play(name, volume, pitch, pos)
  863.   end
  864.  
  865.   def me_play(name, volume, pitch)
  866.     volume *= $game_system.musicRate if defined?($game_system)
  867.     mrm_extrememenu_me_play(name, volume, pitch)
  868.   end
  869.  
  870.   def bgs_play(name, volume, pitch, pos)
  871.     volume *= $game_system.soundRate if defined?($game_system)
  872.     mrm_extrememenu_bgs_play(name, volume, pitch, pos)
  873.   end
  874.  
  875.   def se_play(name, volume, pitch)
  876.     volume *= $game_system.soundRate if defined?($game_system)
  877.     mrm_extrememenu_se_play(name, volume, pitch)
  878.   end
  879. end
  880.  
  881. #==============================================================================
  882. # ** Bitmap
  883. #------------------------------------------------------------------------------
  884. # Classe que rege as informações sobre bitmaps na memória
  885. #==============================================================================
  886. class Bitmap
  887.   #--------------------------------------------------------------------------
  888.   # Constantes
  889.   #--------------------------------------------------------------------------
  890.   RtlMoveMemory1 = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  891.   RtlMoveMemory2 = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  892.  
  893.   #--------------------------------------------------------------------------
  894.   # * Preenche a informação de cores
  895.   #     data  : Blob
  896.   #     width : Largura
  897.   #--------------------------------------------------------------------------
  898.   def self.new_from_data(data, width)
  899.     b = Bitmap.new(width, data.length/(4 * width))
  900.     RtlMoveMemory2.call(b.address, data, data.length)
  901.     return b
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # * Retorna a informação de cores
  905.   #--------------------------------------------------------------------------
  906.   def get_color_data
  907.     data  = "bgra" * width * height              
  908.     RtlMoveMemory1.call(data, self.address, data.length)
  909.     return data
  910.   end
  911.   #--------------------------------------------------------------------------
  912.   # * Endereço na memória da informação de cores:
  913.   #   *(*(*(bitmap << 1 + 16) + 8) + 16)
  914.   #--------------------------------------------------------------------------
  915.   def address
  916.     buffer = "xxxx"
  917.     ad     = self.object_id * 2 + 16
  918.     RtlMoveMemory1.call(buffer, ad, 4);   ad = buffer.unpack("L").first +  8
  919.     RtlMoveMemory1.call(buffer, ad, 4);   ad = buffer.unpack("L").first + 16
  920.     RtlMoveMemory1.call(buffer, ad, 4); return buffer.unpack("L").first
  921.   end
  922. end
  923.  
  924. #==============================================================================
  925. # ** RPG::BaseItem
  926. #------------------------------------------------------------------------------
  927. # Classe mãe de
  928. #==============================================================================
  929. class RPG::BaseItem
  930.   #--------------------------------------------------------------------------
  931.   # Variáveis de instância públicas
  932.   #--------------------------------------------------------------------------
  933.   attr_accessor :image
  934.  
  935.   #--------------------------------------------------------------------------
  936.   # * Carrega informação necessária das notas do item
  937.   #--------------------------------------------------------------------------
  938.   def load_notetags_aso
  939.     self.note.split(/[\r\n]+/).each{|line|
  940.       if line =~ /<(?:IMAGE|image):[ ](.*)>/i
  941.         @image = $1.to_s
  942.       end
  943.     }
  944.   end
  945.  
  946. end
  947.  
  948. #==============================================================================
  949. # ** DataManager
  950. #------------------------------------------------------------------------------
  951. #  Este módulo gerencia o jogo e objetos do banco de dados utilizados no jogo.
  952. # Quase todas as variáveis globais são inicializadas no módulo.
  953. #==============================================================================
  954. class << DataManager
  955.   alias mrm_extrememenu_init init
  956.   alias mrm_extrememenu_msh  make_save_header
  957.   alias mrm_extrememenu_lg   load_game
  958.   alias mrm_extrememenu_sg   save_game
  959.   alias mrm_extrememenu_ldb  load_database
  960.  
  961.   @last_menu_saveindex = nil
  962.  
  963.   #--------------------------------------------------------------------------
  964.   # * Inicialização
  965.   #     *args, &block : Argumentos
  966.   #--------------------------------------------------------------------------
  967.   def init(*args, &block)
  968.     mrm_extrememenu_init(*args, &block)
  969.     load_config_data
  970.     @last_menu_saveindex = nil
  971.   end
  972.   #--------------------------------------------------------------------------
  973.   # * Carregamento do Banco de Dados
  974.   #     *args, &block : Argumentos
  975.   #--------------------------------------------------------------------------
  976.   def load_database(*args, &block)
  977.     mrm_extrememenu_ldb(*args, &block)
  978.     load_notetags_aso unless $BTEST
  979.   end
  980.   #--------------------------------------------------------------------------
  981.   # * Salva informação de configuração (Última configuração salva)
  982.   #--------------------------------------------------------------------------
  983.   def save_config_data
  984.     File.open("Config.rvdata2", "wb") { |f|
  985.       Marshal.dump($game_system.musicRate, f)
  986.       Marshal.dump($game_system.soundRate, f)
  987.     }
  988.   end
  989.   #--------------------------------------------------------------------------
  990.   # * Carrega informação de configuração
  991.   #--------------------------------------------------------------------------
  992.   def load_config_data
  993.     return unless File.exist?("Config.rvdata2")
  994.     File.open("Config.rvdata2", "rb"){|f|
  995.       $game_system.musicRate = Marshal.load(f)
  996.       $game_system.soundRate = Marshal.load(f)
  997.     }
  998.   end
  999.   #--------------------------------------------------------------------------
  1000.   # * Salvar a criação de cabeçalho
  1001.   #     *args // &block : Argumentos
  1002.   #--------------------------------------------------------------------------
  1003.   def make_save_header(*args, &block)
  1004.     header = mrm_extrememenu_msh(*args, &block)
  1005.    
  1006.     bmap = Bitmap.new(157, 120)
  1007.     ss   = SceneManager.background_bitmap
  1008.     bmap.stretch_blt(bmap.rect, ss, ss.rect)
  1009.     header[:preview] = bmap.get_color_data
  1010.    
  1011.     return header
  1012.   end
  1013.   #--------------------------------------------------------------------------
  1014.   # * Salvar Jogo
  1015.   #     index : índice
  1016.   #--------------------------------------------------------------------------
  1017.   def save_game(index)
  1018.     result = mrm_extrememenu_sg(index)
  1019.     save_config_data
  1020.     @last_menu_saveindex = index if result
  1021.     return result
  1022.   end
  1023.   #--------------------------------------------------------------------------
  1024.   # * Carregamento do Jogo
  1025.   #     index : índice
  1026.   #--------------------------------------------------------------------------
  1027.   def load_game(index)
  1028.     result = mrm_extrememenu_lg(index)
  1029.     @last_menu_saveindex = index if result
  1030.     return result
  1031.   end
  1032.   #--------------------------------------------------------------------------
  1033.   # * Última index carregada
  1034.   #--------------------------------------------------------------------------
  1035.   def last_menu_saveindex
  1036.     return (@last_menu_saveindex || -1) + 1
  1037.   end
  1038.  
  1039.   #--------------------------------------------------------------------------
  1040.   # * Carrega notas dos itens
  1041.   #--------------------------------------------------------------------------
  1042.   def load_notetags_aso
  1043.     [$data_items, $data_weapons, $data_armors].each{|group| group.each{|obj|
  1044.       next unless obj
  1045.       obj.load_notetags_aso
  1046.     }}
  1047.   end
  1048. end
  1049.  
  1050. #==============================================================================
  1051. # ** BattleManager
  1052. #------------------------------------------------------------------------------
  1053. #  Este módulo gerencia o andamento da batalha.
  1054. #==============================================================================
  1055. if MRM::ExtremeMenu::AutoBestiaryAdd
  1056.   class << BattleManager
  1057.     alias mrm_extrememenu_process_victory process_victory
  1058.    
  1059.     #------------------------------------------------------------------------
  1060.     # * Processar vitória
  1061.     #     *args // &block : Argumentos
  1062.     #------------------------------------------------------------------------
  1063.     def process_victory(*args, &block)
  1064.       mrm_extrememenu_process_victory(*args, &block)
  1065.       $game_troop.troop.members.map{|member| member.enemy_id}.uniq.each{|id|
  1066.         $game_system.bestiaryAddMonster(id)
  1067.       }
  1068.     end
  1069.   end
  1070. end
  1071.  
  1072. #==============================================================================
  1073. # ** Game_System
  1074. #------------------------------------------------------------------------------
  1075. # Esta classe gerencia os dados relacionados ao sistema. Também gerencia
  1076. # veículos, BGM, etc.
  1077. # A instância desta classe é referenciada por $game_system.
  1078. #==============================================================================
  1079. class Game_System
  1080.   attr_accessor :musicRate
  1081.   attr_accessor :soundRate
  1082.   attr_accessor :new_monsters
  1083.   attr_reader   :monsters
  1084.  
  1085.   alias mrm_extrememenu_initialize initialize
  1086.  
  1087.   #-------------------------------------------------------------------------
  1088.   # * Inicialização
  1089.   #     *args // &block : Argumentos
  1090.   #-------------------------------------------------------------------------
  1091.   def initialize(*args, &block)
  1092.     mrm_extrememenu_initialize(*args, &block)
  1093.     if defined?($game_system)
  1094.       @musicRate = $game_system.musicRate
  1095.       @soundRate = $game_system.soundRate
  1096.     else
  1097.       @musicRate = 1.0
  1098.       @soundRate = 1.0
  1099.     end
  1100.     @monsters     = []
  1101.     @new_monsters = false
  1102.   end
  1103.  
  1104.   #-------------------------------------------------------------------------
  1105.   # * Adiciona monstros ao bestiário
  1106.   #   id : Identificação do monstro (ID no banco de dados)
  1107.   #-------------------------------------------------------------------------
  1108.   def bestiaryAddMonster(id)
  1109.     return unless id.between?(1, $data_enemies.size - 1)
  1110.     return if @monsters.include?(id)
  1111.     @monsters << id
  1112.     @new_monsters = true
  1113.   end
  1114.  
  1115.   #-------------------------------------------------------------------------
  1116.   # * Retira monstros do bestiário
  1117.   #   id : Identificação do monstro (ID no banco de dados)
  1118.   #-------------------------------------------------------------------------
  1119.   def bestiaryRemoveMonster(id)
  1120.     @monsters.delete(id)
  1121.   end
  1122. end
  1123.  
  1124. #==============================================================================
  1125. # ** Game_Actor
  1126. #------------------------------------------------------------------------------
  1127. #  Esta classe gerencia os heróis. Ela é utilizada internamente pela classe
  1128. # Game_Actors ($game_actors). A instância desta classe é referenciada
  1129. # pela classe Game_Party ($game_party).
  1130. #==============================================================================
  1131. class Game_Actor
  1132.   alias mrm_extrememenu_initialize   initialize
  1133.   alias mrm_extrememenu_level_up     level_up
  1134.   alias mrm_extrememenu_change_class change_class
  1135.  
  1136.   attr_writer :attrPoints
  1137.   attr_reader :pointsSheet
  1138.  
  1139.   #--------------------------------------------------------------------------
  1140.   # * Inicialização do objeto
  1141.   #     *args // &block : Argumentos
  1142.   #--------------------------------------------------------------------------
  1143.   def initialize(*args, &block)
  1144.     mrm_extrememenu_initialize(*args, &block)
  1145.     @attrPoints  = 0
  1146.     update_points_sheet
  1147.   end
  1148.   #--------------------------------------------------------------------------
  1149.   # * Aumento de nível
  1150.   #     *args // &block : Argumentos
  1151.   #--------------------------------------------------------------------------
  1152.   def level_up(*args, &block)
  1153.     mrm_extrememenu_level_up(*args, &block)
  1154.     @attrPoints += @pointsSheet[:PPN]
  1155.   end
  1156.   #--------------------------------------------------------------------------
  1157.   # * Leitura dos pontos de atributo
  1158.   #--------------------------------------------------------------------------
  1159.   def attrPoints
  1160.     return @attrPoints.to_i
  1161.   end
  1162.   #--------------------------------------------------------------------------
  1163.   # * Mudança de classe
  1164.   #   *args // &block : Argumentos
  1165.   #--------------------------------------------------------------------------
  1166.   def change_class(*args, &block)
  1167.     mrm_extrememenu_change_class(*args, &block)
  1168.     update_points_sheet
  1169.   end
  1170.   #--------------------------------------------------------------------------
  1171.   # * Adiciona pontos de atributos
  1172.   #     index : Identificação do atributo
  1173.   #     qt    : Quantidade
  1174.   #--------------------------------------------------------------------------
  1175.   def add_param_plus(index, qt)
  1176.     @param_plus[index] += qt
  1177.   end
  1178.   #--------------------------------------------------------------------------
  1179.   # * Atualiza tabela de pontos da classe
  1180.   #--------------------------------------------------------------------------
  1181.   def update_points_sheet
  1182.     @pointsSheet = MRM::ExtremeMenu::PDistPoints[@class_id]
  1183.     # Se não for definida uma configuração, anula distribuição de pontos
  1184.     # para aquela classe.
  1185.     if @pointsSheet.nil?
  1186.       @pointsSheet = {
  1187.         PNN: 0,
  1188.         HPM: [0, 0], MPM: [0, 0], ATK: [0, 0], DEF: [0, 0],
  1189.         ATM: [0, 0], DEM: [0, 0], AGI: [0, 0], SOR: [0, 0],
  1190.       }
  1191.     end
  1192.   end
  1193. end
  1194.  
  1195. #==============================================================================
  1196. # ** Menu_Base_Window
  1197. #------------------------------------------------------------------------------
  1198. # Classe básica para todas as janelas do menu
  1199. #==============================================================================
  1200. class Menu_Base_Window < Window_Base
  1201.   include MRM::ExtremeMenu
  1202.  
  1203.   BC1 = Color.new(*BarColor1)
  1204.   BC2 = Color.new(*BarColor2)
  1205.   BC3 = Color.new(*BarColor3)
  1206.   BC4 = Color.new(*BarColor4)
  1207.  
  1208.   #--------------------------------------------------------------------------
  1209.   # Inicialização do objeto
  1210.   #   *args // &block : Argumentos
  1211.   #--------------------------------------------------------------------------
  1212.   def initialize(*args, &block)
  1213.     super(*args, &block)
  1214.     self.applyFont(self.contents)
  1215.   end
  1216.   #--------------------------------------------------------------------------
  1217.   # * Desenho do HP
  1218.   #     actor  : herói
  1219.   #     x      : coordenada X
  1220.   #     y      : coordenada Y
  1221.   #     width  : largura
  1222.   #--------------------------------------------------------------------------
  1223.   def draw_actor_hp(actor, x, y, width = 124)
  1224.     rate = actor.hp_rate
  1225.    
  1226.     gc1 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
  1227.     gc2 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
  1228.    
  1229.     draw_special_gauge(x, y, width, rate, gc1, gc2)
  1230.    
  1231.     change_color(system_color)
  1232.     draw_text(x, y, 30, line_height, ::Vocab::hp_a)
  1233.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  1234.       hp_color(actor), normal_color)
  1235.   end
  1236.   #--------------------------------------------------------------------------
  1237.   # * Desenho do MP
  1238.   #     actor  : herói
  1239.   #     x      : coordenada X
  1240.   #     y      : coordenada Y
  1241.   #     width  : largura
  1242.   #--------------------------------------------------------------------------
  1243.   def draw_actor_mp(actor, x, y, width = 124)
  1244.     rate = actor.mp_rate
  1245.  
  1246.     gc1 = Color.new(14 * rate,  80 - 24 * rate, 80 * rate, 192)
  1247.     gc2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  1248.    
  1249.     draw_special_gauge(x, y, width, rate, gc1, gc2)
  1250.    
  1251.     change_color(system_color)
  1252.     draw_text(x, y, 30, line_height, ::Vocab::mp_a)
  1253.     draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
  1254.       mp_color(actor), normal_color)
  1255.   end
  1256.   #-------------------------------------------------------------------------
  1257.   # * Desenha a barra especial estilo Cogwheel
  1258.   #     x     : Posição X
  1259.   #     y     : Posição Y
  1260.   #     width : Largura
  1261.   #     rate  : Porção de preenchimento
  1262.   #     gc1   : Cor 1
  1263.   #     gc2   : Cor 2
  1264.   #-------------------------------------------------------------------------
  1265.   def draw_special_gauge(x, y, width, rate, gc1, gc2)
  1266.     contents.fill_rect(x, y + line_height - 10, width, 10, BC1)
  1267.     contents.fill_rect(x + 1, y + line_height -  9,  width - 2,  8, BC2)
  1268.     contents.gradient_fill_rect(x + 2, y + line_height - 8, width - 4, 6, BC3, BC4)
  1269.     contents.gradient_fill_rect(x + 2, y + line_height - 8, (width*rate) - 4, 6, gc1, gc2)    
  1270.   end
  1271.   #-------------------------------------------------------------------------
  1272.   # * Desenho de uma linha horizontal
  1273.   #     y : Posição y de desenho
  1274.   #-------------------------------------------------------------------------
  1275.   def draw_horz_line(y)
  1276.     line_y = y + line_height / 2 - 1
  1277.     color = normal_color
  1278.     color.alpha = 48
  1279.     contents.fill_rect(128, line_y, contents_width - 128, 2, color)
  1280.   end
  1281.  
  1282.   protected
  1283.   #-------------------------------------------------------------------------
  1284.   # * Aplica opções de fonte no bitmap
  1285.   #     b : Bitmap
  1286.   #-------------------------------------------------------------------------
  1287.   def applyFont(b)
  1288.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  1289.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  1290.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  1291.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  1292.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  1293.     return b
  1294.   end
  1295. end
  1296.  
  1297. #==============================================================================
  1298. # ** Menu_ItemInfo_Window
  1299. #------------------------------------------------------------------------------
  1300. # Mostra informações do item selecionado
  1301. #==============================================================================
  1302. class Menu_ItemInfo_Window < Menu_Base_Window
  1303.   attr_reader :item
  1304.  
  1305.   #-------------------------------------------------------------------------
  1306.   # * Inicialização do objeto
  1307.   #     x : Coordenada X
  1308.   #     y : Coordenada Y
  1309.   #     w : Largura
  1310.   #     h : Altura
  1311.   #-------------------------------------------------------------------------
  1312.   def initialize(x, y, w, h)
  1313.     super(x, y, w, h)
  1314.     self.opacity = 0
  1315.     @item = nil
  1316.     refresh
  1317.   end
  1318.   #-------------------------------------------------------------------------
  1319.   # * Seleciona item e redesenha conteúdo
  1320.   #     item : Novo item
  1321.   #-------------------------------------------------------------------------
  1322.   def item=(value)
  1323.     @item = value
  1324.     refresh
  1325.   end
  1326.   #-------------------------------------------------------------------------
  1327.   # * Desenho do conteúdo da janela
  1328.   #-------------------------------------------------------------------------
  1329.   def refresh
  1330.     contents.clear
  1331.     return if @item.nil?
  1332.     draw_item_image
  1333.     draw_item_stats
  1334.     draw_item_effects
  1335.     draw_item_description
  1336.   end
  1337.   #--------------------------------------------------------------------------
  1338.   # * Desenha imagem do item
  1339.   #--------------------------------------------------------------------------
  1340.   def draw_item_image
  1341.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  1342.     center = (contents_width - 96) / 2
  1343.     rect = Rect.new(center + 1, 1, 94, 94)
  1344.     if @item.image.nil?
  1345.       icon_index = @item.icon_index
  1346.       bitmap = Cache.system("Iconset")
  1347.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  1348.       target = Rect.new(center, 0, 96, 96)
  1349.       contents.stretch_blt(target, bitmap, rect)
  1350.     else
  1351.       bitmap = Cache.picture(@item.image)
  1352.       contents.blt(0, 0, bitmap, bitmap.rect, 255)
  1353.     end
  1354.   end
  1355.   #--------------------------------------------------------------------------
  1356.   # * Desenha status do item
  1357.   #--------------------------------------------------------------------------
  1358.   def draw_item_stats
  1359.     return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  1360.     dx = 0; dy = 96
  1361.     dw = contents.width / 2
  1362.     8.times{|i|
  1363.       draw_equip_param(i, dx, dy, dw)
  1364.       dx = dx >= dw ? 0 : dw
  1365.       dy += line_height if dx == 0
  1366.     }
  1367.   end
  1368.   #--------------------------------------------------------------------------
  1369.   # * Desenha parâmetro (nome) do item
  1370.   #     param_id : Identificação do  parâmetro
  1371.   #     dx       : Posição X
  1372.   #     dy       : Posição Y
  1373.   #     dw       : Largura
  1374.   #--------------------------------------------------------------------------
  1375.   def draw_equip_param(param_id, dx, dy, dw)
  1376.     change_color(system_color)
  1377.     draw_text(dx+4, dy, dw-8, line_height, ::Vocab::param(param_id))
  1378.     draw_set_param(param_id, dx, dy, dw)
  1379.   end
  1380.   #--------------------------------------------------------------------------
  1381.   # * Desenha parâmetro (valor) do item
  1382.   #     param_id : Identificação do  parâmetro
  1383.   #     dx       : Posição X
  1384.   #     dy       : Posição Y
  1385.   #     dw       : Largura
  1386.   #--------------------------------------------------------------------------
  1387.   def draw_set_param(param_id, dx, dy, dw)
  1388.     value = @item.params[param_id]
  1389.     change_color(param_change_color(value), value != 0)
  1390.     text = value.group
  1391.     text = "+" + text if value > 0
  1392.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1393.     return text
  1394.   end
  1395.   #--------------------------------------------------------------------------
  1396.   # * Desenha efeitos do ítem
  1397.   #--------------------------------------------------------------------------
  1398.   def draw_item_effects
  1399.     return if @item.is_a?(RPG::EquipItem)
  1400.     dx = 0; dy = 96
  1401.    
  1402.     if @item.is_a?(RPG::Skill)
  1403.       dw = contents.width
  1404.       draw_applies(dx, dy + line_height * 0, dw)
  1405.       draw_removes(dx, dy + line_height * 1, dw)
  1406.       return
  1407.     end
  1408.    
  1409.     dw = contents.width / 2
  1410.     draw_hp_recover(dx, dy + line_height * 0, dw)
  1411.     draw_mp_recover(dx, dy + line_height * 1, dw)
  1412.     draw_tp_recover(dx + dw, dy + line_height * 0, dw)
  1413.     draw_tp_gain(dx + dw, dy + line_height * 1, dw)
  1414.    
  1415.     dw = contents.width
  1416.     draw_applies(dx, dy + line_height * 2, dw)
  1417.     draw_removes(dx, dy + line_height * 3, dw)
  1418.   end
  1419.   #--------------------------------------------------------------------------
  1420.   # * Desenha recuperação de HP
  1421.   #     dx       : Posição X
  1422.   #     dy       : Posição Y
  1423.   #     dw       : Largura
  1424.   #--------------------------------------------------------------------------
  1425.   def draw_hp_recover(dx, dy, dw)
  1426.     change_color(system_color)
  1427.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:HPRecover])
  1428.     per = 0
  1429.     set = 0
  1430.     for effect in @item.effects
  1431.       next unless effect.code == 11
  1432.       per += (effect.value1 * 100).to_i
  1433.       set += effect.value2.to_i
  1434.     end
  1435.     if per != 0 && set != 0
  1436.       change_color(param_change_color(set))
  1437.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1438.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1439.       dw -= text_size(text).width
  1440.       change_color(param_change_color(per))
  1441.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1442.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1443.       return
  1444.     elsif per != 0
  1445.       change_color(param_change_color(per))
  1446.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1447.     elsif set != 0
  1448.       change_color(param_change_color(set))
  1449.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1450.     else
  1451.       change_color(normal_color, false)
  1452.       text = Vocab[:Empty]
  1453.     end
  1454.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1455.   end
  1456.   #--------------------------------------------------------------------------
  1457.   # * Desenha recuperação de MP
  1458.   #     dx       : Posição X
  1459.   #     dy       : Posição Y
  1460.   #     dw       : Largura
  1461.   #--------------------------------------------------------------------------
  1462.   def draw_mp_recover(dx, dy, dw)
  1463.     change_color(system_color)
  1464.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:MPRecover])
  1465.     per = 0
  1466.     set = 0
  1467.     for effect in @item.effects
  1468.       next unless effect.code == 12
  1469.       per += (effect.value1 * 100).to_i
  1470.       set += effect.value2.to_i
  1471.     end
  1472.     if per != 0 && set != 0
  1473.       change_color(param_change_color(set))
  1474.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1475.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1476.       dw -= text_size(text).width
  1477.       change_color(param_change_color(per))
  1478.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1479.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1480.       return
  1481.     elsif per != 0
  1482.       change_color(param_change_color(per))
  1483.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1484.     elsif set != 0
  1485.       change_color(param_change_color(set))
  1486.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1487.     else
  1488.       change_color(normal_color, false)
  1489.       text = Vocab[:Empty]
  1490.     end
  1491.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1492.   end
  1493.   #--------------------------------------------------------------------------
  1494.   # * Desenha recuperação de TP
  1495.   #     dx       : Posição X
  1496.   #     dy       : Posição Y
  1497.   #     dw       : Largura
  1498.   #--------------------------------------------------------------------------
  1499.   def draw_tp_recover(dx, dy, dw)
  1500.     change_color(system_color)
  1501.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:TPRecover])
  1502.     set = 0
  1503.     for effect in @item.effects
  1504.       next unless effect.code == 13
  1505.       set += effect.value1.to_i
  1506.     end
  1507.     if set != 0
  1508.       change_color(param_change_color(set))
  1509.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1510.     else
  1511.       change_color(normal_color, false)
  1512.       text = Vocab[:Empty]
  1513.     end
  1514.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1515.   end
  1516.   #--------------------------------------------------------------------------
  1517.   # * Desenha ganho de TP
  1518.   #     dx       : Posição X
  1519.   #     dy       : Posição Y
  1520.   #     dw       : Largura
  1521.   #--------------------------------------------------------------------------
  1522.   def draw_tp_gain(dx, dy, dw)
  1523.     change_color(system_color)
  1524.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:TPGain])
  1525.     set = @item.tp_gain
  1526.     if set != 0
  1527.       change_color(param_change_color(set))
  1528.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1529.     else
  1530.       change_color(normal_color, false)
  1531.       text = Vocab[:Empty]
  1532.     end
  1533.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1534.   end
  1535.   #--------------------------------------------------------------------------
  1536.   # * Desenha efeito aplicados
  1537.   #     dx       : Posição X
  1538.   #     dy       : Posição Y
  1539.   #     dw       : Largura
  1540.   #--------------------------------------------------------------------------
  1541.   def draw_applies(dx, dy, dw)
  1542.     change_color(system_color)
  1543.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:Applies])
  1544.     icons = []
  1545.     for effect in @item.effects
  1546.       case effect.code
  1547.       when 21
  1548.         next unless effect.value1 > 0
  1549.         next if $data_states[effect.value1].nil?
  1550.         icons.push($data_states[effect.value1].icon_index)
  1551.       when 31
  1552.         icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  1553.       when 32
  1554.         icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  1555.       end
  1556.       icons.delete(0)
  1557.       break if icons.size >= MaxIconsDrawn
  1558.     end
  1559.     draw_icons(dx, dy, dw, icons)
  1560.   end
  1561.   #--------------------------------------------------------------------------
  1562.   # * Desenha efeitos removidos
  1563.   #     dx       : Posição X
  1564.   #     dy       : Posição Y
  1565.   #     dw       : Largura
  1566.   #--------------------------------------------------------------------------
  1567.   def draw_removes(dx, dy, dw)
  1568.     change_color(system_color)
  1569.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:Removes])
  1570.     icons = []
  1571.     for effect in @item.effects
  1572.       case effect.code
  1573.       when 22
  1574.         next unless effect.value1 > 0
  1575.         next if $data_states[effect.value1].nil?
  1576.         icons.push($data_states[effect.data_id].icon_index)
  1577.       when 33
  1578.         icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  1579.       when 34
  1580.         icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  1581.       end
  1582.       icons.delete(0)
  1583.       break if icons.size >= MaxIconsDrawn
  1584.     end
  1585.     draw_icons(dx, dy, dw, icons)
  1586.   end
  1587.   #--------------------------------------------------------------------------
  1588.   # * Desenha ícones
  1589.   #     dx       : Posição X
  1590.   #     dy       : Posição Y
  1591.   #     dw       : Largura
  1592.   #     icons    : Array com identificação dos itens
  1593.   #--------------------------------------------------------------------------
  1594.   def draw_icons(dx, dy, dw, icons)
  1595.     dx += dw - 4
  1596.     dx -= icons.size * 24
  1597.     for icon_id in icons
  1598.       draw_icon(icon_id, dx, dy)
  1599.       dx += 24
  1600.     end
  1601.     if icons.size == 0
  1602.       change_color(normal_color, false)
  1603.       text = Vocab[:Empty]
  1604.       draw_text(4, dy, contents.width-8, line_height, text, 2)
  1605.     end
  1606.   end
  1607.   #--------------------------------------------------------------------------
  1608.   # * Desenha a descrição do item
  1609.   #--------------------------------------------------------------------------
  1610.   def draw_item_description
  1611.     change_color(normal_color)
  1612.     text = @item.description.split(/\s/)
  1613.     dy   = (@item.is_a?(RPG::Skill) ? line_height * 3 + 96 : 200) - line_height
  1614.    
  1615.     word = text.shift
  1616.     tlen = contents.text_size(word).width
  1617.     phrs = (word or "") + " "
  1618.    
  1619.     until text.empty?
  1620.       word = text.shift
  1621.       len  = contents.text_size(word).width
  1622.       if len + tlen >= contents_width / 1.25
  1623.         draw_text(0, dy += line_height, contents_width, line_height, phrs, 1)
  1624.         text.unshift(word)
  1625.         tlen = 0
  1626.         phrs = ''
  1627.       else
  1628.         tlen += len
  1629.         phrs += word + " "
  1630.       end      
  1631.     end
  1632.     draw_text(0, dy + line_height, contents_width, line_height, phrs, 1)
  1633.    
  1634.   end
  1635. end
  1636. #==============================================================================
  1637. # ** Menu_Item_Window
  1638. #------------------------------------------------------------------------------
  1639. # Janela responsável por mostrar itens filtrados (Itens, Armaduras, etc)
  1640. #==============================================================================
  1641. class Menu_Item_Window < Window_Command
  1642.   attr_reader :info
  1643.   attr_reader :equipMode
  1644.  
  1645.   #--------------------------------------------------------------------------
  1646.   # * Inicialização do objeto
  1647.   #     x : Coordenada X
  1648.   #     y : Coordenada Y
  1649.   #     w : Largura
  1650.   #     h : Altura
  1651.   #--------------------------------------------------------------------------
  1652.   def initialize(x, y, w, h)
  1653.     @width     = w
  1654.     @height    = h
  1655.     @equipMode = nil
  1656.     super(x, y)
  1657.     self.applyFont(self.contents)
  1658.     self.open
  1659.   end
  1660.   #--------------------------------------------------------------------------
  1661.   # * Definição de uma flag para ativar a seleção de equipamentos
  1662.   #     index : Novo modo
  1663.   #     actor : Ator
  1664.   #--------------------------------------------------------------------------
  1665.   def enableEquipMode(index, actor)
  1666.     @equipMode = {index: index, actor: actor}
  1667.   end
  1668.   #--------------------------------------------------------------------------
  1669.   # * Desativa a flag de seleção de equipamentos
  1670.   #--------------------------------------------------------------------------
  1671.   def disableEquipMode
  1672.     @equipMode = nil
  1673.   end
  1674.   #--------------------------------------------------------------------------
  1675.   # * Atualização do cursor
  1676.   #     *args // &block : Argumentos
  1677.   #--------------------------------------------------------------------------
  1678.   def update_cursor(*args, &block)
  1679.     super(*args, &block)
  1680.     @info.item = @data[index] if @data
  1681.   end
  1682.   #--------------------------------------------------------------------------
  1683.   # * Definição de resultado ao pressionar o botão de confirmação
  1684.   #--------------------------------------------------------------------------
  1685.   def process_ok
  1686.   end
  1687.   #--------------------------------------------------------------------------
  1688.   # * Define janela de informação
  1689.   #     win : Janela
  1690.   #--------------------------------------------------------------------------
  1691.   def info=(win)
  1692.     @info = win
  1693.     win.item = @data[index] if @data
  1694.   end
  1695.   #--------------------------------------------------------------------------
  1696.   # * Aquisição da largura da janela
  1697.   #--------------------------------------------------------------------------
  1698.   def window_width
  1699.     return @width
  1700.   end
  1701.   #--------------------------------------------------------------------------
  1702.   # * Aquisição da altura da janela
  1703.   #--------------------------------------------------------------------------
  1704.   def window_height
  1705.     return @height
  1706.   end
  1707.   #--------------------------------------------------------------------------
  1708.   # * Desenho de um item
  1709.   #     index : índice do item
  1710.   #--------------------------------------------------------------------------
  1711.   def draw_item(index)
  1712.     item = @data[index]
  1713.     if item
  1714.       rect = item_rect(index)
  1715.       rect.width -= 4
  1716.       draw_item_name(item, rect.x, rect.y, enable?(item))
  1717.       draw_item_number(rect, item)
  1718.     end
  1719.   end
  1720.   #--------------------------------------------------------------------------
  1721.   # * Desenho do número de itens possuido
  1722.   #     rect : retângulo
  1723.   #     item : item
  1724.   #--------------------------------------------------------------------------
  1725.   def draw_item_number(rect, item)
  1726.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  1727.   end
  1728.   #--------------------------------------------------------------------------
  1729.   # * Criação da lista de comandos
  1730.   #--------------------------------------------------------------------------
  1731.   def make_command_list
  1732.     return unless @data
  1733.     @data.each{|item| add_command(item, :item_select) }
  1734.   end
  1735.   #------------------------------------------------------------------------
  1736.   # * Aplica filtro de itens
  1737.   #     type : Tipo de filtro
  1738.   #------------------------------------------------------------------------
  1739.   def applyFilter(type)
  1740.     @category = [:item, :weapon, :armor, :key_item][type]
  1741.     self.make_item_list
  1742.     @info.item = @data[index] if @data
  1743.     self.refresh
  1744.   end
  1745.   #--------------------------------------------------------------------------
  1746.   # * Inclusão do item na lista
  1747.   #     item : item
  1748.   #--------------------------------------------------------------------------
  1749.   def include?(item)
  1750.     if @equipMode
  1751.       return true  if item.nil?
  1752.       return false unless item.is_a?(RPG::EquipItem)
  1753.       return false if item.etype_id != @equipMode[:actor].equip_slots[@equipMode[:index]]
  1754.       return @equipMode[:actor].equippable?(item)
  1755.     end
  1756.  
  1757.     case @category
  1758.     when :item
  1759.       item.is_a?(RPG::Item) && !item.key_item?
  1760.     when :weapon
  1761.       item.is_a?(RPG::Weapon)
  1762.     when :armor
  1763.       item.is_a?(RPG::Armor)
  1764.     when :key_item
  1765.       item.is_a?(RPG::Item) && item.key_item?
  1766.     else
  1767.       true
  1768.     end
  1769.   end
  1770.   #--------------------------------------------------------------------------
  1771.   # * Definição de habilitação do item
  1772.   #     item : item
  1773.   #--------------------------------------------------------------------------
  1774.   def enable?(item)
  1775.     return true  if @equipMode
  1776.    
  1777.     return false if not item.is_a?(RPG::Item)
  1778.     return false if item.key_item?
  1779.    
  1780.     user = $game_party.movable_members.max_by {|member| member.pha }
  1781.     case item.scope
  1782.     when 0..6
  1783.       data = []
  1784.     when 7..8, 11
  1785.       data = $game_party.members
  1786.     when 9..10
  1787.       data = $game_party.members.select{|actor| actor.dead?}
  1788.     end
  1789.    
  1790.     return false if data.empty?
  1791.     return data.any?{|actor| actor.item_test(user, item) }
  1792.   end
  1793.   #--------------------------------------------------------------------------
  1794.   # * Definição de habilitação do item selecionado
  1795.   #--------------------------------------------------------------------------
  1796.   def current_item_enabled?
  1797.     return enable?(current_data[:name])
  1798.   end
  1799.   #--------------------------------------------------------------------------
  1800.   # * Criação da lista de itens
  1801.   #--------------------------------------------------------------------------
  1802.   def make_item_list
  1803.     @data = $game_party.all_items.select{|item| include?(item)}
  1804.     @data.push(nil) if include?(nil)
  1805.   end
  1806.   #--------------------------------------------------------------------------
  1807.   # * Criação do conteúdo das janelas
  1808.   #--------------------------------------------------------------------------
  1809.   def create_contents(*args, &block)
  1810.     super(*args, &block)
  1811.     self.applyFont(contents)
  1812.   end
  1813.  
  1814.   protected
  1815.   #-------------------------------------------------------------------------
  1816.   # * Aplica opções de fonte no bitmap
  1817.   #     b : Bitmap
  1818.   #-------------------------------------------------------------------------
  1819.   def applyFont(b)
  1820.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  1821.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  1822.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  1823.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  1824.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  1825.     return b
  1826.   end
  1827. end
  1828.  
  1829. #==============================================================================
  1830. # ** Menu_Equips_Window
  1831. #------------------------------------------------------------------------------
  1832. #  Esta classe mostra as informações de um monstro
  1833. #==============================================================================
  1834. class Menu_Equips_Window < Menu_Base_Window
  1835.   attr_reader :index
  1836.   attr_reader :info
  1837.  
  1838.   #-------------------------------------------------------------------------
  1839.   # * Inícialização do objeto
  1840.   #     x     : Posição X inicial da janela
  1841.   #     y     : Posição Y inicial da janela
  1842.   #     w     : Largura
  1843.   #-------------------------------------------------------------------------
  1844.   def initialize(x, y, w)
  1845.     super(x, y, w, fitting_height(7))
  1846.     self.opacity          = 0
  1847.     self.contents_opacity = 0
  1848.     @actor                = nil
  1849.     @index                = 0
  1850.    
  1851.     vs = contents_height / 7.0
  1852.     @rect = Array.new(6){|i|
  1853.       Rect.new(0, (vs * i).round, contents_width, line_height)
  1854.     }
  1855.     @rect.last.y += vs
  1856.   end
  1857.   #--------------------------------------------------------------------------
  1858.   # * Define janela de informação
  1859.   #     win : Janela
  1860.   #--------------------------------------------------------------------------
  1861.   def info=(win)
  1862.     @info = win
  1863.   end
  1864.   #-------------------------------------------------------------------------
  1865.   # * Seleção do ator
  1866.   #   actor : Game_Actor da janela
  1867.   #-------------------------------------------------------------------------
  1868.   def actor=(actor)
  1869.     @actor = actor
  1870.     refresh
  1871.   end
  1872.   #-------------------------------------------------------------------------
  1873.   # * Determina estado de atividade
  1874.   #   state : Ativa ou não a janela
  1875.   #-------------------------------------------------------------------------
  1876.   def active=(state)
  1877.     @active = state
  1878.     self.cursor_rect.set(@active ? @rect[@index] : Rect.new)
  1879.   end
  1880.   #-------------------------------------------------------------------------
  1881.   # * Modificação do índice da janela
  1882.   #     value : Novo índice
  1883.   #-------------------------------------------------------------------------
  1884.   def index=(value)
  1885.     @index = value
  1886.     self.cursor_rect.set(@rect[@index])
  1887.     @info.item = @actor.equips[@index] if @info
  1888.   end
  1889.   #-------------------------------------------------------------------------
  1890.   # * Desenho do conteúdo
  1891.   #-------------------------------------------------------------------------
  1892.   def refresh
  1893.     contents.clear
  1894.     return unless @actor
  1895.     dy = 0
  1896.     @actor.equips.each_with_index{|item,index|
  1897.       if item
  1898.         draw_item_name(item, 0, dy, enable?(index), contents_width)
  1899.       else
  1900.         change_color(system_color)
  1901.         index = 0 if @actor.dual_wield? and index == 1
  1902.         draw_text(@rect[index], ::Vocab::etype(index).isoUpcase, 1)
  1903.         change_color(normal_color)
  1904.       end
  1905.       dy += line_height
  1906.     }
  1907.     draw_text(@rect.last, Vocab[:Optimize], 1)
  1908.   end
  1909.   #--------------------------------------------------------------------------
  1910.   # * Definição de habilitação do item
  1911.   #     item : item
  1912.   #--------------------------------------------------------------------------
  1913.   def enable?(index)
  1914.     @actor ? @actor.equip_change_ok?(index) : false
  1915.   end
  1916.   #--------------------------------------------------------------------------
  1917.   # * Desenho do nome de itens
  1918.   #     item    : objeto
  1919.   #     x       : coordenada X
  1920.   #     y       : coordenada Y
  1921.   #     enabled : habilitar flag, translucido quando false
  1922.   #     width   : largura
  1923.   #--------------------------------------------------------------------------
  1924.   def draw_item_name(item, x, y, enabled = true, width = 172)
  1925.     return unless item
  1926.     draw_icon(item.icon_index, x, y, enabled)
  1927.     change_color(normal_color, enabled)
  1928.     draw_text(x, y, width, line_height, item.name, 1)
  1929.   end
  1930. end
  1931.  
  1932.  
  1933. #==============================================================================
  1934. # ** Menu_SkillCommand_Window
  1935. #------------------------------------------------------------------------------
  1936. #  Esta janela exibe a lista de comandos para tela de habilidades
  1937. # (como habilidades especiais e magias).
  1938. #==============================================================================
  1939.  
  1940. class Menu_SkillCommand_Window < Window_Command
  1941.   #--------------------------------------------------------------------------
  1942.   # * Variáveis públicas
  1943.   #--------------------------------------------------------------------------
  1944.   attr_reader   :skill_window
  1945.   #--------------------------------------------------------------------------
  1946.   # * Inicialização do objeto
  1947.   #     x      : Coordenada X
  1948.   #     y      : Coordenada Y
  1949.   #     w      : Largura
  1950.   #     h      : Altura
  1951.   #--------------------------------------------------------------------------
  1952.   def initialize(x, y, w, h)
  1953.     @width, @height = w, h
  1954.     super(x, y)
  1955.     self.opacity = 0
  1956.     self.active  = false
  1957.     @actor = nil
  1958.   end
  1959.   #--------------------------------------------------------------------------
  1960.   # * Aquisição da largura da janela
  1961.   #--------------------------------------------------------------------------
  1962.   def window_width
  1963.     @width
  1964.   end
  1965.   #--------------------------------------------------------------------------
  1966.   # * Aquisição da altura da janela
  1967.   #--------------------------------------------------------------------------
  1968.   def window_height
  1969.     @height
  1970.   end
  1971.   #--------------------------------------------------------------------------
  1972.   # * Definição de resultado ao pressionar o botão de confirmação
  1973.   #--------------------------------------------------------------------------
  1974.   def process_ok
  1975.   end
  1976.   #--------------------------------------------------------------------------
  1977.   # * Alinhamento do texto
  1978.   #--------------------------------------------------------------------------
  1979.   def alignment
  1980.     return 1
  1981.   end
  1982.   #--------------------------------------------------------------------------
  1983.   # * Definição de herói
  1984.   #     actor : herói
  1985.   #--------------------------------------------------------------------------
  1986.   def actor=(actor)
  1987.     return if @actor == actor
  1988.     @actor = actor
  1989.     refresh
  1990.   end
  1991.   #--------------------------------------------------------------------------
  1992.   # * Criação da lista de comandos
  1993.   #--------------------------------------------------------------------------
  1994.   def make_command_list
  1995.     return unless @actor
  1996.     @actor.added_skill_types.sort.each do |stype_id|
  1997.       name = $data_system.skill_types[stype_id]
  1998.       add_command(name, :skill, true, stype_id)
  1999.     end
  2000.   end
  2001.   #--------------------------------------------------------------------------
  2002.   # * Atualização da tela
  2003.   #--------------------------------------------------------------------------
  2004.   def update
  2005.     super
  2006.     @skill_window.stype_id = current_ext if @skill_window
  2007.   end
  2008.   #--------------------------------------------------------------------------
  2009.   # * Definição da janela de habilidades
  2010.   #     skill_window : janela de habilidades
  2011.   #--------------------------------------------------------------------------
  2012.   def skill_window=(skill_window)
  2013.     @skill_window = skill_window
  2014.     update
  2015.   end
  2016.   #--------------------------------------------------------------------------
  2017.   # * Criação do conteúdo das janelas
  2018.   #--------------------------------------------------------------------------
  2019.   def create_contents(*args, &block)
  2020.     super(*args, &block)
  2021.     self.applyFont(contents)
  2022.   end
  2023.  
  2024.   protected
  2025.   #-------------------------------------------------------------------------
  2026.   # * Aplica opções de fonte no bitmap
  2027.   #     b : Bitmap
  2028.   #-------------------------------------------------------------------------
  2029.   def applyFont(b)
  2030.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  2031.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  2032.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  2033.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  2034.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  2035.     return b
  2036.   end
  2037. end
  2038.  
  2039.  
  2040. #==============================================================================
  2041. # ** Menu_SkillList_Window
  2042. #------------------------------------------------------------------------------
  2043. #  Esta janela exibe uma lista de habilidades usáveis na tela de habilidades.
  2044. #==============================================================================
  2045.  
  2046. class Menu_SkillList_Window < Window_Command
  2047.   #--------------------------------------------------------------------------
  2048.   # * Inicialização do objeto
  2049.   #     x : Coordenada X
  2050.   #     y : Coordenada Y
  2051.   #     w : Largura
  2052.   #     h : Altura
  2053.   #--------------------------------------------------------------------------
  2054.   def initialize(x, y, w, h)
  2055.     @width, @height = w, h
  2056.     super(x, y)
  2057.     self.opacity = 0
  2058.     self.active  = false
  2059.     @actor = nil
  2060.     @stype_id = 0
  2061.     @data = []
  2062.   end
  2063.   #--------------------------------------------------------------------------
  2064.   # * Aquisição da largura da janela
  2065.   #--------------------------------------------------------------------------
  2066.   def window_width
  2067.     @width
  2068.   end
  2069.   #--------------------------------------------------------------------------
  2070.   # * Aquisição da altura da janela
  2071.   #--------------------------------------------------------------------------
  2072.   def window_height
  2073.     @height
  2074.   end
  2075.   #--------------------------------------------------------------------------
  2076.   # * Atualização do cursor
  2077.   #     *args // &block : Argumentos
  2078.   #--------------------------------------------------------------------------
  2079.   def update_cursor(*args, &block)
  2080.     super(*args, &block)
  2081.     @info.item = @data[index] if @data && @info
  2082.   end
  2083.   #--------------------------------------------------------------------------
  2084.   # * Definição de resultado ao pressionar o botão de confirmação
  2085.   #--------------------------------------------------------------------------
  2086.   def process_ok
  2087.   end
  2088.   #--------------------------------------------------------------------------
  2089.   # * Define janela de informação
  2090.   #     win : Janela
  2091.   #--------------------------------------------------------------------------
  2092.   def info=(win)
  2093.     @info = win
  2094.     win.item = @data[index] if @data
  2095.   end
  2096.   #--------------------------------------------------------------------------
  2097.   # * Máximo de itens desenhados
  2098.   #--------------------------------------------------------------------------
  2099.   def item_max
  2100.     @data ? @data.size : 0
  2101.   end
  2102.   #--------------------------------------------------------------------------
  2103.   # * Definição de herói
  2104.   #     actor : herói
  2105.   #--------------------------------------------------------------------------
  2106.   def actor=(actor)
  2107.     return if @actor == actor
  2108.     @actor = actor
  2109.     refresh
  2110.     self.oy = 0
  2111.   end
  2112.   #--------------------------------------------------------------------------
  2113.   # * Definição da ID do tipo de habilidade
  2114.   #     stype_id : ID do tipo de habilidade
  2115.   #--------------------------------------------------------------------------
  2116.   def stype_id=(stype_id)
  2117.     return if @stype_id == stype_id
  2118.     @stype_id = stype_id
  2119.     refresh
  2120.     self.oy = 0
  2121.   end
  2122.   #--------------------------------------------------------------------------
  2123.   # * Aquisição das informações da skill
  2124.   #--------------------------------------------------------------------------
  2125.   def item
  2126.     @data && index >= 0 ? @data[index] : nil
  2127.   end
  2128.   #--------------------------------------------------------------------------
  2129.   # * Definição de habilitação de seleção
  2130.   #--------------------------------------------------------------------------
  2131.   def current_item_enabled?
  2132.     enable?(@data[index])
  2133.   end
  2134.   #--------------------------------------------------------------------------
  2135.   # * Inclusão do item na lista
  2136.   #     item : item
  2137.   #--------------------------------------------------------------------------
  2138.   def include?(item)
  2139.     item && item.stype_id == @stype_id
  2140.   end
  2141.   #--------------------------------------------------------------------------
  2142.   # * Definição de habilitação do item
  2143.   #     item : item
  2144.   #--------------------------------------------------------------------------
  2145.   def enable?(item)
  2146.     @actor && @actor.usable?(item)
  2147.   end
  2148.   #--------------------------------------------------------------------------
  2149.   # * Criação da lista de itens
  2150.   #--------------------------------------------------------------------------
  2151.   def make_item_list
  2152.     @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
  2153.   end
  2154.   #--------------------------------------------------------------------------
  2155.   # * Desenho de um item
  2156.   #     index : índice do item
  2157.   #--------------------------------------------------------------------------
  2158.   def draw_item(index)
  2159.     skill = @data[index]
  2160.     if skill
  2161.       rect = item_rect(index)
  2162.       rect.width -= 4
  2163.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  2164.       draw_skill_cost(rect, skill)
  2165.     end
  2166.   end
  2167.   #--------------------------------------------------------------------------
  2168.   # * Desenho do custo das habilidades
  2169.   #     rect  : retângulo
  2170.   #     skill : habilidade
  2171.   #--------------------------------------------------------------------------
  2172.   def draw_skill_cost(rect, skill)
  2173.     if @actor.skill_tp_cost(skill) > 0
  2174.       change_color(tp_cost_color, enable?(skill))
  2175.       draw_text(rect, @actor.skill_tp_cost(skill), 2)
  2176.     elsif @actor.skill_mp_cost(skill) > 0
  2177.       change_color(mp_cost_color, enable?(skill))
  2178.       draw_text(rect, @actor.skill_mp_cost(skill), 2)
  2179.     end
  2180.   end
  2181.   #--------------------------------------------------------------------------
  2182.   # * Renovação
  2183.   #--------------------------------------------------------------------------
  2184.   def refresh
  2185.     make_item_list
  2186.     create_contents
  2187.     draw_all_items
  2188.   end
  2189.   #--------------------------------------------------------------------------
  2190.   # * Criação do conteúdo das janelas
  2191.   #--------------------------------------------------------------------------
  2192.   def create_contents(*args, &block)
  2193.     super(*args, &block)
  2194.     self.applyFont(contents)
  2195.   end
  2196.  
  2197.   protected
  2198.   #-------------------------------------------------------------------------
  2199.   # * Aplica opções de fonte no bitmap
  2200.   #     b : Bitmap
  2201.   #-------------------------------------------------------------------------
  2202.   def applyFont(b)
  2203.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  2204.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  2205.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  2206.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  2207.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  2208.     return b
  2209.   end
  2210. end
  2211.  
  2212. #==============================================================================
  2213. # ** Menu_ActorBase_Window
  2214. #------------------------------------------------------------------------------
  2215. #  Esta classe mostra as informações simples do ator
  2216. #==============================================================================
  2217. class Menu_ActorBase_Window < Menu_Base_Window
  2218.   #-------------------------------------------------------------------------
  2219.   # * Inícialização do objeto
  2220.   #     actor : Ator
  2221.   #     x     : Posição X inicial da janela
  2222.   #     y     : Posição Y inicial da janela
  2223.   #     w     : Largura
  2224.   #     h     : Altura
  2225.   #-------------------------------------------------------------------------
  2226.   def initialize(actor, x, y, w, h)
  2227.     super(x, y, w, h)
  2228.     self.opacity          = 0
  2229.     self.contents_opacity = 0
  2230.     self.actor = actor
  2231.   end
  2232.   #-------------------------------------------------------------------------
  2233.   # * Seleção do ator
  2234.   #   actor : Game_Actor da janela
  2235.   #-------------------------------------------------------------------------
  2236.   def actor=(actor)
  2237.     @actor = actor
  2238.    
  2239.     @charBitmap = Cache.character(@actor.character_name)
  2240.    
  2241.     sign = @actor.character_name[/^[\!\$]./]
  2242.     if sign && sign.include?('$')
  2243.       @cw = @charBitmap.width / 3
  2244.       @ch = @charBitmap.height / 4
  2245.     else
  2246.       @cw = @charBitmap.width / 12
  2247.       @ch = @charBitmap.height / 8
  2248.     end
  2249.      
  2250.     @pattern = 1
  2251.    
  2252.     refresh
  2253.   end
  2254.   #-------------------------------------------------------------------------
  2255.   # * Desenho do conteúdo
  2256.   #-------------------------------------------------------------------------
  2257.   def refresh
  2258.     half_width = contents.width/2
  2259.    
  2260.     contents.clear
  2261.     # FACE
  2262.     draw_actor_face(@actor, half_width - 48, line_height * 2)
  2263.     # NOME
  2264.     change_color(hp_color(@actor))
  2265.     draw_text(0, 0, contents_width, line_height, @actor.name, 1)
  2266.     # LINHA HORIZONTAL
  2267.     draw_horz_line(line_height * 1)
  2268.     # LINHA HORIZONTAL
  2269.     draw_horz_line(line_height * 6)
  2270.     # LEVEL
  2271.     rect = Rect.new(half_width - 44, line_height * 7, 88, line_height)
  2272.     change_color(system_color)
  2273.     draw_text(rect, ::Vocab::level_a)
  2274.     change_color(normal_color)
  2275.     draw_text(rect, @actor.level, 2)
  2276.     # ÍCONES
  2277.     icons = (@actor.state_icons + @actor.buff_icons)[0, contents_width / 24]
  2278.     bx    = half_width - (icons.size * 12)
  2279.     icons.each_with_index{|n, i| draw_icon(n, bx + 24 * i, line_height * 8) }
  2280.     # HP
  2281.     draw_actor_hp(@actor, 3, line_height * 10, contents_width - 6)
  2282.     # MP
  2283.     draw_actor_mp(@actor, 3, line_height * 11, contents_width - 6)
  2284.   end
  2285.   #-------------------------------------------------------------------------
  2286.   # * Determina estado de atividade
  2287.   #   state : Ativa ou não a janela
  2288.   #-------------------------------------------------------------------------
  2289.   def active=(state)
  2290.     @active = state
  2291.     self.cursor_rect.set(@active ? contents.rect : Rect.new)
  2292.   end
  2293. end
  2294.  
  2295. #==============================================================================
  2296. # ** Menu_Formation_Window
  2297. #------------------------------------------------------------------------------
  2298. # Exibe informações do personagem para 'cena' de formação
  2299. #==============================================================================
  2300. class Menu_Formation_Window < Menu_ActorBase_Window
  2301.   #-------------------------------------------------------------------------
  2302.   # * Desenho do conteúdo
  2303.   #-------------------------------------------------------------------------
  2304.   def refresh
  2305.     contents.clear
  2306.     half_height = contents_height / 2
  2307.    
  2308.     # FACE
  2309.     draw_actor_face(@actor, 4, half_height - 48)
  2310.     # NOME
  2311.     change_color(hp_color(@actor))
  2312.     draw_text(156, 0, contents_width - 156, line_height, @actor.name, 0)
  2313.     # LINHA HORIZONTAL
  2314.     draw_horz_line(line_height / 2 - 4)
  2315.     # LEVEL
  2316.     rect = Rect.new(156, line_height * 2.5, 88, line_height)
  2317.     change_color(system_color)
  2318.     draw_text(rect, ::Vocab::level_a)
  2319.     change_color(normal_color)
  2320.     draw_text(rect, @actor.level, 2)
  2321.     # ÍCONES
  2322.     states  = (@actor.state_icons + @actor.buff_icons)
  2323.     num     = (contents_width - 260) / 24
  2324.     [
  2325.       states[  0, num],
  2326.       states[num, num]
  2327.     ].each_with_index{|icons, i|
  2328.       next unless icons
  2329.       icons.each_with_index{|n, j|
  2330.         draw_icon(n, 260 + 24 * j, line_height + i * 26)
  2331.       }
  2332.     }
  2333.     # HP
  2334.     draw_actor_hp(@actor, 156, line_height * 0.75, 100)
  2335.     # MP
  2336.     draw_actor_mp(@actor, 156, line_height * 1.65, 100)
  2337.   end
  2338. end
  2339.  
  2340. #==============================================================================
  2341. # ** Menu_ActorSelect_Window
  2342. #------------------------------------------------------------------------------
  2343. #  Janela que exibe a face dos atores para seleção
  2344. #==============================================================================
  2345. class Menu_ActorSelect_Window < Menu_Base_Window
  2346.   attr_reader :faces
  2347.   attr_reader :index
  2348.  
  2349.   #-------------------------------------------------------------------------
  2350.   # * Inícialização do objeto
  2351.   #     actor : Ator
  2352.   #     x     : Posição X inicial da janela
  2353.   #     y     : Posição Y inicial da janela
  2354.   #     w     : Largura
  2355.   #     h     : Altura
  2356.   #-------------------------------------------------------------------------
  2357.   def initialize(x, y, w, h)
  2358.     super(x, y, w, h)
  2359.     self.opacity = 0
  2360.     @faces = []
  2361.     @index = 0
  2362.   end
  2363.   #-------------------------------------------------------------------------
  2364.   # * Retorna o ator selecionado
  2365.   #-------------------------------------------------------------------------
  2366.   def actor
  2367.     @faces[@index]
  2368.   end
  2369.   #-------------------------------------------------------------------------
  2370.   # * Índice máximo
  2371.   #-------------------------------------------------------------------------
  2372.   def maxIndex
  2373.     @faces.size
  2374.   end
  2375.   #-------------------------------------------------------------------------
  2376.   # * Modificação do índice da janela
  2377.   #     value : Novo índice
  2378.   #-------------------------------------------------------------------------
  2379.   def index=(value)
  2380.     @index = value % @faces.size
  2381.   end
  2382.   #-------------------------------------------------------------------------
  2383.   # * Ajuste do cursor de acordo com a posição ox
  2384.   #     value : Nova posição ox
  2385.   #-------------------------------------------------------------------------
  2386.   def ox=(value)
  2387.     super(value)
  2388.     self.cursor_rect.x = value
  2389.   end
  2390.   #-------------------------------------------------------------------------
  2391.   # * Posição ox correta (para animação)
  2392.   #-------------------------------------------------------------------------
  2393.   def trueOx
  2394.     @index * (standard_padding + 96)
  2395.   end
  2396.   #-------------------------------------------------------------------------
  2397.   # * Modificação das faces
  2398.   #     nfs : Novas faces
  2399.   #-------------------------------------------------------------------------
  2400.   def faces=(value)
  2401.     @faces = value
  2402.     self.index = @index
  2403.     contents.dispose
  2404.     self.contents = Bitmap.new(
  2405.       @faces.size * (96 + standard_padding) - standard_padding,
  2406.       contents_height
  2407.     )
  2408.     self.applyFont(contents)
  2409.     refresh
  2410.   end
  2411.   #-------------------------------------------------------------------------
  2412.   # * Determina se a janela está ou não ativa
  2413.   #     value : Atividade
  2414.   #-------------------------------------------------------------------------
  2415.   def active=(value)
  2416.     @active = value
  2417.     rect = contents.rect
  2418.     rect.x += 1
  2419.     rect.width = width - 2 * standard_padding - 2
  2420.     self.cursor_rect.set(@active ? rect : Rect.new)
  2421.   end
  2422.   #-------------------------------------------------------------------------
  2423.   # * Desenho da janela
  2424.   #-------------------------------------------------------------------------
  2425.   def refresh
  2426.     self.contents.clear
  2427.     faceW = 96 + standard_padding
  2428.     ax    = (contents_width  - 96) / 2 - faceW
  2429.     ay    = (contents_height - 96) / 2
  2430.     @faces.each{|actor| draw_actor_face(actor, ax += faceW, ay) }
  2431.   end
  2432. end
  2433.  
  2434. #==============================================================================
  2435. # ** Menu_ActorFull_Window
  2436. #------------------------------------------------------------------------------
  2437. #  Esta janela exibe as especificações completas na janela de atributos.
  2438. #==============================================================================
  2439. class Menu_ActorFull_Window < Menu_Base_Window
  2440.   #-------------------------------------------------------------------------
  2441.   # * Início
  2442.   #     actor : Ator
  2443.   #     x     : Posição X inicial da janela
  2444.   #     y     : Posição Y inicial da janela
  2445.   #     w     : Largura
  2446.   #     h     : Altura
  2447.   #-------------------------------------------------------------------------
  2448.   def initialize(actor, x, y, w, h)
  2449.     super(x, y, w, h)
  2450.     self.opacity = 0
  2451.     @actor = actor
  2452.   end
  2453.   #--------------------------------------------------------------------------
  2454.   # * Definição de herói
  2455.   #     actor : herói
  2456.   #--------------------------------------------------------------------------
  2457.   def actor=(actor)
  2458.     return if @actor == actor
  2459.     @actor = actor
  2460.     refresh
  2461.   end
  2462.   #--------------------------------------------------------------------------
  2463.   # * Renovação
  2464.   #--------------------------------------------------------------------------
  2465.   def refresh
  2466.     contents.clear
  2467.     draw_block1   (line_height * 0)
  2468.     draw_horz_line(line_height * 1)
  2469.     draw_block2   (line_height * 2)
  2470.     draw_horz_line(line_height * 6)
  2471.     draw_block3   (line_height * 7)
  2472.   end
  2473.   #--------------------------------------------------------------------------
  2474.   # * Desenho do bloco 1
  2475.   #     y : coordenada Y
  2476.   #--------------------------------------------------------------------------
  2477.   def draw_block1(y)
  2478.     draw_actor_name(@actor, 4, y)
  2479.     draw_actor_class(@actor, 128, y)
  2480.     draw_actor_nickname(@actor, 288, y)
  2481.   end
  2482.   #--------------------------------------------------------------------------
  2483.   # * Desenho do bloco 1
  2484.   #     y : coordenada Y
  2485.   #--------------------------------------------------------------------------
  2486.   def draw_block2(y)
  2487.     draw_actor_face(@actor, 8, y)
  2488.     draw_basic_info(136, y)
  2489.     draw_exp_info(304, y)
  2490.   end
  2491.   #--------------------------------------------------------------------------
  2492.   # * Desenho do bloco 3
  2493.   #     y : coordenada Y
  2494.   #--------------------------------------------------------------------------
  2495.   def draw_block3(y)
  2496.     draw_parameters(32, y)
  2497.     draw_equipments(288, y)
  2498.   end
  2499.   #--------------------------------------------------------------------------
  2500.   # * Desenho das informações básicas
  2501.   #     x : coordenada X
  2502.   #     y : coordenada Y
  2503.   #--------------------------------------------------------------------------
  2504.   def draw_basic_info(x, y)
  2505.     draw_actor_level(@actor, x, y + line_height * 0)
  2506.     draw_actor_icons(@actor, x, y + line_height * 1)
  2507.     draw_actor_hp(@actor, x, y + line_height * 2)
  2508.     draw_actor_mp(@actor, x, y + line_height * 3)
  2509.   end
  2510.   #--------------------------------------------------------------------------
  2511.   # * Desenho dos parâmetros
  2512.   #     x : coordenada X
  2513.   #     y : coordenada Y
  2514.   #--------------------------------------------------------------------------
  2515.   def draw_parameters(x, y)
  2516.     6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  2517.   end
  2518.   #--------------------------------------------------------------------------
  2519.   # * Desenho das informações de experiência
  2520.   #     x : coordenada X
  2521.   #     y : coordenada Y
  2522.   #--------------------------------------------------------------------------
  2523.   def draw_exp_info(x, y)
  2524.     s1 = @actor.max_level? ? "-------" : @actor.exp
  2525.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  2526.     s_next = sprintf(::Vocab::ExpNext, ::Vocab::level)
  2527.     change_color(system_color)
  2528.     draw_text(x, y + line_height * 0, 180, line_height, ::Vocab::ExpTotal)
  2529.     draw_text(x, y + line_height * 2, 180, line_height, s_next)
  2530.     change_color(normal_color)
  2531.     draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  2532.     draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  2533.   end
  2534.   #--------------------------------------------------------------------------
  2535.   # * Desenho dos equipamentos
  2536.   #     x : coordenada X
  2537.   #     y : coordenada Y
  2538.   #--------------------------------------------------------------------------
  2539.   def draw_equipments(x, y)
  2540.     @actor.equips.each_with_index do |item, i|
  2541.       draw_item_name(item, x, y + line_height * i)
  2542.     end
  2543.   end
  2544.   #--------------------------------------------------------------------------
  2545.   # * Desenho da descrição
  2546.   #     x : coordenada X
  2547.   #     y : coordenada Y
  2548.   #--------------------------------------------------------------------------
  2549.   def draw_description(x, y)
  2550.     draw_text_ex(x, y, @actor.description)
  2551.   end
  2552. end
  2553.  
  2554. #==============================================================================
  2555. # ** Menu_PDist_Window
  2556. #------------------------------------------------------------------------------
  2557. #  Esta janela exibe os pontos e controla a adição de novos pontos de atribu-
  2558. #  tos aos atores.
  2559. #==============================================================================
  2560. class Menu_PDist_Window < Menu_ActorFull_Window
  2561.   attr_reader :actor
  2562.   attr_reader :index
  2563.   attr_reader :active
  2564.   attr_reader :drawn
  2565.   #-------------------------------------------------------------------------
  2566.   # * Início
  2567.   #     actor : Ator
  2568.   #     x     : Posição X inicial da janela
  2569.   #     y     : Posição Y inicial da janela
  2570.   #     w     : Largura
  2571.   #     h     : Altura
  2572.   #-------------------------------------------------------------------------
  2573.   def initialize(actor, x, y, w, h)
  2574.     @index  = 0
  2575.     @active = false
  2576.     @drawn  = false
  2577.     ay = line_height
  2578.     @rects  = Array.new(8){|i|
  2579.       Rect.new(300, ay += line_height, 171, line_height)
  2580.     }
  2581.     @actorSheet = actor.pointsSheet
  2582.     super(actor, x, y, w, h)
  2583.   end
  2584.   #--------------------------------------------------------------------------
  2585.   # * Redesenho da janela
  2586.   #--------------------------------------------------------------------------
  2587.   def refresh
  2588.     super
  2589.     @drawn = true
  2590.   end
  2591.   #--------------------------------------------------------------------------
  2592.   # * Definição de atividade de janela
  2593.   #     value : Novo valor
  2594.   #--------------------------------------------------------------------------
  2595.   def active=(value)
  2596.     @active = value
  2597.     if @active
  2598.       self.cursor_rect.set(@rects[@index])
  2599.     else
  2600.       self.cursor_rect.set(0, 0, 0, 0)
  2601.     end
  2602.   end
  2603.   #--------------------------------------------------------------------------
  2604.   # * Definição do índice da janela
  2605.   #     value : Novo valor
  2606.   #--------------------------------------------------------------------------
  2607.   def index=(value)
  2608.     @index = value
  2609.     self.cursor_rect.set(@rects[@index])
  2610.     refresh
  2611.   end
  2612.   #--------------------------------------------------------------------------
  2613.   # * Desenho dos parâmetros
  2614.   #     x : coordenada X
  2615.   #     y : coordenada Y
  2616.   #--------------------------------------------------------------------------
  2617.   def draw_parameters(x, y)
  2618.     8.times {|i| draw_actor_param(@actor, x, y + line_height * i, i) }
  2619.   end
  2620.   #--------------------------------------------------------------------------
  2621.   # * Desenho do bloco 2
  2622.   #     y : coordenada Y
  2623.   #--------------------------------------------------------------------------
  2624.   def draw_block2(y)
  2625.     draw_actor_face(@actor, 8, y)
  2626.     draw_basic_info(136, y)
  2627.     draw_parameters(304, y)
  2628.   end
  2629.   #--------------------------------------------------------------------------
  2630.   # * Desenho do bloco 3
  2631.   #     y : coordenada Y
  2632.   #--------------------------------------------------------------------------
  2633.   def draw_block3(y)
  2634.     draw_actor_sheetInfo(32, y)
  2635.   end
  2636.   #--------------------------------------------------------------------------
  2637.   # * Desenho dos parâmetros
  2638.   #     actor : herói
  2639.   #     x     : coordenada X
  2640.   #     y     : coordenada Y
  2641.   #--------------------------------------------------------------------------
  2642.   def draw_actor_param(actor, x, y, param_id)
  2643.     plus = actor.param_plus(param_id)
  2644.    
  2645.     change_color(system_color)
  2646.     draw_text(x, y, 120, line_height, ::Vocab::param(param_id))
  2647.     change_color(normal_color)
  2648.     draw_text(x + 90, y, 36, line_height, actor.param(param_id) - plus, 2)
  2649.    
  2650.     if plus >= 0
  2651.       clr = plus == 0 ? normal_color : power_up_color
  2652.       sym = "+"
  2653.     elsif plus < 0
  2654.       clr = power_down_color
  2655.       sym = "-"
  2656.     end
  2657.    
  2658.     change_color(clr)
  2659.     draw_text(x + 132, y, 10, line_height, sym, 1)
  2660.     draw_text(x + 142, y, 23, line_height, actor.param_plus(param_id).abs, 2)
  2661.    
  2662.     change_color(normal_color)
  2663.   end
  2664.   #--------------------------------------------------------------------------
  2665.   # * Desenha mensagem de distribuição de pontos
  2666.   #     x     : coordenada X
  2667.   #     y     : coordenada Y
  2668.   #--------------------------------------------------------------------------
  2669.   def draw_actor_sheetInfo(x, y)
  2670.     PDistDiag.each_with_index{|line, i|
  2671.       draw_text_ex(x, y + line_height * i, parseDiag(line))
  2672.     }
  2673.   end
  2674.   #--------------------------------------------------------------------------
  2675.   # * Desenho de uma linha horzontal
  2676.   #--------------------------------------------------------------------------
  2677.   def draw_horz_line(y)
  2678.     line_y = y + line_height / 2 - 1
  2679.     color = normal_color
  2680.     color.alpha = 48
  2681.     contents.fill_rect(0, line_y, 275, 2, color)
  2682.   end
  2683.   #--------------------------------------------------------------------------
  2684.   # * Desenho do texto com caracteres de controle
  2685.   #     x    : coordenada X
  2686.   #     y    : coordenada Y
  2687.   #     text : string de texto
  2688.   #--------------------------------------------------------------------------
  2689.   def draw_text_ex(x, y, text)
  2690.     text = convert_escape_characters(text)
  2691.     pos = {x: x, y: y, new_x: x, height: calc_line_height(text)}
  2692.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  2693.   end
  2694.  
  2695.   protected
  2696.   #--------------------------------------------------------------------------
  2697.   # * Trata a linha para substituir as informações do ator
  2698.   #     line : String
  2699.   #--------------------------------------------------------------------------
  2700.   def parseDiag(line)
  2701.     paramSym = @actorSheet.keys[@index + 1]
  2702.  
  2703.     line
  2704.       .gsub("{actorName}"  , @actor.name)
  2705.       .gsub("{actorPoints}", @actor.attrPoints.to_s)
  2706.       .gsub("{attrName}",    ::Vocab::param(@index))
  2707.       .gsub("{attrNPoints}", @actorSheet[paramSym].first.to_s)
  2708.       .gsub("{attrGPoints}", @actorSheet[paramSym].last.to_s)
  2709.   end
  2710. end
  2711.  
  2712. #==============================================================================
  2713. # ** Menu_MonsterList_Window
  2714. #------------------------------------------------------------------------------
  2715. # Janela que mostra informações de monstros descobertos
  2716. #==============================================================================
  2717. class Menu_MonsterList_Window < Menu_Base_Window
  2718.  
  2719.   attr_reader :columns
  2720.   attr_reader :index
  2721.   attr_reader :rowMax
  2722.  
  2723.   #-------------------------------------------------------------------------
  2724.   # * Inicialização
  2725.   #     monsters : Lista de Monstros
  2726.   #     x        : Posição X inicial da janela
  2727.   #     y        : Posição Y inicial da janela
  2728.   #     w        : Largura
  2729.   #     h        : Altura
  2730.   #-------------------------------------------------------------------------
  2731.   def initialize(monsters, x, y, w, h)
  2732.     super(x, y, w, h)
  2733.     self.opacity = 0
  2734.     @rects    = []
  2735.     @columns  = 3
  2736.     @monsters = monsters
  2737.     @index    = 0
  2738.     @rowMax   = 1
  2739.     refresh
  2740.   end
  2741.   #-------------------------------------------------------------------------
  2742.   # * Define atividade da janela
  2743.   #     value : Nova definição
  2744.   #-------------------------------------------------------------------------
  2745.   def active=(value)
  2746.     @active = value
  2747.     if @active
  2748.       self.cursor_rect.set(@rects[@index])
  2749.     else
  2750.       self.cursor_rect.set(0,0,0,0)
  2751.     end
  2752.   end
  2753.   #-------------------------------------------------------------------------
  2754.   # * Define índice
  2755.   #     value : Novo índice
  2756.   #-------------------------------------------------------------------------
  2757.   def index=(value)
  2758.     return if value >= @monsters.size
  2759.     @index = value
  2760.     self.cursor_rect.set(@rects[@index])
  2761.   end
  2762.   #-------------------------------------------------------------------------
  2763.   # * Retorna o monstro selecionado
  2764.   #-------------------------------------------------------------------------
  2765.   def monster
  2766.     $data_enemies[@monsters[@index]]
  2767.   end
  2768.  
  2769.   #-------------------------------------------------------------------------
  2770.   # * Desenho da janela
  2771.   #-------------------------------------------------------------------------
  2772.   def refresh
  2773.     contents.clear
  2774.     monsters    = $data_enemies
  2775.    
  2776.     rate = (@monsters.size.to_f / (monsters.size - 1))
  2777.     text = Vocab[:BComplete].gsub("{c}", (100 * rate).round(1).to_s)
  2778.    
  2779.     gc1 = Color.new( 80 * rate, 14 * rate,  80 - 24 * rate, 192)
  2780.     gc2 = Color.new(240 * rate, 62 * rate, 240 - 72 * rate, 192)
  2781.     draw_special_gauge(0, 0, contents_width, rate, gc1, gc2)    
  2782.    
  2783.     draw_text(0, 0, contents_width, line_height, text, 1)
  2784.    
  2785.     x, y, i, cw = 0, line_height * 1.5, 0, contents_width / @columns
  2786.     @monsters.each_with_index{|id, index|
  2787.       @rects << Rect.new(x, y, cw, line_height)
  2788.      
  2789.       draw_text(x + 4, y, cw - 8, line_height, "#{index + 1}.")
  2790.       draw_text(@rects.last, monsters[id].name, 1)
  2791.      
  2792.       x += cw
  2793.       if (i += 1) == @columns
  2794.         i = x = 0
  2795.         y += line_height
  2796.       end
  2797.     }
  2798.    
  2799.     @rowMax = (@monsters.size.to_f / @columns).ceil
  2800.   end
  2801. end
  2802.  
  2803. #==============================================================================
  2804. # ** Menu_Monster_Window
  2805. #------------------------------------------------------------------------------
  2806. #  Esta classe mostra as informações de um monstro
  2807. #==============================================================================
  2808. class Menu_Monster_Window < Menu_Base_Window
  2809.   attr_reader :monster
  2810.   #-------------------------------------------------------------------------
  2811.   # * Inicialização
  2812.   #     monster : Monstro (RPG::Enemy)
  2813.   #     x       : Posição X inicial da janela
  2814.   #     y       : Posição Y inicial da janela
  2815.   #     w       : Largura
  2816.   #     h       : Altura
  2817.   #-------------------------------------------------------------------------
  2818.   def initialize(monster, x, y, w, h)
  2819.     super(x, y, w, h)
  2820.     self.applyFont(self.contents)
  2821.     self.opacity = 0
  2822.    
  2823.     @fill = Bitmap.new(276, contents_height)
  2824.     @fill.fill_rect(@fill.rect, Color.new(0, 0, 0, 127))
  2825.    
  2826.     self.monster = monster
  2827.   end
  2828.   #-------------------------------------------------------------------------
  2829.   # * Determina inimigo que deverá ser mostrado
  2830.   #     monster : Novo inimigo (RPG::Enemy)
  2831.   #-------------------------------------------------------------------------
  2832.   def monster=(monster)
  2833.     @monster = monster
  2834.     return unless @monster
  2835.     @battler = Cache.battler(@monster.battler_name, @monster.battler_hue)
  2836.     refresh
  2837.   end
  2838.   #-------------------------------------------------------------------------
  2839.   # Desenho da janela
  2840.   #-------------------------------------------------------------------------
  2841.   def refresh
  2842.     contents.clear
  2843.    
  2844.     contents.blt(
  2845.       contents_width - @battler.width,
  2846.       contents_height - @battler.height,
  2847.       @battler, @battler.rect
  2848.     )
  2849.     contents.blt(0, 0, @fill, @fill.rect)
  2850.    
  2851.     lh = line_height
  2852.     ay = lh * 4
  2853.    
  2854.     change_color(system_color)
  2855.     draw_text(6, 0, 124, line_height, @monster.name, 1)
  2856.     draw_text(6, ay += lh, 124, line_height, Vocab[:Experience])
  2857.     draw_text(6, ay += lh + lh, 124, line_height, Vocab[:Loot], 1)
  2858.     change_color(normal_color)
  2859.    
  2860.     ay = lh
  2861.    
  2862.     draw_hp(6, ay += lh)
  2863.     draw_mp(6, ay += lh)
  2864.     draw_text(6, ay += lh * 2, 124, line_height, @monster.exp, 2)
  2865.     ay += lh * 2
  2866.    
  2867.     draw_icon(Icon[:Gold], 6, ay += lh)
  2868.     draw_text(30, ay, 80, line_height, @monster.gold, 1)
  2869.    
  2870.     if @monster.drop_items.any?{|item| item.kind != 0}
  2871.       @monster.drop_items.each{|item|
  2872.         next if item.kind.zero?
  2873.         draw_item_name(item_object(item.kind, item.data_id), 6, ay += lh)
  2874.       }
  2875.     end
  2876.    
  2877.     ay = -lh
  2878.     6.times{|index| draw_param(144, ay += lh, index + 2) }
  2879.    
  2880.   end
  2881.   #--------------------------------------------------------------------------
  2882.   # * Aquisição das informações do item
  2883.   #     kind    : tipo do item
  2884.   #     data_id : ID do item
  2885.   #--------------------------------------------------------------------------
  2886.   def item_object(kind, data_id)
  2887.     return $data_items  [data_id] if kind == 1
  2888.     return $data_weapons[data_id] if kind == 2
  2889.     return $data_armors [data_id] if kind == 3
  2890.     return nil
  2891.   end
  2892.   #--------------------------------------------------------------------------
  2893.   # * Desenho do HP
  2894.   #     x      : coordenada X
  2895.   #     y      : coordenada Y
  2896.   #     width  : largura
  2897.   #--------------------------------------------------------------------------
  2898.   def draw_hp(x, y, width = 124)
  2899.     gc1 = Color.new( 56,  80, 14, 192)
  2900.     gc2 = Color.new(168, 240, 62, 192)
  2901.    
  2902.     draw_special_gauge(x, y, width, 1, gc1, gc2)
  2903.    
  2904.     change_color(system_color)
  2905.     draw_text(x + width/2 - 20, y, 30, line_height, ::Vocab::hp_a)
  2906.     change_color(normal_color)
  2907.     draw_text(x + width/2 + 5, y, width/2, line_height, @monster.params[0])
  2908.   end
  2909.   #--------------------------------------------------------------------------
  2910.   # * Desenho do MP
  2911.   #     x      : coordenada X
  2912.   #     y      : coordenada Y
  2913.   #     width  : largura
  2914.   #--------------------------------------------------------------------------
  2915.   def draw_mp(x, y, width = 124)
  2916.     gc1 = Color.new(14,  56,  80, 192)
  2917.     gc2 = Color.new(62, 168, 240, 192)
  2918.    
  2919.     draw_special_gauge(x, y, width, 1, gc1, gc2)
  2920.    
  2921.     change_color(system_color)
  2922.     draw_text(x + width/2 - 20, y, 30, line_height, ::Vocab::mp_a)
  2923.     change_color(normal_color)
  2924.     draw_text(x + width/2 + 5, y, width/2, line_height, @monster.params[1])
  2925.   end
  2926.   #--------------------------------------------------------------------------
  2927.   # * Desenho dos parâmetros
  2928.   #     x        : coordenada X
  2929.   #     y        : coordenada Y
  2930.   #     param_id : ID do parâmetro
  2931.   #--------------------------------------------------------------------------
  2932.   def draw_param(x, y, param_id)
  2933.     change_color(system_color)
  2934.     draw_text(x, y, 120, line_height, ::Vocab::param(param_id))
  2935.     change_color(normal_color)
  2936.     draw_text(x + 90, y, 36, line_height, @monster.params[param_id], 2)
  2937.     change_color(normal_color)
  2938.   end
  2939. end
  2940.  
  2941. #==============================================================================
  2942. # ** Menu_SaveFile_Window
  2943. #------------------------------------------------------------------------------
  2944. #  Mostra a informação de save e criação de novo jogo
  2945. #==============================================================================
  2946. class Menu_SaveFile_Window < Menu_Base_Window
  2947.   attr_reader :active
  2948.   attr_reader :exist
  2949.   attr_reader :index
  2950.   #-------------------------------------------------------------------------
  2951.   # * Inicialização
  2952.   #     x     : Posição X inicial da janela
  2953.   #     y     : Posição Y inicial da janela
  2954.   #     w     : Largura
  2955.   #     h     : Altura
  2956.   #     index : Index do save
  2957.   #     exist : Save existe? (Se não, será criada uma janela de "Novo Save"
  2958.   #-------------------------------------------------------------------------
  2959.   def initialize(x, y, w, h, index, exist)
  2960.     super(x, y, w, h)
  2961.     self.opacity = 0
  2962.     self.applyFont(contents)
  2963.    
  2964.     @active     = false
  2965.     @pattern    = 0
  2966.     @patternAux = 1
  2967.     self.load_data(index, exist)
  2968.    
  2969.     @blankRect = Rect.new
  2970.    
  2971.     refresh(true)
  2972.   end
  2973.   #-------------------------------------------------------------------------
  2974.   # * Carregamento da informação do save
  2975.   #     index : Index do save
  2976.   #     header : Save existe? (Se não, será criada uma janela de "Novo Save"
  2977.   #-------------------------------------------------------------------------
  2978.   def load_data(index, header)
  2979.     @index = index
  2980.     if header
  2981.       @data    = header
  2982.       @preview = Bitmap.new_from_data(@data[:preview], 157)
  2983.     end
  2984.    
  2985.     @previewRect = Rect.new(0, line_height, contents_width, line_height)
  2986.   end
  2987.   #-------------------------------------------------------------------------
  2988.   # * Atualização
  2989.   #-------------------------------------------------------------------------
  2990.   def update
  2991.     super
  2992.     if (Graphics.frame_count % Graphics.frame_rate) == 0
  2993.       refresh
  2994.     elsif (Graphics.frame_count % ActorsSpeed) == 0
  2995.       @pattern += @patternAux
  2996.      
  2997.       unless @pattern.between?(0, 2)
  2998.         @patternAux *= -1
  2999.         @pattern     = 1
  3000.       end
  3001.      
  3002.       redraw_chars
  3003.     end
  3004.   end
  3005.   #-------------------------------------------------------------------------
  3006.   # * Redesenha janela
  3007.   #   complete : Redesenho completo?
  3008.   #-------------------------------------------------------------------------
  3009.   def refresh(complete = false)
  3010.     if complete
  3011.       contents.clear
  3012.       if @data
  3013.         contents.blt(0, line_height, @preview, @preview.rect)
  3014.         @previewRect.y = 86 + 4 * line_height
  3015.         draw_text(@previewRect, @data[:playtime_s], 1)
  3016.       else
  3017.         change_color(system_color)
  3018.         draw_text(@previewRect, Vocab[:FreeSlot], 1)
  3019.         change_color(normal_color)
  3020.         @previewRect.y += line_height
  3021.         draw_text(@previewRect, Vocab[:NewSave], 1)
  3022.       end
  3023.      
  3024.       change_color(system_color)
  3025.       @previewRect.y = 86 + 3 * line_height
  3026.       draw_text(@previewRect, Vocab[:PlayTime], 1)
  3027.       @previewRect.y = 86 + 6 * line_height
  3028.       draw_text(@previewRect, Vocab[:Party], 1)
  3029.       change_color(normal_color)
  3030.     elsif !@data
  3031.       @previewRect.y = 86 + 4 * line_height
  3032.       contents.clear_rect(@previewRect)
  3033.       draw_text(@previewRect, $game_system.playtime_s, 1)
  3034.     end
  3035.    
  3036.     redraw_chars
  3037.   end
  3038.   #-------------------------------------------------------------------------
  3039.   # * Redesenha atores
  3040.   #-------------------------------------------------------------------------
  3041.   def redraw_chars
  3042.     y = 86 + line_height * 7
  3043.     contents.clear_rect(0, y, contents_width, contents_height - y)
  3044.     if @data
  3045.       space = (contents_width / @data[:characters].size)
  3046.       @data[:characters].each_with_index{|data, index|
  3047.         draw_character(data[0], data[1], (index + 0.5) * space, y)        
  3048.       }
  3049.     else
  3050.       chars = $game_party.battle_members
  3051.       space = (contents_width / chars.size)
  3052.  
  3053.       chars.each_with_index{|char, index|
  3054.         draw_character(char.character_name, char.character_index, (index + 0.5) * space, y)
  3055.       }
  3056.     end
  3057.   end
  3058.   #--------------------------------------------------------------------------
  3059.   # * Desenho do gráfico do personagem
  3060.   #     character_name  : nome do gráfico do personagem
  3061.   #     character_index : índice do gráfico de personagem
  3062.   #     x               : coordenada X
  3063.   #     y               : coordenada Y
  3064.   #--------------------------------------------------------------------------
  3065.   def draw_character(character_name, character_index, x, y)
  3066.     return unless character_name
  3067.     bitmap = Cache.character(character_name)
  3068.     sign = character_name[/^[\!\$]./]
  3069.     if sign && sign.include?('$')
  3070.       cw = bitmap.width / 3
  3071.       ch = bitmap.height / 4
  3072.     else
  3073.       cw = bitmap.width / 12
  3074.       ch = bitmap.height / 8
  3075.     end
  3076.     n = character_index
  3077.    
  3078.     src_rect = Rect.new((n%4*3+@pattern)*cw, (n/4*4)*ch, cw, ch)
  3079.     contents.blt(x - cw / 2, y, bitmap, src_rect)
  3080.    
  3081.     return cw
  3082.   end
  3083.   #-------------------------------------------------------------------------
  3084.   # * Determina se a janela é de novo save ou já possui um
  3085.   #-------------------------------------------------------------------------
  3086.   def exist
  3087.     return !!@data
  3088.   end
  3089.   #-------------------------------------------------------------------------
  3090.   # * Determina estado de atividade
  3091.   #   state : Ativa ou não a janela
  3092.   #-------------------------------------------------------------------------
  3093.   def active=(state)
  3094.     @active = state
  3095.     self.cursor_rect.set(@active ? contents.rect : @blankRect)
  3096.   end
  3097. end
  3098. #==============================================================================
  3099. # ** StaticMiniMap
  3100. #------------------------------------------------------------------------------
  3101. # Classe responsável por gerar um mini-map estático que será usado no menu
  3102. #==============================================================================
  3103. class StaticMiniMap  
  3104.   include MRM::ExtremeMenu
  3105.  
  3106.   attr_reader :viewport
  3107.  
  3108.   #-------------------------------------------------------------------------
  3109.   # * Inicialização do objeto
  3110.   #     viewport : Camada de visibilidade
  3111.   #-------------------------------------------------------------------------
  3112.   def initialize(viewport)
  3113.     @viewport = viewport
  3114.     @opacity  = 255
  3115.    
  3116.     precalculus
  3117.     refresh
  3118.   end
  3119.   #-------------------------------------------------------------------------
  3120.   # * Realiza pré-calculo
  3121.   #-------------------------------------------------------------------------
  3122.   def precalculus
  3123.     maxX  = (@viewport.rect.width.to_f  / TileSize).ceil
  3124.     halfX = (maxX / 2.0).ceil
  3125.     maxY  = (@viewport.rect.height.to_f / TileSize).ceil
  3126.     halfY = (maxY / 2.0).ceil
  3127.    
  3128.     @range = [
  3129.       ([$game_player.real_x - halfX, 0].max.to_i)..([$game_player.real_x + halfX, maxX].min.to_i),
  3130.       ([$game_player.real_y - halfY, 0].max.to_i)..([$game_player.real_y + halfY, maxY].min.to_i),
  3131.     ]
  3132.    
  3133.     @events = $game_map.events.values.select{|event|
  3134.       @range.first.include?(event.real_x) && @range.last.include?(event.real_y)
  3135.     }
  3136.    
  3137.     @halfWidth  = (halfX - $game_player.real_x) * TileSize
  3138.     @halfHeight = (halfY - $game_player.real_y) * TileSize
  3139.        
  3140.     @objColor = {}
  3141.     ObjectColor.each_pair{|key, value|
  3142.       @objColor[key] = Color.new(*value)
  3143.     }
  3144.    
  3145.     @playerColor    = Color.new(*PlayerColor)
  3146.     @mapColor       = Color.new(*MapColor)
  3147.     @mapBorderColor = Color.new(*MapBorderColor)
  3148.     @borderColor    = Color.new(*BorderColor)
  3149.   end
  3150.   #-------------------------------------------------------------------------
  3151.   # * Desenha o conteúdo
  3152.   #-------------------------------------------------------------------------
  3153.   def refresh
  3154.     @map        = Sprite.new(@viewport)
  3155.     @map.z      = 0
  3156.     @map.bitmap = make_map_bitmap(@mapColor, @mapBorderColor)
  3157.    
  3158.     @object_layer         = Sprite.new(@viewport)
  3159.     @object_layer.z       = 1
  3160.     @object_layer.bitmap  = Bitmap.new(@viewport.rect.width, @viewport.rect.height)
  3161.     @object_layer.opacity = ObjectLayerOpacity
  3162.    
  3163.     draw_object_layer
  3164.   end
  3165.   #-------------------------------------------------------------------------
  3166.   # * Desenha a camada com eventos e com o jogador
  3167.   #-------------------------------------------------------------------------
  3168.   def draw_object_layer
  3169.     comment = [108, 408]
  3170.    
  3171.     @events.each{|event|
  3172.       next unless event.list
  3173.       event.list.each{|item|
  3174.         next unless comment.include?(item.code)
  3175.         type = item.parameters[0]
  3176.         next unless @objColor.has_key?(type)
  3177.         draw_object(event, @objColor[type])
  3178.       }
  3179.     }
  3180.    
  3181.     draw_object($game_player, @playerColor)
  3182.   end
  3183.   #-------------------------------------------------------------------------
  3184.   # * Desenha um character
  3185.   #     obj   : Game_Character
  3186.   #     color : Cor de preenchimento
  3187.   #-------------------------------------------------------------------------
  3188.   def draw_object(obj, color)
  3189.     x = obj.real_x * TileSize + @halfWidth  + MapOffset
  3190.     y = obj.real_y * TileSize + @halfHeight + MapOffset
  3191.    
  3192.     @object_layer.bitmap.fill_rect(x, y, TileSize, TileSize,  @borderColor)
  3193.     @object_layer.bitmap.fill_rect(x + 1, y + 1, TileSize - 2, TileSize - 2, color)
  3194.   end
  3195.   #-------------------------------------------------------------------------
  3196.   # * Desenha os obstáculos do mapa em determinada cor
  3197.   #     color : Cor de destino
  3198.   #     color : Cor da borda
  3199.   #-------------------------------------------------------------------------
  3200.   def make_map_bitmap(color, borderColor)
  3201.     bitmap = Bitmap.new(@viewport.rect.width, @viewport.rect.height)
  3202.    
  3203.     @range.first.each{|x| @range.last.each{|y|
  3204.       next if $game_map.passable?(x, y, 4)
  3205.       ax = x * TileSize + @halfWidth  + MapOffset
  3206.       ay = y * TileSize + @halfHeight + MapOffset
  3207.       bitmap.fill_rect(ax, ay, TileSize, TileSize, borderColor)
  3208.       bitmap.fill_rect(ax + 1, ay + 1, TileSize - 2, TileSize - 2, color)
  3209.     }}
  3210.    
  3211.     return bitmap
  3212.   end
  3213.   #-------------------------------------------------------------------------
  3214.   # * Retorna coordenada X
  3215.   #-------------------------------------------------------------------------
  3216.   def x
  3217.     return @viewport.rect.x
  3218.   end
  3219.   #-------------------------------------------------------------------------
  3220.   # * Redefine a coordenada X
  3221.   #     value : Nova coordenada
  3222.   #-------------------------------------------------------------------------
  3223.   def x=(value)
  3224.     @viewport.rect.x = value
  3225.   end
  3226.   #-------------------------------------------------------------------------
  3227.   # * Retorna opacidade
  3228.   #-------------------------------------------------------------------------
  3229.   def opacity
  3230.     return @opacity
  3231.   end
  3232.   #-------------------------------------------------------------------------
  3233.   # * Redefine a opacidade
  3234.   #     value : Nova opacidade
  3235.   #-------------------------------------------------------------------------
  3236.   def opacity=(value)
  3237.     @opacity = value
  3238.     @map.opacity = value
  3239.     @object_layer.opacity = value * ObjectLayerOpacity / 255.0
  3240.   end
  3241.   #-------------------------------------------------------------------------
  3242.   # * Dispõe o conjunto
  3243.   #-------------------------------------------------------------------------
  3244.   def dispose
  3245.     @map.dispose
  3246.     @object_layer.dispose
  3247.   end
  3248. end
  3249. #==============================================================================
  3250. # ** Menu_Options_Window
  3251. #------------------------------------------------------------------------------
  3252. # Classe controladora das opções no menu
  3253. #==============================================================================
  3254. class Menu_Options_Window < Menu_Base_Window
  3255.   attr_accessor :barActive
  3256.   attr_reader   :index
  3257.  
  3258.   #-------------------------------------------------------------------------
  3259.   # * Inicialização
  3260.   #     x     : Posição X inicial da janela
  3261.   #     y     : Posição Y inicial da janela
  3262.   #     w     : Largura
  3263.   #     h     : Altura
  3264.   #-------------------------------------------------------------------------
  3265.   def initialize(x, y, w, h)
  3266.     super(x, y, w, h)
  3267.     self.opacity = 0
  3268.     self.applyFont(self.contents)
  3269.    
  3270.     cx = contents_width/2
  3271.    
  3272.     @rect = {
  3273.       sfx:   Rect.new(0,        line_height * 4, cx * 2, line_height * 2),
  3274.       music: Rect.new(cx - 140, line_height * 6, 125,    line_height    ),
  3275.       sound: Rect.new(cx - 140, line_height * 7, 125,    line_height    )
  3276.     }
  3277.    
  3278.     @barActive = false
  3279.     @index     = 0
  3280.    
  3281.     refresh
  3282.     self.index = -1
  3283.   end
  3284.   #-------------------------------------------------------------------------
  3285.   # * Redesenha conteúdo
  3286.   #-------------------------------------------------------------------------
  3287.   def refresh
  3288.     contents.clear
  3289.    
  3290.     # Texto
  3291.     change_color(system_color)
  3292.     contents.font.size *= 1.1
  3293.     contents.draw_text(@rect[:sfx],   Vocab[:OptionsSFX], 1)
  3294.     contents.font.size /= 1.1
  3295.     change_color(normal_color)
  3296.     contents.draw_text(@rect[:music], Vocab[:OptionsMsc], 1)
  3297.     contents.draw_text(@rect[:sound], Vocab[:OptionsSnd], 1)
  3298.    
  3299.     # Barras
  3300.     drawRect(:music, $game_system.musicRate)
  3301.     drawRect(:sound, $game_system.soundRate)
  3302.   end
  3303.   #-------------------------------------------------------------------------
  3304.   # * Desenha Barra
  3305.   #   type : Tipo
  3306.   #   rate : Proporção do preenchimento
  3307.   #-------------------------------------------------------------------------
  3308.   def drawRect(type, rate)
  3309.     rect = Rect.new.set(@rect[type])
  3310.     rect.x      += rect.width + 26
  3311.     rect.y      += 3
  3312.     rect.width  -= 6
  3313.     rect.height -= 10
  3314.  
  3315.     gc1 = Color.new(14 * rate,  80 - 24 * rate, 80 * rate, 192)
  3316.     gc2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  3317.    
  3318.     draw_special_gauge(rect.x, rect.y, rect.width, rect.height, rate, gc1, gc2)
  3319.    
  3320.     change_color(system_color)
  3321.     draw_text(rect, "-   #{(rate * 100).round}%   +", 1)
  3322.     change_color(normal_color)
  3323.   end
  3324.   #-------------------------------------------------------------------------
  3325.   # * Desenha a barra especial estilo Cogwheel
  3326.   #     x      : Posição X
  3327.   #     y      : Posição Y
  3328.   #     width  : Largura
  3329.   #     height : Altura
  3330.   #     rate   : Porção de preenchimento
  3331.   #     gc1    : Cor 1
  3332.   #     gc2    : Cor 2
  3333.   #-------------------------------------------------------------------------
  3334.   def draw_special_gauge(x, y, width, height, rate, gc1, gc2)
  3335.     y += line_height/2
  3336.     contents.fill_rect(x, y - 10, width, height, BC1)
  3337.     contents.fill_rect(x + 1, y -  9,  width - 2,  height - 2, BC2)
  3338.     contents.gradient_fill_rect(x + 2, y - 8, width - 4, height - 4, BC3, BC4)
  3339.     contents.gradient_fill_rect(x + 2, y - 8, (width*rate) - 4, height-4, gc1, gc2)    
  3340.   end
  3341.   #-------------------------------------------------------------------------
  3342.   # * Atualização do índice
  3343.   #-------------------------------------------------------------------------
  3344.   def index=(value)
  3345.     @index = value
  3346.     if (@index == -1)
  3347.       self.cursor_rect.set(0,0,0,0)
  3348.     else
  3349.       _rect = @rect[@index == 0 ? :music : :sound].dup
  3350.       if @barActive
  3351.         _rect.x      += _rect.width + 25
  3352.         _rect.y      += 4
  3353.         _rect.width  -= 4
  3354.         _rect.height -= 8
  3355.       end
  3356.      
  3357.       self.cursor_rect.set(_rect)
  3358.     end
  3359.   end
  3360. end
  3361.  
  3362. #==============================================================================
  3363. # ** Menu_Gold_Window
  3364. #------------------------------------------------------------------------------
  3365. #  Mostra a quantia de dinheiro do grupo
  3366. #==============================================================================
  3367. class Menu_Gold_Window < Menu_Base_Window
  3368.   include MRM::ExtremeMenu
  3369.  
  3370.   #-------------------------------------------------------------------------
  3371.   # * Inicialização
  3372.   #     x     : Posição X inicial da janela
  3373.   #     y     : Posição Y inicial da janela
  3374.   #     w     : Largura
  3375.   #     h     : Altura
  3376.   #-------------------------------------------------------------------------
  3377.   def initialize(x, y, w, h)
  3378.     super(x, y, w, h)
  3379.     self.opacity = 0
  3380.     self.contents_opacity = 0
  3381.     refresh
  3382.   end
  3383.  
  3384.   def refresh
  3385.     draw_icon(Icon[:Gold], 0, 0, true)
  3386.     draw_text(32, 0, contents_width - 32, line_height, $game_party.gold.to_s, 2)
  3387.   end
  3388. end
  3389.  
  3390. # Remove menu anterior
  3391. Object.send(:remove_const, :Scene_Menu)
  3392.  
  3393. #==============================================================================
  3394. # ** Scene_Menu
  3395. #------------------------------------------------------------------------------
  3396. #  Esta classe executa o processamento da tela de menu.
  3397. #==============================================================================
  3398. class Scene_Menu < Scene_Base
  3399.  
  3400.   #-------------------------------------------------------------------------
  3401.   # * Início da cena
  3402.   #-------------------------------------------------------------------------
  3403.   def start
  3404.     super
  3405.    
  3406.     @stage           = :Base
  3407.     @baseIndex       = 0
  3408.     @itemIndex       = 0
  3409.     @equipsIndex     = 0
  3410.     @skillsIndex     = 0
  3411.     @formationIndex1 = 0
  3412.     @formationIndex2 = 0
  3413.     @statusIndex     = 0
  3414.     @bestiaryIndex   = 0
  3415.     @pdistIndex      = 0
  3416.     @optionIndex     = 0
  3417.     @saveIndex       = 0
  3418.     @saveOverIndex   = 0
  3419.     @exitIndex       = 0
  3420.    
  3421.     @removedFormationWin = nil
  3422.     @iconset         = Cache.system("Iconset")
  3423.    
  3424.     # Flag necessária para remover lag
  3425.     # de inicialização do menu.
  3426.     @__NeedRefresh = []
  3427.    
  3428.     load_vocabulary
  3429.     process_move_data
  3430.     create_background
  3431.     create_icons
  3432.     if @baseIcons.size > 0
  3433.       create_cursor
  3434.       create_message
  3435.     end
  3436.     create_windows
  3437.     create_minimap if @baseIcons.size > 0
  3438.    
  3439.     #RPG::BGM.fade(@winsEnter[:time] * 1000)
  3440.     #RPG::BGS.fade(@winsEnter[:time] * 1000)
  3441.   end
  3442.   #-------------------------------------------------------------------------
  3443.   # * Atualização da cena
  3444.   #-------------------------------------------------------------------------
  3445.   def update
  3446.     super
  3447.     Tween.update
  3448.     if @baseIcons.size == 0
  3449.       process_return if Input.trigger?(:B)
  3450.       return
  3451.     end
  3452.    
  3453.     update_input
  3454.    
  3455.     # Faz processo de desenho das janelas de distribuição
  3456.     # de pontos. Este é um método necessário para remover
  3457.     # o lag de inicialização do menu, simulando uma espé-
  3458.     # cie de processo paralelo entre os frames. Garante
  3459.     # que as janelas existam mas remove o tempo inicial
  3460.     # usado para desenho e distribui entre os frames até
  3461.     # que todas as janelas tenham sido desenhadas.
  3462.     unless @__NeedRefresh.empty?
  3463.       if Graphics.frame_count % (Graphics.frame_rate/5) == 0
  3464.         @__NeedRefresh.shift.refresh
  3465.       end
  3466.     end
  3467.  
  3468.     case @stage
  3469.     when :Base, :Exit, :Formation, :Equips, :Skills
  3470.       update_actors_windows
  3471.     when :Items, :ItemsSelection, :EquipsTrade
  3472.       update_items_window
  3473.     when :ItemsActorSelection, :SkillsActorSelection
  3474.       @actorSelect.update
  3475.     when :EquipsSelection
  3476.       update_equips_windows
  3477.     when :SkillsTSelection, :SkillsSelection
  3478.       update_skills_windows
  3479.     when :PDist
  3480.       update_pdist_windows
  3481.     when :Save, :SaveOverWrite
  3482.       update_save_windows
  3483.     when :FormationNextActor
  3484.       @actorsWindows[@formationIndex1].update
  3485.       update_formation_windows
  3486.     end
  3487.   end
  3488.   #-------------------------------------------------------------------------
  3489.   # * Finalização da cena
  3490.   #-------------------------------------------------------------------------
  3491.   def terminate
  3492.     super
  3493.     dispose_background
  3494.     return dispose_actors_windows if @baseIcons.size == 0
  3495.     dispose_icons
  3496.     dispose_cursor
  3497.     dispose_message
  3498.     dispose_windows
  3499.   end
  3500.   #-------------------------------------------------------------------------
  3501.   # * Carrega informação de vocabulário
  3502.   #-------------------------------------------------------------------------
  3503.   def load_vocabulary
  3504.     @baseVocab = MRM::ExtremeMenu.enabledOptions(:name)
  3505.     @itemVocab = MRM::ExtremeMenu.enabledSubOption(:Items, :Names)
  3506.     @saveVocab = MRM::ExtremeMenu.enabledSubOption(:Save,  :Names)
  3507.     @exitVocab = MRM::ExtremeMenu.enabledSubOption(:Exit,  :Names)
  3508.   end
  3509.   #-------------------------------------------------------------------------
  3510.   # * Processa informação de movimento
  3511.   #-------------------------------------------------------------------------
  3512.   def process_move_data
  3513.     [
  3514.       [:IconsEnter,     :@iconsEnter    ],
  3515.       [:IconsMove,      :@iconsMove     ],
  3516.       [:CursorEnter,    :@cursorEnter   ],
  3517.       [:CursorMove,     :@cursorMove    ],
  3518.       [:Message,        :@messageAnim   ],
  3519.       [:ActorSelEnter,  :@actorSelEnter ],
  3520.       [:ActorSelMove,   :@actorSelMove  ],
  3521.       [:ItemsEnter,     :@itemsEnter    ],
  3522.       [:ItemsMove,      :@itemsMove     ],
  3523.       [:EquipsEnter,    :@equipsEnter   ],
  3524.       [:EquipsMove,     :@equipsMove    ],
  3525.       [:SkillsEnter,    :@skillsEnter   ],
  3526.       [:SkillsMove,     :@skillsMove    ],
  3527.       [:WindowsEnter,   :@winsEnter     ],
  3528.       [:WindowsMove,    :@winsMove      ],
  3529.       [:SaveEnter,      :@saveEnter     ],
  3530.       [:SaveMove,       :@saveMove      ],
  3531.       [:StatusEnter,    :@statusEnter   ],
  3532.       [:StatusMove,     :@statusMove    ],
  3533.       [:BestiaryEnter,  :@bestiaryEnter ],
  3534.       [:BestiaryMove,   :@bestiaryMove  ],
  3535.       [:PDistEnter,     :@pdistEnter    ],
  3536.       [:PDistMove,      :@pdistMove     ],
  3537.       [:MiniMapEnter,   :@minimapEnter  ],
  3538.       [:MiniMapMove,    :@minimapMove   ],
  3539.       [:OptionEnter,    :@optionEnter   ],
  3540.       [:FormationEnter, :@formationEnter],
  3541.       [:FormationMove,  :@formationMove ],
  3542.       [:GoldEnter,      :@goldEnter     ],
  3543.     ].each{|key, var|
  3544.       data  = MRM::ExtremeMenu::Animation[key]
  3545.       moveData = {
  3546.         :style => Tween::EASERS[data[0]] || Tween::Linear,
  3547.         :time  => data[1]
  3548.       }
  3549.       moveData[:off] = data[2] if data[2]
  3550.       self.instance_variable_set(var, moveData)
  3551.     }
  3552.   end
  3553.   #-------------------------------------------------------------------------
  3554.   # * Cria fundo
  3555.   #-------------------------------------------------------------------------
  3556.   def create_background
  3557.     @background_sprite = Sprite.new
  3558.     @background_sprite.bitmap = SceneManager.background_bitmap
  3559.     @background_sprite.color.set(16, 16, 16, 128)
  3560.   end
  3561.   #-------------------------------------------------------------------------
  3562.   # * Cria ícones
  3563.   #-------------------------------------------------------------------------
  3564.   def create_icons
  3565.     create_base_icons
  3566.     create_item_icons
  3567.     create_save_icons if MRM::ExtremeMenu::ConfirmOverwrite
  3568.     create_exit_icons
  3569.   end
  3570.   #-------------------------------------------------------------------------
  3571.   # * Cria ícones base
  3572.   #-------------------------------------------------------------------------
  3573.   def create_base_icons
  3574.     icons  = MRM::ExtremeMenu.enabledOptions(:icon)
  3575.     @baseIcons = self.create_generic_icons(icons)
  3576.   end
  3577.   #-------------------------------------------------------------------------
  3578.   # * Cria ícones de itens
  3579.   #-------------------------------------------------------------------------
  3580.   def create_item_icons
  3581.     icons      = MRM::ExtremeMenu.enabledSubOption(:Items, :Icons)
  3582.     @itemIcons = self.create_generic_icons(icons, false)
  3583.   end
  3584.   #-------------------------------------------------------------------------
  3585.   # * Cria ícones de save (confirmação de sobreescrita)
  3586.   #-------------------------------------------------------------------------
  3587.   def create_save_icons
  3588.     icons      = MRM::ExtremeMenu.enabledSubOption(:Save, :Icons)
  3589.     @saveIcons = self.create_generic_icons(icons, false)
  3590.   end
  3591.   #-------------------------------------------------------------------------
  3592.   # * Cria ícones de saída
  3593.   #-------------------------------------------------------------------------
  3594.   def create_exit_icons
  3595.     icons      = MRM::ExtremeMenu.enabledSubOption(:Exit, :Icons)
  3596.     @exitIcons = self.create_generic_icons(icons, false)
  3597.   end
  3598.   #-------------------------------------------------------------------------
  3599.   # * Cria cursor
  3600.   #-------------------------------------------------------------------------
  3601.   def create_cursor
  3602.     b = self.applyFont(Bitmap.new(1,1))
  3603.    
  3604.     s = (@baseVocab + @exitVocab).inject([0,0]){|max,act|
  3605.       v = b.text_size(act)
  3606.       [
  3607.         v.width  > max[0] ? v.width  : max[0],
  3608.         v.height > max[1] ? v.height : max[1]
  3609.       ]
  3610.     }
  3611.    
  3612.     b.dispose
  3613.    
  3614.     @cursor         = Sprite.new
  3615.     @cursor.opacity = 0
  3616.     @cursor.bitmap  = self.applyFont(Bitmap.new(*s))
  3617.     @cursor.ox      = @cursor.width / 2.0
  3618.     @cursor.x       = Graphics.width / (2 * @baseIcons.size)
  3619.     @cursor.y       = @baseIcons.first.y - @cursor.height - 60
  3620.     @cursor.bitmap.draw_text(0, 0, *s, @baseVocab.first, 1)
  3621.    
  3622.     Tween.start(@cursor, @cursorEnter[:style], @cursorEnter[:time],
  3623.       :opacity => 255
  3624.     )
  3625.   end
  3626.   #-------------------------------------------------------------------------
  3627.   # * Cria mensagem
  3628.   #-------------------------------------------------------------------------
  3629.   def create_message
  3630.     s = self.applyFont(Bitmap.new(1,1))
  3631.     sz = s.text_size("www.mundorpgmaker.com.br")
  3632.    
  3633.     @message         = Sprite.new
  3634.     @message.bitmap  = self.applyFont(Bitmap.new(Graphics.width, sz.height))
  3635.     @message.y       = @cursor.y - sz.height - 8
  3636.     @message.opacity = 0
  3637.    
  3638.     s.dispose
  3639.   end
  3640.   #-------------------------------------------------------------------------
  3641.   # * Cria janelas
  3642.   #-------------------------------------------------------------------------
  3643.   def create_windows
  3644.     create_actors_windows
  3645.     create_gold_window
  3646.     return if @baseIcons.size == 0
  3647.     create_items_windows
  3648.     create_equips_window
  3649.     create_skills_windows
  3650.     create_status_windows
  3651.     create_formation_windows
  3652.     create_bestiary_windows
  3653.     create_pdist_windows
  3654.     create_options_window
  3655.     create_save_windows
  3656.     create_actor_select_window
  3657.   end
  3658.   #-------------------------------------------------------------------------
  3659.   # * Cria as janelas de informação base dos atores
  3660.   #-------------------------------------------------------------------------
  3661.   def create_actors_windows
  3662.     size   = $game_party.battle_members.size
  3663.     width  = Graphics.width / size
  3664.     height = @cursor ? @cursor.y - 16 : Graphics.width
  3665.        
  3666.     baseX = size == 1 ? (width /= 2) / 2 : 0
  3667.    
  3668.     @actorsWindows = $game_party.battle_members.map.with_index{|actor, index|
  3669.       win = Menu_ActorBase_Window.new(actor, Graphics.width, 0, width, height)
  3670.       Tween.start(win, @winsEnter[:style], @winsEnter[:time], @winsEnter[:off] * index,
  3671.         :contents_opacity => 255,
  3672.         :x => baseX + (width * index)
  3673.       )
  3674.       win
  3675.     }
  3676.   end
  3677.   #-------------------------------------------------------------------------
  3678.   # * Cria janela para mostrar a quantia de ouro do grupo
  3679.   #-------------------------------------------------------------------------
  3680.   def create_gold_window
  3681.     w, h = Graphics.width / 4, 48
  3682.     x, y = (Graphics.width - w) / 2, @cursor.y - (2*h/3)
  3683.     @goldWindow = Menu_Gold_Window.new(x, y, w, h)
  3684.      
  3685.     Tween.start(@goldWindow, @goldEnter[:style], @goldEnter[:time],
  3686.         :contents_opacity => 255,
  3687.     )
  3688.   end
  3689.  
  3690.   #-------------------------------------------------------------------------
  3691.   # * Cria janelas de itens
  3692.   #-------------------------------------------------------------------------
  3693.   def create_items_windows
  3694.     x, y, w, h = Graphics.width, 0, Graphics.width/2, @cursor.y - 16
  3695.    
  3696.     @itemsWindow                  = Menu_Item_Window.new(x, y, w, h)
  3697.     @itemsWindow.active           = false
  3698.     @itemsWindow.opacity          = 0
  3699.     @itemsWindow.contents_opacity = 0
  3700.    
  3701.     @itemsInfo = Menu_ItemInfo_Window.new(x, y, Graphics.width - w, h)
  3702.     @itemsWindow.info = @itemsInfo
  3703.   end
  3704.   #-------------------------------------------------------------------------
  3705.   # * Cria janelas de equipamentos
  3706.   #-------------------------------------------------------------------------
  3707.   def create_equips_window
  3708.     @equipsWindow = Menu_Equips_Window.new(Graphics.width, 0, Graphics.width/2)
  3709.     @equipsWindow.info = @itemsInfo
  3710.   end
  3711.   #-------------------------------------------------------------------------
  3712.   # * Cria janelas de habilidades
  3713.   #-------------------------------------------------------------------------
  3714.   def create_skills_windows
  3715.     x, y, w, h = Graphics.width, 0, Graphics.width / 2, @cursor.y - 16
  3716.     @stypeWindow = Menu_SkillCommand_Window.new(x, y, w, h)
  3717.     @slistWindow = Menu_SkillList_Window.new(x, y, w, h)
  3718.     @stypeWindow.contents_opacity = 0
  3719.     @slistWindow.contents_opacity = 0
  3720.     @stypeWindow.skill_window     = @slistWindow
  3721.     @slistWindow.info             = @itemsInfo
  3722.   end
  3723.   #-------------------------------------------------------------------------
  3724.   # * Cria janelas de formação
  3725.   #-------------------------------------------------------------------------
  3726.   def create_formation_windows
  3727.     size   = $game_party.battle_members.size
  3728.     x      = Graphics.width / size
  3729.     y      = Graphics.height
  3730.     width  = Graphics.width - x
  3731.     height = (@cursor.y - 16) / 3
  3732.    
  3733.     @formationWindows = $game_party.members.map.with_index{|actor, index|
  3734.       win = Menu_Formation_Window.new(actor, x, y, width, height)
  3735.       win.contents_opacity = 0
  3736.       win
  3737.     }
  3738.    
  3739.     @__NeedRefresh += @formationWindows
  3740.   end
  3741.   #-------------------------------------------------------------------------
  3742.   # * Cria janelas de informação completa dos atores
  3743.   #-------------------------------------------------------------------------
  3744.   def create_status_windows
  3745.     width = Graphics.width
  3746.     height = @cursor.y - 16
  3747.     @statusWindows = $game_party.members.map.with_index{|actor, index|
  3748.       win = Menu_ActorFull_Window.new(actor, Graphics.width, 0, width, height)
  3749.       win.contents_opacity = 0
  3750.       win
  3751.     }
  3752.     @__NeedRefresh += @statusWindows
  3753.   end
  3754.   #-------------------------------------------------------------------------
  3755.   # * Cria janelas de monstros do bestiário
  3756.   #-------------------------------------------------------------------------
  3757.   def create_bestiary_windows
  3758.     x, y, w, h = Graphics.width, 0, Graphics.width, @cursor.y - 16
  3759.    
  3760.     @monsterList   = Menu_MonsterList_Window.new($game_system.monsters, x, y, w, h)
  3761.     @monsterWindow = Menu_Monster_Window.new(nil, x, y, w, h)
  3762.   end
  3763.   #-------------------------------------------------------------------------
  3764.   # * Cria janelas de distribuição de pontos
  3765.   #-------------------------------------------------------------------------
  3766.   def create_pdist_windows
  3767.     width = Graphics.width
  3768.     height = @cursor.y - 16
  3769.     @pdistWindows = $game_party.members.map.with_index{|actor, index|
  3770.       win = Menu_PDist_Window.new(actor, Graphics.width, 0, width, height)
  3771.       win.contents_opacity = 0
  3772.       win
  3773.     }
  3774.     @__NeedRefresh += @pdistWindows
  3775.   end
  3776.   #-------------------------------------------------------------------------
  3777.   # * Cria janela de save
  3778.   #-------------------------------------------------------------------------
  3779.   def create_save_windows
  3780.     @saveWindows = []
  3781.     index        = -1
  3782.     continue     = false
  3783.     x, y, w, h   = Graphics.width, 0, Graphics.width/3, @cursor.y - 16
  3784.    
  3785.     begin
  3786.       @saveWindows << Menu_SaveFile_Window.new(x, y, w, h, index, continue)
  3787.       @saveWindows.last.contents_opacity = 0
  3788.       continue = DataManager.load_header(index += 1)
  3789.     end until not continue or index >= DataManager.savefile_max
  3790.     @saveWindows.shift.dispose if @saveWindows.size == DataManager.savefile_max + 1
  3791.   end
  3792.   #-------------------------------------------------------------------------
  3793.   # * Cria janela de opções
  3794.   #-------------------------------------------------------------------------
  3795.   def create_options_window
  3796.     @optionWindow = Menu_Options_Window.new(Graphics.width, 0, Graphics.width, @cursor.y - 16)
  3797.     @optionWindow.contents_opacity = 0
  3798.   end
  3799.   #-------------------------------------------------------------------------
  3800.   # * Cria mini-mapa
  3801.   #-------------------------------------------------------------------------
  3802.   def create_minimap
  3803.     viewport = Viewport.new(Graphics.width, 0, Graphics.width, @cursor.y - 16)
  3804.     @minimap = StaticMiniMap.new(viewport)
  3805.   end
  3806.   #-------------------------------------------------------------------------
  3807.   # * Cria janela de seleção de atores
  3808.   #-------------------------------------------------------------------------
  3809.   def create_actor_select_window
  3810.     x = Graphics.width
  3811.    
  3812.     @actorSelect = Menu_ActorSelect_Window.new(x, @cursor.y - 16 - 128, 128, 128)
  3813.     @actorSelect.contents_opacity = 0
  3814.   end
  3815.   #-------------------------------------------------------------------------
  3816.   # * Atualização de Entrada
  3817.   #-------------------------------------------------------------------------
  3818.   def update_input
  3819.     if Input.trigger?(:B)
  3820.       process_return
  3821.     elsif Input.trigger?(:C)
  3822.       process_confirm
  3823.     else
  3824.       [:LEFT, :RIGHT, :UP, :DOWN].each{|key|
  3825.         process_move(key.capitalize) if Input.repeat?(key)
  3826.       }
  3827.     end
  3828.   end
  3829.   #-------------------------------------------------------------------------
  3830.   # * Desabilita atualização automatica de janelas
  3831.   #   (Processo desnecessário)
  3832.   #-------------------------------------------------------------------------
  3833.   def update_all_windows
  3834.   end
  3835.   #-------------------------------------------------------------------------
  3836.   # * Atualização das janelas dos atores
  3837.   #-------------------------------------------------------------------------
  3838.   def update_actors_windows
  3839.     @actorsWindows.each(&:update)
  3840.   end
  3841.   #-------------------------------------------------------------------------
  3842.   # * Atualização da janela de itens
  3843.   #-------------------------------------------------------------------------
  3844.   def update_items_window
  3845.     @itemsWindow.update
  3846.     @itemsInfo.update
  3847.   end
  3848.   #-------------------------------------------------------------------------
  3849.   # * Atualização das janelas de equipamentos
  3850.   #-------------------------------------------------------------------------
  3851.   def update_equips_windows
  3852.     @equipsWindow.update
  3853.     @itemsInfo.update
  3854.   end
  3855.   #-------------------------------------------------------------------------
  3856.   # * Atualização das janelas de habilidades
  3857.   #-------------------------------------------------------------------------
  3858.   def update_skills_windows
  3859.     @stypeWindow.update
  3860.     @slistWindow.update
  3861.     @itemsInfo.update
  3862.   end
  3863.   #-------------------------------------------------------------------------
  3864.   # * Atualização das janelas de formação
  3865.   #-------------------------------------------------------------------------
  3866.   def update_formation_windows
  3867.     @formationWindows[@formationIndex2].update
  3868.   end
  3869.   #-------------------------------------------------------------------------
  3870.   # * Atualização da janela de distribuição de pontos
  3871.   #-------------------------------------------------------------------------
  3872.   def update_pdist_windows
  3873.     @pdistWindows.each(&:update)
  3874.   end
  3875.   #-------------------------------------------------------------------------
  3876.   # * Atualização da janela de opções
  3877.   #-------------------------------------------------------------------------
  3878.   def update_options_window
  3879.     @optionWindow.update
  3880.   end
  3881.   #-------------------------------------------------------------------------
  3882.   # * Atualização das janelas de save
  3883.   #-------------------------------------------------------------------------
  3884.   def update_save_windows
  3885.     @saveWindows.each(&:update)
  3886.   end
  3887.   #-------------------------------------------------------------------------
  3888.   # * Processa retorno
  3889.   #-------------------------------------------------------------------------
  3890.   def process_return
  3891.     case @stage
  3892.     when :Base
  3893.       SceneManager.goto(Scene_Map)
  3894.       $game_map.autoplay
  3895.       Sound.play_cancel
  3896.     when :Items
  3897.       self.hide_icons(*@itemIcons)
  3898.       self.show_icons(*@baseIcons)
  3899.       self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
  3900.       self.show_gold_window
  3901.       self.show_actors_windows
  3902.       self.hide_items_window
  3903.       @stage = :Base
  3904.       Sound.play_cancel
  3905.     when :ItemsSelection
  3906.       self.items_filter_animation{
  3907.         @itemsWindow.applyFilter(0)
  3908.         @itemsWindow.active = false
  3909.         @itemsWindow.index  = -1
  3910.       }
  3911.       @stage = :Items
  3912.       Sound.play_cancel
  3913.     when :ItemsActorSelection
  3914.       @actorSelect.index = 0
  3915.       self.hide_actor_selection
  3916.       @stage = :Items
  3917.       Sound.play_cancel
  3918.     when :Equips
  3919.       @actorsWindows[@equipsIndex].active = false
  3920.       @stage = :Base
  3921.       Sound.play_cancel
  3922.     when :EquipsSelection
  3923.       @actorsWindows[@equipsIndex].active = true
  3924.       @equipsWindow.active = false
  3925.       self.show_gold_window
  3926.       self.show_actors_windows
  3927.       self.hide_equips_windows
  3928.       @stage = :Equips
  3929.       Sound.play_cancel
  3930.     when :EquipsTrade
  3931.       @itemsWindow.disableEquipMode
  3932.       @equipsWindow.index = @equipsWindow.index
  3933.       self.hide_inventory_equips
  3934.       @stage = :EquipsSelection
  3935.       Sound.play_cancel
  3936.     when :Skills
  3937.       @actorsWindows[@skillsIndex].active = false
  3938.       @stage = :Base
  3939.       Sound.play_cancel
  3940.     when :SkillsTSelection
  3941.       @stypeWindow.active = false
  3942.       self.hide_skills_windows
  3943.       self.show_gold_window
  3944.       self.show_actors_windows
  3945.       @actorsWindows[@skillsIndex].active = true
  3946.       @stage = :Skills
  3947.       Sound.play_cancel
  3948.     when :SkillsSelection
  3949.       @stypeWindow.active = true
  3950.       @slistWindow.active = false
  3951.       @slistWindow.index  = -1
  3952.       @stage = :SkillsTSelection
  3953.       self.hide_skills_description
  3954.       Sound.play_cancel
  3955.     when :SkillsActorSelection
  3956.       @actorSelect.index = 0
  3957.       self.hide_actor_selection
  3958.       @stage = :SkillsSelection
  3959.       Sound.play_cancel
  3960.     when :Formation
  3961.       @actorsWindows[@formationIndex1].active = false
  3962.       @stage = :Base
  3963.       Sound.play_cancel
  3964.     when :FormationNextActor
  3965.       @actorsWindows[@formationIndex1].active = true
  3966.       self.show_gold_window
  3967.       self.show_actors_windows
  3968.       self.hide_formation_windows
  3969.       self.unselect_formation_actor(@formationIndex1)
  3970.       @formationWindows[@formationIndex2].active = false
  3971.       @formationWindows.insert(*@removedFormationWin)
  3972.       @formationIndex2 = 0
  3973.       @stage = :Formation
  3974.       Sound.play_cancel
  3975.     when :Status
  3976.       self.show_gold_window
  3977.       self.show_actors_windows
  3978.       self.hide_status_window(@statusIndex, :Right)
  3979.       @statusWindows.each_with_index{|window, index|
  3980.         next if index == @statusIndex
  3981.         window.x = Graphics.width
  3982.       }
  3983.       @stage = :Base
  3984.       Sound.play_cancel
  3985.     when :Bestiary
  3986.       self.show_gold_window
  3987.       self.show_actors_windows
  3988.       self.hide_bestiary_list
  3989.       @stage = :Base
  3990.       Sound.play_cancel
  3991.     when :BestiaryDetail
  3992.       self.switch_monster_windows(true)
  3993.       @stage = :Bestiary
  3994.       Sound.play_cancel
  3995.     when :PDist
  3996.       self.show_gold_window
  3997.       self.show_actors_windows
  3998.       self.hide_pdist_window(@pdistIndex, :Right)
  3999.       @pdistWindows[@pdistIndex].active = false
  4000.       @pdistWindows.each_with_index{|window, index|
  4001.         next if index == @pdistIndex
  4002.         window.x = Graphics.width
  4003.       }
  4004.       @stage = :Base
  4005.       Sound.play_cancel
  4006.     when :MiniMap
  4007.       self.show_gold_window
  4008.       self.show_actors_windows
  4009.       self.hide_minimap
  4010.       @stage = :Base
  4011.       Sound.play_cancel
  4012.     when :Options
  4013.       if @optionWindow.barActive
  4014.         @optionWindow.barActive ^= true
  4015.         @optionWindow.index = @optionWindow.index
  4016.       else
  4017.         DataManager.save_config_data
  4018.         self.show_gold_window
  4019.         self.show_actors_windows
  4020.         self.hide_options_window
  4021.         @optionWindow.index = -1
  4022.         @stage = :Base
  4023.       end
  4024.       Sound.play_cancel
  4025.     when :Save
  4026.       self.show_gold_window
  4027.       self.show_actors_windows
  4028.       self.hide_save_windows
  4029.       @saveWindows[@saveIndex].active = false
  4030.       @stage = :Base
  4031.       Sound.play_cancel
  4032.     when :SaveOverWrite
  4033.       self.hide_icons(*@saveIcons)
  4034.       self.show_icons(*@baseIcons)
  4035.       self.hide_message
  4036.       self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
  4037.       @stage = :Save
  4038.       Sound.play_cancel
  4039.     when :Exit
  4040.       @exitIndex = 2
  4041.       process_confirm
  4042.     end
  4043.   end
  4044.   #-------------------------------------------------------------------------
  4045.   # * Processa confirmação
  4046.   #-------------------------------------------------------------------------
  4047.   def process_confirm
  4048.     case @stage
  4049.     when :Base
  4050.       option = MRM::ExtremeMenu.enabledOptions[@baseIndex]
  4051.       case option
  4052.       when :Items
  4053.         Sound.play_ok
  4054.         self.hide_gold_window
  4055.         self.hide_icons(*@baseIcons)
  4056.         self.show_icons(*@itemIcons)
  4057.         self.select_icon(@itemIcons.first, @itemVocab.first)
  4058.         self.hide_actors_windows
  4059.         self.show_items_window
  4060.         @itemIndex = 0
  4061.         self.items_filter_animation{
  4062.           @itemsWindow.applyFilter(0)
  4063.           @itemsWindow.active = true
  4064.           @itemsWindow.index  = 0
  4065.           @itemsWindow.refresh
  4066.         }
  4067.       when :Equips
  4068.         @actorsWindows.first.active = true
  4069.         @equipsIndex                = 0
  4070.       when :Skills
  4071.         @actorsWindows.first.active = true
  4072.         @skillsIndex                = 0
  4073.       when :Formation
  4074.         if $game_party.members.size == 1
  4075.           Sound.play_buzzer
  4076.           self.show_message(MRM::ExtremeMenu::Vocab[:InsufActs], :error)
  4077.           return
  4078.         end
  4079.         @actorsWindows.first.active = true
  4080.         @formationIndex1            = 0
  4081.       when :Status
  4082.         self.hide_gold_window
  4083.         self.hide_actors_windows
  4084.         self.show_status_window(@statusIndex = 0)
  4085.       when :Bestiary
  4086.         if $game_system.monsters.size.zero?
  4087.           Sound.play_buzzer
  4088.           self.show_message(MRM::ExtremeMenu::Vocab[:ZeroMonster], :error)
  4089.           return
  4090.         end
  4091.         $game_system.new_monsters = false
  4092.         self.hide_gold_window
  4093.         self.hide_actors_windows
  4094.         self.show_bestiary_list
  4095.         @monsterList.active = true
  4096.         @monsterList.index  = 0
  4097.       when :PDist
  4098.         self.hide_gold_window
  4099.         self.hide_actors_windows
  4100.         self.show_pdist_window(@pdistIndex = 0)
  4101.         @pdistWindows.first.active = true
  4102.         @pdistWindows.first.index  = 0
  4103.       when :MiniMap
  4104.         self.hide_gold_window
  4105.         self.hide_actors_windows
  4106.         self.show_minimap
  4107.       when :Options
  4108.         self.hide_gold_window
  4109.         self.hide_actors_windows
  4110.         self.show_options_window
  4111.         @optionWindow.index = 0
  4112.         @optionIndex        = 0
  4113.       when :Save
  4114.         if $game_system.save_disabled
  4115.           Sound.play_buzzer
  4116.           self.show_message(MRM::ExtremeMenu::Vocab[:SaveBlock], :error)
  4117.           return
  4118.         end
  4119.         self.hide_gold_window
  4120.         self.hide_actors_windows
  4121.         index = DataManager.last_menu_saveindex
  4122.         @saveWindows[index].active = true        
  4123.         @saveIndex = index
  4124.         self.show_save_windows
  4125.       when :Exit
  4126.         Sound.play_ok
  4127.         self.hide_icons(*@baseIcons)
  4128.         self.show_icons(*@exitIcons)
  4129.         self.select_icon(@exitIcons.first, @exitVocab.first)
  4130.         @exitIndex = 0
  4131.       end
  4132.       @stage = option
  4133.     #-------------------
  4134.     when :Items
  4135.       item    = @itemsWindow.info.item
  4136.       return Sound.play_buzzer if item.nil?
  4137.       return Sound.play_buzzer unless @itemsWindow.current_item_enabled?
  4138.       Sound.play_ok
  4139.       targets = item_target_actors(item)
  4140.      
  4141.       user = itemUser
  4142.       if user.nil?
  4143.         self.show_message(MRM::ExtremeMenu::Vocab[:NoItemUser], :error)
  4144.         return Sound.play_buzzer
  4145.       end
  4146.      
  4147.       if item.for_friend? and (item.scope == 11 or item.need_selection?) and not targets.empty?
  4148.         @stage = :ItemsActorSelection
  4149.         self.show_actor_selection(targets)
  4150.         @actorSelect.active = true
  4151.       else
  4152.         self.use_item(item, user)
  4153.         self.items_filter_animation {
  4154.           @itemsWindow.index  = 0
  4155.           @itemsWindow.make_item_list
  4156.           @itemsWindow.refresh
  4157.         }
  4158.       end
  4159.     #-------------------
  4160.     when :ItemsActorSelection
  4161.       item = @itemsWindow.info.item
  4162.      
  4163.       self.use_item(item, itemUser)
  4164.       self.items_filter_animation{
  4165.         @itemsWindow.index  = 0
  4166.         @itemsWindow.make_item_list
  4167.         @itemsWindow.refresh
  4168.       }
  4169.       process_return
  4170.     #-------------------
  4171.     when :Equips
  4172.       @actorsWindows[@equipsIndex].active = false
  4173.       @equipsWindow.actor = $game_party.members[@equipsIndex]
  4174.       @equipsWindow.active = true
  4175.       self.hide_gold_window
  4176.       self.hide_actors_windows
  4177.       self.show_equips_windows
  4178.       @equipsWindow.index = 0
  4179.       @stage = :EquipsSelection
  4180.     #-------------------
  4181.     when :EquipsSelection
  4182.       actor = $game_party.members[@equipsIndex]
  4183.       index = @equipsWindow.index
  4184.      
  4185.       if index == 5
  4186.         Sound.play_equip
  4187.         actor.optimize_equipments
  4188.         @statusWindows[@equipsIndex].refresh
  4189.         @equipsWindow.refresh
  4190.         @equipsWindow.index = @equipsWindow.index
  4191.         return
  4192.       end
  4193.      
  4194.       unless actor.equip_change_ok?(index)
  4195.         Sound.play_buzzer
  4196.         self.show_message(MRM::ExtremeMenu::Vocab[:FixEquip], :error)
  4197.         return
  4198.       end
  4199.      
  4200.       weapon = [0]
  4201.       weapon << 1 if actor.dual_wield?
  4202.       filter = weapon.include?(@equipsWindow.index) ? 1 : 2
  4203.      
  4204.       @itemsWindow.enableEquipMode(@equipsWindow.index, actor)
  4205.       @itemsWindow.applyFilter(filter)
  4206.       @itemsWindow.make_item_list
  4207.       @itemsWindow.active = true      
  4208.       self.show_inventory_equips
  4209.      
  4210.       @stage = :EquipsTrade
  4211.     #-------------------
  4212.     when :EquipsTrade
  4213.       index = @equipsWindow.index
  4214.       actor = $game_party.members[@equipsIndex]
  4215.       equip = @itemsWindow.info.item
  4216.      
  4217.       Sound.play_equip
  4218.       actor.change_equip(index, equip)
  4219.      
  4220.       @equipsWindow.refresh
  4221.       @statusWindows[@equipsIndex].refresh
  4222.       process_return
  4223.     #-------------------
  4224.     when :Skills
  4225.       @actorsWindows[@skillsIndex].active = false
  4226.       @stypeWindow.actor  = $game_party.members[@skillsIndex]
  4227.       @slistWindow.actor  = $game_party.members[@skillsIndex]
  4228.       @stypeWindow.active = true
  4229.       @slistWindow.index  = -1
  4230.       self.hide_gold_window
  4231.       self.hide_actors_windows
  4232.       self.show_skills_windows
  4233.       @slistWindow.index = 0
  4234.       @stage = :SkillsTSelection
  4235.     #-------------------
  4236.     when :SkillsTSelection
  4237.       self.show_skills_description
  4238.       @stypeWindow.active = false
  4239.       @slistWindow.active = true
  4240.       @slistWindow.index  = 0
  4241.       @stage = :SkillsSelection
  4242.     #-------------------
  4243.     when :SkillsSelection
  4244.       item    = @slistWindow.item
  4245.       return Sound.play_buzzer unless @slistWindow.current_item_enabled?
  4246.       Sound.play_ok
  4247.      
  4248.       targets = item_target_actors(item)
  4249.      
  4250.       if item.for_friend? and item.need_selection? and not targets.empty?
  4251.         @stage = :SkillsActorSelection
  4252.         self.show_actor_selection(targets)
  4253.         @actorSelect.active = true
  4254.       else
  4255.         self.use_item(item, itemUser)
  4256.       end
  4257.     #-------------------
  4258.     when :SkillsActorSelection
  4259.       item    = @slistWindow.item
  4260.       self.use_item(item, itemUser)
  4261.       @slistWindow.refresh
  4262.       process_return
  4263.     #-------------------
  4264.     when :Formation
  4265.       @formationIndex2 = 0
  4266.       self.hide_gold_window
  4267.       self.hide_actors_windows
  4268.       @removedFormationWin = [
  4269.         @formationIndex1,
  4270.         @formationWindows.delete_at(@formationIndex1)
  4271.       ]
  4272.       @actorsWindows[@formationIndex1].active = false
  4273.       @formationWindows.first.active = true
  4274.       self.show_formation_windows
  4275.       self.select_formation_actor(@formationIndex1)
  4276.       @stage = :FormationNextActor
  4277.     #-------------------
  4278.     when :FormationNextActor
  4279.       self.trade_actors_formation
  4280.       Sound.play_ok
  4281.     #-------------------
  4282.     when :Bestiary
  4283.       @monsterWindow.monster = @monsterList.monster
  4284.       self.switch_monster_windows(false)
  4285.       @stage = :BestiaryDetail
  4286.     #-------------------
  4287.     when :PDist
  4288.       win   = @pdistWindows[@pdistIndex]
  4289.       actor = win.actor
  4290.       sheet = actor.pointsSheet
  4291.       attr  = sheet[sheet.keys[win.index + 1]]
  4292.      
  4293.       if actor.attrPoints < attr.first
  4294.         self.show_message(MRM::ExtremeMenu::Vocab[:InsufPts], :error)
  4295.         return Sound.play_buzzer
  4296.       end
  4297.      
  4298.       Sound.play_ok
  4299.       actor.attrPoints            -= attr.first
  4300.       actor.add_param_plus(win.index, attr.last)
  4301.       win.refresh
  4302.     #-------------------
  4303.     when :Options
  4304.       @optionWindow.barActive ^= true
  4305.       @optionWindow.index = @optionWindow.index
  4306.      
  4307.       unless @optionWindow.barActive
  4308.         [RPG::BGM.last, RPG::BGS.last].each{|audio| audio.replay if audio}
  4309.       end
  4310.      
  4311.       Sound.play_ok
  4312.     #-------------------
  4313.     when :Save
  4314.       unless @saveWindows[@saveIndex].exist
  4315.         Sound.play_save
  4316.         self.create_new_save
  4317.         x, y, w, h = Graphics.width, 0, Graphics.width/3, @cursor.y - 16
  4318.         index = @saveWindows.last.index + 1
  4319.         @saveWindows << Menu_SaveFile_Window.new(x, y, w, h, index, DataManager.load_header(index))
  4320.         @saveWindows.last.contents_opacity = 0
  4321.         Tween.start(@saveWindows.last, @saveEnter[:style], @saveEnter[:time],
  4322.           :contents_opacity => 255
  4323.         )
  4324.         if @saveWindows.size == DataManager.savefile_max + 1
  4325.           Tween.start(@saveWindows.first, @saveEnter[:style], @saveEnter[:time],
  4326.             :x => -@saveWindows.shift.width,
  4327.             :contents_opacity => 0
  4328.           ){|window| window.dispose}
  4329.          
  4330.           @saveWindows.first.active = true
  4331.         end
  4332.        
  4333.         self.move_save_windows
  4334.       else
  4335.         Sound.play_ok
  4336.         if MRM::ExtremeMenu::ConfirmOverwrite
  4337.           self.hide_icons(*@baseIcons)
  4338.           self.show_icons(*@saveIcons)
  4339.           self.select_icon(@saveIcons.last, @saveVocab.last)
  4340.           self.show_message(MRM::ExtremeMenu::Vocab[:SaveOver], :info, :show)
  4341.           @saveOverIndex = 1
  4342.           @stage = :SaveOverWrite
  4343.         else
  4344.           index = @saveIndex - 1
  4345.           self.save_game_on(index)
  4346.           header = DataManager.load_header(index)
  4347.           @saveWindows[@saveIndex].load_data(index, header)
  4348.           @saveWindows[@saveIndex].refresh(true)
  4349.           self.show_message(MRM::ExtremeMenu::Vocab[:Saved], :ok)
  4350.         end
  4351.       end
  4352.     #-------------------
  4353.     when :SaveOverWrite
  4354.       if @saveOverIndex == 0
  4355.         index = @saveIndex - 1
  4356.         self.save_game_on(index)
  4357.         header = DataManager.load_header(index)
  4358.         @saveWindows[@saveIndex].load_data(index, header)
  4359.         @saveWindows[@saveIndex].refresh(true)
  4360.         self.show_message(MRM::ExtremeMenu::Vocab[:Saved], :ok)
  4361.       end      
  4362.       process_return
  4363.     #-------------------
  4364.     when :Exit
  4365.       case @exitIndex
  4366.       when 0 # Título
  4367.         SceneManager.goto(Scene_Title)
  4368.         Sound.play_ok
  4369.       when 1 # Sair
  4370.         SceneManager.exit
  4371.         Sound.play_ok
  4372.       when 2 # Voltar
  4373.         self.hide_icons(*@exitIcons)
  4374.         self.show_icons(*@baseIcons)
  4375.         self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
  4376.         @stage = :Base
  4377.         Sound.play_cancel
  4378.       end
  4379.     end
  4380.   end
  4381.   #-------------------------------------------------------------------------
  4382.   # * Processa movimento
  4383.   #     direction : Direção (:Left, :Right, :Up, :Down)
  4384.   #-------------------------------------------------------------------------
  4385.   def process_move(dir)
  4386.     case @stage
  4387.     when :Base
  4388.       self.processMovement(:@baseIndex, dir, :hor, @baseIcons, @baseVocab)
  4389.     when :Items
  4390.       self.processMovement(:@itemIndex, dir, :hor, @itemIcons, @itemVocab){|i0, i1|
  4391.         break if i0 == i1
  4392.         self.items_filter_animation{
  4393.           @itemsWindow.applyFilter(i1)
  4394.           @itemsWindow.index  = 0
  4395.           @itemsWindow.refresh
  4396.         }
  4397.       }
  4398.     when :ItemsActorSelection, :SkillsActorSelection
  4399.       @tmp = @actorSelect.index
  4400.      
  4401.       self.processBaseMovement(:@tmp, dir, :hor, @actorSelect.maxIndex){|i0, i1|
  4402.         break if i0 == i1
  4403.         Sound.play_cursor
  4404.         @actorSelect.index = i1
  4405.         self.adjustActorSelect
  4406.       }    
  4407.     when :Equips
  4408.       self.processBaseMovement(:@equipsIndex, dir, :hor, @actorsWindows.size){|i0, i1|
  4409.         break if i0 == i1
  4410.         Sound.play_cursor
  4411.         @actorsWindows[i0].active = !@actorsWindows[i1].active = true
  4412.       }
  4413.     when :EquipsSelection
  4414.       @tmp = @equipsWindow.index
  4415.       self.processBaseMovement(:@tmp, dir, :vert, 6){|i0, i1|
  4416.         break if i0 == i1
  4417.         Sound.play_cursor
  4418.         @equipsWindow.index = i1
  4419.       }
  4420.     when :Skills
  4421.       self.processBaseMovement(:@skillsIndex, dir, :hor, @actorsWindows.size){|i0, i1|
  4422.         break if i0 == i1
  4423.         Sound.play_cursor
  4424.         @actorsWindows[i0].active = !@actorsWindows[i1].active = true
  4425.       }
  4426.     when :Formation
  4427.       self.processBaseMovement(:@formationIndex1, dir, :hor, @actorsWindows.size){|i0, i1|
  4428.         break if i0 == i1
  4429.         Sound.play_cursor
  4430.         @actorsWindows[i0].active = !@actorsWindows[i1].active = true
  4431.       }
  4432.     when :FormationNextActor
  4433.       self.processBaseMovement(:@formationIndex2, dir, :vert, @formationWindows.size){|i0, i1|
  4434.         break if i0 == i1
  4435.         Sound.play_cursor
  4436.         @formationWindows[i0].active = !@formationWindows[i1].active = true
  4437.         self.move_formation_windows
  4438.       }
  4439.     when :Status
  4440.       self.processBaseMovement(:@statusIndex, dir, :hor, @statusWindows.size){|i0, i1|
  4441.         break if i0 == i1
  4442.         newDir = dir == :Left ? :Right : :Left
  4443.         self.hide_status_window(i0, newDir)
  4444.         self.show_status_window(i1, newDir)
  4445.       }
  4446.     when :Bestiary
  4447.       win  = @monsterList
  4448.       tmp  = win.index
  4449.       @row = tmp / 3
  4450.       @off = tmp % 3
  4451.      
  4452.       self.processBaseMovement(:@off, dir, :hor, win.columns){|i0, i1|
  4453.         break if i0 == i1
  4454.         Sound.play_cursor
  4455.         win.index = (@row * win.columns) + i1
  4456.       }
  4457.      
  4458.       self.processBaseMovement(:@row, dir, :vert, win.rowMax){|i0, i1|
  4459.         break if i0 == i1
  4460.         Sound.play_cursor
  4461.         win.index = @off + (i1 * win.columns)
  4462.       }
  4463.     when :PDist
  4464.       self.processBaseMovement(:@pdistIndex, dir, :hor, @pdistWindows.size){|i0, i1|
  4465.         break if i0 == i1
  4466.         newDir = dir == :Left ? :Right : :Left
  4467.         self.hide_pdist_window(i0, newDir)
  4468.         self.show_pdist_window(i1, newDir)
  4469.         @pdistWindows[i0].active = !@pdistWindows[i1].active = true
  4470.         @pdistWindows[i1].index  =  @pdistWindows[i0].index
  4471.       }
  4472.      
  4473.       @tmp = @pdistWindows[@pdistIndex].index
  4474.       self.processBaseMovement(:@tmp, dir, :vert, 8){|i0, i1|
  4475.         @pdistWindows[@pdistIndex].index = i1
  4476.       }
  4477.     when :Options
  4478.       unless @optionWindow.barActive
  4479.         self.processBaseMovement(:@optionIndex, dir, :vert, 2){|i0, i1|
  4480.           break if i0 == i1
  4481.           Sound.play_cursor
  4482.           @optionWindow.index = i1
  4483.         }
  4484.       else
  4485.         case @optionIndex
  4486.         when 0; @tmpValue = $game_system.musicRate
  4487.         when 1; @tmpValue = $game_system.soundRate
  4488.         end
  4489.         @tmpValue *= 100
  4490.        
  4491.         self.processBaseMovement(:@tmpValue, dir, :hor, 101){|i0, i1|
  4492.           i1 = 100 if i1 > 100  
  4493.           break    if i0 == i1
  4494.      
  4495.           i1 /= 100.0
  4496.          
  4497.           Sound.play_cursor
  4498.           case @optionIndex
  4499.           when 0; $game_system.musicRate = i1
  4500.           when 1; $game_system.soundRate = i1
  4501.           end
  4502.          
  4503.           @optionWindow.refresh
  4504.         }
  4505.       end
  4506.     when :Save
  4507.       self.processBaseMovement(:@saveIndex, dir, :hor, @saveWindows.size){|i0, i1|
  4508.         break if i0 == i1
  4509.         Sound.play_cursor
  4510.         self.move_save_windows
  4511.         @saveWindows[i0].active = !@saveWindows[i1].active = true
  4512.       }
  4513.     when :SaveOverWrite
  4514.       self.processMovement(:@saveOverIndex, dir, :hor, @saveIcons, @saveVocab)      
  4515.     when :Exit
  4516.       self.processMovement(:@exitIndex, dir, :hor, @exitIcons, @exitVocab)
  4517.     end
  4518.   end
  4519.   #-------------------------------------------------------------------------
  4520.   # * Dispõe fundo
  4521.   #-------------------------------------------------------------------------
  4522.   def dispose_background
  4523.     @background_sprite.dispose
  4524.   end
  4525.   #-------------------------------------------------------------------------
  4526.   # * Dispõe ícones
  4527.   #-------------------------------------------------------------------------
  4528.   def dispose_icons
  4529.     dispose_base_icons
  4530.     dispose_item_icons
  4531.     dispose_save_icons
  4532.     dispose_exit_icons
  4533.   end
  4534.   #-------------------------------------------------------------------------
  4535.   # * Dispõe os ícones base
  4536.   #-------------------------------------------------------------------------
  4537.   def dispose_base_icons
  4538.     @baseIcons.each(&:dispose)
  4539.     Tween.remove(@baseIcons)
  4540.   end
  4541.   #-------------------------------------------------------------------------
  4542.   # * Dispõe os ícones de itens
  4543.   #-------------------------------------------------------------------------
  4544.   def dispose_item_icons
  4545.     @itemIcons.each(&:dispose)
  4546.     Tween.remove(@itemIcons)
  4547.   end
  4548.   #-------------------------------------------------------------------------
  4549.   # * Dispõe os ícones de salver
  4550.   #-------------------------------------------------------------------------
  4551.   def dispose_save_icons
  4552.     @saveIcons.each(&:dispose)
  4553.     Tween.remove(@saveIcons)
  4554.   end
  4555.   #-------------------------------------------------------------------------
  4556.   # * Dispões mensagem
  4557.   #-------------------------------------------------------------------------
  4558.   def dispose_message
  4559.     @message.dispose
  4560.     Tween.remove(@message)
  4561.   end
  4562.   #-------------------------------------------------------------------------
  4563.   # * Dispõe os ícones de saída
  4564.   #-------------------------------------------------------------------------
  4565.   def dispose_exit_icons
  4566.     @exitIcons.each(&:dispose)
  4567.     Tween.remove(@exitIcons)
  4568.   end
  4569.   #-------------------------------------------------------------------------
  4570.   # * Dispõe o cursor
  4571.   #-------------------------------------------------------------------------
  4572.   def dispose_cursor
  4573.     @cursor.dispose
  4574.     Tween.remove(@cursor)
  4575.   end
  4576.   #-------------------------------------------------------------------------
  4577.   # * Dispõe as janelas
  4578.   #-------------------------------------------------------------------------
  4579.   def dispose_windows
  4580.     dispose_actors_windows
  4581.     dispose_items_windows
  4582.     dispose_equips_window
  4583.     dispose_status_windows
  4584.     dispose_formation_windows
  4585.     dispose_bestiary_windows
  4586.     dispose_pdist_windows
  4587.     dispose_options_window
  4588.     dispose_save_windows
  4589.     dispose_actor_select_window
  4590.   end
  4591.   #-------------------------------------------------------------------------
  4592.   # * Dispõe as janelas de informação dos atores
  4593.   #-------------------------------------------------------------------------
  4594.   def dispose_actors_windows
  4595.     @actorsWindows.each(&:dispose)
  4596.     Tween.remove(@actorsWindows)
  4597.   end
  4598.   #-------------------------------------------------------------------------
  4599.   # * Dispõe a janela de itens
  4600.   #-------------------------------------------------------------------------
  4601.   def dispose_items_windows
  4602.     @itemsWindow.dispose
  4603.     @itemsInfo.dispose
  4604.     Tween.remove(@itemsWindow)
  4605.     Tween.remove(@itemsInfo)
  4606.   end
  4607.   #-------------------------------------------------------------------------
  4608.   # * Dispõe a janela de equipamentos
  4609.   #-------------------------------------------------------------------------
  4610.   def dispose_equips_window
  4611.     @equipsWindow.dispose
  4612.     Tween.remove(@equipsWindow)
  4613.   end
  4614.   #-------------------------------------------------------------------------
  4615.   # * Dispões as janelas de status
  4616.   #-------------------------------------------------------------------------
  4617.   def dispose_status_windows
  4618.     @statusWindows.each(&:dispose)
  4619.     Tween.remove(@statusWindows)
  4620.   end
  4621.   #-------------------------------------------------------------------------
  4622.   # * Dispõe as janelas de formação
  4623.   #-------------------------------------------------------------------------
  4624.   def dispose_formation_windows
  4625.     @formationWindows.each(&:dispose)
  4626.     Tween.remove(@formationWindows)
  4627.   end
  4628.   #-------------------------------------------------------------------------
  4629.   # * Dispõe as janelas de monstros do bestiário
  4630.   #-------------------------------------------------------------------------
  4631.   def dispose_bestiary_windows
  4632.     @monsterList.dispose
  4633.     @monsterWindow.dispose
  4634.     Tween.remove(@monsterList)
  4635.     Tween.remove(@monsterWindow)
  4636.   end
  4637.   #-------------------------------------------------------------------------
  4638.   # * Dispõe as janelas de distribuição de atributos  
  4639.   #-------------------------------------------------------------------------
  4640.   def dispose_pdist_windows
  4641.     @pdistWindows.each(&:dispose)
  4642.     Tween.remove(@pdistWindows)
  4643.   end
  4644.   #-------------------------------------------------------------------------
  4645.   # * Dispõe a janela de opções
  4646.   #-------------------------------------------------------------------------
  4647.   def dispose_options_window
  4648.     @optionWindow.dispose
  4649.     Tween.remove(@optionWindow)
  4650.   end
  4651.   #-------------------------------------------------------------------------
  4652.   # * Dispõe as janelas de save
  4653.   #-------------------------------------------------------------------------
  4654.   def dispose_save_windows
  4655.     @saveWindows.each(&:dispose)
  4656.     Tween.remove(@saveWindows)
  4657.   end
  4658.   #-------------------------------------------------------------------------
  4659.   # * Dispõe a janela de criação de atores
  4660.   #-------------------------------------------------------------------------
  4661.   def dispose_actor_select_window
  4662.     @actorSelect.dispose
  4663.     Tween.remove(@actor_select)
  4664.   end
  4665.   #-------------------------------------------------------------------------
  4666.   # * Dispõe mini-mapa
  4667.   #-------------------------------------------------------------------------
  4668.   def dispose_minimap
  4669.     @minimap.dispose
  4670.     Tween.remove(@minimap)
  4671.   end
  4672.  
  4673.   protected
  4674.   #-------------------------------------------------------------------------
  4675.   # * Cria novo save
  4676.   #-------------------------------------------------------------------------
  4677.   def create_new_save
  4678.     self.save_game_on(@saveWindows.size - 1)
  4679.   end
  4680.   #-------------------------------------------------------------------------
  4681.   # * Sobreescreve arquivo de save
  4682.   #   index : Identificador do arquivo
  4683.   #-------------------------------------------------------------------------
  4684.   def save_game_on(index)
  4685.     DataManager.save_game(index)
  4686.   end
  4687.   #-------------------------------------------------------------------------
  4688.   # * Aplica opções de fonte no bitmap
  4689.   #     b : Bitmap
  4690.   #-------------------------------------------------------------------------
  4691.   def applyFont(b)
  4692.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  4693.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  4694.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  4695.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  4696.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  4697.     return b
  4698.   end
  4699.   #--------------------------------------------------------------------------
  4700.   # * Aquisição do usuário do ítem
  4701.   #--------------------------------------------------------------------------
  4702.   def itemUser
  4703.     if @stage == :SkillsSelection or @stage == :SkillsActorSelection # Habilidades
  4704.       $game_party.members[@skillsIndex]
  4705.     else # Itens
  4706.       $game_party.movable_members.max_by{|member| member.pha}
  4707.     end
  4708.   end
  4709.   #--------------------------------------------------------------------------
  4710.   # * Aquisição da lista de heróis válidos como alvos do item
  4711.   #     item : Item que será usado
  4712.   #--------------------------------------------------------------------------
  4713.   def item_target_actors(item)
  4714.     # 0: None
  4715.     # 1: One Enemy
  4716.     # 2: All Enemies
  4717.     # 3: One Random Enemy
  4718.     # 4: Two Random Enemies
  4719.     # 5: Three Random Enemies
  4720.     # 6: Four Random Enemies
  4721.     # 7: One Ally
  4722.     # 8: All Allies
  4723.     # 9: One Ally (Dead)
  4724.     # 10: All Allies (Dead)
  4725.     # 11: The User
  4726.    
  4727.     case item.scope
  4728.     when 7,8,11
  4729.       data = $game_party.members
  4730.     when 9,10
  4731.       data = $game_party.members.select{|actor| actor.dead?}
  4732.     end
  4733.  
  4734.     user = itemUser
  4735.     return data.select{|actor| actor.item_test(user, item) }
  4736.   end
  4737.   #--------------------------------------------------------------------------
  4738.   # * Usa item
  4739.   #     item : Item
  4740.   #     user : Usuário
  4741.   #--------------------------------------------------------------------------
  4742.   def use_item(item, user)
  4743.     if @stage == :SkillsSelection or @stage == :SkillsActorSelection
  4744.       Sound.play_use_skill
  4745.     else
  4746.       Sound.play_use_item
  4747.     end
  4748.  
  4749.     user.use_item(item)
  4750.    
  4751.     targets = []
  4752.     case item.scope
  4753.     when 7, 9, 11
  4754.       targets << @actorSelect.actor
  4755.     when 8
  4756.       targets += $game_party.members.select{|actor|
  4757.         not actor.dead? and actor.usable?(item)
  4758.       }
  4759.     when 10
  4760.       targets += $game_party.members.select{|actor|  
  4761.         actor.dead? and actor.item_test(user, item)
  4762.       }
  4763.     end
  4764.    
  4765.     targets.each{|target|
  4766.       item.repeats.times{
  4767.         target.item_apply(user, item)
  4768.       }
  4769.     }
  4770.    
  4771.     self.check_common_event
  4772.     self.check_gameover
  4773.    
  4774.     @actorsWindows.each(&:refresh)
  4775.   end
  4776.   #--------------------------------------------------------------------------
  4777.   # * Definição de reserva de evento comun.
  4778.   #    Transição para tela do mapa se a chamada è reservada para o evento
  4779.   #--------------------------------------------------------------------------
  4780.   def check_common_event
  4781.     SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
  4782.   end
  4783.   #--------------------------------------------------------------------------
  4784.   #  * Mostra a janela de atores para seleção
  4785.   #     actors : Atores disponíveis
  4786.   #--------------------------------------------------------------------------
  4787.   def show_actor_selection(actors)
  4788.     @actorSelect.faces = actors
  4789.     Tween.start(@actorSelect, @actorSelEnter[:style], @actorSelEnter[:time],
  4790.       :x => (@itemsWindow.width + Graphics.width - @actorSelect.width)/2,
  4791.       :contents_opacity => 255
  4792.     )
  4793.     self.adjustActorSelect
  4794.   end
  4795.   #-------------------------------------------------------------------------
  4796.   # * Esconde a janela de atores para seleção
  4797.   #-------------------------------------------------------------------------
  4798.   def hide_actor_selection
  4799.     Tween.start(@actorSelect, @actorSelEnter[:style], @actorSelEnter[:time],
  4800.       :x => Graphics.width,
  4801.       :contents_opacity => 0
  4802.     )
  4803.     self.adjustActorSelect
  4804.   end
  4805.   #-------------------------------------------------------------------------
  4806.   # * Ajusta face mostrada
  4807.   #-------------------------------------------------------------------------
  4808.   def adjustActorSelect
  4809.     Tween.start(@actorSelect, @actorSelMove[:style], @actorSelMove[:time],
  4810.       :ox => @actorSelect.trueOx
  4811.     )
  4812.   end
  4813.   #-------------------------------------------------------------------------
  4814.   # * Mostra mensagem
  4815.   #   text : Texto
  4816.   #   type : Tipo (:ok = Ok, :info = Informação, :error = Erro)
  4817.   #   mode : Modo (:blink = Piscar, :show = Mostrar)
  4818.   #-------------------------------------------------------------------------
  4819.   def show_message(text, type = :info, mode = :blink)
  4820.     case type
  4821.     when :ok
  4822.       @message.bitmap.font.color = MRM::ExtremeMenu::ColorOk
  4823.     when :info
  4824.       @message.bitmap.font.color = MRM::ExtremeMenu::ColorInfo
  4825.     when :error
  4826.       @message.bitmap.font.color = MRM::ExtremeMenu::ColorError
  4827.     end
  4828.    
  4829.     @message.bitmap.clear
  4830.     @message.bitmap.draw_text(@message.bitmap.rect, text, 1)
  4831.    
  4832.     block = (mode == :blink) ? ->(*){self.hide_message} : ->(*){}
  4833.    
  4834.     Tween.start(@message, @messageAnim[:style], @messageAnim[:time],
  4835.         :opacity => 255,
  4836.     &block)
  4837.   end
  4838.   #-------------------------------------------------------------------------
  4839.   # * Esconde mensagem
  4840.   #-------------------------------------------------------------------------
  4841.   def hide_message
  4842.     Tween.start(@message, @messageAnim[:style], @messageAnim[:time],
  4843.       :opacity => 0
  4844.     )
  4845.   end
  4846.   #-------------------------------------------------------------------------
  4847.   # * Cria sprites de ícones e os posiciona
  4848.   #     icons : Array com id dos ícones
  4849.   #     anim  : Animar?
  4850.   #-------------------------------------------------------------------------
  4851.   def create_generic_icons(icons, anim=true)
  4852.     iconSpace = Graphics.width / (icons.size == 0 ? 1 : icons.size)
  4853.    
  4854.     sprites = icons.map.with_index{|id, index|    
  4855.       gray = id < 0
  4856.       id   = id.abs
  4857.      
  4858.       icon          = Sprite.new
  4859.       icon.bitmap   = @iconset
  4860.       icon.src_rect = Rect.new(id % 16 * 24, id / 16 * 24, 24, 24)
  4861.       icon.ox       = icon.src_rect.width / 2
  4862.       icon.oy       = icon.src_rect.height / 2
  4863.       icon.x        = (index + 0.5) * iconSpace
  4864.       icon.y        = Graphics.height + icon.oy
  4865.      
  4866.       icon.tone.set(0, 0, 0, 255) if gray
  4867.      
  4868.       icon
  4869.     }
  4870.    
  4871.     self.show_icons(*sprites) if anim
  4872.     return sprites
  4873.   end
  4874.   #-------------------------------------------------------------------------
  4875.   # * Mostra ícones
  4876.   #     icons : Array de ícones
  4877.   #-------------------------------------------------------------------------
  4878.   def show_icons(*icons)
  4879.     motion = @iconsEnter
  4880.     icons.each_with_index{|icon, index|
  4881.       Tween.start(icon, motion[:style], motion[:time], motion[:off] * index,
  4882.         :y => Graphics.height - 24
  4883.       )
  4884.     }
  4885.   end
  4886.   #-------------------------------------------------------------------------
  4887.   # * Esconde ícones
  4888.   #     icons : Array de ícones
  4889.   #-------------------------------------------------------------------------
  4890.   def hide_icons(*icons)
  4891.     motion = @iconsEnter
  4892.     icons.each_with_index{|icon, index|
  4893.       Tween.start(icon, motion[:style], motion[:time], motion[:off] * index,
  4894.         :y => Graphics.height + 12
  4895.       )
  4896.     }
  4897.   end
  4898.   #-------------------------------------------------------------------------
  4899.   # * Seleciona ícone
  4900.   #     icon : Ícone
  4901.   #     name : Vocabulário para o nome
  4902.   #-------------------------------------------------------------------------
  4903.   def select_icon(icon, name)    
  4904.     Tween.start(icon, @iconsMove[:style], @iconsMove[:time],
  4905.       :y => Graphics.height - 36
  4906.     )
  4907.    
  4908.     Tween.start(@cursor, @cursorMove[:style], @cursorMove[:time],
  4909.       :x => icon.x
  4910.     )
  4911.      
  4912.     @cursor.bitmap.clear
  4913.     @cursor.bitmap.draw_text(@cursor.bitmap.rect, name, 1)
  4914.   end
  4915.   #-------------------------------------------------------------------------
  4916.   # * Deseleciona ícone
  4917.   #     icon : Ícone
  4918.   #-------------------------------------------------------------------------
  4919.   def unselect_icon(icon)
  4920.     Tween.start(icon, @iconsMove[:style], @iconsMove[:time],
  4921.       :y => Graphics.height - 24
  4922.     )
  4923.   end
  4924.   #-------------------------------------------------------------------------
  4925.   # * Processa movimento base do cursor
  4926.   #     indexName : Simbolo com nome da variável indexadora
  4927.   #     direction : Direção do movimento
  4928.   #     type      : Horizontal (:hor), Vertical (:vert)
  4929.   #     max       : Valor máximo
  4930.   #-------------------------------------------------------------------------
  4931.   def processBaseMovement(indexName, direction, type, max)
  4932.     index = instance_variable_get(indexName)
  4933.     lastIndex = index
  4934.     hor = (type == :hor)
  4935.     if direction == (hor ? :Left : :Up)
  4936.       index -= 1
  4937.     elsif direction == (hor ? :Right : :Down)
  4938.       index += 1
  4939.     end
  4940.     index %= max
  4941.     self.instance_variable_set(indexName, index)
  4942.     if block_given?
  4943.       yield(lastIndex, index)
  4944.     else
  4945.       return lastIndex, index
  4946.     end
  4947.   end
  4948.   #-------------------------------------------------------------------------
  4949.   # * Processa movimento de cursor e atualiza ícones
  4950.   #     indexName : Simbolo com nome da variável indexadora
  4951.   #     direction : Direção do movimento
  4952.   #     type      : Horizontal (:hor), Vertical (:vert)
  4953.   #     icons     : Array de ícones referentes ao movimento
  4954.   #     vocab     : Array de vocabulário
  4955.   #     cursor    : Executar som de movimento do cursor?
  4956.   #-------------------------------------------------------------------------
  4957.   def processMovement(indexName, direction, type, icons, vocab, cursor = true)
  4958.     processBaseMovement(indexName, direction, type, icons.size){|lastIndex, index|
  4959.       Sound.play_cursor if cursor
  4960.    
  4961.       self.unselect_icon(icons[lastIndex])
  4962.       self.select_icon(icons[index], vocab[index])
  4963.      
  4964.       yield(lastIndex, index) if block_given?
  4965.     }
  4966.   end
  4967.   #-------------------------------------------------------------------------
  4968.   # * Mostra janelas de ator (básica)
  4969.   #-------------------------------------------------------------------------
  4970.   def show_actors_windows
  4971.     @actorsWindows.each_with_index{|window, index|
  4972.       Tween.start(window, @winsMove[:style], @winsMove[:time], @winsMove[:off] * index,
  4973.         :y => 0,
  4974.         :contents_opacity => 255
  4975.       )
  4976.     }
  4977.   end
  4978.   #-------------------------------------------------------------------------
  4979.   # * Esconde janelas de ator (básica)
  4980.   #-------------------------------------------------------------------------
  4981.   def hide_actors_windows
  4982.     @actorsWindows.each_with_index{|window, index|
  4983.       Tween.start(window, @winsMove[:style], @winsMove[:time], @winsMove[:off] * index,
  4984.         :y => -window.height,
  4985.         :contents_opacity => 0
  4986.       )
  4987.     }
  4988.   end
  4989.   #-------------------------------------------------------------------------
  4990.   # * Mostra janela de ouro
  4991.   #-------------------------------------------------------------------------
  4992.   def show_gold_window
  4993.       Tween.start(@goldWindow, @goldEnter[:style], @goldEnter[:time],
  4994.         :contents_opacity => 255
  4995.       )
  4996.   end
  4997.  
  4998.   #-------------------------------------------------------------------------
  4999.   # * Enconde janela de ouro
  5000.   #-------------------------------------------------------------------------
  5001.   def hide_gold_window
  5002.     Tween.start(@goldWindow, @goldEnter[:style], @goldEnter[:time],
  5003.         :contents_opacity => 0
  5004.       )
  5005.   end
  5006.  
  5007.   #-------------------------------------------------------------------------
  5008.   # * Mostra janela de itens
  5009.   #-------------------------------------------------------------------------
  5010.   def show_items_window
  5011.     Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time],
  5012.       :x => 0,
  5013.       :contents_opacity => 255
  5014.     )
  5015.     Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
  5016.       :x => @itemsInfo.width,
  5017.       :contents_opacity => 255
  5018.     )
  5019.   end
  5020.   #-------------------------------------------------------------------------
  5021.   # * Esconde a janela de itens
  5022.   #-------------------------------------------------------------------------
  5023.   def hide_items_window
  5024.     Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time],
  5025.       :x => Graphics.width,
  5026.       :contents_opacity => 0
  5027.     )
  5028.     Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
  5029.       :x => Graphics.width,
  5030.       :contents_opacity => 0
  5031.     )
  5032.   end
  5033.   #-------------------------------------------------------------------------
  5034.   # * Aplicação de filtro na janela de itens
  5035.   #     &block : Bloco que será iniciado quando a janela estiver com opaci-
  5036.   #              dade mínima.
  5037.   #-------------------------------------------------------------------------
  5038.   def items_filter_animation(&block)
  5039.     Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time] / 4.0,
  5040.       :contents_opacity => 0
  5041.     ){
  5042.       block.call
  5043.       Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time] / 4.0,
  5044.         :contents_opacity => 255
  5045.       )
  5046.     }
  5047.   end
  5048.   #-------------------------------------------------------------------------
  5049.   # * Mostra as janelas de equipamentos
  5050.   #-------------------------------------------------------------------------
  5051.   def show_equips_windows
  5052.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  5053.       :x => 0,
  5054.       :contents_opacity => 255
  5055.     )
  5056.     Tween.start(@itemsInfo, @equipsEnter[:style], @equipsEnter[:time],
  5057.       :x => @equipsWindow.width,
  5058.       :contents_opacity => 255
  5059.     )
  5060.   end
  5061.   #-------------------------------------------------------------------------
  5062.   # * Esconde as janelas de equipamentos
  5063.   #-------------------------------------------------------------------------
  5064.   def hide_equips_windows
  5065.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  5066.       :x => Graphics.width,
  5067.       :contents_opacity => 0
  5068.     )
  5069.     Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
  5070.       :x => Graphics.width,
  5071.       :contents_opacity => 0
  5072.     )
  5073.   end
  5074.   #-------------------------------------------------------------------------
  5075.   # * Mostra a janela de equipamentos disponíveis
  5076.   #-------------------------------------------------------------------------
  5077.   def show_inventory_equips
  5078.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  5079.       :contents_opacity => 0
  5080.     )
  5081.     @itemsWindow.x = 0
  5082.     Tween.start(@itemsWindow, @equipsEnter[:style], @equipsEnter[:time],
  5083.       :contents_opacity => 255
  5084.     )
  5085.   end
  5086.   #-------------------------------------------------------------------------
  5087.   # * Esconde a janela de equipamentos disponíveis
  5088.   #-------------------------------------------------------------------------
  5089.   def hide_inventory_equips
  5090.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  5091.       :contents_opacity => 255
  5092.     )
  5093.     Tween.start(@itemsWindow, @equipsEnter[:style], @equipsEnter[:time],
  5094.       :contents_opacity => 0
  5095.     ){
  5096.       @itemsWindow.x = Graphics.width
  5097.     }
  5098.   end
  5099.   #-------------------------------------------------------------------------
  5100.   # * Mostra as janelas de habilidades
  5101.   #-------------------------------------------------------------------------
  5102.   def show_skills_windows
  5103.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5104.       :x => 0,
  5105.       :contents_opacity => 255
  5106.     )
  5107.     Tween.start(@slistWindow, @skillsEnter[:style], @skillsEnter[:time],
  5108.       :x => @stypeWindow.width,
  5109.       :contents_opacity => 255
  5110.     )
  5111.   end
  5112.   #-------------------------------------------------------------------------
  5113.   # * Esconde as janelas de habilidades
  5114.   #-------------------------------------------------------------------------
  5115.   def hide_skills_windows
  5116.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5117.       :x => Graphics.width,
  5118.       :contents_opacity => 0
  5119.     )
  5120.     Tween.start(@slistWindow, @skillsEnter[:style], @skillsEnter[:time],
  5121.       :x => Graphics.width,
  5122.       :contents_opacity => 0
  5123.     )
  5124.   end
  5125.   #-------------------------------------------------------------------------
  5126.   # * Mostra a janela de descrição da habilidade
  5127.   #-------------------------------------------------------------------------
  5128.   def show_skills_description
  5129.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5130.       :contents_opacity => 0
  5131.     )
  5132.     @itemsInfo.x = 0
  5133.     Tween.start(@itemsInfo, @equipsEnter[:style], @equipsEnter[:time],
  5134.       :contents_opacity => 255
  5135.     )
  5136.   end
  5137.   #-------------------------------------------------------------------------
  5138.   # * Esconde a janela de descrição da habilidade
  5139.   #-------------------------------------------------------------------------
  5140.   def hide_skills_description
  5141.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5142.       :contents_opacity => 255
  5143.     )
  5144.     Tween.start(@itemsInfo, @skillsEnter[:style], @skillsEnter[:time],
  5145.       :contents_opacity => 0
  5146.     ){
  5147.       @itemsInfo.x = Graphics.width
  5148.     }
  5149.   end
  5150.   #-------------------------------------------------------------------------
  5151.   # * Mostra janelas de formação
  5152.   #-------------------------------------------------------------------------
  5153.   def show_formation_windows
  5154.     mot = @formationEnter
  5155.     @formationWindows[0,3].each_with_index{|win, index|
  5156.       Tween.start(win, mot[:style], mot[:time], mot[:off] * index,
  5157.         :y => win.height * index,
  5158.         :contents_opacity => 255.0 / (index + 1)
  5159.       )
  5160.     }
  5161.   end
  5162.   #-------------------------------------------------------------------------
  5163.   # * Atualiza posição das janelas de formação
  5164.   #-------------------------------------------------------------------------
  5165.   def move_formation_windows
  5166.     mot = @formationMove
  5167.     windows = @formationWindows[@formationIndex2, @formationWindows.size - @formationIndex2]
  5168.     windows += @formationWindows - windows
  5169.    
  5170.     windows.each_with_index{|win, index|
  5171.       Tween.start(win, mot[:style], mot[:time],
  5172.         :y => win.height * (index > 3 ? 3 : index),
  5173.         :contents_opacity => index.between?(0, 2) ? 255.0 / (index + 1) : 0
  5174.       )
  5175.     }
  5176.   end
  5177.   #-------------------------------------------------------------------------
  5178.   # * Esconde janelas de formação
  5179.   #-------------------------------------------------------------------------
  5180.   def hide_formation_windows
  5181.     mot   = @formationEnter
  5182.    
  5183.     @formationWindows.each_with_index{|win, index|
  5184.       Tween.start(win, mot[:style], mot[:time], mot[:off] * index,
  5185.         :y => Graphics.width,
  5186.         :contents_opacity => 0
  5187.       )
  5188.     }
  5189.   end
  5190.   #-------------------------------------------------------------------------
  5191.   # * Seleciona uma janela de ator (o que será trocado)
  5192.   #     index   : Identificador
  5193.   #     fromPos : Ir para o destino a partir da posição atual?
  5194.   #-------------------------------------------------------------------------
  5195.   def select_formation_actor(index, fromPos=true)
  5196.     win = @actorsWindows[index]
  5197.     win.x = -win.width unless fromPos
  5198.     Tween.start(win,  @winsMove[:style], @winsMove[:time],
  5199.       :x => 0,
  5200.       :y => 0,
  5201.       :contents_opacity => 255
  5202.     )
  5203.   end
  5204.   #-------------------------------------------------------------------------
  5205.   # * Deseleciona uma janela de ator
  5206.   #     index : Identificador
  5207.   #     toPos : Ir para a posição correta?
  5208.   #-------------------------------------------------------------------------
  5209.   def unselect_formation_actor(index, toPos=true)
  5210.     Tween.start(@actorsWindows[index],  @winsMove[:style], @winsMove[:time],
  5211.       :x => (toPos ? index : -1) * @actorsWindows[index].width
  5212.     )
  5213.   end
  5214.   #-------------------------------------------------------------------------
  5215.   # * Troca informações de formação e das janelas de atores
  5216.   #-------------------------------------------------------------------------
  5217.   def trade_actors_formation
  5218.     actor1 = @formationIndex1
  5219.     actor2 = @formationIndex2 + (@formationIndex2 < @formationIndex1 ? 0 : 1)
  5220.    
  5221.     $game_party.swap_order(actor1, actor2)
  5222.     @statusWindows[actor1], @statusWindows[actor2] = @statusWindows[actor2], @statusWindows[actor1]
  5223.     @pdistWindows[actor1], @pdistWindows[actor2] = @pdistWindows[actor2], @pdistWindows[actor1]
  5224.    
  5225.     winActor1 = actor1
  5226.     winActor2 = actor2 < 4 ? actor2 : nil
  5227.    
  5228.     Tween.start(@actorsWindows[winActor1],  @winsMove[:style], @winsMove[:time]/2.0,
  5229.       :x => -@actorsWindows[@formationIndex1].width
  5230.     ){
  5231.       @actorsWindows[winActor1].actor = $game_party.members[actor1]
  5232.       @actorsWindows[winActor2].actor = $game_party.members[actor2] if winActor2
  5233.       Tween.start(@actorsWindows[winActor1],  @winsMove[:style], @winsMove[:time]/2.0,
  5234.         :x => 0
  5235.       )
  5236.     }
  5237.    
  5238.     winForm1 = @formationWindows[@formationIndex2]
  5239.     winForm2 = @removedFormationWin.last
  5240.    
  5241.     winForm1.active = false
  5242.     winForm2.active = true
  5243.    
  5244.     mot              = @formationMove
  5245.    
  5246.     Tween.start(winForm1, mot[:style], mot[:time],
  5247.       :y => winForm1.height * 3,
  5248.       :contents_opacity => 0
  5249.     )
  5250.    
  5251.     Tween.start(winForm2, mot[:style], mot[:time],
  5252.       :y => 0,
  5253.       :contents_opacity => 255
  5254.     )
  5255.    
  5256.     @formationWindows.delete(winForm1)
  5257.     @formationWindows.insert(@formationIndex2, winForm2)
  5258.    
  5259.     @removedFormationWin = [
  5260.       @formationIndex2,
  5261.       winForm1
  5262.     ]
  5263.   end
  5264.   #-------------------------------------------------------------------------
  5265.   # * Mostra janela de informação completa do ator
  5266.   #     index : Identificador
  5267.   #     dir   : Direção de entrada
  5268.   #-------------------------------------------------------------------------
  5269.   def show_status_window(index, dir = :Left)
  5270.     window = @statusWindows[index]
  5271.     window.x = dir == :Left ? Graphics.width : -window.width
  5272.     Tween.start(window, @statusMove[:style], @statusMove[:time],
  5273.       :x => 0,
  5274.       :contents_opacity => 255
  5275.     )
  5276.   end
  5277.   #-------------------------------------------------------------------------
  5278.   # * Esconde janela de informação completa do ator
  5279.   #     index : Identificador
  5280.   #     dir   : Direção de saída
  5281.   #-------------------------------------------------------------------------
  5282.   def hide_status_window(index, dir = :Left)
  5283.     window = @statusWindows[index]
  5284.     Tween.start(window, @statusMove[:style], @statusMove[:time],
  5285.       :x => (dir == :Left ? -window.width : Graphics.width),
  5286.       :contents_opacity => 0
  5287.     )
  5288.   end
  5289.   #-------------------------------------------------------------------------
  5290.   # * Mostra lista de monstros do bestiário
  5291.   #-------------------------------------------------------------------------
  5292.   def show_bestiary_list
  5293.     window = @monsterList
  5294.     Tween.start(window, @bestiaryEnter[:style], @bestiaryEnter[:time],
  5295.       :x => 0,
  5296.       :contents_opacity => 255
  5297.     )
  5298.   end
  5299.   #-------------------------------------------------------------------------
  5300.   # * Esconde lista de monstros do bestiário
  5301.   #-------------------------------------------------------------------------
  5302.   def hide_bestiary_list
  5303.     window = @monsterList
  5304.     Tween.start(window, @bestiaryEnter[:style], @bestiaryEnter[:time],
  5305.       :x => Graphics.width,
  5306.       :contents_opacity => 0
  5307.     )
  5308.   end
  5309.   #-------------------------------------------------------------------------
  5310.   # * Move janelas de monstros do bestiário
  5311.   #     back : Voltando?
  5312.   #-------------------------------------------------------------------------
  5313.   def switch_monster_windows(back)
  5314.     window = @monsterList
  5315.     Tween.start(window, @bestiaryMove[:style], @bestiaryMove[:time],
  5316.       :x => back ? 0 : -window.width,
  5317.       :contents_opacity => back ? 255 : 0
  5318.     )
  5319.     window = @monsterWindow
  5320.     Tween.start(window, @bestiaryMove[:style], @bestiaryMove[:time],
  5321.       :x => back ? Graphics.width : 0,
  5322.       :contents_opacity => back ? 0 : 255
  5323.     )
  5324.   end
  5325.   #-------------------------------------------------------------------------
  5326.   # * Mostra janela de distribuição de pontos
  5327.   #     index : Identificador
  5328.   #     dir   : Direção de entrada
  5329.   #-------------------------------------------------------------------------
  5330.   def show_pdist_window(index, dir = :Left)
  5331.     window = @pdistWindows[index]
  5332.     window.x = dir == :Left ? Graphics.width : -window.width
  5333.     Tween.start(window, @pdistMove[:style], @pdistMove[:time],
  5334.       :x => 0,
  5335.       :contents_opacity => 255
  5336.     )
  5337.   end
  5338.   #-------------------------------------------------------------------------
  5339.   # * Esconde janela de distribuição de pontos
  5340.   #     index : Identificador
  5341.   #     dir   : Direção de saída
  5342.   #-------------------------------------------------------------------------
  5343.   def hide_pdist_window(index, dir = :Left)
  5344.     window = @pdistWindows[index]
  5345.     Tween.start(window, @pdistMove[:style], @pdistMove[:time],
  5346.       :x => (dir == :Left ? -window.width : Graphics.width),
  5347.       :contents_opacity => 0
  5348.     )
  5349.   end
  5350.   #-------------------------------------------------------------------------
  5351.   # * Mostra mini-mapa
  5352.   #-------------------------------------------------------------------------
  5353.   def show_minimap
  5354.     Tween.start(@minimap, @minimapEnter[:style], @minimapEnter[:time],
  5355.       :x => 0,
  5356.       :opacity => 255
  5357.     )
  5358.   end
  5359.   #-------------------------------------------------------------------------
  5360.   # * Esconde o mini-mapa
  5361.   #-------------------------------------------------------------------------
  5362.   def hide_minimap
  5363.     Tween.start(@minimap, @minimapEnter[:style], @minimapEnter[:time],
  5364.       :x => Graphics.width,
  5365.       :opacity => 0
  5366.     )
  5367.   end
  5368.   #-------------------------------------------------------------------------
  5369.   # * Mostra janela de opções
  5370.   #-------------------------------------------------------------------------
  5371.   def show_options_window
  5372.     Tween.start(@optionWindow, @optionEnter[:style], @optionEnter[:time],
  5373.       :x => 0,
  5374.       :contents_opacity => 255
  5375.     )
  5376.   end
  5377.   #-------------------------------------------------------------------------
  5378.   # * Esconde janela de opções
  5379.   #-------------------------------------------------------------------------
  5380.   def hide_options_window
  5381.     Tween.start(@optionWindow, @optionEnter[:style], @optionEnter[:time],
  5382.       :x => Graphics.width,
  5383.       :contents_opacity => 0
  5384.     )
  5385.   end
  5386.   #-------------------------------------------------------------------------
  5387.   # * Mostra janelas de save
  5388.   #-------------------------------------------------------------------------
  5389.   def show_save_windows
  5390.     baseX = (Graphics.width - @saveWindows.first.width) / 2
  5391.    
  5392.     @saveWindows.each_with_index{|window, index|
  5393.       Tween.start(window, @saveEnter[:style], @saveEnter[:time], @saveEnter[:off] * index,
  5394.         :x => baseX - ((@saveIndex - index) * window.width),
  5395.         :contents_opacity => 255
  5396.       )
  5397.     }
  5398.   end
  5399.   #-------------------------------------------------------------------------
  5400.   # * Esconde janelas de save
  5401.   #-------------------------------------------------------------------------
  5402.   def hide_save_windows
  5403.     @saveWindows.each_with_index{|window, index|
  5404.       Tween.start(window, @saveEnter[:style], @saveEnter[:time], @saveEnter[:off] * index,
  5405.         :x => Graphics.width,
  5406.         :contents_opacity => 0
  5407.       )
  5408.     }
  5409.   end
  5410.   #-------------------------------------------------------------------------
  5411.   # * Move janelas de save
  5412.   #-------------------------------------------------------------------------
  5413.   def move_save_windows
  5414.     baseX = (Graphics.width - @saveWindows.first.width) / 2
  5415.    
  5416.     @saveWindows.each_with_index{|window, index|
  5417.       Tween.start(window, @saveMove[:style], @saveMove[:time],
  5418.         :x => baseX - ((@saveIndex - index) * window.width)
  5419.       )
  5420.     }
  5421.   end
  5422. end
  5423.  
  5424.  
  5425. #=============================================================================
  5426. # Tweening [Scripter's Tool]
  5427. #---------------------------------------------------------------------------
  5428. # Formulas by: Robert Penner
  5429. # Compiled to Ruby by: UziMonkey
  5430. # Modified by: Gab!
  5431. #=============================================================================
  5432.  
  5433. class Tween
  5434.  
  5435.   @@__current  = {}
  5436.  
  5437.   def self.start(obj, style = Tween::Linear, time = 1, offset = 0, prop, &block)
  5438.     @@__current[obj] ||= {}
  5439.     prop.each_pair{|pr, final|
  5440.       act = obj.method(pr).call
  5441.       @@__current[obj][pr] = {
  5442.         tween: Tween.new(act, final, style, time),
  5443.         set: obj.method((pr.to_s + "=").to_sym),
  5444.         lfr: Time.new,
  5445.         tfr: 0,
  5446.         off: (offset / 100.0),
  5447.         blk: block
  5448.       }
  5449.     }
  5450.   end
  5451.  
  5452.   def self.update
  5453.     remove = []
  5454.    
  5455.     @@__current.each_pair{|obj, prop|
  5456.       done = true
  5457.       prop.each_value{|property|
  5458.         next if property[:tween].done
  5459.         done = false
  5460.        
  5461.         property[:tfr] = Time.new
  5462.         delta = (property[:tfr] - property[:lfr]).round(3)
  5463.         property[:lfr] = property[:tfr]
  5464.        
  5465.         if property[:off] > 0
  5466.           property[:off] -= delta
  5467.           next if property[:off] >= 0
  5468.           delta = -property[:off]
  5469.         end
  5470.          
  5471.         property[:tween].update(delta)
  5472.         property[:set].call(property[:tween].value) rescue nil
  5473.        
  5474.         property[:blk].call(obj) if property[:tween].done && property[:blk]
  5475.       }
  5476.      
  5477.       @@__current.delete(obj) if done
  5478.     }
  5479.   end
  5480.  
  5481.   def self.remove(obj, prop = nil)
  5482.     return obj.each{|object|
  5483.       Tween.remove(*(object.is_a?(Array) ? object : [object]))
  5484.     } if obj.is_a?(Array)
  5485.      
  5486.     if (@@__current.has_key?(obj))
  5487.       if (prop.nil?)
  5488.         @@__current.delete(obj)
  5489.       elsif @@__current[obj].has_key?(prop)
  5490.         @@__current[obj].delete(prop)
  5491.       end
  5492.     end
  5493.   end
  5494.  
  5495.   def self.ready?(obj)
  5496.     return !@@__current.has_key?(obj)
  5497.   end
  5498.  
  5499.  
  5500.   attr_reader :done
  5501.   attr_reader :easer
  5502.  
  5503.   def initialize(start, finish, easer, duration)
  5504.     @start, @finish = start, finish
  5505.     @delta = @finish - @start
  5506.     @easer, @duration = easer, duration
  5507.     @time = 0
  5508.     @done = false
  5509.   end
  5510.  
  5511.   def update(delta)
  5512.     @time += delta
  5513.     if @time > @duration
  5514.       @time = @duration
  5515.       @done = true
  5516.     end
  5517.   end
  5518.  
  5519.   def value
  5520.     @easer.ease(@time, @start, @delta, @duration)
  5521.   end
  5522.  
  5523.   module Linear
  5524.     def self.ease(t, st, ch, d)
  5525.       ch * t / d + st
  5526.     end
  5527.   end
  5528.  
  5529.   module Sine
  5530.     HALF_PI = Math::PI / 2
  5531.    
  5532.     module In
  5533.       def self.ease(t, st, ch, d)
  5534.         -ch * Math.cos(t / d * HALF_PI) + ch + st
  5535.       end
  5536.     end
  5537.    
  5538.     module Out
  5539.       def self.ease(t, st, ch, d)
  5540.         ch * Math.sin(t / d * HALF_PI) + st
  5541.       end
  5542.     end
  5543.    
  5544.     module InOut
  5545.       def self.ease(t, st, ch, d)
  5546.         -ch / 2 * (Math.cos(Math::PI * t / d) - 1) + st
  5547.       end
  5548.     end
  5549.   end
  5550.  
  5551.   module Circ
  5552.     module In
  5553.       def self.ease(t, st, ch, d)
  5554.         rate = t/d
  5555.         -ch * (Math.sqrt(1 - rate * rate) - 1) + st
  5556.       end
  5557.     end
  5558.    
  5559.     module Out
  5560.       def self.ease(t, st, ch, d)
  5561.         t = t/d - 1
  5562.         ch * Math.sqrt(1 - t * t) + st
  5563.       end
  5564.     end
  5565.    
  5566.     module InOut
  5567.       def self.ease(t, st, ch, d)
  5568.         if (t /= d/2.0) < 1
  5569.           return -ch / 2 * (Math.sqrt(1 - t*t) - 1) + st
  5570.         else
  5571.           return ch / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + st
  5572.         end
  5573.       end
  5574.     end
  5575.   end
  5576.  
  5577.   module Bounce
  5578.     module Out
  5579.       def self.ease(t, st, ch, d)
  5580.         if (t /= d) < (1/2.75)
  5581.           ch * (7.5625 * t * t) + st
  5582.         elsif t < (2 / 2.75)
  5583.           ch * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + st
  5584.         elsif t < (2.5 / 2.75)
  5585.           ch * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + st
  5586.         else
  5587.           ch * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + st
  5588.         end
  5589.       end
  5590.     end
  5591.    
  5592.     module In
  5593.       def self.ease(t, st, ch, d)
  5594.         ch - Tween::Bounce::Out.ease(d-t, 0, ch, d) + st
  5595.       end
  5596.     end
  5597.    
  5598.     module InOut
  5599.       def self.ease(t, st, ch, d)
  5600.         t *= 2
  5601.         if t < d
  5602.           Tween::Bounce::In.ease(t, 0, ch, d) * 0.5 + st
  5603.         else
  5604.           Tween::Bounce::Out.ease(t - d, 0, ch, d) * 0.5 + ch * 0.5 + st
  5605.         end
  5606.       end
  5607.     end
  5608.   end
  5609.  
  5610.   module Back
  5611.     module In
  5612.       def self.ease(t, st, ch, d, s=1.70158)      
  5613.         ch * (t/=d) * t * ((s+1) * t - s) + st
  5614.       end
  5615.     end
  5616.    
  5617.     module Out
  5618.       def self.ease(t, st, ch, d, s=1.70158)
  5619.         ch * ((t=t/d-1) * t * ((s+1) * t + s) + 1) + st
  5620.       end
  5621.     end
  5622.    
  5623.     module InOut
  5624.       def self.ease(t, st, ch, d, s=1.70158)
  5625.         if (t /= d/2.0) < 1
  5626.           ch / 2.0 * (t * t * (((s *= 1.525) + 1) * t - s)) + st
  5627.         else
  5628.           ch / 2.0 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + st
  5629.         end
  5630.       end
  5631.     end
  5632.   end
  5633.        
  5634.   module Cubic
  5635.     module In
  5636.       def self.ease(t, st, ch, d)
  5637.         ch * (t /= d) * t * t + st
  5638.       end
  5639.     end
  5640.    
  5641.     module Out
  5642.       def self.ease(t, st, ch, d)
  5643.         ch * ((t = t / d.to_f - 1) * t * t + 1) + st
  5644.       end
  5645.     end
  5646.    
  5647.     module InOut
  5648.       def self.ease(t, st, ch, d)
  5649.         if (t /= d / 2.0) < 1
  5650.           ch / 2.0 * t * t * t + st
  5651.         else
  5652.           ch / 2.0 * ((t -= 2) * t * t + 2) + st
  5653.         end
  5654.       end
  5655.     end
  5656.   end
  5657.  
  5658.   module Expo
  5659.     module In
  5660.       def self.ease(t, st, ch, d)
  5661.         if t == 0
  5662.           st
  5663.         else
  5664.           ch * (2 ** (10 * (t / d.to_f - 1))) + st
  5665.         end
  5666.       end
  5667.     end
  5668.    
  5669.     module Out
  5670.       def self.ease(t, st, ch, d)
  5671.         if t == d
  5672.           st + ch
  5673.         else
  5674.           ch * (1 - (2 ** (-10 * t / d.to_f))) + st
  5675.         end
  5676.       end
  5677.     end
  5678.    
  5679.     module InOut
  5680.       def self.ease(t, st, ch, d)
  5681.         if t == 0
  5682.           st
  5683.         elsif t == d
  5684.           st + ch
  5685.         elsif (t /= d / 2.0) < 1
  5686.           ch / 2.0 * (2 ** (10 * (t - 1))) + st
  5687.         else
  5688.           ch / 2.0 * (-(2 ** (-10 * (t -= 1))) + 2) + st
  5689.         end
  5690.       end
  5691.     end
  5692.   end
  5693.  
  5694.   module Quad
  5695.     module In
  5696.       def self.ease(t, st, ch, d)
  5697.         ch * (t /= d.to_f) * t + st
  5698.       end
  5699.     end
  5700.    
  5701.     module Out
  5702.       def self.ease(t, st, ch, d)
  5703.         -ch * (t /= d.to_f) * (t - 2) + st
  5704.       end
  5705.     end
  5706.    
  5707.     module InOut
  5708.       def self.ease(t, st, ch, d)
  5709.         if (t /= d / 2.0) < 1
  5710.           ch / 2.0 * t * t + st
  5711.         else
  5712.           -ch / 2.0 * ((t -= 1) * (t - 2) - 1) + st
  5713.         end
  5714.       end
  5715.     end
  5716.   end
  5717.  
  5718.   module Quart
  5719.     module In
  5720.       def self.ease(t, st, ch, d)
  5721.         ch * (t /= d.to_f) * t * t * t + st
  5722.       end
  5723.     end
  5724.    
  5725.     module Out
  5726.       def self.ease(t, st, ch, d)
  5727.         -ch * ((t = t / d.to_f - 1) * t * t * t - 1) + st
  5728.       end
  5729.     end
  5730.    
  5731.     module InOut
  5732.       def self.ease(t, st, ch, d)
  5733.         if (t /= d / 2.0) < 1
  5734.           ch / 2.0 * t * t * t * t + st
  5735.         else
  5736.           -ch / 2.0 * ((t -= 2) * t * t * t - 2) + st
  5737.         end
  5738.       end
  5739.     end
  5740.   end
  5741.  
  5742.   module Quint
  5743.     module In
  5744.       def self.ease(t, st, ch, d)
  5745.         ch * (t /= d.to_f) * t * t * t * t + st
  5746.       end
  5747.     end
  5748.    
  5749.     module Out
  5750.       def self.ease(t, st, ch, d)
  5751.         ch * ((t = t / d.to_f - 1) * t * t * t * t + 1) + st
  5752.       end
  5753.     end
  5754.    
  5755.     module InOut
  5756.       def self.ease(t, st, ch, d)
  5757.         ch /= 2.0
  5758.         if (t /= d / 2.0) < 1
  5759.           ch * t * t * t * t * t + st
  5760.         else
  5761.           ch * ((t -= 2) * t * t * t * t + 2) + st
  5762.         end
  5763.       end
  5764.     end
  5765.   end
  5766.  
  5767.   module Elastic
  5768.     DOUBLE_PI = 2 * Math::PI
  5769.    
  5770.     module In
  5771.       def self.ease(t, st, ch, d, a = 5, p = 0)
  5772.         s = 0
  5773.        
  5774.         if t == 0
  5775.           return st
  5776.         elsif (t /= d.to_f) >= 1
  5777.           return st + ch
  5778.         end
  5779.        
  5780.         p = d * 0.3 if p == 0
  5781.        
  5782.         if (a == 0) || (a < ch.abs)
  5783.           a = ch
  5784.           s = p / 4.0
  5785.         else
  5786.           s = p / DOUBLE_PI * Math.asin(ch / a.to_f)
  5787.         end
  5788.        
  5789.         -(a * (2 ** (10 * (t -= 1))) * Math.sin((t * d - s) * DOUBLE_PI / p)) + st
  5790.       end
  5791.     end
  5792.    
  5793.     module Out
  5794.       def self.ease(t, st, ch, d, a = 0.1, p = 0)
  5795.         s = 0
  5796.        
  5797.         if t == 0
  5798.           return st
  5799.         elsif (t /= d.to_f) >= 1
  5800.           return st + ch
  5801.         end
  5802.        
  5803.         p = d * 0.3 if p == 0
  5804.        
  5805.         if (a == 0) || (a < ch.abs)
  5806.           a = ch
  5807.           s = p / 4.0
  5808.         else
  5809.           s = p / DOUBLE_PI * Math.asin(ch / a.to_f)
  5810.         end
  5811.        
  5812.         a * (2 ** (-10 * t)) * Math.sin((t * d - s) * DOUBLE_PI / p.to_f) + ch + st
  5813.       end
  5814.     end
  5815.   end
  5816.          
  5817.   EASERS = [
  5818.     Linear,
  5819.    
  5820.     Sine::In,
  5821.     Sine::Out,
  5822.     Sine::InOut,
  5823.    
  5824.     Circ::In,
  5825.     Circ::Out,
  5826.     Circ::InOut,
  5827.    
  5828.     Bounce::Out,
  5829.     Bounce::In,
  5830.     Bounce::InOut,
  5831.    
  5832.     Back::In,
  5833.     Back::Out,
  5834.     Back::InOut,
  5835.    
  5836.     Cubic::In,
  5837.     Cubic::Out,
  5838.     Cubic::InOut,
  5839.    
  5840.     Expo::In,
  5841.     Expo::Out,
  5842.     Expo::InOut,
  5843.    
  5844.     Quad::In,
  5845.     Quad::Out,
  5846.     Quad::InOut,
  5847.    
  5848.     Quart::In,
  5849.     Quart::Out,
  5850.     Quart::InOut,
  5851.    
  5852.     Quint::In,
  5853.     Quint::Out,
  5854.     Quint::InOut,
  5855.    
  5856.     Elastic::In,
  5857.     Elastic::Out
  5858.   ]
  5859. end
Advertisement
Add Comment
Please, Sign In to add comment