Gabz

Gab Extreme Menu

Nov 13th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 202.77 KB | None | 0 0
  1. #=============================================================================
  2. # * Mundo RPG Maker Extreme Menu
  3. #---------------------------------------------------------------------------
  4. # Autor: Gab!
  5. # Data:  22/12/12 ~ 20/12/12
  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.     Item:        "Item Comum",           # Item Comum
  116.     Weapon:      "Arma",                 # Armas
  117.     Armor:       "Armadura",             # Armaduras
  118.     KeyItem:     "Item Chave",           # Itens chave
  119.     Empty:       "---",                  # Quando nada é mostrado
  120.     HPRecover:   "Recup. de HP",         # Recuperação de HP
  121.     MPRecover:   "Recup. de MP",         # Recuperação de MP
  122.     TPRecover:   "Recup. de TP",         # Recuperação de TP
  123.     TPGain:      "Ganho de TP",          # Ganho de TP
  124.     Applies:     "Provoca",              # Estados provacados
  125.     Removes:     "Remove",               # Estados removidos
  126.     #==========================
  127.     FixEquip:    "Equipamento fixo!",    # Equipamento fixo
  128.     Optimize:    "Melhor Equipamento",   # Otimizar equipamentos e selecionar
  129.                                          # os melhores
  130.     #==========================
  131.     InsufActs:   "Apenas um membro no grupo!", # Membros insuficientes para abrir
  132.                                                # o menu de formação
  133.    
  134.     #==========================
  135.     ZeroMonster: "Bestiário vazio!",     # Não existem monstros no bestiário
  136.     BComplete:   "Progresso: {c}%",      # Progresso. ({c} será substituido pela
  137.                                          # porcentagem de progresso.)
  138.     Experience:  "Experiência",          # Experiência
  139.     Loot:        "Recompensas",          # Recompensas
  140.    
  141.     #==========================
  142.     InsufPts:    "Pontos insuficientes", # Pontos insuficientes
  143.    
  144.     #==========================
  145.     OptionsSFX:  "Efeitos Sonoros",      # Efeitos sonoros
  146.     OptionsMsc:  "Música",               # Música (BGM, ME)
  147.     OptionsSnd:  "Som",                  # Som (BGS, SE)
  148.    
  149.     #==========================
  150.     SaveBlock:   "Save Bloqueado",       # Salvar desabilitado
  151.     FreeSlot:    "Slot vazio",           # Slot de save vazio
  152.     NewSave:     "Novo save",            # Criar novo save
  153.     PlayTime:    "Tempo de Jogo:",       # Tempo de jogo
  154.     Party:       "Grupo",                # Grupo
  155.     SaveOver:    "Sobrescrever?",        # Confirmação de sobresctrita
  156.     SaveYes:     "Sim",                  # Confirmação de Sobrescrita (Sim)
  157.     SaveNo:      "Não",                  # Confirmação de Sobrescrita (Não)
  158.     Saved:       "Jogo salvo!",          # Jogo salvo
  159.    
  160.     #==========================
  161.     ExitTitle:   "Tela de Título",       # Voltar ao título
  162.     ExitGame:    "Deixar Jogo",          # Sair do jogo
  163.     ExitCanc:    "Cancelar",             # Cancelar Saída
  164.   }
  165.  
  166.   Font = { # Definições de fonte
  167.     Name:    "Trebuchet MS",       # Nome
  168.     Size:    18,                   # Tamanho
  169.     Color:   [255, 255, 255, 255], # Cor (R, G, B, A)
  170.     Shadow:  true,                 # Usar sombra?
  171.     Outline: false,                # Usar outline?
  172.   }
  173.  
  174.   Icon = { # ID dos ícones
  175.     Items:      194, # Itens
  176.     Equips:     115, # Equipamentos
  177.     Skills:     116, # Skills
  178.     Status:      10, # Estado
  179.     Formation:   11, # Formação
  180.     Bestiary:     9, # Bestiário
  181.     PDist:      125, # Distribuição de pontos
  182.     MiniMap:    231, # Mini-Mapa
  183.     Options:    185, # Opções (Som)
  184.     Save:       230, # Salvar jogo
  185.     Exit:       121, # Sair
  186.     #=============================
  187.     Item:       197, # Itens comuns
  188.     Weapon:     148, # Armas
  189.     Armor:      169, # Armadura
  190.     KeyItem:    243, # Item Chave
  191.     #=============================
  192.     SaveYes:    113, # Confirmação de Sobrescrita (Sim)
  193.     SaveNo:     114, # Confirmação de Sobrescrita (Não)
  194.     #=============================
  195.     ExitTitle:   16, # Voltar ao título
  196.     ExitGame:     1, # Sair do jogo
  197.     ExitCanc:   114, # Cancelar Saída
  198.     #=============================
  199.     Gold:       361, # Ouro
  200.   }
  201.  
  202.   DisabledIcon = {  # Ícones desabilitados
  203.                     # Use -1 para usar o mesmo ícone porém escurecido
  204.                    
  205.     Formation:  -1, # Ícone de formação quando não é possível modificá-la
  206.     Bestiary:   -1, # Ícone do bestiário quando não existem monstros novos
  207.     PDist:     126, # Ícone de distribuição de pontos quando não existem
  208.                     # pontos para ser distribuidos
  209.     Save:      368, # Ícone de save desabilitado
  210.   }
  211.  
  212.   # Velocidade de atualização dos sprites dos atores
  213.   ActorsSpeed = 25
  214.  
  215.   # Confirmar sobreescrita em slot de save?
  216.   ConfirmOverwrite = true
  217.  
  218.   # Adicionar monstros ao bestiário automaticamente após as batalhas ganhas?
  219.   # (Pode não funcionar quando utilizando um sistema de batalha diferente)
  220.   AutoBestiaryAdd  = true
  221.  
  222.   # Número máximo de efeitos adicionados/removidos que são mostrados nos
  223.   # itens do inventário
  224.   MaxIconsDrawn = 5
  225.  
  226.   # Barras de HP e MP
  227.   BarColor1 = [  0,   0,   0, 192] # Borda exterior
  228.   BarColor2 = [255, 255, 192, 192] # Borda interior
  229.   BarColor3 = [  0,   0,   0,  12] # Metade do sombreamento
  230.   BarColor4 = [ 64,   0,   0,  92] # Metade do sombreamento
  231.  
  232.   # Cores de mensagens
  233.   MsgOk    = [204, 255,   0, 230] # Mensagem Ok
  234.   MsgInfo  = [  0, 204, 255, 230] # Mensagem de informação/pergunta
  235.   MsgError = [255,   0,  68, 250] # Mensagem de erro
  236.  
  237.   #-------------------------------------------------------------------------
  238.   # DISTRIBUIÇÃO DE PONTOS
  239.   #-------------------------------------------------------------------------
  240.   # É possível determinar, para cada classe, quantos pontos serão ganhos por
  241.   # nível e quantos serão requeridos para cada atributo.
  242.   #
  243.   # Existe uma notação [X,Y] que indica o seguinte:
  244.   #   X é a quantidade de pontos que serão necessário para aumentar em Y
  245.   #   o atributo indicado.
  246.   #
  247.   # A quantidade de pontos ganhos por nível PODE ser um valor decimal. Porém
  248.   # só será considerado um valor inteiro. Logo, se PPN = 3.5, o ator ganhará
  249.   # 3 pontos no primeiro e no segundo nível, porém no terceiro ganhará 4.
  250.   #-------------------------------------------------------------------------
  251.   PDistPoints = {
  252.     # Siga este padrão, caso existam mais classes:
  253.     # ID DA CLASSE => {
  254.     #   PPN: Pontos ganhos por nível,
  255.     #   HPM: [X, Y], # HP Máximo
  256.     #   MPM: [X, Y], # MP Máximo
  257.     #   ATK: [X, Y], # Ataque
  258.     #   DEF: [X, Y], # Defesa
  259.     #   ATM: [X, Y], # Ataque Mágico (Inteligência)
  260.     #   DEM: [X, Y], # Defesa Mágica (Resistência)
  261.     #   AGI: [X, Y], # Agilidade
  262.     #   SOR: [X, Y], # Sorte
  263.     # },
  264.    
  265.     1 => { # Guerreiro
  266.       PPN: 4,
  267.       HPM: [1, 10], # HP Máximo
  268.       MPM: [1, 10], # MP Máximo
  269.       ATK: [1,  5], # Ataque
  270.       DEF: [1,  5], # Defesa
  271.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  272.       DEM: [3,  5], # Defesa Mágica (Resistência)
  273.       AGI: [1,  3], # Agilidade
  274.       SOR: [3,  1], # Sorte
  275.     },
  276.      
  277.     2 => { # Monge
  278.       PPN: 4,
  279.       HPM: [1, 10], # HP Máximo
  280.       MPM: [1, 10], # MP Máximo
  281.       ATK: [2, 10], # Ataque
  282.       DEF: [1,  8], # Defesa
  283.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  284.       DEM: [2,  5], # Defesa Mágica (Resistência)
  285.       AGI: [1,  5], # Agilidade
  286.       SOR: [3,  1], # Sorte
  287.     },
  288.    
  289.     3 => { # Cavaleiro
  290.       PPN: 4,
  291.       HPM: [1, 10], # HP Máximo
  292.       MPM: [1, 10], # MP Máximo
  293.       ATK: [1,  8], # Ataque
  294.       DEF: [1,  7], # Defesa
  295.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  296.       DEM: [3,  5], # Defesa Mágica (Resistência)
  297.       AGI: [1,  3], # Agilidade
  298.       SOR: [3,  1], # Sorte
  299.     },
  300.    
  301.     4 => { # Espadachim
  302.       PPN: 5,
  303.       HPM: [1, 15], # HP Máximo
  304.       MPM: [2, 15], # MP Máximo
  305.       ATK: [1,  8], # Ataque
  306.       DEF: [1,  7], # Defesa
  307.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  308.       DEM: [3,  5], # Defesa Mágica (Resistência)
  309.       AGI: [1,  3], # Agilidade
  310.       SOR: [3,  1], # Sorte
  311.     },
  312.    
  313.     5 => { # Samurai
  314.       PPN: 4,
  315.       HPM: [1, 10], # HP Máximo
  316.       MPM: [1, 10], # MP Máximo
  317.       ATK: [1,  5], # Ataque
  318.       DEF: [1,  5], # Defesa
  319.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  320.       DEM: [3,  5], # Defesa Mágica (Resistência)
  321.       AGI: [1,  7], # Agilidade
  322.       SOR: [3,  1], # Sorte
  323.     },
  324.    
  325.     6 => { # Arqueiro
  326.       PPN: 4,
  327.       HPM: [1, 10], # HP Máximo
  328.       MPM: [1, 10], # MP Máximo
  329.       ATK: [1,  5], # Ataque
  330.       DEF: [1,  5], # Defesa
  331.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  332.       DEM: [3,  5], # Defesa Mágica (Resistência)
  333.       AGI: [1,  3], # Agilidade
  334.       SOR: [3,  1], # Sorte
  335.     },
  336.    
  337.     7 => { # Ladino
  338.       PPN: 4,
  339.       HPM: [1, 10], # HP Máximo
  340.       MPM: [1, 10], # MP Máximo
  341.       ATK: [1,  5], # Ataque
  342.       DEF: [1,  5], # Defesa
  343.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  344.       DEM: [3,  5], # Defesa Mágica (Resistência)
  345.       AGI: [1,  3], # Agilidade
  346.       SOR: [3,  1], # Sorte
  347.     },
  348.    
  349.     8 => { # Sacerdote
  350.       PPN: 4,
  351.       HPM: [1, 10], # HP Máximo
  352.       MPM: [1, 10], # MP Máximo
  353.       ATK: [1,  5], # Ataque
  354.       DEF: [1,  5], # Defesa
  355.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  356.       DEM: [3,  5], # Defesa Mágica (Resistência)
  357.       AGI: [1,  3], # Agilidade
  358.       SOR: [3,  1], # Sorte
  359.     },
  360.    
  361.     9 => { # Mago
  362.       PPN: 4,
  363.       HPM: [1,  7], # HP Máximo
  364.       MPM: [1, 20], # MP Máximo
  365.       ATK: [2,  5], # Ataque
  366.       DEF: [2,  5], # Defesa
  367.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  368.       DEM: [1,  5], # Defesa Mágica (Resistência)
  369.       AGI: [1,  3], # Agilidade
  370.       SOR: [3,  1], # Sorte
  371.     },
  372.    
  373.     10 => { # Sábio
  374.       PPN: 6,
  375.       HPM: [1, 10], # HP Máximo
  376.       MPM: [1, 10], # MP Máximo
  377.       ATK: [1,  5], # Ataque
  378.       DEF: [1,  5], # Defesa
  379.       ATM: [2,  5], # Ataque Mágico (Inteligência)
  380.       DEM: [3,  5], # Defesa Mágica
  381.       AGI: [1,  3], # Agilidade
  382.       SOR: [3,  1], # Sorte
  383.     },
  384.   }
  385.  
  386.   #------------------------------------------------------------------------
  387.   # Diálogo que alerta o jogador sobre a quantidade de pontos necessários
  388.   # para aprimorar determinado atributo.
  389.   #
  390.   # Separe as linhas por vírgula.
  391.   #
  392.   # As mudanças de cor, substituições de variáveis, nomes de personagens
  393.   # da equipe, etc, serão serão aceitas. Certifique-se de usar barras duplas
  394.   # para que possa funcionar.
  395.   #
  396.   # Existem substituições que o sistema fará:
  397.   # {actorName}   será substituido pelo nome do ator.
  398.   # {actorPoints} será substituido pela quantidade de pontos que o ator tem.
  399.   # {attrName}    será substituido pelo nome do atributo.
  400.   # {attrNPoints} será substituido pela quantidade de pontos que o atributo
  401.   #               precisa para ser aprimorado.
  402.   # {attrGPoints} será substituido pela quantia que o ator ganhará no
  403.   #               atributo selecionado.
  404.   #-------------------------------------------------------------------------
  405.  
  406.   PDistDiag = [
  407.     "\\c[1]Pontos de {actorName}: \\c[0]{actorPoints}",
  408.     "\\c[1]Pontos necessários: \\c[0]{attrNPoints}",
  409.     "\\c[1]Ganhos: \\c[0]{attrGPoints} de {attrName}",
  410.     "",
  411.     "Pressione \\c[10][Enter]\\c[0] para confirmar."
  412.   ]
  413.    
  414.   #-------------------------------------------------------------------------
  415.   # MINI-MAPA
  416.   #-------------------------------------------------------------------------
  417.   # O principal foco aqui são as cores. Perceba que estão todas no formato
  418.   # RGBA, ou seja, você terá quatro campos para preencher: [R, G, B, A]
  419.   # Onde:
  420.   #   R = Vermelho
  421.   #   G = Verde
  422.   #   B = Azul
  423.   #   A = Opacidade
  424.   # Cada um pode ir de 0 até 255.
  425.   #-------------------------------------------------------------------------
  426.  
  427.   # Tamanho dos tiles
  428.   TileSize    = 8
  429.  
  430.   # Dependendo do tamanho dos tiles, pode exister necessidade de fazer um
  431.   # ajuste de posições.
  432.   MapOffset   = -4
  433.  
  434.   # Cor do player
  435.   PlayerColor = [255, 0, 0, 255]
  436.    
  437.   # Cor dos eventos
  438.   ObjectColor = {
  439.    
  440.     # Esta configuração permite que você adicione
  441.     # diferentes cores para cada tipo de evento.
  442.     #
  443.     # Para que um evento apareça no mini-map você
  444.     # deve colocar um comentário com uma das
  445.     # opções abaixo.
  446.     #
  447.     # Utilize este padrão:
  448.     # "comentário" => [R, G, B, A],
  449.    
  450.     "npc"   => [  0, 255,   0, 255],
  451.     "door"  => [  0,   0, 255, 255],
  452.     "chest" => [100, 100, 100, 255],
  453.   }
  454.  
  455.   # Cor da borda dos eventos e do player
  456.   BorderColor        = [  0,   0,   0, 255]  
  457.  
  458.   # Cor dos obstáculos
  459.   MapColor           = [  0,   0,   0, 255]
  460.  
  461.   # Cor da borda dos obstáculos
  462.   MapBorderColor     = [ 50,  50,  50, 255]
  463.  
  464.   # Opacidade da camada de eventos
  465.   ObjectLayerOpacity = 255
  466.  
  467.   #-------------------------------------------------------------------------
  468.   # ANIMAÇÕES
  469.   #-------------------------------------------------------------------------
  470.   # O menu permite a configuração das animações, deve-se usar um número de 0
  471.   # até 29 para selecionar a animação que você quer. Sendo que:
  472.   #
  473.   #  0 = Linear                     | 15 = Cúbica (Entrada e Saída)
  474.   #  1 = Senoidal (Entrada)         | 16 = Exponencial (Entrada)
  475.   #  2 = Senoidal (Saída)           | 17 = Exponencial (Saída)
  476.   #  3 = Senoidal (Entrada e Saída) | 18 = Exponencial (Entrada e Saída)
  477.   #  4 = Circular (Entrada)         | 19 = Quadrática (Entrada)
  478.   #  5 = Circular (Saída)           | 20 = Quadrática (Saída)
  479.   #  6 = Circular (Entrada e Saída) | 21 = Quadrática (Entrada e Saída)
  480.   #  7 = Mola (Entrada)             | 22 = Quártica (Entrada)
  481.   #  8 = Mola (Saída)               | 23 = Quártica (Saída)
  482.   #  9 = Mola (Entrada e Saída)     | 24 = Quártica (Entrada e Saída)
  483.   # 10 = Retorno (Entrada)          | 25 = Quíntica (Entrada)
  484.   # 11 = Retorno (Saída)            | 26 = Quíntica (Saída)
  485.   # 12 = Retorno (Entrada e Saída)  | 27 = Quíntica (Entrada e Saída)
  486.   # 13 = Cúbico (Entrada)           | 28 = Elástica (Entrada)
  487.   # 14 = Cúbica (Saída)             | 29 = Elástica (Saída)
  488.   #
  489.   # Todos os campos "Duração" são referentes ao tempo da animação em segundos
  490.   # Todos os campos "Atraso" são referentes ao atraso da animação em centésimos
  491.   #-------------------------------------------------------------------------
  492.   Animation = {
  493.     # Animação de entrada dos ícones
  494.     IconsEnter: [
  495.       9, # ID da animação
  496.       1, # Duração
  497.       5, # Atraso
  498.     ],
  499.    
  500.     # Animação de movimendo dos ícones
  501.     IconsMove: [
  502.        12, # ID da animação
  503.       0.5, # Duração
  504.     ],
  505.    
  506.     # Animação de entrada do Cursor
  507.     CursorEnter: [
  508.       13, # ID da animação
  509.        1, # Duração
  510.     ],
  511.    
  512.     # Animação de movimento do Cursor
  513.     CursorMove: [
  514.        29, # ID da animação
  515.       0.5, # Duração
  516.     ],
  517.    
  518.     # Animação da mensagem
  519.     Message: [
  520.       21, # ID da animação
  521.        1, # Duração
  522.     ],
  523.    
  524.     # Animação de entrada das informações (básicas) dos atores
  525.     WindowsEnter: [
  526.       27, # ID da animação
  527.        2, # Duração
  528.        5, # Atraso
  529.     ],
  530.    
  531.     # Animação de movimento das informações (básicas) dos atores
  532.     WindowsMove: [
  533.        16, # ID da animação
  534.         1, # Duração
  535.         1, # Atraso
  536.     ],
  537.    
  538.     # Animação de entrada da janela de seleção de atores
  539.     ActorSelEnter: [
  540.       4, # ID da animação
  541.       1, # Duração
  542.     ],
  543.    
  544.     # Animação de movimento da janela de seleção de atores
  545.     ActorSelMove: [
  546.        24, # ID da animação
  547.       0.5, # Duração
  548.     ],
  549.    
  550.     # Animação de entrada das janelas de itens
  551.     ItemsEnter: [
  552.       9, # ID da animação
  553.       1, # Duração
  554.     ],
  555.    
  556.     # Animação de movimento das janelas de itens
  557.     ItemsMove: [
  558.        12, # ID da animação
  559.       0.5, # Duração
  560.     ],
  561.    
  562.     # Animação de entrada das janelas de equipamentos
  563.     EquipsEnter: [
  564.       9, # ID da animação
  565.       1, # Duração
  566.     ],
  567.    
  568.     # Animação de movimento das janelas de equipamentos
  569.     EquipsMove: [
  570.        12, # ID da animação
  571.       0.5, # Duração
  572.     ],
  573.    
  574.     # Animação de entrada das janelas de habilidades
  575.     SkillsEnter: [
  576.      12, # ID da animação
  577.       1, # Duração
  578.     ],
  579.    
  580.     # Animação de movimento das janelas de habilidades
  581.     SkillsMove: [
  582.        15, # ID da animação
  583.       0.5, # Duração
  584.     ],
  585.    
  586.     # Animação de entrada das janelas de formação
  587.     FormationEnter: [
  588.        29, # ID da animação
  589.       1.5, # Duração
  590.         1, # Atraso
  591.     ],
  592.    
  593.     # Animação de movimento das janelas de formação
  594.     FormationMove: [
  595.        12, # ID da animação
  596.       1.5, # Duração
  597.     ],
  598.    
  599.     # Animação de entrada das janelas de informações completas
  600.     StatusEnter: [
  601.       29, # ID da animação
  602.        2, # Duração
  603.     ],
  604.    
  605.     # Animação de movimento das janelas de informações completas
  606.     StatusMove: [
  607.        3, # ID da animação
  608.      0.5, # Duração
  609.     ],
  610.    
  611.     # Animação de entrada das janelas de monstros do bestiário
  612.     BestiaryEnter: [
  613.       22, # ID da animação
  614.        1, # Duração
  615.        1, # Atraso
  616.     ],
  617.    
  618.     # Animação de movimento das janelas de monstros do bestiário
  619.     BestiaryMove: [
  620.       15, # ID da animação
  621.      0.3, # Duração
  622.     ],
  623.    
  624.     # Animação de entrada das janelas de informações completas
  625.     PDistEnter: [
  626.       29, # ID da animação
  627.        2, # Duração
  628.     ],
  629.    
  630.     # Animação de movimento das janelas de informações completas
  631.     PDistMove: [
  632.        3, # ID da animação
  633.      0.5, # Duração
  634.     ],
  635.    
  636.     # Animação de entrada do mini-mapa
  637.     MiniMapEnter: [
  638.        9, # ID da animação
  639.        1, # Duração
  640.     ],
  641.    
  642.     # Animação de movimento do mini-mapa
  643.     MiniMapMove: [
  644.        9, # ID da animação
  645.        1, # Duração
  646.     ],
  647.    
  648.     # Animação de entrada da janela de opções
  649.     OptionEnter: [
  650.       29, # ID da animação
  651.        2, # Duração
  652.     ],
  653.        
  654.     # Animação de entrada das janelas de save
  655.     SaveEnter: [
  656.        27, # ID da animação
  657.       1.5, # Duração
  658.         1, # Atraso
  659.     ],
  660.    
  661.     # Animação de movimento das janelas de save
  662.     SaveMove: [
  663.          1, # ID da animação
  664.       0.25, # Duração
  665.     ],
  666.   }
  667.  
  668.   #===========================================================================
  669.   # ** FIM DA CONFIGURAÇÃO
  670.   #===========================================================================
  671.  
  672.   ColorOk    = Color.new(*MsgOk   )
  673.   ColorInfo  = Color.new(*MsgInfo )
  674.   ColorError = Color.new(*MsgError)
  675.  
  676.   #---
  677.  
  678.   @enabled = []
  679.   @cache   = false
  680.  
  681.   Use.each_pair{|key, value| @enabled << key if value}
  682.  
  683.   module_function
  684.  
  685.   #-------------------------------------------------------------------------
  686.   # * Ativa uma opção do menu durante o jogo (Chamada por eventos)
  687.   #     option : Chave que identifica o comando
  688.   #-------------------------------------------------------------------------
  689.   def enable(option)
  690.     if Use.keys.include?(option) and not @enabled.include?(option)
  691.       @enabled.push(option)
  692.     end
  693.   end
  694.  
  695.   #-------------------------------------------------------------------------
  696.   # * Desativa uma opção do menu durante o jogo (Chamada por eventos)
  697.   #     option : Chave que identifica o comando
  698.   #-------------------------------------------------------------------------
  699.   def disable(option)
  700.     @enabled.delete(option) if Use.keys.include?(option)
  701.   end
  702.  
  703.   #-------------------------------------------------------------------------
  704.   # * Verifica se um comando está ativado
  705.   #     option : Chave que identifica o comando
  706.   #-------------------------------------------------------------------------
  707.   def enabled?(option)
  708.     return @enabled.include?(option)
  709.   end
  710.  
  711.   #-------------------------------------------------------------------------
  712.   # * Dá pontos de atributo à um ator
  713.   #     id : ID do ator na database
  714.   #     qt : Quantidade de pontos
  715.   #-------------------------------------------------------------------------
  716.   def giveActorPoints(id, qt)
  717.     members = $game_party.members
  718.     index   = members.map{|actor| actor.id}.index(id)
  719.     return unless index
  720.     members[index].attrPoints += qt
  721.     members[index].attrPoints  = 0 if members[index].attrPoints < 0
  722.   end
  723.  
  724.   #-------------------------------------------------------------------------
  725.   # * Dá pontos de atributo de um ator
  726.   #     id : ID do ator na database
  727.   #     qt : Quantidade de pontos
  728.   #-------------------------------------------------------------------------
  729.   def removeActorPoints(id, qt)
  730.     giveActorsPoints(id, -qt)
  731.   end
  732.  
  733.   #-------------------------------------------------------------------------
  734.   # * Adiciona monstro ao bestiário
  735.   #     id : ID do monstro na database
  736.   #-------------------------------------------------------------------------
  737.   def bestiaryAddMonster(id)
  738.     $game_system.bestiaryAddMonster(id)
  739.   end
  740.  
  741.   #-------------------------------------------------------------------------
  742.   # * Remove monstro do bestiário
  743.   #     id : ID do monstro na database
  744.   #-------------------------------------------------------------------------
  745.   def bestiaryRemoveMonster(id)
  746.     $game_system.bestiaryRemoveMonster(id)
  747.   end
  748.  
  749.   #================
  750.  
  751.   #-------------------------------------------------------------------------
  752.   # * Retorna todas as opções ativas
  753.   #-------------------------------------------------------------------------
  754.   def enabled
  755.     return @enabled
  756.   end
  757.   #-------------------------------------------------------------------------
  758.   # * Retorna todas as opções ativas
  759.   #-------------------------------------------------------------------------
  760.   def enabledOptions(ret = :none)
  761.     options = @enabled.dup
  762.     return options if ret == :none
  763.    
  764.     case ret
  765.     when :icon
  766.       options.map!{|key|
  767.         base = Icon[key]
  768.      
  769.         if (key == :Formation) and ($game_party.members.size < 2)
  770.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  771.         end
  772.        
  773.         if (key == :Bestiary) and (!$game_system.new_monsters)
  774.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  775.         end
  776.        
  777.         if (key == :PDist) and ($game_party.members.all?{|ac| ac.attrPoints == 0})
  778.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  779.         end
  780.        
  781.         if (key == :Save) and ($game_system.save_disabled)
  782.           base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
  783.         end
  784.        
  785.         base      
  786.       }
  787.      
  788.     when :name
  789.       options.map!{|key| Vocab[key]}
  790.      
  791.     end
  792.   end
  793.   #-------------------------------------------------------------------------
  794.   # * Retorna todas as subopções ativas
  795.   #-------------------------------------------------------------------------
  796.   def enabledSubOption(option = :none, type = :none)
  797.     case option
  798.     when :Items
  799.       keys = [:Item, :Weapon, :Armor, :KeyItem]
  800.     when :Save
  801.       keys = [:SaveYes, :SaveNo]
  802.     when :Exit
  803.       keys = [:ExitTitle, :ExitGame, :ExitCanc]
  804.     end
  805.    
  806.     return keys if type == :none
  807.     return keys.map{|key| type == :Names ? Vocab[key] : Icon[key] }
  808.   end
  809. end
  810.  
  811. #==============================================================================
  812. # ** Numeric
  813. #------------------------------------------------------------------------------
  814. # Classe que rege as instâncias numéricas
  815. #==============================================================================
  816. class Numeric
  817.   #-------------------------------------------------------------------------
  818.   # * Converte o numérico para string
  819.   #-------------------------------------------------------------------------
  820.   def group
  821.     self.to_s
  822.   end
  823. end
  824.  
  825. #==============================================================================
  826. # ** String
  827. #------------------------------------------------------------------------------
  828. # Classe que rege todas as instâncias de strings
  829. #==============================================================================
  830. class String
  831.   UPCASE_ISOTAB   = 'ÀÁÂÃÄÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÇÑÝŸ'
  832.   DOWNCASE_ISOTAB = 'àáâãäèéêëÍíîïòóôõöùúûüçñýÿ'
  833.  
  834.   #-------------------------------------------------------------------------
  835.   # * Faz com que caracteres especiais também sejam colocado em caixa-alta
  836.   #-------------------------------------------------------------------------
  837.   def isoUpcase
  838.     return upcase.tr(DOWNCASE_ISOTAB, UPCASE_ISOTAB)
  839.   end
  840. end
  841.  
  842. #==============================================================================
  843. # ** Audio
  844. #------------------------------------------------------------------------------
  845. # Módulo que coordena toda operação sonora do jogo
  846. #==============================================================================
  847. class << Audio
  848.   alias mrm_extrememenu_bgm_play bgm_play
  849.   alias mrm_extrememenu_me_play  me_play
  850.   alias mrm_extrememenu_bgs_play bgs_play
  851.   alias mrm_extrememenu_se_play  se_play
  852.  
  853.   def bgm_play(name, volume, pitch, pos)
  854.     volume *= $game_system.musicRate if defined?($game_system)
  855.     mrm_extrememenu_bgm_play(name, volume, pitch, pos)
  856.   end
  857.  
  858.   def me_play(name, volume, pitch)
  859.     volume *= $game_system.musicRate if defined?($game_system)
  860.     mrm_extrememenu_bgm_play(name, volume, pitch)
  861.   end
  862.  
  863.   def bgs_play(name, volume, pitch, pos)
  864.     volume *= $game_system.soundRate if defined?($game_system)
  865.     mrm_extrememenu_bgs_play(name, volume, pitch, pos)
  866.   end
  867.  
  868.   def se_play(name, volume, pitch)
  869.     volume *= $game_system.soundRate if defined?($game_system)
  870.     mrm_extrememenu_se_play(name, volume, pitch)
  871.   end
  872. end
  873. #==============================================================================
  874. # ** Bitmap
  875. #------------------------------------------------------------------------------
  876. # Classe que rege as informações sobre bitmaps na memória
  877. #==============================================================================
  878. class Bitmap
  879.   #--------------------------------------------------------------------------
  880.   # Constantes
  881.   #--------------------------------------------------------------------------
  882.   RtlMoveMemory1 = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  883.   RtlMoveMemory2 = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  884.  
  885.   #--------------------------------------------------------------------------
  886.   # * Preenche a informação de cores
  887.   #     data  : Blob
  888.   #     width : Largura
  889.   #--------------------------------------------------------------------------
  890.   def self.new_from_data(data, width)
  891.     b = Bitmap.new(width, data.length/(4 * width))
  892.     RtlMoveMemory2.call(b.address, data, data.length)
  893.     return b
  894.   end
  895.   #--------------------------------------------------------------------------
  896.   # * Retorna a informação de cores
  897.   #--------------------------------------------------------------------------
  898.   def get_color_data
  899.     data  = "bgra" * width * height              
  900.     RtlMoveMemory1.call(data, self.address, data.length)
  901.     return data
  902.   end
  903.   #--------------------------------------------------------------------------
  904.   # * Endereço na memória da informação de cores:
  905.   #   *(*(*(bitmap << 1 + 16) + 8) + 16)
  906.   #--------------------------------------------------------------------------
  907.   def address
  908.     buffer = "xxxx"
  909.     ad     = self.object_id * 2 + 16
  910.     RtlMoveMemory1.call(buffer, ad, 4);   ad = buffer.unpack("L").first +  8
  911.     RtlMoveMemory1.call(buffer, ad, 4);   ad = buffer.unpack("L").first + 16
  912.     RtlMoveMemory1.call(buffer, ad, 4); return buffer.unpack("L").first
  913.   end
  914. end
  915.  
  916. #==============================================================================
  917. # ** RPG::BaseItem
  918. #------------------------------------------------------------------------------
  919. # Classe mãe de
  920. #==============================================================================
  921. class RPG::BaseItem
  922.   #--------------------------------------------------------------------------
  923.   # Variáveis de instância públicas
  924.   #--------------------------------------------------------------------------
  925.   attr_accessor :image
  926.  
  927.   #--------------------------------------------------------------------------
  928.   # * Carrega informação necessária das notas do item
  929.   #--------------------------------------------------------------------------
  930.   def load_notetags_aso
  931.     self.note.split(/[\r\n]+/).each{|line|
  932.       if line =~ /<(?:IMAGE|image):[ ](.*)>/i
  933.         @image = $1.to_s
  934.       end
  935.     }
  936.   end
  937.  
  938. end
  939.  
  940. #==============================================================================
  941. # ** DataManager
  942. #------------------------------------------------------------------------------
  943. #  Este módulo gerencia o jogo e objetos do banco de dados utilizados no jogo.
  944. # Quase todas as variáveis globais são inicializadas no módulo.
  945. #==============================================================================
  946. class << DataManager
  947.   alias mrm_extrememenu_init init
  948.   alias mrm_extrememenu_msh  make_save_header
  949.   alias mrm_extrememenu_lg   load_game
  950.   alias mrm_extrememenu_sg   save_game
  951.   alias mrm_extrememenu_ldb  load_database
  952.  
  953.   @last_menu_saveindex = nil
  954.  
  955.   #--------------------------------------------------------------------------
  956.   # * Inicialização
  957.   #     *args, &block : Argumentos
  958.   #--------------------------------------------------------------------------
  959.   def init(*args, &block)
  960.     mrm_extrememenu_init(*args, &block)
  961.     load_config_data
  962.     @last_menu_saveindex = nil
  963.   end
  964.   #--------------------------------------------------------------------------
  965.   # * Carregamento do Banco de Dados
  966.   #     *args, &block : Argumentos
  967.   #--------------------------------------------------------------------------
  968.   def load_database(*args, &block)
  969.     mrm_extrememenu_ldb(*args, &block)
  970.     load_notetags_aso unless $BTEST
  971.   end
  972.   #--------------------------------------------------------------------------
  973.   # * Salva informação de configuração (Última configuração salva)
  974.   #--------------------------------------------------------------------------
  975.   def save_config_data
  976.     File.open("Config.rvdata2", "wb") { |f|
  977.       Marshal.dump($game_system.musicRate, f)
  978.       Marshal.dump($game_system.soundRate, f)
  979.     }
  980.   end
  981.   #--------------------------------------------------------------------------
  982.   # * Carrega informação de configuração
  983.   #--------------------------------------------------------------------------
  984.   def load_config_data
  985.     return unless File.exist?("Config.rvdata2")
  986.     File.open("Config.rvdata2", "rb"){|f|
  987.       $game_system.musicRate = Marshal.load(f)
  988.       $game_system.soundRate = Marshal.load(f)
  989.     }
  990.   end
  991.   #--------------------------------------------------------------------------
  992.   # * Salvar a criação de cabeçalho
  993.   #     *args // &block : Argumentos
  994.   #--------------------------------------------------------------------------
  995.   def make_save_header(*args, &block)
  996.     header = mrm_extrememenu_msh(*args, &block)
  997.    
  998.     bmap = Bitmap.new(157, 120)
  999.     ss   = SceneManager.background_bitmap
  1000.     bmap.stretch_blt(bmap.rect, ss, ss.rect)
  1001.     header[:preview] = bmap.get_color_data
  1002.    
  1003.     return header
  1004.   end
  1005.   #--------------------------------------------------------------------------
  1006.   # * Salvar Jogo
  1007.   #     index : índice
  1008.   #--------------------------------------------------------------------------
  1009.   def save_game(index)
  1010.     result = mrm_extrememenu_sg(index)
  1011.     save_config_data
  1012.     @last_menu_saveindex = index if result
  1013.     return result
  1014.   end
  1015.   #--------------------------------------------------------------------------
  1016.   # * Carregamento do Jogo
  1017.   #     index : índice
  1018.   #--------------------------------------------------------------------------
  1019.   def load_game(index)
  1020.     result = mrm_extrememenu_lg(index)
  1021.     @last_menu_saveindex = index if result
  1022.     return result
  1023.   end
  1024.   #--------------------------------------------------------------------------
  1025.   # * Última index carregada
  1026.   #--------------------------------------------------------------------------
  1027.   def last_menu_saveindex
  1028.     return (@last_menu_saveindex || -1) + 1
  1029.   end
  1030.  
  1031.   #--------------------------------------------------------------------------
  1032.   # * Carrega notas dos itens
  1033.   #--------------------------------------------------------------------------
  1034.   def load_notetags_aso
  1035.     [$data_items, $data_weapons, $data_armors].each{|group| group.each{|obj|
  1036.       next unless obj
  1037.       obj.load_notetags_aso
  1038.     }}
  1039.   end
  1040. end
  1041.  
  1042. #==============================================================================
  1043. # ** BattleManager
  1044. #------------------------------------------------------------------------------
  1045. #  Este módulo gerencia o andamento da batalha.
  1046. #==============================================================================
  1047. if MRM::ExtremeMenu::AutoBestiaryAdd
  1048.   class << BattleManager
  1049.     alias mrm_extrememenu_process_victory process_victory
  1050.    
  1051.     #------------------------------------------------------------------------
  1052.     # * Processar vitória
  1053.     #     *args // &block : Argumentos
  1054.     #------------------------------------------------------------------------
  1055.     def process_victory(*args, &block)
  1056.       mrm_extrememenu_process_victory
  1057.       $game_troop.troop.members.map{|member| member.enemy_id}.uniq.each{|id|
  1058.         $game_system.bestiaryAddMonster(id)
  1059.       }
  1060.     end
  1061.   end
  1062. end
  1063.  
  1064. #==============================================================================
  1065. # ** Game_System
  1066. #------------------------------------------------------------------------------
  1067. # Esta classe gerencia os dados relacionados ao sistema. Também gerencia
  1068. # veículos, BGM, etc.
  1069. # A instância desta classe é referenciada por $game_system.
  1070. #==============================================================================
  1071. class Game_System
  1072.   attr_accessor :musicRate
  1073.   attr_accessor :soundRate
  1074.   attr_accessor :new_monsters
  1075.   attr_reader   :monsters
  1076.  
  1077.   alias mrm_extrememenu_initialize initialize
  1078.  
  1079.   #-------------------------------------------------------------------------
  1080.   # * Inicialização
  1081.   #     *args // &block : Argumentos
  1082.   #-------------------------------------------------------------------------
  1083.   def initialize(*args, &block)
  1084.     mrm_extrememenu_initialize(*args, &block)
  1085.     if defined?($game_system)
  1086.       @musicRate = $game_system.musicRate
  1087.       @soundRate = $game_system.soundRate
  1088.     else
  1089.       @musicRate = 1.0
  1090.       @soundRate = 1.0
  1091.     end
  1092.     @monsters     = []
  1093.     @new_monsters = false
  1094.   end
  1095.  
  1096.   #-------------------------------------------------------------------------
  1097.   # * Adiciona monstros ao bestiário
  1098.   #   id : Identificação do monstro (ID no banco de dados)
  1099.   #-------------------------------------------------------------------------
  1100.   def bestiaryAddMonster(id)
  1101.     return unless id.between?(1, $data_enemies.size - 1)
  1102.     return if @monsters.include?(id)
  1103.     @monsters << id
  1104.     @new_monsters = true
  1105.   end
  1106.  
  1107.   #-------------------------------------------------------------------------
  1108.   # * Retira monstros do bestiário
  1109.   #   id : Identificação do monstro (ID no banco de dados)
  1110.   #-------------------------------------------------------------------------
  1111.   def bestiaryRemoveMonster(id)
  1112.     @monsters.delete(id)
  1113.   end
  1114. end
  1115.  
  1116. #==============================================================================
  1117. # ** Game_Actor
  1118. #------------------------------------------------------------------------------
  1119. #  Esta classe gerencia os heróis. Ela é utilizada internamente pela classe
  1120. # Game_Actors ($game_actors). A instância desta classe é referenciada
  1121. # pela classe Game_Party ($game_party).
  1122. #==============================================================================
  1123. class Game_Actor
  1124.   alias mrm_extrememenu_initialize   initialize
  1125.   alias mrm_extrememenu_level_up     level_up
  1126.   alias mrm_extrememenu_change_class change_class
  1127.  
  1128.   attr_writer :attrPoints
  1129.   attr_reader :pointsSheet
  1130.  
  1131.   #--------------------------------------------------------------------------
  1132.   # * Inicialização do objeto
  1133.   #     *args // &block : Argumentos
  1134.   #--------------------------------------------------------------------------
  1135.   def initialize(*args, &block)
  1136.     mrm_extrememenu_initialize(*args, &block)
  1137.     @attrPoints  = 0
  1138.     update_points_sheet
  1139.   end
  1140.   #--------------------------------------------------------------------------
  1141.   # * Aumento de nível
  1142.   #     *args // &block : Argumentos
  1143.   #--------------------------------------------------------------------------
  1144.   def level_up(*args, &block)
  1145.     mrm_extrememenu_level_up(*args, &block)
  1146.     @attrPoints += @pointsSheet[:PPN]
  1147.   end
  1148.   #--------------------------------------------------------------------------
  1149.   # * Leitura dos pontos de atributo
  1150.   #--------------------------------------------------------------------------
  1151.   def attrPoints
  1152.     return @attrPoints.to_i
  1153.   end
  1154.   #--------------------------------------------------------------------------
  1155.   # * Mudança de classe
  1156.   #   *args // &block : Argumentos
  1157.   #--------------------------------------------------------------------------
  1158.   def change_class(*args, &block)
  1159.     mrm_extrememenu_change_class(*args, &block)
  1160.     update_points_sheet
  1161.   end
  1162.   #--------------------------------------------------------------------------
  1163.   # * Adiciona pontos de atributos
  1164.   #     index : Identificação do atributo
  1165.   #     qt    : Quantidade
  1166.   #--------------------------------------------------------------------------
  1167.   def add_param_plus(index, qt)
  1168.     @param_plus[index] += qt
  1169.   end
  1170.   #--------------------------------------------------------------------------
  1171.   # * Atualiza tabela de pontos da classe
  1172.   #--------------------------------------------------------------------------
  1173.   def update_points_sheet
  1174.     @pointsSheet = MRM::ExtremeMenu::PDistPoints[@class_id]
  1175.     # Se não for definida uma configuração, anula distribuição de pontos
  1176.     # para aquela classe.
  1177.     if @pointsSheet.nil?
  1178.       @pointsSheet = {
  1179.         PNN: 0,
  1180.         HPM: [0, 0], MPM: [0, 0], ATK: [0, 0], DEF: [0, 0],
  1181.         ATM: [0, 0], DEM: [0, 0], AGI: [0, 0], SOR: [0, 0],
  1182.       }
  1183.     end
  1184.   end
  1185. end
  1186.  
  1187. #==============================================================================
  1188. # ** Menu_Base_Window
  1189. #------------------------------------------------------------------------------
  1190. # Classe básica para todas as janelas do menu
  1191. #==============================================================================
  1192. class Menu_Base_Window < Window_Base
  1193.   include MRM::ExtremeMenu
  1194.  
  1195.   BC1 = Color.new(*BarColor1)
  1196.   BC2 = Color.new(*BarColor2)
  1197.   BC3 = Color.new(*BarColor3)
  1198.   BC4 = Color.new(*BarColor4)
  1199.  
  1200.   #--------------------------------------------------------------------------
  1201.   # Inicialização do objeto
  1202.   #   *args // &block : Argumentos
  1203.   #--------------------------------------------------------------------------
  1204.   def initialize(*args, &block)
  1205.     super(*args, &block)
  1206.     self.applyFont(self.contents)
  1207.   end
  1208.   #--------------------------------------------------------------------------
  1209.   # * Desenho do HP
  1210.   #     actor  : herói
  1211.   #     x      : coordenada X
  1212.   #     y      : coordenada Y
  1213.   #     width  : largura
  1214.   #--------------------------------------------------------------------------
  1215.   def draw_actor_hp(actor, x, y, width = 124)
  1216.     rate = actor.hp_rate
  1217.    
  1218.     gc1 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
  1219.     gc2 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
  1220.    
  1221.     draw_special_gauge(x, y, width, rate, gc1, gc2)
  1222.    
  1223.     change_color(system_color)
  1224.     draw_text(x, y, 30, line_height, ::Vocab::hp_a)
  1225.     draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
  1226.       hp_color(actor), normal_color)
  1227.   end
  1228.   #--------------------------------------------------------------------------
  1229.   # * Desenho do MP
  1230.   #     actor  : herói
  1231.   #     x      : coordenada X
  1232.   #     y      : coordenada Y
  1233.   #     width  : largura
  1234.   #--------------------------------------------------------------------------
  1235.   def draw_actor_mp(actor, x, y, width = 124)
  1236.     rate = actor.mp_rate
  1237.  
  1238.     gc1 = Color.new(14 * rate,  80 - 24 * rate, 80 * rate, 192)
  1239.     gc2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  1240.    
  1241.     draw_special_gauge(x, y, width, rate, gc1, gc2)
  1242.    
  1243.     change_color(system_color)
  1244.     draw_text(x, y, 30, line_height, ::Vocab::mp_a)
  1245.     draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
  1246.       mp_color(actor), normal_color)
  1247.   end
  1248.   #-------------------------------------------------------------------------
  1249.   # * Desenha a barra especial estilo Cogwheel
  1250.   #     x     : Posição X
  1251.   #     y     : Posição Y
  1252.   #     width : Largura
  1253.   #     rate  : Porção de preenchimento
  1254.   #     gc1   : Cor 1
  1255.   #     gc2   : Cor 2
  1256.   #-------------------------------------------------------------------------
  1257.   def draw_special_gauge(x, y, width, rate, gc1, gc2)
  1258.     contents.fill_rect(x, y + line_height - 10, width, 10, BC1)
  1259.     contents.fill_rect(x + 1, y + line_height -  9,  width - 2,  8, BC2)
  1260.     contents.gradient_fill_rect(x + 2, y + line_height - 8, width - 4, 6, BC3, BC4)
  1261.     contents.gradient_fill_rect(x + 2, y + line_height - 8, (width*rate) - 4, 6, gc1, gc2)    
  1262.   end
  1263.   #-------------------------------------------------------------------------
  1264.   # * Desenho de uma linha horizontal
  1265.   #     y : Posição y de desenho
  1266.   #-------------------------------------------------------------------------
  1267.   def draw_horz_line(y)
  1268.     line_y = y + line_height / 2 - 1
  1269.     color = normal_color
  1270.     color.alpha = 48
  1271.     contents.fill_rect(128, line_y, contents_width - 128, 2, color)
  1272.   end
  1273.  
  1274.   protected
  1275.   #-------------------------------------------------------------------------
  1276.   # * Aplica opções de fonte no bitmap
  1277.   #     b : Bitmap
  1278.   #-------------------------------------------------------------------------
  1279.   def applyFont(b)
  1280.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  1281.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  1282.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  1283.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  1284.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  1285.     return b
  1286.   end
  1287. end
  1288.  
  1289. #==============================================================================
  1290. # ** Menu_ItemInfo_Window
  1291. #------------------------------------------------------------------------------
  1292. # Mostra informações do item selecionado
  1293. #==============================================================================
  1294. class Menu_ItemInfo_Window < Menu_Base_Window
  1295.   attr_reader :item
  1296.  
  1297.   #-------------------------------------------------------------------------
  1298.   # * Inicialização do objeto
  1299.   #     x : Coordenada X
  1300.   #     y : Coordenada Y
  1301.   #     w : Largura
  1302.   #     h : Altura
  1303.   #-------------------------------------------------------------------------
  1304.   def initialize(x, y, w, h)
  1305.     super(x, y, w, h)
  1306.     self.opacity = 0
  1307.     @item = nil
  1308.     refresh
  1309.   end
  1310.   #-------------------------------------------------------------------------
  1311.   # * Seleciona item e redesenha conteúdo
  1312.   #     item : Novo item
  1313.   #-------------------------------------------------------------------------
  1314.   def item=(value)
  1315.     @item = value
  1316.     refresh
  1317.   end
  1318.   #-------------------------------------------------------------------------
  1319.   # * Desenho do conteúdo da janela
  1320.   #-------------------------------------------------------------------------
  1321.   def refresh
  1322.     contents.clear
  1323.     return if @item.nil?
  1324.     draw_item_image
  1325.     draw_item_stats
  1326.     draw_item_effects
  1327.     draw_item_description
  1328.   end
  1329.   #--------------------------------------------------------------------------
  1330.   # * Desenha imagem do item
  1331.   #--------------------------------------------------------------------------
  1332.   def draw_item_image
  1333.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  1334.     center = (contents_width - 96) / 2
  1335.     rect = Rect.new(center + 1, 1, 94, 94)
  1336.     if @item.image.nil?
  1337.       icon_index = @item.icon_index
  1338.       bitmap = Cache.system("Iconset")
  1339.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  1340.       target = Rect.new(center, 0, 96, 96)
  1341.       contents.stretch_blt(target, bitmap, rect)
  1342.     else
  1343.       bitmap = Cache.picture(@item.image)
  1344.       contents.blt(0, 0, bitmap, bitmap.rect, 255)
  1345.     end
  1346.   end
  1347.   #--------------------------------------------------------------------------
  1348.   # * Desenha status do item
  1349.   #--------------------------------------------------------------------------
  1350.   def draw_item_stats
  1351.     return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  1352.     dx = 0; dy = 96
  1353.     dw = contents.width / 2
  1354.     8.times{|i|
  1355.       draw_equip_param(i, dx, dy, dw)
  1356.       dx = dx >= dw ? 0 : dw
  1357.       dy += line_height if dx == 0
  1358.     }
  1359.   end
  1360.   #--------------------------------------------------------------------------
  1361.   # * Desenha parâmetro (nome) do item
  1362.   #     param_id : Identificação do  parâmetro
  1363.   #     dx       : Posição X
  1364.   #     dy       : Posição Y
  1365.   #     dw       : Largura
  1366.   #--------------------------------------------------------------------------
  1367.   def draw_equip_param(param_id, dx, dy, dw)
  1368.     change_color(system_color)
  1369.     draw_text(dx+4, dy, dw-8, line_height, ::Vocab::param(param_id))
  1370.     draw_set_param(param_id, dx, dy, dw)
  1371.   end
  1372.   #--------------------------------------------------------------------------
  1373.   # * Desenha parâmetro (valor) do item
  1374.   #     param_id : Identificação do  parâmetro
  1375.   #     dx       : Posição X
  1376.   #     dy       : Posição Y
  1377.   #     dw       : Largura
  1378.   #--------------------------------------------------------------------------
  1379.   def draw_set_param(param_id, dx, dy, dw)
  1380.     value = @item.params[param_id]
  1381.     change_color(param_change_color(value), value != 0)
  1382.     text = value.group
  1383.     text = "+" + text if value > 0
  1384.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1385.     return text
  1386.   end
  1387.   #--------------------------------------------------------------------------
  1388.   # * Desenha efeitos do ítem
  1389.   #--------------------------------------------------------------------------
  1390.   def draw_item_effects
  1391.     return if @item.is_a?(RPG::EquipItem)
  1392.     dx = 0; dy = 96
  1393.    
  1394.     if @item.is_a?(RPG::Skill)
  1395.       dw = contents.width
  1396.       draw_applies(dx, dy + line_height * 0, dw)
  1397.       draw_removes(dx, dy + line_height * 1, dw)
  1398.       return
  1399.     end
  1400.    
  1401.     dw = contents.width / 2
  1402.     draw_hp_recover(dx, dy + line_height * 0, dw)
  1403.     draw_mp_recover(dx, dy + line_height * 1, dw)
  1404.     draw_tp_recover(dx + dw, dy + line_height * 0, dw)
  1405.     draw_tp_gain(dx + dw, dy + line_height * 1, dw)
  1406.    
  1407.     dw = contents.width
  1408.     draw_applies(dx, dy + line_height * 2, dw)
  1409.     draw_removes(dx, dy + line_height * 3, dw)
  1410.   end
  1411.   #--------------------------------------------------------------------------
  1412.   # * Desenha recuperação de HP
  1413.   #     dx       : Posição X
  1414.   #     dy       : Posição Y
  1415.   #     dw       : Largura
  1416.   #--------------------------------------------------------------------------
  1417.   def draw_hp_recover(dx, dy, dw)
  1418.     change_color(system_color)
  1419.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:HPRecover])
  1420.     per = 0
  1421.     set = 0
  1422.     for effect in @item.effects
  1423.       next unless effect.code == 11
  1424.       per += (effect.value1 * 100).to_i
  1425.       set += effect.value2.to_i
  1426.     end
  1427.     if per != 0 && set != 0
  1428.       change_color(param_change_color(set))
  1429.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1430.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1431.       dw -= text_size(text).width
  1432.       change_color(param_change_color(per))
  1433.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1434.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1435.       return
  1436.     elsif per != 0
  1437.       change_color(param_change_color(per))
  1438.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1439.     elsif set != 0
  1440.       change_color(param_change_color(set))
  1441.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1442.     else
  1443.       change_color(normal_color, false)
  1444.       text = Vocab[:Empty]
  1445.     end
  1446.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1447.   end
  1448.   #--------------------------------------------------------------------------
  1449.   # * Desenha recuperação de MP
  1450.   #     dx       : Posição X
  1451.   #     dy       : Posição Y
  1452.   #     dw       : Largura
  1453.   #--------------------------------------------------------------------------
  1454.   def draw_mp_recover(dx, dy, dw)
  1455.     change_color(system_color)
  1456.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:MPRecover])
  1457.     per = 0
  1458.     set = 0
  1459.     for effect in @item.effects
  1460.       next unless effect.code == 12
  1461.       per += (effect.value1 * 100).to_i
  1462.       set += effect.value2.to_i
  1463.     end
  1464.     if per != 0 && set != 0
  1465.       change_color(param_change_color(set))
  1466.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1467.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1468.       dw -= text_size(text).width
  1469.       change_color(param_change_color(per))
  1470.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1471.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1472.       return
  1473.     elsif per != 0
  1474.       change_color(param_change_color(per))
  1475.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  1476.     elsif set != 0
  1477.       change_color(param_change_color(set))
  1478.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1479.     else
  1480.       change_color(normal_color, false)
  1481.       text = Vocab[:Empty]
  1482.     end
  1483.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1484.   end
  1485.   #--------------------------------------------------------------------------
  1486.   # * Desenha recuperação de TP
  1487.   #     dx       : Posição X
  1488.   #     dy       : Posição Y
  1489.   #     dw       : Largura
  1490.   #--------------------------------------------------------------------------
  1491.   def draw_tp_recover(dx, dy, dw)
  1492.     change_color(system_color)
  1493.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:TPRecover])
  1494.     set = 0
  1495.     for effect in @item.effects
  1496.       next unless effect.code == 13
  1497.       set += effect.value1.to_i
  1498.     end
  1499.     if set != 0
  1500.       change_color(param_change_color(set))
  1501.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1502.     else
  1503.       change_color(normal_color, false)
  1504.       text = Vocab[:Empty]
  1505.     end
  1506.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1507.   end
  1508.   #--------------------------------------------------------------------------
  1509.   # * Desenha ganho de TP
  1510.   #     dx       : Posição X
  1511.   #     dy       : Posição Y
  1512.   #     dw       : Largura
  1513.   #--------------------------------------------------------------------------
  1514.   def draw_tp_gain(dx, dy, dw)
  1515.     change_color(system_color)
  1516.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:TPGain])
  1517.     set = @item.tp_gain
  1518.     if set != 0
  1519.       change_color(param_change_color(set))
  1520.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  1521.     else
  1522.       change_color(normal_color, false)
  1523.       text = Vocab[:Empty]
  1524.     end
  1525.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  1526.   end
  1527.   #--------------------------------------------------------------------------
  1528.   # * Desenha efeito aplicados
  1529.   #     dx       : Posição X
  1530.   #     dy       : Posição Y
  1531.   #     dw       : Largura
  1532.   #--------------------------------------------------------------------------
  1533.   def draw_applies(dx, dy, dw)
  1534.     change_color(system_color)
  1535.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:Applies])
  1536.     icons = []
  1537.     for effect in @item.effects
  1538.       case effect.code
  1539.       when 21
  1540.         next unless effect.value1 > 0
  1541.         next if $data_states[effect.value1].nil?
  1542.         icons.push($data_states[effect.value1].icon_index)
  1543.       when 31
  1544.         icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  1545.       when 32
  1546.         icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  1547.       end
  1548.       icons.delete(0)
  1549.       break if icons.size >= MaxIconsDrawn
  1550.     end
  1551.     draw_icons(dx, dy, dw, icons)
  1552.   end
  1553.   #--------------------------------------------------------------------------
  1554.   # * Desenha efeitos removidos
  1555.   #     dx       : Posição X
  1556.   #     dy       : Posição Y
  1557.   #     dw       : Largura
  1558.   #--------------------------------------------------------------------------
  1559.   def draw_removes(dx, dy, dw)
  1560.     change_color(system_color)
  1561.     draw_text(dx+4, dy, dw-8, line_height, Vocab[:Removes])
  1562.     icons = []
  1563.     for effect in @item.effects
  1564.       case effect.code
  1565.       when 22
  1566.         next unless effect.value1 > 0
  1567.         next if $data_states[effect.value1].nil?
  1568.         icons.push($data_states[effect.data_id].icon_index)
  1569.       when 33
  1570.         icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  1571.       when 34
  1572.         icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  1573.       end
  1574.       icons.delete(0)
  1575.       break if icons.size >= MaxIconsDrawn
  1576.     end
  1577.     draw_icons(dx, dy, dw, icons)
  1578.   end
  1579.   #--------------------------------------------------------------------------
  1580.   # * Desenha ícones
  1581.   #     dx       : Posição X
  1582.   #     dy       : Posição Y
  1583.   #     dw       : Largura
  1584.   #     icons    : Array com identificação dos itens
  1585.   #--------------------------------------------------------------------------
  1586.   def draw_icons(dx, dy, dw, icons)
  1587.     dx += dw - 4
  1588.     dx -= icons.size * 24
  1589.     for icon_id in icons
  1590.       draw_icon(icon_id, dx, dy)
  1591.       dx += 24
  1592.     end
  1593.     if icons.size == 0
  1594.       change_color(normal_color, false)
  1595.       text = Vocab[:Empty]
  1596.       draw_text(4, dy, contents.width-8, line_height, text, 2)
  1597.     end
  1598.   end
  1599.   #--------------------------------------------------------------------------
  1600.   # * Desenha a descrição do item
  1601.   #--------------------------------------------------------------------------
  1602.   def draw_item_description
  1603.     change_color(normal_color)
  1604.     text = @item.description.split(/\s/)
  1605.     dy   = (@item.is_a?(RPG::Skill) ? line_height * 3 + 96 : 200) - line_height
  1606.    
  1607.     word = text.shift
  1608.     tlen = contents.text_size(word).width
  1609.     phrs = word + " "
  1610.    
  1611.     until text.empty?
  1612.       word = text.shift
  1613.       len  = contents.text_size(word).width
  1614.       if len + tlen >= contents_width / 1.25
  1615.         draw_text(0, dy += line_height, contents_width, line_height, phrs, 1)
  1616.         text.unshift(word)
  1617.         tlen = 0
  1618.         phrs = ''
  1619.       else
  1620.         tlen += len
  1621.         phrs += word + " "
  1622.       end      
  1623.     end
  1624.     draw_text(0, dy + line_height, contents_width, line_height, phrs, 1)
  1625.    
  1626.   end
  1627. end
  1628. #==============================================================================
  1629. # ** Menu_Item_Window
  1630. #------------------------------------------------------------------------------
  1631. # Janela responsável por mostrar itens filtrados (Itens, Armaduras, etc)
  1632. #==============================================================================
  1633. class Menu_Item_Window < Window_Command
  1634.   attr_reader :info
  1635.   attr_reader :equipMode
  1636.  
  1637.   #--------------------------------------------------------------------------
  1638.   # * Inicialização do objeto
  1639.   #     x : Coordenada X
  1640.   #     y : Coordenada Y
  1641.   #     w : Largura
  1642.   #     h : Altura
  1643.   #--------------------------------------------------------------------------
  1644.   def initialize(x, y, w, h)
  1645.     @width     = w
  1646.     @height    = h
  1647.     @equipMode = nil
  1648.     super(x, y)
  1649.     self.applyFont(self.contents)
  1650.     self.open
  1651.   end
  1652.   #--------------------------------------------------------------------------
  1653.   # * Definição de uma flag para ativar a seleção de equipamentos
  1654.   #     index : Novo modo
  1655.   #     actor : Ator
  1656.   #--------------------------------------------------------------------------
  1657.   def enableEquipMode(index, actor)
  1658.     @equipMode = {index: index, actor: actor}
  1659.   end
  1660.   #--------------------------------------------------------------------------
  1661.   # * Desativa a flag de seleção de equipamentos
  1662.   #--------------------------------------------------------------------------
  1663.   def disableEquipMode
  1664.     @equipMode = nil
  1665.   end
  1666.   #--------------------------------------------------------------------------
  1667.   # * Atualização do cursor
  1668.   #     *args // &block : Argumentos
  1669.   #--------------------------------------------------------------------------
  1670.   def update_cursor(*args, &block)
  1671.     super(*args, &block)
  1672.     @info.item = @data[index] if @data
  1673.   end
  1674.   #--------------------------------------------------------------------------
  1675.   # * Definição de resultado ao pressionar o botão de confirmação
  1676.   #--------------------------------------------------------------------------
  1677.   def process_ok
  1678.   end
  1679.   #--------------------------------------------------------------------------
  1680.   # * Define janela de informação
  1681.   #     win : Janela
  1682.   #--------------------------------------------------------------------------
  1683.   def info=(win)
  1684.     @info = win
  1685.     win.item = @data[index] if @data
  1686.   end
  1687.   #--------------------------------------------------------------------------
  1688.   # * Aquisição da largura da janela
  1689.   #--------------------------------------------------------------------------
  1690.   def window_width
  1691.     return @width
  1692.   end
  1693.   #--------------------------------------------------------------------------
  1694.   # * Aquisição da altura da janela
  1695.   #--------------------------------------------------------------------------
  1696.   def window_height
  1697.     return @height
  1698.   end
  1699.   #--------------------------------------------------------------------------
  1700.   # * Desenho de um item
  1701.   #     index : índice do item
  1702.   #--------------------------------------------------------------------------
  1703.   def draw_item(index)
  1704.     item = @data[index]
  1705.     if item
  1706.       rect = item_rect(index)
  1707.       rect.width -= 4
  1708.       draw_item_name(item, rect.x, rect.y, enable?(item))
  1709.       draw_item_number(rect, item)
  1710.     end
  1711.   end
  1712.   #--------------------------------------------------------------------------
  1713.   # * Desenho do número de itens possuido
  1714.   #     rect : retângulo
  1715.   #     item : item
  1716.   #--------------------------------------------------------------------------
  1717.   def draw_item_number(rect, item)
  1718.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  1719.   end
  1720.   #--------------------------------------------------------------------------
  1721.   # * Criação da lista de comandos
  1722.   #--------------------------------------------------------------------------
  1723.   def make_command_list
  1724.     return unless @data
  1725.     @data.each{|item| add_command(item, :item_select) }
  1726.   end
  1727.   #------------------------------------------------------------------------
  1728.   # * Aplica filtro de itens
  1729.   #     type : Tipo de filtro
  1730.   #------------------------------------------------------------------------
  1731.   def applyFilter(type)
  1732.     @category = [:item, :weapon, :armor, :key_item][type]
  1733.     self.make_item_list
  1734.     @info.item = @data[index] if @data
  1735.     self.refresh
  1736.   end
  1737.   #--------------------------------------------------------------------------
  1738.   # * Inclusão do item na lista
  1739.   #     item : item
  1740.   #--------------------------------------------------------------------------
  1741.   def include?(item)
  1742.     if @equipMode
  1743.       return true  if item.nil?
  1744.       return false unless item.is_a?(RPG::EquipItem)
  1745.       return false if item.etype_id != @equipMode[:actor].equip_slots[@equipMode[:index]]
  1746.       return @equipMode[:actor].equippable?(item)
  1747.     end
  1748.  
  1749.     case @category
  1750.     when :item
  1751.       item.is_a?(RPG::Item) && !item.key_item?
  1752.     when :weapon
  1753.       item.is_a?(RPG::Weapon)
  1754.     when :armor
  1755.       item.is_a?(RPG::Armor)
  1756.     when :key_item
  1757.       item.is_a?(RPG::Item) && item.key_item?
  1758.     else
  1759.       true
  1760.     end
  1761.   end
  1762.   #--------------------------------------------------------------------------
  1763.   # * Definição de habilitação do item
  1764.   #     item : item
  1765.   #--------------------------------------------------------------------------
  1766.   def enable?(item)
  1767.     return true  if @equipMode
  1768.    
  1769.     return false if not item.is_a?(RPG::Item)
  1770.     return false if item.key_item?
  1771.    
  1772.     user = $game_party.movable_members.max_by {|member| member.pha }
  1773.     case item.scope
  1774.     when 0..6
  1775.       data = []
  1776.     when 7..8
  1777.       data = $game_party.members
  1778.     when 9..10
  1779.       data = $game_party.members.select{|actor| actor.dead?}
  1780.     end
  1781.    
  1782.     return false if data.empty?
  1783.     return data.any?{|actor| actor.item_test(user, item) }
  1784.   end
  1785.   #--------------------------------------------------------------------------
  1786.   # * Definição de habilitação do item selecionado
  1787.   #--------------------------------------------------------------------------
  1788.   def current_item_enabled?
  1789.     return enable?(current_data[:name])
  1790.   end
  1791.   #--------------------------------------------------------------------------
  1792.   # * Criação da lista de itens
  1793.   #--------------------------------------------------------------------------
  1794.   def make_item_list
  1795.     @data = $game_party.all_items.select{|item| include?(item)}
  1796.     @data.push(nil) if include?(nil)
  1797.   end
  1798.   #--------------------------------------------------------------------------
  1799.   # * Criação do conteúdo das janelas
  1800.   #--------------------------------------------------------------------------
  1801.   def create_contents(*args, &block)
  1802.     super(*args, &block)
  1803.     self.applyFont(contents)
  1804.   end
  1805.  
  1806.   protected
  1807.   #-------------------------------------------------------------------------
  1808.   # * Aplica opções de fonte no bitmap
  1809.   #     b : Bitmap
  1810.   #-------------------------------------------------------------------------
  1811.   def applyFont(b)
  1812.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  1813.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  1814.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  1815.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  1816.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  1817.     return b
  1818.   end
  1819. end
  1820.  
  1821. #==============================================================================
  1822. # ** Menu_Equips_Window
  1823. #------------------------------------------------------------------------------
  1824. #  Esta classe mostra as informações de um monstro
  1825. #==============================================================================
  1826. class Menu_Equips_Window < Menu_Base_Window
  1827.   attr_reader :index
  1828.   attr_reader :info
  1829.  
  1830.   #-------------------------------------------------------------------------
  1831.   # * Inícialização do objeto
  1832.   #     x     : Posição X inicial da janela
  1833.   #     y     : Posição Y inicial da janela
  1834.   #     w     : Largura
  1835.   #-------------------------------------------------------------------------
  1836.   def initialize(x, y, w)
  1837.     super(x, y, w, fitting_height(7))
  1838.     self.opacity          = 0
  1839.     self.contents_opacity = 0
  1840.     @actor                = nil
  1841.     @index                = 0
  1842.    
  1843.     vs = contents_height / 7.0
  1844.     @rect = Array.new(6){|i|
  1845.       Rect.new(0, (vs * i).round, contents_width, line_height)
  1846.     }
  1847.     @rect.last.y += vs
  1848.   end
  1849.   #--------------------------------------------------------------------------
  1850.   # * Define janela de informação
  1851.   #     win : Janela
  1852.   #--------------------------------------------------------------------------
  1853.   def info=(win)
  1854.     @info = win
  1855.   end
  1856.   #-------------------------------------------------------------------------
  1857.   # * Seleção do ator
  1858.   #   actor : Game_Actor da janela
  1859.   #-------------------------------------------------------------------------
  1860.   def actor=(actor)
  1861.     @actor = actor
  1862.     refresh
  1863.   end
  1864.   #-------------------------------------------------------------------------
  1865.   # * Determina estado de atividade
  1866.   #   state : Ativa ou não a janela
  1867.   #-------------------------------------------------------------------------
  1868.   def active=(state)
  1869.     @active = state
  1870.     self.cursor_rect.set(@active ? @rect[@index] : Rect.new)
  1871.   end
  1872.   #-------------------------------------------------------------------------
  1873.   # * Modificação do índice da janela
  1874.   #     value : Novo índice
  1875.   #-------------------------------------------------------------------------
  1876.   def index=(value)
  1877.     @index = value
  1878.     self.cursor_rect.set(@rect[@index])
  1879.     @info.item = @actor.equips[@index] if @info
  1880.   end
  1881.   #-------------------------------------------------------------------------
  1882.   # * Desenho do conteúdo
  1883.   #-------------------------------------------------------------------------
  1884.   def refresh
  1885.     contents.clear
  1886.     return unless @actor
  1887.     dy = 0
  1888.     @actor.equips.each_with_index{|item,index|
  1889.       if item
  1890.         draw_item_name(item, 0, dy, enable?(index), contents_width)
  1891.       else
  1892.         change_color(system_color)
  1893.         index = 0 if @actor.dual_wield? and index == 1
  1894.         draw_text(@rect[index], ::Vocab::etype(index).isoUpcase, 1)
  1895.         change_color(normal_color)
  1896.       end
  1897.       dy += line_height
  1898.     }
  1899.     draw_text(@rect.last, Vocab[:Optimize], 1)
  1900.   end
  1901.   #--------------------------------------------------------------------------
  1902.   # * Definição de habilitação do item
  1903.   #     item : item
  1904.   #--------------------------------------------------------------------------
  1905.   def enable?(index)
  1906.     @actor ? @actor.equip_change_ok?(index) : false
  1907.   end
  1908.   #--------------------------------------------------------------------------
  1909.   # * Desenho do nome de itens
  1910.   #     item    : objeto
  1911.   #     x       : coordenada X
  1912.   #     y       : coordenada Y
  1913.   #     enabled : habilitar flag, translucido quando false
  1914.   #     width   : largura
  1915.   #--------------------------------------------------------------------------
  1916.   def draw_item_name(item, x, y, enabled = true, width = 172)
  1917.     return unless item
  1918.     draw_icon(item.icon_index, x, y, enabled)
  1919.     change_color(normal_color, enabled)
  1920.     draw_text(x, y, width, line_height, item.name, 1)
  1921.   end
  1922. end
  1923.  
  1924.  
  1925. #==============================================================================
  1926. # ** Menu_SkillCommand_Window
  1927. #------------------------------------------------------------------------------
  1928. #  Esta janela exibe a lista de comandos para tela de habilidades
  1929. # (como habilidades especiais e magias).
  1930. #==============================================================================
  1931.  
  1932. class Menu_SkillCommand_Window < Window_Command
  1933.   #--------------------------------------------------------------------------
  1934.   # * Variáveis públicas
  1935.   #--------------------------------------------------------------------------
  1936.   attr_reader   :skill_window
  1937.   #--------------------------------------------------------------------------
  1938.   # * Inicialização do objeto
  1939.   #     x      : Coordenada X
  1940.   #     y      : Coordenada Y
  1941.   #     w      : Largura
  1942.   #     h      : Altura
  1943.   #--------------------------------------------------------------------------
  1944.   def initialize(x, y, w, h)
  1945.     @width, @height = w, h
  1946.     super(x, y)
  1947.     self.opacity = 0
  1948.     self.active  = false
  1949.     @actor = nil
  1950.   end
  1951.   #--------------------------------------------------------------------------
  1952.   # * Aquisição da largura da janela
  1953.   #--------------------------------------------------------------------------
  1954.   def window_width
  1955.     @width
  1956.   end
  1957.   #--------------------------------------------------------------------------
  1958.   # * Aquisição da altura da janela
  1959.   #--------------------------------------------------------------------------
  1960.   def window_height
  1961.     @height
  1962.   end
  1963.   #--------------------------------------------------------------------------
  1964.   # * Definição de resultado ao pressionar o botão de confirmação
  1965.   #--------------------------------------------------------------------------
  1966.   def process_ok
  1967.   end
  1968.   #--------------------------------------------------------------------------
  1969.   # * Alinhamento do texto
  1970.   #--------------------------------------------------------------------------
  1971.   def alignment
  1972.     return 1
  1973.   end
  1974.   #--------------------------------------------------------------------------
  1975.   # * Definição de herói
  1976.   #     actor : herói
  1977.   #--------------------------------------------------------------------------
  1978.   def actor=(actor)
  1979.     return if @actor == actor
  1980.     @actor = actor
  1981.     refresh
  1982.   end
  1983.   #--------------------------------------------------------------------------
  1984.   # * Criação da lista de comandos
  1985.   #--------------------------------------------------------------------------
  1986.   def make_command_list
  1987.     return unless @actor
  1988.     @actor.added_skill_types.sort.each do |stype_id|
  1989.       name = $data_system.skill_types[stype_id]
  1990.       add_command(name, :skill, true, stype_id)
  1991.     end
  1992.   end
  1993.   #--------------------------------------------------------------------------
  1994.   # * Atualização da tela
  1995.   #--------------------------------------------------------------------------
  1996.   def update
  1997.     super
  1998.     @skill_window.stype_id = current_ext if @skill_window
  1999.   end
  2000.   #--------------------------------------------------------------------------
  2001.   # * Definição da janela de habilidades
  2002.   #     skill_window : janela de habilidades
  2003.   #--------------------------------------------------------------------------
  2004.   def skill_window=(skill_window)
  2005.     @skill_window = skill_window
  2006.     update
  2007.   end
  2008.   #--------------------------------------------------------------------------
  2009.   # * Criação do conteúdo das janelas
  2010.   #--------------------------------------------------------------------------
  2011.   def create_contents(*args, &block)
  2012.     super(*args, &block)
  2013.     self.applyFont(contents)
  2014.   end
  2015.  
  2016.   protected
  2017.   #-------------------------------------------------------------------------
  2018.   # * Aplica opções de fonte no bitmap
  2019.   #     b : Bitmap
  2020.   #-------------------------------------------------------------------------
  2021.   def applyFont(b)
  2022.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  2023.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  2024.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  2025.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  2026.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  2027.     return b
  2028.   end
  2029. end
  2030.  
  2031.  
  2032. #==============================================================================
  2033. # ** Menu_SkillList_Window
  2034. #------------------------------------------------------------------------------
  2035. #  Esta janela exibe uma lista de habilidades usáveis na tela de habilidades.
  2036. #==============================================================================
  2037.  
  2038. class Menu_SkillList_Window < Window_Command
  2039.   #--------------------------------------------------------------------------
  2040.   # * Inicialização do objeto
  2041.   #     x : Coordenada X
  2042.   #     y : Coordenada Y
  2043.   #     w : Largura
  2044.   #     h : Altura
  2045.   #--------------------------------------------------------------------------
  2046.   def initialize(x, y, w, h)
  2047.     @width, @height = w, h
  2048.     super(x, y)
  2049.     self.opacity = 0
  2050.     self.active  = false
  2051.     @actor = nil
  2052.     @stype_id = 0
  2053.     @data = []
  2054.   end
  2055.   #--------------------------------------------------------------------------
  2056.   # * Aquisição da largura da janela
  2057.   #--------------------------------------------------------------------------
  2058.   def window_width
  2059.     @width
  2060.   end
  2061.   #--------------------------------------------------------------------------
  2062.   # * Aquisição da altura da janela
  2063.   #--------------------------------------------------------------------------
  2064.   def window_height
  2065.     @height
  2066.   end
  2067.   #--------------------------------------------------------------------------
  2068.   # * Atualização do cursor
  2069.   #     *args // &block : Argumentos
  2070.   #--------------------------------------------------------------------------
  2071.   def update_cursor(*args, &block)
  2072.     super(*args, &block)
  2073.     @info.item = @data[index] if @data && @info
  2074.   end
  2075.   #--------------------------------------------------------------------------
  2076.   # * Definição de resultado ao pressionar o botão de confirmação
  2077.   #--------------------------------------------------------------------------
  2078.   def process_ok
  2079.   end
  2080.   #--------------------------------------------------------------------------
  2081.   # * Define janela de informação
  2082.   #     win : Janela
  2083.   #--------------------------------------------------------------------------
  2084.   def info=(win)
  2085.     @info = win
  2086.     win.item = @data[index] if @data
  2087.   end
  2088.   #--------------------------------------------------------------------------
  2089.   # * Máximo de itens desenhados
  2090.   #--------------------------------------------------------------------------
  2091.   def item_max
  2092.     @data ? @data.size : 0
  2093.   end
  2094.   #--------------------------------------------------------------------------
  2095.   # * Definição de herói
  2096.   #     actor : herói
  2097.   #--------------------------------------------------------------------------
  2098.   def actor=(actor)
  2099.     return if @actor == actor
  2100.     @actor = actor
  2101.     refresh
  2102.     self.oy = 0
  2103.   end
  2104.   #--------------------------------------------------------------------------
  2105.   # * Definição da ID do tipo de habilidade
  2106.   #     stype_id : ID do tipo de habilidade
  2107.   #--------------------------------------------------------------------------
  2108.   def stype_id=(stype_id)
  2109.     return if @stype_id == stype_id
  2110.     @stype_id = stype_id
  2111.     refresh
  2112.     self.oy = 0
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   # * Aquisição das informações da skill
  2116.   #--------------------------------------------------------------------------
  2117.   def item
  2118.     @data && index >= 0 ? @data[index] : nil
  2119.   end
  2120.   #--------------------------------------------------------------------------
  2121.   # * Definição de habilitação de seleção
  2122.   #--------------------------------------------------------------------------
  2123.   def current_item_enabled?
  2124.     enable?(@data[index])
  2125.   end
  2126.   #--------------------------------------------------------------------------
  2127.   # * Inclusão do item na lista
  2128.   #     item : item
  2129.   #--------------------------------------------------------------------------
  2130.   def include?(item)
  2131.     item && item.stype_id == @stype_id
  2132.   end
  2133.   #--------------------------------------------------------------------------
  2134.   # * Definição de habilitação do item
  2135.   #     item : item
  2136.   #--------------------------------------------------------------------------
  2137.   def enable?(item)
  2138.     @actor && @actor.usable?(item)
  2139.   end
  2140.   #--------------------------------------------------------------------------
  2141.   # * Criação da lista de itens
  2142.   #--------------------------------------------------------------------------
  2143.   def make_item_list
  2144.     @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
  2145.   end
  2146.   #--------------------------------------------------------------------------
  2147.   # * Desenho de um item
  2148.   #     index : índice do item
  2149.   #--------------------------------------------------------------------------
  2150.   def draw_item(index)
  2151.     skill = @data[index]
  2152.     if skill
  2153.       rect = item_rect(index)
  2154.       rect.width -= 4
  2155.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  2156.       draw_skill_cost(rect, skill)
  2157.     end
  2158.   end
  2159.   #--------------------------------------------------------------------------
  2160.   # * Desenho do custo das habilidades
  2161.   #     rect  : retângulo
  2162.   #     skill : habilidade
  2163.   #--------------------------------------------------------------------------
  2164.   def draw_skill_cost(rect, skill)
  2165.     if @actor.skill_tp_cost(skill) > 0
  2166.       change_color(tp_cost_color, enable?(skill))
  2167.       draw_text(rect, @actor.skill_tp_cost(skill), 2)
  2168.     elsif @actor.skill_mp_cost(skill) > 0
  2169.       change_color(mp_cost_color, enable?(skill))
  2170.       draw_text(rect, @actor.skill_mp_cost(skill), 2)
  2171.     end
  2172.   end
  2173.   #--------------------------------------------------------------------------
  2174.   # * Renovação
  2175.   #--------------------------------------------------------------------------
  2176.   def refresh
  2177.     make_item_list
  2178.     create_contents
  2179.     draw_all_items
  2180.   end
  2181.   #--------------------------------------------------------------------------
  2182.   # * Criação do conteúdo das janelas
  2183.   #--------------------------------------------------------------------------
  2184.   def create_contents(*args, &block)
  2185.     super(*args, &block)
  2186.     self.applyFont(contents)
  2187.   end
  2188.  
  2189.   protected
  2190.   #-------------------------------------------------------------------------
  2191.   # * Aplica opções de fonte no bitmap
  2192.   #     b : Bitmap
  2193.   #-------------------------------------------------------------------------
  2194.   def applyFont(b)
  2195.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  2196.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  2197.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  2198.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  2199.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  2200.     return b
  2201.   end
  2202. end
  2203.  
  2204. #==============================================================================
  2205. # ** Menu_ActorBase_Window
  2206. #------------------------------------------------------------------------------
  2207. #  Esta classe mostra as informações simples do ator
  2208. #==============================================================================
  2209. class Menu_ActorBase_Window < Menu_Base_Window
  2210.   #-------------------------------------------------------------------------
  2211.   # * Inícialização do objeto
  2212.   #     actor : Ator
  2213.   #     x     : Posição X inicial da janela
  2214.   #     y     : Posição Y inicial da janela
  2215.   #     w     : Largura
  2216.   #     h     : Altura
  2217.   #-------------------------------------------------------------------------
  2218.   def initialize(actor, x, y, w, h)
  2219.     super(x, y, w, h)
  2220.     self.opacity          = 0
  2221.     self.contents_opacity = 0
  2222.     self.actor = actor
  2223.   end
  2224.   #-------------------------------------------------------------------------
  2225.   # * Seleção do ator
  2226.   #   actor : Game_Actor da janela
  2227.   #-------------------------------------------------------------------------
  2228.   def actor=(actor)
  2229.     @actor = actor
  2230.    
  2231.     @charBitmap = Cache.character(@actor.character_name)
  2232.    
  2233.     sign = @actor.character_name[/^[\!\$]./]
  2234.     if sign && sign.include?('$')
  2235.       @cw = @charBitmap.width / 3
  2236.       @ch = @charBitmap.height / 4
  2237.     else
  2238.       @cw = @charBitmap.width / 12
  2239.       @ch = @charBitmap.height / 8
  2240.     end
  2241.      
  2242.     @pattern = 1
  2243.    
  2244.     refresh
  2245.   end
  2246.   #-------------------------------------------------------------------------
  2247.   # * Desenho do conteúdo
  2248.   #-------------------------------------------------------------------------
  2249.   def refresh
  2250.     half_width = contents.width/2
  2251.    
  2252.     contents.clear
  2253.     # FACE
  2254.     draw_actor_face(@actor, half_width - 48, line_height * 2)
  2255.     # NOME
  2256.     change_color(hp_color(@actor))
  2257.     draw_text(0, 0, contents_width, line_height, @actor.name, 1)
  2258.     # LINHA HORIZONTAL
  2259.     draw_horz_line(line_height * 1)
  2260.     # LINHA HORIZONTAL
  2261.     draw_horz_line(line_height * 6)
  2262.     # LEVEL
  2263.     rect = Rect.new(half_width - 44, line_height * 7, 88, line_height)
  2264.     change_color(system_color)
  2265.     draw_text(rect, ::Vocab::level_a)
  2266.     change_color(normal_color)
  2267.     draw_text(rect, @actor.level, 2)
  2268.     # ÍCONES
  2269.     icons = (@actor.state_icons + @actor.buff_icons)[0, contents_width / 24]
  2270.     bx    = half_width - (icons.size * 12)
  2271.     icons.each_with_index{|n, i| draw_icon(n, bx + 24 * i, line_height * 8) }
  2272.     # HP
  2273.     draw_actor_hp(@actor, 3, line_height * 10, contents_width - 6)
  2274.     # MP
  2275.     draw_actor_mp(@actor, 3, line_height * 11, contents_width - 6)
  2276.   end
  2277.   #-------------------------------------------------------------------------
  2278.   # * Determina estado de atividade
  2279.   #   state : Ativa ou não a janela
  2280.   #-------------------------------------------------------------------------
  2281.   def active=(state)
  2282.     @active = state
  2283.     self.cursor_rect.set(@active ? contents.rect : Rect.new)
  2284.   end
  2285. end
  2286.  
  2287. #==============================================================================
  2288. # ** Menu_Formation_Window
  2289. #------------------------------------------------------------------------------
  2290. # Exibe informações do personagem para 'cena' de formação
  2291. #==============================================================================
  2292. class Menu_Formation_Window < Menu_ActorBase_Window
  2293.   #-------------------------------------------------------------------------
  2294.   # * Desenho do conteúdo
  2295.   #-------------------------------------------------------------------------
  2296.   def refresh
  2297.     contents.clear
  2298.     half_height = contents_height / 2
  2299.    
  2300.     # FACE
  2301.     draw_actor_face(@actor, 4, half_height - 48)
  2302.     # NOME
  2303.     change_color(hp_color(@actor))
  2304.     draw_text(156, 0, contents_width - 156, line_height, @actor.name, 0)
  2305.     # LINHA HORIZONTAL
  2306.     draw_horz_line(line_height / 2 - 4)
  2307.     # LEVEL
  2308.     rect = Rect.new(156, line_height * 2.5, 88, line_height)
  2309.     change_color(system_color)
  2310.     draw_text(rect, ::Vocab::level_a)
  2311.     change_color(normal_color)
  2312.     draw_text(rect, @actor.level, 2)
  2313.     # ÍCONES
  2314.     states  = (@actor.state_icons + @actor.buff_icons)
  2315.     num     = (contents_width - 260) / 24
  2316.     [
  2317.       states[  0, num],
  2318.       states[num, num]
  2319.     ].each_with_index{|icons, i|
  2320.       next unless icons
  2321.       icons.each_with_index{|n, j|
  2322.         draw_icon(n, 260 + 24 * j, line_height + i * 26)
  2323.       }
  2324.     }
  2325.     # HP
  2326.     draw_actor_hp(@actor, 156, line_height * 0.75, 100)
  2327.     # MP
  2328.     draw_actor_mp(@actor, 156, line_height * 1.65, 100)
  2329.   end
  2330. end
  2331.  
  2332. #==============================================================================
  2333. # ** Menu_ActorSelect_Window
  2334. #------------------------------------------------------------------------------
  2335. #  Janela que exibe a face dos atores para seleção
  2336. #==============================================================================
  2337. class Menu_ActorSelect_Window < Menu_Base_Window
  2338.   attr_reader :faces
  2339.   attr_reader :index
  2340.  
  2341.   #-------------------------------------------------------------------------
  2342.   # * Inícialização do objeto
  2343.   #     actor : Ator
  2344.   #     x     : Posição X inicial da janela
  2345.   #     y     : Posição Y inicial da janela
  2346.   #     w     : Largura
  2347.   #     h     : Altura
  2348.   #-------------------------------------------------------------------------
  2349.   def initialize(x, y, w, h)
  2350.     super(x, y, w, h)
  2351.     self.opacity = 0
  2352.     @faces = []
  2353.     @index = 0
  2354.   end
  2355.   #-------------------------------------------------------------------------
  2356.   # * Retorna o ator selecionado
  2357.   #-------------------------------------------------------------------------
  2358.   def actor
  2359.     @faces[@index]
  2360.   end
  2361.   #-------------------------------------------------------------------------
  2362.   # * Índice máximo
  2363.   #-------------------------------------------------------------------------
  2364.   def maxIndex
  2365.     @faces.size
  2366.   end
  2367.   #-------------------------------------------------------------------------
  2368.   # * Modificação do índice da janela
  2369.   #     value : Novo índice
  2370.   #-------------------------------------------------------------------------
  2371.   def index=(value)
  2372.     @index = value % @faces.size
  2373.   end
  2374.   #-------------------------------------------------------------------------
  2375.   # * Ajuste do cursor de acordo com a posição ox
  2376.   #     value : Nova posição ox
  2377.   #-------------------------------------------------------------------------
  2378.   def ox=(value)
  2379.     super(value)
  2380.     self.cursor_rect.x = value
  2381.   end
  2382.   #-------------------------------------------------------------------------
  2383.   # * Posição ox correta (para animação)
  2384.   #-------------------------------------------------------------------------
  2385.   def trueOx
  2386.     @index * (standard_padding + 96)
  2387.   end
  2388.   #-------------------------------------------------------------------------
  2389.   # * Modificação das faces
  2390.   #     nfs : Novas faces
  2391.   #-------------------------------------------------------------------------
  2392.   def faces=(value)
  2393.     @faces = value
  2394.     self.index = @index
  2395.     contents.dispose
  2396.     self.contents = Bitmap.new(
  2397.       @faces.size * (96 + standard_padding) - standard_padding,
  2398.       contents_height
  2399.     )
  2400.     self.applyFont(contents)
  2401.     refresh
  2402.   end
  2403.   #-------------------------------------------------------------------------
  2404.   # * Determina se a janela está ou não ativa
  2405.   #     value : Atividade
  2406.   #-------------------------------------------------------------------------
  2407.   def active=(value)
  2408.     @active = value
  2409.     rect = contents.rect
  2410.     rect.x += 1
  2411.     rect.width = width - 2 * standard_padding - 2
  2412.     self.cursor_rect.set(@active ? rect : Rect.new)
  2413.   end
  2414.   #-------------------------------------------------------------------------
  2415.   # * Desenho da janela
  2416.   #-------------------------------------------------------------------------
  2417.   def refresh
  2418.     self.contents.clear
  2419.     faceW = 96 + standard_padding
  2420.     ax    = (contents_width  - 96) / 2 - faceW
  2421.     ay    = (contents_height - 96) / 2
  2422.     @faces.each{|actor| draw_actor_face(actor, ax += faceW, ay) }
  2423.   end
  2424. end
  2425.  
  2426. #==============================================================================
  2427. # ** Menu_ActorFull_Window
  2428. #------------------------------------------------------------------------------
  2429. #  Esta janela exibe as especificações completas na janela de atributos.
  2430. #==============================================================================
  2431. class Menu_ActorFull_Window < Menu_Base_Window
  2432.   #-------------------------------------------------------------------------
  2433.   # * Início
  2434.   #     actor : Ator
  2435.   #     x     : Posição X inicial da janela
  2436.   #     y     : Posição Y inicial da janela
  2437.   #     w     : Largura
  2438.   #     h     : Altura
  2439.   #-------------------------------------------------------------------------
  2440.   def initialize(actor, x, y, w, h)
  2441.     super(x, y, w, h)
  2442.     self.opacity = 0
  2443.     @actor = actor
  2444.   end
  2445.   #--------------------------------------------------------------------------
  2446.   # * Definição de herói
  2447.   #     actor : herói
  2448.   #--------------------------------------------------------------------------
  2449.   def actor=(actor)
  2450.     return if @actor == actor
  2451.     @actor = actor
  2452.     refresh
  2453.   end
  2454.   #--------------------------------------------------------------------------
  2455.   # * Renovação
  2456.   #--------------------------------------------------------------------------
  2457.   def refresh
  2458.     contents.clear
  2459.     draw_block1   (line_height * 0)
  2460.     draw_horz_line(line_height * 1)
  2461.     draw_block2   (line_height * 2)
  2462.     draw_horz_line(line_height * 6)
  2463.     draw_block3   (line_height * 7)
  2464.   end
  2465.   #--------------------------------------------------------------------------
  2466.   # * Desenho do bloco 1
  2467.   #     y : coordenada Y
  2468.   #--------------------------------------------------------------------------
  2469.   def draw_block1(y)
  2470.     draw_actor_name(@actor, 4, y)
  2471.     draw_actor_class(@actor, 128, y)
  2472.     draw_actor_nickname(@actor, 288, y)
  2473.   end
  2474.   #--------------------------------------------------------------------------
  2475.   # * Desenho do bloco 1
  2476.   #     y : coordenada Y
  2477.   #--------------------------------------------------------------------------
  2478.   def draw_block2(y)
  2479.     draw_actor_face(@actor, 8, y)
  2480.     draw_basic_info(136, y)
  2481.     draw_exp_info(304, y)
  2482.   end
  2483.   #--------------------------------------------------------------------------
  2484.   # * Desenho do bloco 3
  2485.   #     y : coordenada Y
  2486.   #--------------------------------------------------------------------------
  2487.   def draw_block3(y)
  2488.     draw_parameters(32, y)
  2489.     draw_equipments(288, y)
  2490.   end
  2491.   #--------------------------------------------------------------------------
  2492.   # * Desenho das informações básicas
  2493.   #     x : coordenada X
  2494.   #     y : coordenada Y
  2495.   #--------------------------------------------------------------------------
  2496.   def draw_basic_info(x, y)
  2497.     draw_actor_level(@actor, x, y + line_height * 0)
  2498.     draw_actor_icons(@actor, x, y + line_height * 1)
  2499.     draw_actor_hp(@actor, x, y + line_height * 2)
  2500.     draw_actor_mp(@actor, x, y + line_height * 3)
  2501.   end
  2502.   #--------------------------------------------------------------------------
  2503.   # * Desenho dos parâmetros
  2504.   #     x : coordenada X
  2505.   #     y : coordenada Y
  2506.   #--------------------------------------------------------------------------
  2507.   def draw_parameters(x, y)
  2508.     6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  2509.   end
  2510.   #--------------------------------------------------------------------------
  2511.   # * Desenho das informações de experiência
  2512.   #     x : coordenada X
  2513.   #     y : coordenada Y
  2514.   #--------------------------------------------------------------------------
  2515.   def draw_exp_info(x, y)
  2516.     s1 = @actor.max_level? ? "-------" : @actor.exp
  2517.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  2518.     s_next = sprintf(::Vocab::ExpNext, ::Vocab::level)
  2519.     change_color(system_color)
  2520.     draw_text(x, y + line_height * 0, 180, line_height, ::Vocab::ExpTotal)
  2521.     draw_text(x, y + line_height * 2, 180, line_height, s_next)
  2522.     change_color(normal_color)
  2523.     draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  2524.     draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  2525.   end
  2526.   #--------------------------------------------------------------------------
  2527.   # * Desenho dos equipamentos
  2528.   #     x : coordenada X
  2529.   #     y : coordenada Y
  2530.   #--------------------------------------------------------------------------
  2531.   def draw_equipments(x, y)
  2532.     @actor.equips.each_with_index do |item, i|
  2533.       draw_item_name(item, x, y + line_height * i)
  2534.     end
  2535.   end
  2536.   #--------------------------------------------------------------------------
  2537.   # * Desenho da descrição
  2538.   #     x : coordenada X
  2539.   #     y : coordenada Y
  2540.   #--------------------------------------------------------------------------
  2541.   def draw_description(x, y)
  2542.     draw_text_ex(x, y, @actor.description)
  2543.   end
  2544. end
  2545.  
  2546. #==============================================================================
  2547. # ** Menu_PDist_Window
  2548. #------------------------------------------------------------------------------
  2549. #  Esta janela exibe os pontos e controla a adição de novos pontos de atribu-
  2550. #  tos aos atores.
  2551. #==============================================================================
  2552. class Menu_PDist_Window < Menu_ActorFull_Window
  2553.   attr_reader :actor
  2554.   attr_reader :index
  2555.   attr_reader :active
  2556.   attr_reader :drawn
  2557.   #-------------------------------------------------------------------------
  2558.   # * Início
  2559.   #     actor : Ator
  2560.   #     x     : Posição X inicial da janela
  2561.   #     y     : Posição Y inicial da janela
  2562.   #     w     : Largura
  2563.   #     h     : Altura
  2564.   #-------------------------------------------------------------------------
  2565.   def initialize(actor, x, y, w, h)
  2566.     @index  = 0
  2567.     @active = false
  2568.     @drawn  = false
  2569.     ay = line_height
  2570.     @rects  = Array.new(8){|i|
  2571.       Rect.new(300, ay += line_height, 171, line_height)
  2572.     }
  2573.     @actorSheet = actor.pointsSheet
  2574.     super(actor, x, y, w, h)
  2575.   end
  2576.   #--------------------------------------------------------------------------
  2577.   # * Redesenho da janela
  2578.   #--------------------------------------------------------------------------
  2579.   def refresh
  2580.     super
  2581.     @drawn = true
  2582.   end
  2583.   #--------------------------------------------------------------------------
  2584.   # * Definição de atividade de janela
  2585.   #     value : Novo valor
  2586.   #--------------------------------------------------------------------------
  2587.   def active=(value)
  2588.     @active = value
  2589.     if @active
  2590.       self.cursor_rect.set(@rects[@index])
  2591.     else
  2592.       self.cursor_rect.set(0, 0, 0, 0)
  2593.     end
  2594.   end
  2595.   #--------------------------------------------------------------------------
  2596.   # * Definição do índice da janela
  2597.   #     value : Novo valor
  2598.   #--------------------------------------------------------------------------
  2599.   def index=(value)
  2600.     @index = value
  2601.     self.cursor_rect.set(@rects[@index])
  2602.     refresh
  2603.   end
  2604.   #--------------------------------------------------------------------------
  2605.   # * Desenho dos parâmetros
  2606.   #     x : coordenada X
  2607.   #     y : coordenada Y
  2608.   #--------------------------------------------------------------------------
  2609.   def draw_parameters(x, y)
  2610.     8.times {|i| draw_actor_param(@actor, x, y + line_height * i, i) }
  2611.   end
  2612.   #--------------------------------------------------------------------------
  2613.   # * Desenho do bloco 2
  2614.   #     y : coordenada Y
  2615.   #--------------------------------------------------------------------------
  2616.   def draw_block2(y)
  2617.     draw_actor_face(@actor, 8, y)
  2618.     draw_basic_info(136, y)
  2619.     draw_parameters(304, y)
  2620.   end
  2621.   #--------------------------------------------------------------------------
  2622.   # * Desenho do bloco 3
  2623.   #     y : coordenada Y
  2624.   #--------------------------------------------------------------------------
  2625.   def draw_block3(y)
  2626.     draw_actor_sheetInfo(32, y)
  2627.   end
  2628.   #--------------------------------------------------------------------------
  2629.   # * Desenho dos parâmetros
  2630.   #     actor : herói
  2631.   #     x     : coordenada X
  2632.   #     y     : coordenada Y
  2633.   #--------------------------------------------------------------------------
  2634.   def draw_actor_param(actor, x, y, param_id)
  2635.     plus = actor.param_plus(param_id)
  2636.    
  2637.     change_color(system_color)
  2638.     draw_text(x, y, 120, line_height, ::Vocab::param(param_id))
  2639.     change_color(normal_color)
  2640.     draw_text(x + 90, y, 36, line_height, actor.param(param_id) - plus, 2)
  2641.    
  2642.     if plus >= 0
  2643.       clr = plus == 0 ? normal_color : power_up_color
  2644.       sym = "+"
  2645.     elsif plus < 0
  2646.       clr = power_down_color
  2647.       sym = "-"
  2648.     end
  2649.    
  2650.     change_color(clr)
  2651.     draw_text(x + 132, y, 10, line_height, sym, 1)
  2652.     draw_text(x + 142, y, 23, line_height, actor.param_plus(param_id).abs, 2)
  2653.    
  2654.     change_color(normal_color)
  2655.   end
  2656.   #--------------------------------------------------------------------------
  2657.   # * Desenha mensagem de distribuição de pontos
  2658.   #     x     : coordenada X
  2659.   #     y     : coordenada Y
  2660.   #--------------------------------------------------------------------------
  2661.   def draw_actor_sheetInfo(x, y)
  2662.     PDistDiag.each_with_index{|line, i|
  2663.       draw_text_ex(x, y + line_height * i, parseDiag(line))
  2664.     }
  2665.   end
  2666.   #--------------------------------------------------------------------------
  2667.   # * Desenho de uma linha horzontal
  2668.   #--------------------------------------------------------------------------
  2669.   def draw_horz_line(y)
  2670.     line_y = y + line_height / 2 - 1
  2671.     color = normal_color
  2672.     color.alpha = 48
  2673.     contents.fill_rect(0, line_y, 275, 2, color)
  2674.   end
  2675.   #--------------------------------------------------------------------------
  2676.   # * Desenho do texto com caracteres de controle
  2677.   #     x    : coordenada X
  2678.   #     y    : coordenada Y
  2679.   #     text : string de texto
  2680.   #--------------------------------------------------------------------------
  2681.   def draw_text_ex(x, y, text)
  2682.     text = convert_escape_characters(text)
  2683.     pos = {x: x, y: y, new_x: x, height: calc_line_height(text)}
  2684.     process_character(text.slice!(0, 1), text, pos) until text.empty?
  2685.   end
  2686.  
  2687.   protected
  2688.   #--------------------------------------------------------------------------
  2689.   # * Trata a linha para substituir as informações do ator
  2690.   #     line : String
  2691.   #--------------------------------------------------------------------------
  2692.   def parseDiag(line)
  2693.     paramSym = @actorSheet.keys[@index + 1]
  2694.  
  2695.     line
  2696.       .gsub("{actorName}"  , @actor.name)
  2697.       .gsub("{actorPoints}", @actor.attrPoints.to_s)
  2698.       .gsub("{attrName}",    ::Vocab::param(@index))
  2699.       .gsub("{attrNPoints}", @actorSheet[paramSym].first.to_s)
  2700.       .gsub("{attrGPoints}", @actorSheet[paramSym].last.to_s)
  2701.   end
  2702. end
  2703.  
  2704. #==============================================================================
  2705. # ** Menu_MonsterList_Window
  2706. #------------------------------------------------------------------------------
  2707. # Janela que mostra informações de monstros descobertos
  2708. #==============================================================================
  2709. class Menu_MonsterList_Window < Menu_Base_Window
  2710.  
  2711.   attr_reader :columns
  2712.   attr_reader :index
  2713.   attr_reader :rowMax
  2714.  
  2715.   #-------------------------------------------------------------------------
  2716.   # * Inicialização
  2717.   #     monsters : Lista de Monstros
  2718.   #     x        : Posição X inicial da janela
  2719.   #     y        : Posição Y inicial da janela
  2720.   #     w        : Largura
  2721.   #     h        : Altura
  2722.   #-------------------------------------------------------------------------
  2723.   def initialize(monsters, x, y, w, h)
  2724.     super(x, y, w, h)
  2725.     self.opacity = 0
  2726.     @rects    = []
  2727.     @columns  = 3
  2728.     @monsters = monsters
  2729.     @index    = 0
  2730.     @rowMax   = 1
  2731.     refresh
  2732.   end
  2733.   #-------------------------------------------------------------------------
  2734.   # * Define atividade da janela
  2735.   #     value : Nova definição
  2736.   #-------------------------------------------------------------------------
  2737.   def active=(value)
  2738.     @active = value
  2739.     if @active
  2740.       self.cursor_rect.set(@rects[@index])
  2741.     else
  2742.       self.cursor_rect.set(0,0,0,0)
  2743.     end
  2744.   end
  2745.   #-------------------------------------------------------------------------
  2746.   # * Define índice
  2747.   #     value : Novo índice
  2748.   #-------------------------------------------------------------------------
  2749.   def index=(value)
  2750.     @index = value
  2751.     self.cursor_rect.set(@rects[@index])
  2752.   end
  2753.   #-------------------------------------------------------------------------
  2754.   # Desenho da janela
  2755.   #-------------------------------------------------------------------------
  2756.   def refresh
  2757.     contents.clear
  2758.     monsters    = $data_enemies
  2759.    
  2760.     rate = (@monsters.size.to_f / (monsters.size - 1))
  2761.     text = Vocab[:BComplete].gsub("{c}", (100 * rate).round(1).to_s)
  2762.    
  2763.     gc1 = Color.new( 80 * rate, 14 * rate,  80 - 24 * rate, 192)
  2764.     gc2 = Color.new(240 * rate, 62 * rate, 240 - 72 * rate, 192)
  2765.     draw_special_gauge(0, 0, contents_width, rate, gc1, gc2)    
  2766.    
  2767.     draw_text(0, 0, contents_width, line_height, text, 1)
  2768.    
  2769.     x, y, i, cw = 0, line_height * 1.5, 0, contents_width / @columns
  2770.     @monsters.each_with_index{|id, index|
  2771.       @rects << Rect.new(x, y, cw, line_height)
  2772.      
  2773.       draw_text(x + 4, y, cw - 8, line_height, "#{index + 1}.")
  2774.       draw_text(@rects.last, monsters[id].name, 1)
  2775.      
  2776.       x += cw
  2777.       if (i += 1) == @columns
  2778.         i = x = 0
  2779.         y += line_height
  2780.       end
  2781.     }
  2782.    
  2783.     @rowMax = @monsters.size / @columns
  2784.   end
  2785. end
  2786.  
  2787. #==============================================================================
  2788. # ** Menu_Monster_Window
  2789. #------------------------------------------------------------------------------
  2790. #  Esta classe mostra as informações de um monstro
  2791. #==============================================================================
  2792. class Menu_Monster_Window < Menu_Base_Window
  2793.   attr_reader :monster
  2794.   #-------------------------------------------------------------------------
  2795.   # * Inicialização
  2796.   #     monster : Monstro (RPG::Enemy)
  2797.   #     x       : Posição X inicial da janela
  2798.   #     y       : Posição Y inicial da janela
  2799.   #     w       : Largura
  2800.   #     h       : Altura
  2801.   #-------------------------------------------------------------------------
  2802.   def initialize(monster, x, y, w, h)
  2803.     super(x, y, w, h)
  2804.     self.applyFont(self.contents)
  2805.     self.opacity = 0
  2806.    
  2807.     @fill = Bitmap.new(276, contents_height)
  2808.     @fill.fill_rect(@fill.rect, Color.new(0, 0, 0, 127))
  2809.    
  2810.     self.monster = monster
  2811.   end
  2812.   #-------------------------------------------------------------------------
  2813.   # * Determina inimigo que deverá ser mostrado
  2814.   #     monster : Novo inimigo (RPG::Enemy)
  2815.   #-------------------------------------------------------------------------
  2816.   def monster=(monster)
  2817.     @monster = monster
  2818.     return unless @monster
  2819.     @battler = Cache.battler(@monster.battler_name, @monster.battler_hue)
  2820.     refresh
  2821.   end
  2822.   #-------------------------------------------------------------------------
  2823.   # Desenho da janela
  2824.   #-------------------------------------------------------------------------
  2825.   def refresh
  2826.     contents.clear
  2827.    
  2828.     contents.blt(
  2829.       contents_width - @battler.width,
  2830.       contents_height - @battler.height,
  2831.       @battler, @battler.rect
  2832.     )
  2833.     contents.blt(0, 0, @fill, @fill.rect)
  2834.    
  2835.     lh = line_height
  2836.     ay = lh * 4
  2837.    
  2838.     change_color(system_color)
  2839.     draw_text(6, 0, 124, line_height, @monster.name, 1)
  2840.     draw_text(6, ay += lh, 124, line_height, Vocab[:Experience])
  2841.     draw_text(6, ay += lh + lh, 124, line_height, Vocab[:Loot], 1)
  2842.     change_color(normal_color)
  2843.    
  2844.     ay = lh
  2845.    
  2846.     draw_hp(6, ay += lh)
  2847.     draw_mp(6, ay += lh)
  2848.     draw_text(6, ay += lh * 2, 124, line_height, @monster.exp, 2)
  2849.     ay += lh * 2
  2850.    
  2851.     draw_icon(Icon[:Gold], 6, ay += lh)
  2852.     draw_text(30, ay, 80, line_height, @monster.gold, 1)
  2853.    
  2854.     if @monster.drop_items.any?{|item| item.kind != 0}
  2855.       @monster.drop_items.each{|item|
  2856.         next if item.kind.zero?
  2857.         draw_item_name(item_object(item.kind, item.data_id), 6, ay += lh)
  2858.       }
  2859.     end
  2860.    
  2861.     ay = -lh
  2862.     6.times{|index| draw_param(144, ay += lh, index + 2) }
  2863.    
  2864.   end
  2865.   #--------------------------------------------------------------------------
  2866.   # * Aquisição das informações do item
  2867.   #     kind    : tipo do item
  2868.   #     data_id : ID do item
  2869.   #--------------------------------------------------------------------------
  2870.   def item_object(kind, data_id)
  2871.     return $data_items  [data_id] if kind == 1
  2872.     return $data_weapons[data_id] if kind == 2
  2873.     return $data_armors [data_id] if kind == 3
  2874.     return nil
  2875.   end
  2876.   #--------------------------------------------------------------------------
  2877.   # * Desenho do HP
  2878.   #     x      : coordenada X
  2879.   #     y      : coordenada Y
  2880.   #     width  : largura
  2881.   #--------------------------------------------------------------------------
  2882.   def draw_hp(x, y, width = 124)
  2883.     gc1 = Color.new( 56,  80, 14, 192)
  2884.     gc2 = Color.new(168, 240, 62, 192)
  2885.    
  2886.     draw_special_gauge(x, y, width, 1, gc1, gc2)
  2887.    
  2888.     change_color(system_color)
  2889.     draw_text(x + width/2 - 20, y, 30, line_height, ::Vocab::hp_a)
  2890.     change_color(normal_color)
  2891.     draw_text(x + width/2 + 5, y, width/2, line_height, @monster.params[0])
  2892.   end
  2893.   #--------------------------------------------------------------------------
  2894.   # * Desenho do MP
  2895.   #     x      : coordenada X
  2896.   #     y      : coordenada Y
  2897.   #     width  : largura
  2898.   #--------------------------------------------------------------------------
  2899.   def draw_mp(x, y, width = 124)
  2900.     gc1 = Color.new(14,  56,  80, 192)
  2901.     gc2 = Color.new(62, 168, 240, 192)
  2902.    
  2903.     draw_special_gauge(x, y, width, 1, gc1, gc2)
  2904.    
  2905.     change_color(system_color)
  2906.     draw_text(x + width/2 - 20, y, 30, line_height, ::Vocab::mp_a)
  2907.     change_color(normal_color)
  2908.     draw_text(x + width/2 + 5, y, width/2, line_height, @monster.params[1])
  2909.   end
  2910.   #--------------------------------------------------------------------------
  2911.   # * Desenho dos parâmetros
  2912.   #     x        : coordenada X
  2913.   #     y        : coordenada Y
  2914.   #     param_id : ID do parâmetro
  2915.   #--------------------------------------------------------------------------
  2916.   def draw_param(x, y, param_id)
  2917.     change_color(system_color)
  2918.     draw_text(x, y, 120, line_height, ::Vocab::param(param_id))
  2919.     change_color(normal_color)
  2920.     draw_text(x + 90, y, 36, line_height, @monster.params[param_id], 2)
  2921.     change_color(normal_color)
  2922.   end
  2923. end
  2924.  
  2925. #==============================================================================
  2926. # ** Menu_SaveFile_Window
  2927. #------------------------------------------------------------------------------
  2928. #  Mostra a informação de save e criação de novo jogo
  2929. #==============================================================================
  2930. class Menu_SaveFile_Window < Menu_Base_Window
  2931.   attr_reader :active
  2932.   attr_reader :exist
  2933.   attr_reader :index
  2934.   #-------------------------------------------------------------------------
  2935.   # * Inicialização
  2936.   #     x     : Posição X inicial da janela
  2937.   #     y     : Posição Y inicial da janela
  2938.   #     w     : Largura
  2939.   #     h     : Altura
  2940.   #     index : Index do save
  2941.   #     exist : Save existe? (Se não, será criada uma janela de "Novo Save"
  2942.   #-------------------------------------------------------------------------
  2943.   def initialize(x, y, w, h, index, exist)
  2944.     super(x, y, w, h)
  2945.     self.opacity = 0
  2946.     self.applyFont(contents)
  2947.    
  2948.     @active  = false
  2949.     @pattern = 0
  2950.     self.load_data(index, exist)
  2951.    
  2952.     @blankRect = Rect.new
  2953.    
  2954.     refresh(true)
  2955.   end
  2956.   #-------------------------------------------------------------------------
  2957.   # * Carregamento da informação do save
  2958.   #     index : Index do save
  2959.   #     header : Save existe? (Se não, será criada uma janela de "Novo Save"
  2960.   #-------------------------------------------------------------------------
  2961.   def load_data(index, header)
  2962.     @index = index
  2963.     if header
  2964.       @data    = header
  2965.       @preview = Bitmap.new_from_data(@data[:preview], 157)
  2966.     end
  2967.    
  2968.     @previewRect = Rect.new(0, line_height, contents_width, line_height)
  2969.   end
  2970.   #-------------------------------------------------------------------------
  2971.   # * Atualização
  2972.   #-------------------------------------------------------------------------
  2973.   def update
  2974.     super
  2975.     if (Graphics.frame_count % Graphics.frame_rate) == 0
  2976.       refresh
  2977.     elsif (Graphics.frame_count % ActorsSpeed) == 0
  2978.       @pattern += 1
  2979.       @pattern %= 3
  2980.       redraw_chars
  2981.     end
  2982.   end
  2983.   #-------------------------------------------------------------------------
  2984.   # * Redesenha janela
  2985.   #   complete : Redesenho completo?
  2986.   #-------------------------------------------------------------------------
  2987.   def refresh(complete = false)
  2988.     if complete
  2989.       contents.clear
  2990.       if @data
  2991.         contents.blt(0, line_height, @preview, @preview.rect)
  2992.         @previewRect.y = 86 + 4 * line_height
  2993.         draw_text(@previewRect, @data[:playtime_s], 1)
  2994.       else
  2995.         change_color(system_color)
  2996.         draw_text(@previewRect, Vocab[:FreeSlot], 1)
  2997.         change_color(normal_color)
  2998.         @previewRect.y += line_height
  2999.         draw_text(@previewRect, Vocab[:NewSave], 1)
  3000.       end
  3001.      
  3002.       change_color(system_color)
  3003.       @previewRect.y = 86 + 3 * line_height
  3004.       draw_text(@previewRect, Vocab[:PlayTime], 1)
  3005.       @previewRect.y = 86 + 6 * line_height
  3006.       draw_text(@previewRect, Vocab[:Party], 1)
  3007.       change_color(normal_color)
  3008.     elsif !@data
  3009.       @previewRect.y = 86 + 4 * line_height
  3010.       contents.clear_rect(@previewRect)
  3011.       draw_text(@previewRect, $game_system.playtime_s, 1)
  3012.     end
  3013.    
  3014.     redraw_chars
  3015.   end
  3016.   #-------------------------------------------------------------------------
  3017.   # * Redesenha atores
  3018.   #-------------------------------------------------------------------------
  3019.   def redraw_chars
  3020.     y = 86 + line_height * 7
  3021.     contents.clear_rect(0, y, contents_width, contents_height - y)
  3022.     if @data
  3023.       space = (contents_width / @data[:characters].size)
  3024.       @data[:characters].each_with_index{|data, index|
  3025.         draw_character(data[0], data[1], (index + 0.5) * space, y)        
  3026.       }
  3027.     else
  3028.       chars = $game_party.battle_members
  3029.       space = (contents_width / chars.size)
  3030.       chars.each_with_index{|char, index|
  3031.         draw_character(char.character_name, char.character_index, (index + 0.5) * space, y)
  3032.       }
  3033.     end
  3034.   end
  3035.   #--------------------------------------------------------------------------
  3036.   # * Desenho do gráfico do personagem
  3037.   #     character_name  : nome do gráfico do personagem
  3038.   #     character_index : índice do gráfico de personagem
  3039.   #     x               : coordenada X
  3040.   #     y               : coordenada Y
  3041.   #--------------------------------------------------------------------------
  3042.   def draw_character(character_name, character_index, x, y)
  3043.     return unless character_name
  3044.     bitmap = Cache.character(character_name)
  3045.     sign = character_name[/^[\!\$]./]
  3046.     if sign && sign.include?('$')
  3047.       cw = bitmap.width / 3
  3048.       ch = bitmap.height / 4
  3049.     else
  3050.       cw = bitmap.width / 12
  3051.       ch = bitmap.height / 8
  3052.     end
  3053.     n = character_index
  3054.     src_rect = Rect.new((n%4*3+@pattern)*cw, (n/16)*ch, cw, ch)
  3055.     contents.blt(x - cw / 2, y, bitmap, src_rect)
  3056.    
  3057.     return cw
  3058.   end
  3059.   #-------------------------------------------------------------------------
  3060.   # * Determina se a janela é de novo save ou já possui um
  3061.   #-------------------------------------------------------------------------
  3062.   def exist
  3063.     return !!@data
  3064.   end
  3065.   #-------------------------------------------------------------------------
  3066.   # * Determina estado de atividade
  3067.   #   state : Ativa ou não a janela
  3068.   #-------------------------------------------------------------------------
  3069.   def active=(state)
  3070.     @active = state
  3071.     self.cursor_rect.set(@active ? contents.rect : @blankRect)
  3072.   end
  3073. end
  3074. #==============================================================================
  3075. # ** StaticMiniMap
  3076. #------------------------------------------------------------------------------
  3077. # Classe responsável por gerar um mini-map estático que será usado no menu
  3078. #==============================================================================
  3079. class StaticMiniMap  
  3080.   include MRM::ExtremeMenu
  3081.  
  3082.   attr_reader :viewport
  3083.  
  3084.   #-------------------------------------------------------------------------
  3085.   # * Inicialização do objeto
  3086.   #     viewport : Camada de visibilidade
  3087.   #-------------------------------------------------------------------------
  3088.   def initialize(viewport)
  3089.     @viewport = viewport
  3090.     @opacity  = 255
  3091.    
  3092.     precalculus
  3093.     refresh
  3094.    
  3095.     sx = -$game_player.real_x * TileSize + MapOffset
  3096.     sy = -$game_player.real_y * TileSize + MapOffset
  3097.     @map.x = @object_layer.x = sx
  3098.     @map.y = @object_layer.y = sy
  3099.    
  3100.     draw_object_layer
  3101.   end
  3102.   #-------------------------------------------------------------------------
  3103.   # * Realiza pré-calculo
  3104.   #-------------------------------------------------------------------------
  3105.   def precalculus
  3106.     @finalSize = [
  3107.       $game_map.width  * TileSize + @viewport.rect.width,
  3108.       $game_map.height * TileSize + @viewport.rect.height
  3109.     ]
  3110.    
  3111.     @halfWidth  = @viewport.rect.width  / 2
  3112.     @halfHeight = @viewport.rect.height / 2
  3113.    
  3114.     @tsm2 = TileSize - 2
  3115.    
  3116.     @objColor = {}
  3117.     ObjectColor.each_pair{|key, value|
  3118.       @objColor[key] = Color.new(*value)
  3119.     }
  3120.    
  3121.     @playerColor    = Color.new(*PlayerColor)
  3122.     @mapColor       = Color.new(*MapColor)
  3123.     @mapBorderColor = Color.new(*MapBorderColor)
  3124.     @borderColor    = Color.new(*BorderColor)
  3125.   end
  3126.   #-------------------------------------------------------------------------
  3127.   # * Desenha o conteúdo
  3128.   #-------------------------------------------------------------------------
  3129.   def refresh
  3130.     @map        = Sprite.new(@viewport)
  3131.     @map.z      = 0
  3132.     @map.bitmap = draw_map
  3133.    
  3134.     @object_layer         = Sprite.new(@viewport)
  3135.     @object_layer.z       = 1
  3136.     @object_layer.bitmap  = Bitmap.new(*@finalSize)
  3137.     @object_layer.opacity = ObjectLayerOpacity
  3138.    
  3139.     draw_object_layer
  3140.   end
  3141.   #-------------------------------------------------------------------------
  3142.   # * Desenha a camada com eventos e com o jogador
  3143.   #-------------------------------------------------------------------------
  3144.   def draw_object_layer
  3145.     comment = [108, 408]
  3146.     for event in $game_map.events.keys
  3147.       next unless $game_map.events[event].list
  3148.       $game_map.events[event].list.each{|item|
  3149.         next unless comment.include?(item.code)
  3150.         type = item.parameters[0]
  3151.         next unless @objColor.has_key?(type)
  3152.         draw_object($game_map.events[event], @objColor[type])
  3153.       }
  3154.     end
  3155.    
  3156.     draw_object($game_player, @playerColor)
  3157.   end
  3158.   #-------------------------------------------------------------------------
  3159.   # * Desenha um character
  3160.   #     obj   : Game_Character
  3161.   #     color : Cor de preenchimento
  3162.   #-------------------------------------------------------------------------
  3163.   def draw_object(obj, color)
  3164.     x = obj.real_x * TileSize + @halfWidth
  3165.     y = obj.real_y * TileSize + @halfHeight
  3166.    
  3167.     @object_layer.bitmap.fill_rect(x + 1,     y,    @tsm2, TileSize, @borderColor)
  3168.     @object_layer.bitmap.fill_rect(    x, y + 1, TileSize,    @tsm2, @borderColor)
  3169.     @object_layer.bitmap.fill_rect(x + 1, y + 1,    @tsm2,    @tsm2, color)
  3170.   end
  3171.   #-------------------------------------------------------------------------
  3172.   # * Desenha os obstáculos do mapa
  3173.   #-------------------------------------------------------------------------
  3174.   def draw_map
  3175.     front  = make_map_bitmap(@mapColor)
  3176.     border = make_map_bitmap(@mapBorderColor)
  3177.    
  3178.     result = Bitmap.new(*@finalSize)
  3179.                        
  3180.     result.blt(-1,  0, border, border.rect)
  3181.     result.blt( 1,  0, border, border.rect)
  3182.     result.blt( 0, -1, border, border.rect)
  3183.     result.blt( 0,  1, border, border.rect)
  3184.     result.blt( 0,  0, front,  front.rect )
  3185.    
  3186.     return result
  3187.   end
  3188.   #-------------------------------------------------------------------------
  3189.   # * Desenha os obstáculos do mapa em determinada cor
  3190.   #     color : Cor de destino
  3191.   #-------------------------------------------------------------------------
  3192.   def make_map_bitmap(color)
  3193.     bitmap = Bitmap.new(*@finalSize)
  3194.    
  3195.     $game_map.width.times{|x| $game_map.height.times{|y|
  3196.       next if $game_map.passable?(x, y, 4)
  3197.       ax = x * TileSize + @halfWidth
  3198.       ay = y * TileSize + @halfHeight
  3199.       bitmap.fill_rect(ax, ay, TileSize, TileSize, color)
  3200.     }}
  3201.    
  3202.     return bitmap
  3203.   end
  3204.   #-------------------------------------------------------------------------
  3205.   # * Retorna coordenada X
  3206.   #-------------------------------------------------------------------------
  3207.   def x
  3208.     return @viewport.rect.x
  3209.   end
  3210.   #-------------------------------------------------------------------------
  3211.   # * Redefine a coordenada X
  3212.   #     value : Nova coordenada
  3213.   #-------------------------------------------------------------------------
  3214.   def x=(value)
  3215.     @viewport.rect.x = value
  3216.   end
  3217.   #-------------------------------------------------------------------------
  3218.   # * Retorna opacidade
  3219.   #-------------------------------------------------------------------------
  3220.   def opacity
  3221.     return @opacity
  3222.   end
  3223.   #-------------------------------------------------------------------------
  3224.   # * Redefine a opacidade
  3225.   #     value : Nova opacidade
  3226.   #-------------------------------------------------------------------------
  3227.   def opacity=(value)
  3228.     @opacity = value
  3229.     @map.opacity = value
  3230.     @object_layer.opacity = value * ObjectLayerOpacity / 255.0
  3231.   end
  3232.   #-------------------------------------------------------------------------
  3233.   # * Dispõe o conjunto
  3234.   #-------------------------------------------------------------------------
  3235.   def dispose
  3236.     @map.dispose
  3237.     @object_layer.dispose
  3238.   end
  3239. end
  3240. #==============================================================================
  3241. # ** Menu_Options_Window
  3242. #------------------------------------------------------------------------------
  3243. # Classe controladora das opções no menu
  3244. #==============================================================================
  3245. class Menu_Options_Window < Menu_Base_Window
  3246.   attr_accessor :barActive
  3247.   attr_reader   :index
  3248.  
  3249.   #-------------------------------------------------------------------------
  3250.   # * Inicialização
  3251.   #     x     : Posição X inicial da janela
  3252.   #     y     : Posição Y inicial da janela
  3253.   #     w     : Largura
  3254.   #     h     : Altura
  3255.   #-------------------------------------------------------------------------
  3256.   def initialize(x, y, w, h)
  3257.     super(x, y, w, h)
  3258.     self.opacity = 0
  3259.     self.applyFont(self.contents)
  3260.    
  3261.     cx = contents_width/2
  3262.    
  3263.     @rect = {
  3264.       sfx:   Rect.new(0,        line_height * 4, cx * 2, line_height * 2),
  3265.       music: Rect.new(cx - 140, line_height * 6, 125,    line_height    ),
  3266.       sound: Rect.new(cx - 140, line_height * 7, 125,    line_height    )
  3267.     }
  3268.    
  3269.     @barActive = false
  3270.     @index     = 0
  3271.    
  3272.     refresh
  3273.     self.index = -1
  3274.   end
  3275.   #-------------------------------------------------------------------------
  3276.   # * Redesenha conteúdo
  3277.   #-------------------------------------------------------------------------
  3278.   def refresh
  3279.     contents.clear
  3280.    
  3281.     # Texto
  3282.     change_color(system_color)
  3283.     contents.font.size *= 1.1
  3284.     contents.draw_text(@rect[:sfx],   Vocab[:OptionsSFX], 1)
  3285.     contents.font.size /= 1.1
  3286.     change_color(normal_color)
  3287.     contents.draw_text(@rect[:music], Vocab[:OptionsMsc], 1)
  3288.     contents.draw_text(@rect[:sound], Vocab[:OptionsSnd], 1)
  3289.    
  3290.     # Barras
  3291.     drawRect(:music, $game_system.musicRate)
  3292.     drawRect(:sound, $game_system.soundRate)
  3293.   end
  3294.   #-------------------------------------------------------------------------
  3295.   # * Desenha Barra
  3296.   #   type : Tipo
  3297.   #   rate : Proporção do preenchimento
  3298.   #-------------------------------------------------------------------------
  3299.   def drawRect(type, rate)
  3300.     rect = Rect.new.set(@rect[type])
  3301.     rect.x      += rect.width + 26
  3302.     rect.y      += 3
  3303.     rect.width  -= 6
  3304.     rect.height -= 10
  3305.  
  3306.     gc1 = Color.new(14 * rate,  80 - 24 * rate, 80 * rate, 192)
  3307.     gc2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  3308.    
  3309.     draw_special_gauge(rect.x, rect.y, rect.width, rect.height, rate, gc1, gc2)
  3310.    
  3311.     change_color(system_color)
  3312.     draw_text(rect, "-   #{(rate * 100).round}%   +", 1)
  3313.     change_color(normal_color)
  3314.   end
  3315.   #-------------------------------------------------------------------------
  3316.   # * Desenha a barra especial estilo Cogwheel
  3317.   #     x      : Posição X
  3318.   #     y      : Posição Y
  3319.   #     width  : Largura
  3320.   #     height : Altura
  3321.   #     rate   : Porção de preenchimento
  3322.   #     gc1    : Cor 1
  3323.   #     gc2    : Cor 2
  3324.   #-------------------------------------------------------------------------
  3325.   def draw_special_gauge(x, y, width, height, rate, gc1, gc2)
  3326.     y += line_height/2
  3327.     contents.fill_rect(x, y - 10, width, height, BC1)
  3328.     contents.fill_rect(x + 1, y -  9,  width - 2,  height - 2, BC2)
  3329.     contents.gradient_fill_rect(x + 2, y - 8, width - 4, height - 4, BC3, BC4)
  3330.     contents.gradient_fill_rect(x + 2, y - 8, (width*rate) - 4, height-4, gc1, gc2)    
  3331.   end
  3332.   #-------------------------------------------------------------------------
  3333.   # * Atualização do índice
  3334.   #-------------------------------------------------------------------------
  3335.   def index=(value)
  3336.     @index = value
  3337.     if (@index == -1)
  3338.       self.cursor_rect.set(0,0,0,0)
  3339.     else
  3340.       _rect = @rect[@index == 0 ? :music : :sound].dup
  3341.       if @barActive
  3342.         _rect.x      += _rect.width + 25
  3343.         _rect.y      += 4
  3344.         _rect.width  -= 4
  3345.         _rect.height -= 8
  3346.       end
  3347.      
  3348.       self.cursor_rect.set(_rect)
  3349.     end
  3350.   end
  3351. end
  3352.  
  3353. # Remove menu anterior
  3354. Object.send(:remove_const, :Scene_Menu)
  3355.  
  3356. #==============================================================================
  3357. # ** Scene_Menu
  3358. #------------------------------------------------------------------------------
  3359. #  Esta classe executa o processamento da tela de menu.
  3360. #==============================================================================
  3361. class Scene_Menu < Scene_Base
  3362.  
  3363.   #-------------------------------------------------------------------------
  3364.   # * Início da cena
  3365.   #-------------------------------------------------------------------------
  3366.   def start
  3367.     super
  3368.    
  3369.     @stage           = :Base
  3370.     @baseIndex       = 0
  3371.     @itemIndex       = 0
  3372.     @equipsIndex     = 0
  3373.     @skillsIndex     = 0
  3374.     @formationIndex1 = 0
  3375.     @formationIndex2 = 0
  3376.     @statusIndex     = 0
  3377.     @bestiaryIndex   = 0
  3378.     @pdistIndex      = 0
  3379.     @optionIndex     = 0
  3380.     @saveIndex       = 0
  3381.     @saveOverIndex   = 0
  3382.     @exitIndex       = 0
  3383.    
  3384.     @removedFormationWin = nil
  3385.     @iconset         = Cache.system("Iconset")
  3386.    
  3387.     # Flag necessária para remover lag
  3388.     # de inicialização do menu.
  3389.     @__NeedRefresh = []
  3390.    
  3391.     load_vocabulary
  3392.     process_move_data
  3393.     create_background
  3394.     create_icons
  3395.     if @baseIcons.size > 0
  3396.       create_cursor
  3397.       create_message
  3398.     end
  3399.     create_windows
  3400.     create_minimap if @baseIcons.size > 0
  3401.    
  3402.     #RPG::BGM.fade(@winsEnter[:time] * 1000)
  3403.     #RPG::BGS.fade(@winsEnter[:time] * 1000)
  3404.   end
  3405.   #-------------------------------------------------------------------------
  3406.   # * Atualização da cena
  3407.   #-------------------------------------------------------------------------
  3408.   def update
  3409.     super
  3410.     Tween.update
  3411.     if @baseIcons.size == 0
  3412.       process_return if Input.trigger?(:B)
  3413.       return
  3414.     end
  3415.    
  3416.     update_input
  3417.    
  3418.     # Faz processo de desenho das janelas de distribuição
  3419.     # de pontos. Este é um método necessário para remover
  3420.     # o lag de inicialização do menu, simulando uma espé-
  3421.     # cie de processo paralelo entre os frames. Garante
  3422.     # que as janelas existam mas remove o tempo inicial
  3423.     # usado para desenho e distribui entre os frames até
  3424.     # que todas as janelas tenham sido desenhadas.
  3425.     unless @__NeedRefresh.empty?
  3426.       if Graphics.frame_count % (Graphics.frame_rate/5) == 0
  3427.         @__NeedRefresh.shift.refresh
  3428.       end
  3429.     end
  3430.  
  3431.     case @stage
  3432.     when :Base, :Exit, :Formation, :Equips, :Skills
  3433.       update_actors_windows
  3434.     when :Items, :ItemsSelection, :EquipsTrade
  3435.       update_items_window
  3436.     when :ItemsActorSelection, :SkillsActorSelection
  3437.       @actorSelect.update
  3438.     when :EquipsSelection
  3439.       update_equips_windows
  3440.     when :SkillsTSelection, :SkillsSelection
  3441.       update_skills_windows
  3442.     when :PDist
  3443.       update_pdist_windows
  3444.     when :Save, :SaveOverWrite
  3445.       update_save_windows
  3446.     when :FormationNextActor
  3447.       @actorsWindows[@formationIndex1].update
  3448.       update_formation_windows
  3449.     end
  3450.   end
  3451.   #-------------------------------------------------------------------------
  3452.   # * Finalização da cena
  3453.   #-------------------------------------------------------------------------
  3454.   def terminate
  3455.     super
  3456.     dispose_background
  3457.     return dispose_actors_windows if @baseIcons.size == 0
  3458.     dispose_icons
  3459.     dispose_cursor
  3460.     dispose_message
  3461.     dispose_windows
  3462.   end
  3463.   #-------------------------------------------------------------------------
  3464.   # * Carrega informação de vocabulário
  3465.   #-------------------------------------------------------------------------
  3466.   def load_vocabulary
  3467.     @baseVocab = MRM::ExtremeMenu.enabledOptions(:name)
  3468.     @itemVocab = MRM::ExtremeMenu.enabledSubOption(:Items, :Names)
  3469.     @saveVocab = MRM::ExtremeMenu.enabledSubOption(:Save,  :Names)
  3470.     @exitVocab = MRM::ExtremeMenu.enabledSubOption(:Exit,  :Names)
  3471.   end
  3472.   #-------------------------------------------------------------------------
  3473.   # * Processa informação de movimento
  3474.   #-------------------------------------------------------------------------
  3475.   def process_move_data
  3476.     [
  3477.       [:IconsEnter,     :@iconsEnter    ],
  3478.       [:IconsMove,      :@iconsMove     ],
  3479.       [:CursorEnter,    :@cursorEnter   ],
  3480.       [:CursorMove,     :@cursorMove    ],
  3481.       [:Message,        :@messageAnim   ],
  3482.       [:ActorSelEnter,  :@actorSelEnter ],
  3483.       [:ActorSelMove,   :@actorSelMove  ],
  3484.       [:ItemsEnter,     :@itemsEnter    ],
  3485.       [:ItemsMove,      :@itemsMove     ],
  3486.       [:EquipsEnter,    :@equipsEnter   ],
  3487.       [:EquipsMove,     :@equipsMove    ],
  3488.       [:SkillsEnter,    :@skillsEnter   ],
  3489.       [:SkillsMove,     :@skillsMove    ],
  3490.       [:WindowsEnter,   :@winsEnter     ],
  3491.       [:WindowsMove,    :@winsMove      ],
  3492.       [:SaveEnter,      :@saveEnter     ],
  3493.       [:SaveMove,       :@saveMove      ],
  3494.       [:StatusEnter,    :@statusEnter   ],
  3495.       [:StatusMove,     :@statusMove    ],
  3496.       [:BestiaryEnter,  :@bestiaryEnter ],
  3497.       [:BestiaryMove,   :@bestiaryMove  ],
  3498.       [:PDistEnter,     :@pdistEnter    ],
  3499.       [:PDistMove,      :@pdistMove     ],
  3500.       [:MiniMapEnter,   :@minimapEnter  ],
  3501.       [:MiniMapMove,    :@minimapMove   ],
  3502.       [:OptionEnter,    :@optionEnter   ],
  3503.       [:FormationEnter, :@formationEnter],
  3504.       [:FormationMove,  :@formationMove ],
  3505.     ].each{|key, var|
  3506.       data  = MRM::ExtremeMenu::Animation[key]
  3507.       moveData = {
  3508.         :style => Tween::EASERS[data[0]] || Tween::Linear,
  3509.         :time  => data[1]
  3510.       }
  3511.       moveData[:off] = data[2] if data[2]
  3512.       self.instance_variable_set(var, moveData)
  3513.     }
  3514.   end
  3515.   #-------------------------------------------------------------------------
  3516.   # * Cria fundo
  3517.   #-------------------------------------------------------------------------
  3518.   def create_background
  3519.     @background_sprite = Sprite.new
  3520.     @background_sprite.bitmap = SceneManager.background_bitmap
  3521.     @background_sprite.color.set(16, 16, 16, 128)
  3522.   end
  3523.   #-------------------------------------------------------------------------
  3524.   # * Cria ícones
  3525.   #-------------------------------------------------------------------------
  3526.   def create_icons
  3527.     create_base_icons
  3528.     create_item_icons
  3529.     create_save_icons if MRM::ExtremeMenu::ConfirmOverwrite
  3530.     create_exit_icons
  3531.   end
  3532.   #-------------------------------------------------------------------------
  3533.   # * Cria ícones base
  3534.   #-------------------------------------------------------------------------
  3535.   def create_base_icons
  3536.     icons  = MRM::ExtremeMenu.enabledOptions(:icon)
  3537.     @baseIcons = self.create_generic_icons(icons)
  3538.   end
  3539.   #-------------------------------------------------------------------------
  3540.   # * Cria ícones de itens
  3541.   #-------------------------------------------------------------------------
  3542.   def create_item_icons
  3543.     icons      = MRM::ExtremeMenu.enabledSubOption(:Items, :Icons)
  3544.     @itemIcons = self.create_generic_icons(icons, false)
  3545.   end
  3546.   #-------------------------------------------------------------------------
  3547.   # * Cria ícones de save (confirmação de sobreescrita)
  3548.   #-------------------------------------------------------------------------
  3549.   def create_save_icons
  3550.     icons      = MRM::ExtremeMenu.enabledSubOption(:Save, :Icons)
  3551.     @saveIcons = self.create_generic_icons(icons, false)
  3552.   end
  3553.   #-------------------------------------------------------------------------
  3554.   # * Cria ícones de saída
  3555.   #-------------------------------------------------------------------------
  3556.   def create_exit_icons
  3557.     icons      = MRM::ExtremeMenu.enabledSubOption(:Exit, :Icons)
  3558.     @exitIcons = self.create_generic_icons(icons, false)
  3559.   end
  3560.   #-------------------------------------------------------------------------
  3561.   # * Cria cursor
  3562.   #-------------------------------------------------------------------------
  3563.   def create_cursor
  3564.     b = self.applyFont(Bitmap.new(1,1))
  3565.    
  3566.     s = (@baseVocab + @exitVocab).inject([0,0]){|max,act|
  3567.       v = b.text_size(act)
  3568.       [
  3569.         v.width  > max[0] ? v.width  : max[0],
  3570.         v.height > max[1] ? v.height : max[1]
  3571.       ]
  3572.     }
  3573.    
  3574.     b.dispose
  3575.    
  3576.     @cursor         = Sprite.new
  3577.     @cursor.opacity = 0
  3578.     @cursor.bitmap  = self.applyFont(Bitmap.new(*s))
  3579.     @cursor.ox      = @cursor.width / 2.0
  3580.     @cursor.x       = Graphics.width / (2 * @baseIcons.size)
  3581.     @cursor.y       = @baseIcons.first.y - @cursor.height - 60
  3582.     @cursor.bitmap.draw_text(0, 0, *s, @baseVocab.first, 1)
  3583.    
  3584.     Tween.start(@cursor, @cursorEnter[:style], @cursorEnter[:time],
  3585.       :opacity => 255
  3586.     )
  3587.   end
  3588.   #-------------------------------------------------------------------------
  3589.   # * Cria mensagem
  3590.   #-------------------------------------------------------------------------
  3591.   def create_message
  3592.     s = self.applyFont(Bitmap.new(1,1))
  3593.     sz = s.text_size("www.mundorpgmaker.com")
  3594.    
  3595.     @message         = Sprite.new
  3596.     @message.bitmap  = self.applyFont(Bitmap.new(Graphics.width, sz.height))
  3597.     @message.y       = @cursor.y - sz.height - 8
  3598.     @message.opacity = 0
  3599.    
  3600.     s.dispose
  3601.   end
  3602.   #-------------------------------------------------------------------------
  3603.   # * Cria janelas
  3604.   #-------------------------------------------------------------------------
  3605.   def create_windows
  3606.     create_actors_windows
  3607.     return if @baseIcons.size == 0
  3608.     create_items_windows
  3609.     create_equips_window
  3610.     create_skills_windows
  3611.     create_status_windows
  3612.     create_formation_windows
  3613.     create_bestiary_windows
  3614.     create_pdist_windows
  3615.     create_options_window
  3616.     create_save_windows
  3617.     create_actor_select_window
  3618.   end
  3619.   #-------------------------------------------------------------------------
  3620.   # * Cria as janelas de informação base dos atores
  3621.   #-------------------------------------------------------------------------
  3622.   def create_actors_windows
  3623.     size   = $game_party.battle_members.size
  3624.     width  = Graphics.width / size
  3625.     height = @cursor ? @cursor.y - 16 : Graphics.width
  3626.        
  3627.     baseX = size == 1 ? (width /= 2) / 2 : 0
  3628.    
  3629.     @actorsWindows = $game_party.battle_members.map.with_index{|actor, index|
  3630.       win = Menu_ActorBase_Window.new(actor, Graphics.width, 0, width, height)
  3631.       Tween.start(win, @winsEnter[:style], @winsEnter[:time], @winsEnter[:off] * index,
  3632.         :contents_opacity => 255,
  3633.         :x => baseX + (width * index)
  3634.       )
  3635.       win
  3636.     }
  3637.   end
  3638.   #-------------------------------------------------------------------------
  3639.   # * Cria janelas de itens
  3640.   #-------------------------------------------------------------------------
  3641.   def create_items_windows
  3642.     x, y, w, h = Graphics.width, 0, Graphics.width/2, @cursor.y - 16
  3643.    
  3644.     @itemsWindow                  = Menu_Item_Window.new(x, y, w, h)
  3645.     @itemsWindow.active           = false
  3646.     @itemsWindow.opacity          = 0
  3647.     @itemsWindow.contents_opacity = 0
  3648.    
  3649.     @itemsInfo = Menu_ItemInfo_Window.new(x, y, Graphics.width - w, h)
  3650.     @itemsWindow.info = @itemsInfo
  3651.   end
  3652.   #-------------------------------------------------------------------------
  3653.   # * Cria janelas de equipamentos
  3654.   #-------------------------------------------------------------------------
  3655.   def create_equips_window
  3656.     @equipsWindow = Menu_Equips_Window.new(Graphics.width, 0, Graphics.width/2)
  3657.     @equipsWindow.info = @itemsInfo
  3658.   end
  3659.   #-------------------------------------------------------------------------
  3660.   # * Cria janelas de habilidades
  3661.   #-------------------------------------------------------------------------
  3662.   def create_skills_windows
  3663.     x, y, w, h = Graphics.width, 0, Graphics.width / 2, @cursor.y - 16
  3664.     @stypeWindow = Menu_SkillCommand_Window.new(x, y, w, h)
  3665.     @slistWindow = Menu_SkillList_Window.new(x, y, w, h)
  3666.     @stypeWindow.contents_opacity = 0
  3667.     @slistWindow.contents_opacity = 0
  3668.     @stypeWindow.skill_window     = @slistWindow
  3669.     @slistWindow.info             = @itemsInfo
  3670.   end
  3671.   #-------------------------------------------------------------------------
  3672.   # * Cria janelas de formação
  3673.   #-------------------------------------------------------------------------
  3674.   def create_formation_windows
  3675.     size   = $game_party.battle_members.size
  3676.     x      = Graphics.width / size
  3677.     y      = Graphics.height
  3678.     width  = Graphics.width - x
  3679.     height = (@cursor.y - 16) / 3
  3680.    
  3681.     @formationWindows = $game_party.members.map.with_index{|actor, index|
  3682.       win = Menu_Formation_Window.new(actor, x, y, width, height)
  3683.       win.contents_opacity = 0
  3684.       win
  3685.     }
  3686.    
  3687.     @__NeedRefresh += @formationWindows
  3688.   end
  3689.   #-------------------------------------------------------------------------
  3690.   # * Cria janelas de informação completa dos atores
  3691.   #-------------------------------------------------------------------------
  3692.   def create_status_windows
  3693.     width = Graphics.width
  3694.     height = @cursor.y - 16
  3695.     @statusWindows = $game_party.members.map.with_index{|actor, index|
  3696.       win = Menu_ActorFull_Window.new(actor, Graphics.width, 0, width, height)
  3697.       win.contents_opacity = 0
  3698.       win
  3699.     }
  3700.     @__NeedRefresh += @statusWindows
  3701.   end
  3702.   #-------------------------------------------------------------------------
  3703.   # * Cria janelas de monstros do bestiário
  3704.   #-------------------------------------------------------------------------
  3705.   def create_bestiary_windows
  3706.     x, y, w, h = Graphics.width, 0, Graphics.width, @cursor.y - 16
  3707.    
  3708.     @monsterList   = Menu_MonsterList_Window.new($game_system.monsters, x, y, w, h)
  3709.     @monsterWindow = Menu_Monster_Window.new(nil, x, y, w, h)
  3710.   end
  3711.   #-------------------------------------------------------------------------
  3712.   # * Cria janelas de distribuição de pontos
  3713.   #-------------------------------------------------------------------------
  3714.   def create_pdist_windows
  3715.     width = Graphics.width
  3716.     height = @cursor.y - 16
  3717.     @pdistWindows = $game_party.members.map.with_index{|actor, index|
  3718.       win = Menu_PDist_Window.new(actor, Graphics.width, 0, width, height)
  3719.       win.contents_opacity = 0
  3720.       win
  3721.     }
  3722.     @__NeedRefresh += @pdistWindows
  3723.   end
  3724.   #-------------------------------------------------------------------------
  3725.   # * Cria janela de save
  3726.   #-------------------------------------------------------------------------
  3727.   def create_save_windows
  3728.     @saveWindows = []
  3729.     index        = -1
  3730.     continue     = false
  3731.     x, y, w, h   = Graphics.width, 0, Graphics.width/3, @cursor.y - 16
  3732.    
  3733.     begin
  3734.       @saveWindows << Menu_SaveFile_Window.new(x, y, w, h, index, continue)
  3735.       @saveWindows.last.contents_opacity = 0
  3736.       continue = DataManager.load_header(index += 1)
  3737.     end until not continue or index >= DataManager.savefile_max
  3738.     @saveWindows.shift.dispose if @saveWindows.size == DataManager.savefile_max + 1
  3739.   end
  3740.   #-------------------------------------------------------------------------
  3741.   # * Cria janela de opções
  3742.   #-------------------------------------------------------------------------
  3743.   def create_options_window
  3744.     @optionWindow = Menu_Options_Window.new(Graphics.width, 0, Graphics.width, @cursor.y - 16)
  3745.     @optionWindow.contents_opacity = 0
  3746.   end
  3747.   #-------------------------------------------------------------------------
  3748.   # * Cria mini-mapa
  3749.   #-------------------------------------------------------------------------
  3750.   def create_minimap
  3751.     viewport = Viewport.new(Graphics.width, 0, Graphics.width, @cursor.y - 16)
  3752.     @minimap = StaticMiniMap.new(viewport)
  3753.   end
  3754.   #-------------------------------------------------------------------------
  3755.   # * Cria janela de seleção de atores
  3756.   #-------------------------------------------------------------------------
  3757.   def create_actor_select_window
  3758.     x = Graphics.width
  3759.    
  3760.     @actorSelect = Menu_ActorSelect_Window.new(x, @cursor.y - 16 - 128, 128, 128)
  3761.     @actorSelect.contents_opacity = 0
  3762.   end
  3763.   #-------------------------------------------------------------------------
  3764.   # * Atualização de Entrada
  3765.   #-------------------------------------------------------------------------
  3766.   def update_input
  3767.     if Input.trigger?(:B)
  3768.       process_return
  3769.     elsif Input.trigger?(:C)
  3770.       process_confirm
  3771.     else
  3772.       [:LEFT, :RIGHT, :UP, :DOWN].each{|key|
  3773.         process_move(key.capitalize) if Input.repeat?(key)
  3774.       }
  3775.     end
  3776.   end
  3777.   #-------------------------------------------------------------------------
  3778.   # * Desabilita atualização automatica de janelas
  3779.   #   (Processo desnecessário)
  3780.   #-------------------------------------------------------------------------
  3781.   def update_all_windows
  3782.   end
  3783.   #-------------------------------------------------------------------------
  3784.   # * Atualização das janelas dos atores
  3785.   #-------------------------------------------------------------------------
  3786.   def update_actors_windows
  3787.     @actorsWindows.each(&:update)
  3788.   end
  3789.   #-------------------------------------------------------------------------
  3790.   # * Atualização da janela de itens
  3791.   #-------------------------------------------------------------------------
  3792.   def update_items_window
  3793.     @itemsWindow.update
  3794.     @itemsInfo.update
  3795.   end
  3796.   #-------------------------------------------------------------------------
  3797.   # * Atualização das janelas de equipamentos
  3798.   #-------------------------------------------------------------------------
  3799.   def update_equips_windows
  3800.     @equipsWindow.update
  3801.     @itemsInfo.update
  3802.   end
  3803.   #-------------------------------------------------------------------------
  3804.   # * Atualização das janelas de habilidades
  3805.   #-------------------------------------------------------------------------
  3806.   def update_skills_windows
  3807.     @stypeWindow.update
  3808.     @slistWindow.update
  3809.     @itemsInfo.update
  3810.   end
  3811.   #-------------------------------------------------------------------------
  3812.   # * Atualização das janelas de formação
  3813.   #-------------------------------------------------------------------------
  3814.   def update_formation_windows
  3815.     @formationWindows[@formationIndex2].update
  3816.   end
  3817.   #-------------------------------------------------------------------------
  3818.   # * Atualização da janela de distribuição de pontos
  3819.   #-------------------------------------------------------------------------
  3820.   def update_pdist_windows
  3821.     @pdistWindows.each(&:update)
  3822.   end
  3823.   #-------------------------------------------------------------------------
  3824.   # * Atualização da janela de opções
  3825.   #-------------------------------------------------------------------------
  3826.   def update_options_window
  3827.     @optionWindow.update
  3828.   end
  3829.   #-------------------------------------------------------------------------
  3830.   # * Atualização das janelas de save
  3831.   #-------------------------------------------------------------------------
  3832.   def update_save_windows
  3833.     @saveWindows.each(&:update)
  3834.   end
  3835.   #-------------------------------------------------------------------------
  3836.   # * Processa retorno
  3837.   #-------------------------------------------------------------------------
  3838.   def process_return
  3839.     case @stage
  3840.     when :Base
  3841.       SceneManager.goto(Scene_Map)
  3842.       $game_map.autoplay
  3843.       Sound.play_cancel
  3844.     when :Items
  3845.       self.hide_icons(*@itemIcons)
  3846.       self.show_icons(*@baseIcons)
  3847.       self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
  3848.       self.show_actors_windows
  3849.       self.hide_items_window
  3850.       @stage = :Base
  3851.       Sound.play_cancel
  3852.     when :ItemsSelection
  3853.       self.items_filter_animation{
  3854.         @itemsWindow.applyFilter(0)
  3855.         @itemsWindow.active = false
  3856.         @itemsWindow.index  = -1
  3857.       }
  3858.       @stage = :Items
  3859.       Sound.play_cancel
  3860.     when :ItemsActorSelection
  3861.       @actorSelect.index = 0
  3862.       self.hide_actor_selection
  3863.       @stage = :Items
  3864.       Sound.play_cancel
  3865.     when :Equips
  3866.       @actorsWindows[@equipsIndex].active = false
  3867.       @stage = :Base
  3868.       Sound.play_cancel
  3869.     when :EquipsSelection
  3870.       @actorsWindows[@equipsIndex].active = true
  3871.       @equipsWindow.active = false
  3872.       self.show_actors_windows
  3873.       self.hide_equips_windows
  3874.       @stage = :Equips
  3875.       Sound.play_cancel
  3876.     when :EquipsTrade
  3877.       @itemsWindow.disableEquipMode
  3878.       self.hide_inventory_equips
  3879.       @stage = :EquipsSelection
  3880.       Sound.play_cancel
  3881.     when :Skills
  3882.       @actorsWindows[@skillsIndex].active = false
  3883.       @stage = :Base
  3884.       Sound.play_cancel
  3885.     when :SkillsTSelection
  3886.       @stypeWindow.active = false
  3887.       self.hide_skills_windows
  3888.       self.show_actors_windows
  3889.       @actorsWindows[@skillsIndex].active = true
  3890.       @stage = :Skills
  3891.       Sound.play_cancel
  3892.     when :SkillsSelection
  3893.       @stypeWindow.active = true
  3894.       @slistWindow.active = false
  3895.       @slistWindow.index  = -1
  3896.       @stage = :SkillsTSelection
  3897.       self.hide_skills_description
  3898.       Sound.play_cancel
  3899.     when :SkillsActorSelection
  3900.       @actorSelect.index = 0
  3901.       self.hide_actor_selection
  3902.       @stage = :SkillsSelection
  3903.       Sound.play_cancel
  3904.     when :Formation
  3905.       @actorsWindows[@formationIndex1].active = false
  3906.       @stage = :Base
  3907.       Sound.play_cancel
  3908.     when :FormationNextActor
  3909.       @actorsWindows[@formationIndex1].active = true
  3910.       self.show_actors_windows
  3911.       self.hide_formation_windows
  3912.       self.unselect_formation_actor(@formationIndex1)
  3913.       @formationWindows[@formationIndex2].active = false
  3914.       @formationWindows.insert(*@removedFormationWin)
  3915.       @formationIndex2 = 0
  3916.       @stage = :Formation
  3917.       Sound.play_cancel
  3918.     when :Status
  3919.       self.show_actors_windows
  3920.       self.hide_status_window(@statusIndex, :Right)
  3921.       @statusWindows.each_with_index{|window, index|
  3922.         next if index == @statusIndex
  3923.         window.x = Graphics.width
  3924.       }
  3925.       @stage = :Base
  3926.       Sound.play_cancel
  3927.     when :Bestiary
  3928.       self.show_actors_windows
  3929.       self.hide_bestiary_list
  3930.       @stage = :Base
  3931.       Sound.play_cancel
  3932.     when :BestiaryDetail
  3933.       self.switch_monster_windows(true)
  3934.       @stage = :Bestiary
  3935.       Sound.play_cancel
  3936.     when :PDist
  3937.       self.show_actors_windows
  3938.       self.hide_pdist_window(@pdistIndex, :Right)
  3939.       @pdistWindows[@pdistIndex].active = false
  3940.       @pdistWindows.each_with_index{|window, index|
  3941.         next if index == @pdistIndex
  3942.         window.x = Graphics.width
  3943.       }
  3944.       @stage = :Base
  3945.       Sound.play_cancel
  3946.     when :MiniMap
  3947.       self.show_actors_windows
  3948.       self.hide_minimap
  3949.       @stage = :Base
  3950.       Sound.play_cancel
  3951.     when :Options
  3952.       if @optionWindow.barActive
  3953.         @optionWindow.barActive ^= true
  3954.         @optionWindow.index = @optionWindow.index
  3955.       else
  3956.         DataManager.save_config_data
  3957.         self.show_actors_windows
  3958.         self.hide_options_window
  3959.         @optionWindow.index = -1
  3960.         @stage = :Base
  3961.       end
  3962.       Sound.play_cancel
  3963.     when :Save
  3964.       self.show_actors_windows
  3965.       self.hide_save_windows
  3966.       @saveWindows[@saveIndex].active = false
  3967.       @stage = :Base
  3968.       Sound.play_cancel
  3969.     when :SaveOverWrite
  3970.       self.hide_icons(*@saveIcons)
  3971.       self.show_icons(*@baseIcons)
  3972.       self.hide_message
  3973.       self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
  3974.       @stage = :Save
  3975.       Sound.play_cancel
  3976.     when :Exit
  3977.       @exitIndex = 2
  3978.       process_confirm
  3979.     end
  3980.   end
  3981.   #-------------------------------------------------------------------------
  3982.   # * Processa confirmação
  3983.   #-------------------------------------------------------------------------
  3984.   def process_confirm
  3985.     case @stage
  3986.     when :Base
  3987.       option = MRM::ExtremeMenu.enabledOptions[@baseIndex]
  3988.       case option
  3989.       when :Items
  3990.         Sound.play_ok
  3991.         self.hide_icons(*@baseIcons)
  3992.         self.show_icons(*@itemIcons)
  3993.         self.select_icon(@itemIcons.first, @itemVocab.first)
  3994.         self.hide_actors_windows
  3995.         self.show_items_window
  3996.         @itemIndex = 0
  3997.         self.items_filter_animation{
  3998.           @itemsWindow.applyFilter(0)
  3999.           @itemsWindow.active = true
  4000.           @itemsWindow.index  = 0
  4001.           @itemsWindow.refresh
  4002.         }
  4003.       when :Equips
  4004.         @actorsWindows.first.active = true
  4005.         @equipsIndex                = 0
  4006.       when :Skills
  4007.         @actorsWindows.first.active = true
  4008.         @skillsIndex                = 0
  4009.       when :Formation
  4010.         if $game_party.members.size == 1
  4011.           Sound.play_buzzer
  4012.           self.show_message(MRM::ExtremeMenu::Vocab[:InsufActs], :error)
  4013.           return
  4014.         end
  4015.         @actorsWindows.first.active = true
  4016.         @formationIndex1            = 0
  4017.       when :Status
  4018.         self.hide_actors_windows
  4019.         self.show_status_window(@statusIndex = 0)
  4020.       when :Bestiary
  4021.         if $game_system.monsters.size.zero?
  4022.           Sound.play_buzzer
  4023.           self.show_message(MRM::ExtremeMenu::Vocab[:ZeroMonster], :error)
  4024.           return
  4025.         end
  4026.         $game_system.new_monsters = false
  4027.         self.hide_actors_windows
  4028.         self.show_bestiary_list
  4029.         @monsterList.active = true
  4030.         @monsterList.index  = 0
  4031.       when :PDist
  4032.         self.hide_actors_windows
  4033.         self.show_pdist_window(@pdistIndex = 0)
  4034.         @pdistWindows.first.active = true
  4035.         @pdistWindows.first.index  = 0
  4036.       when :MiniMap
  4037.         self.hide_actors_windows
  4038.         self.show_minimap
  4039.       when :Options
  4040.         self.hide_actors_windows
  4041.         self.show_options_window
  4042.         @optionWindow.index = 0
  4043.         @optionIndex        = 0
  4044.       when :Save
  4045.         if $game_system.save_disabled
  4046.           Sound.play_buzzer
  4047.           self.show_message(MRM::ExtremeMenu::Vocab[:SaveBlock], :error)
  4048.           return
  4049.         end
  4050.         self.hide_actors_windows
  4051.         index = DataManager.last_menu_saveindex
  4052.         @saveWindows[index].active = true        
  4053.         @saveIndex = index
  4054.         self.show_save_windows
  4055.       when :Exit
  4056.         Sound.play_ok
  4057.         self.hide_icons(*@baseIcons)
  4058.         self.show_icons(*@exitIcons)
  4059.         self.select_icon(@exitIcons.first, @exitVocab.first)
  4060.         @exitIndex = 0
  4061.       end
  4062.       @stage = option
  4063.     #-------------------
  4064.     when :Items
  4065.       item    = @itemsWindow.info.item
  4066.       return Sound.play_buzzer unless @itemsWindow.current_item_enabled?
  4067.       Sound.play_ok
  4068.       targets = item_target_actors(item)
  4069.      
  4070.       if item.for_friend? and item.need_selection? and not targets.empty?
  4071.         @stage = :ItemsActorSelection
  4072.         self.show_actor_selection(targets)
  4073.         @actorSelect.active = true
  4074.       else
  4075.         self.use_item(item, itemUser)
  4076.         self.items_filter_animation{
  4077.           @itemsWindow.index  = 0
  4078.           @itemsWindow.make_item_list
  4079.           @itemsWindow.refresh
  4080.         }
  4081.       end
  4082.     #-------------------
  4083.     when :ItemsActorSelection
  4084.       item = @itemsWindow.info.item
  4085.       self.use_item(item, itemUser)
  4086.       self.items_filter_animation{
  4087.         @itemsWindow.index  = 0
  4088.         @itemsWindow.make_item_list
  4089.         @itemsWindow.refresh
  4090.       }
  4091.       process_return
  4092.     #-------------------
  4093.     when :Equips
  4094.       @actorsWindows[@equipsIndex].active = false
  4095.       @equipsWindow.actor = $game_party.members[@equipsIndex]
  4096.       @equipsWindow.active = true
  4097.       self.hide_actors_windows
  4098.       self.show_equips_windows
  4099.       @equipsWindow.index = 0
  4100.       @stage = :EquipsSelection
  4101.     #-------------------
  4102.     when :EquipsSelection
  4103.       actor = $game_party.members[@equipsIndex]
  4104.       index = @equipsWindow.index
  4105.      
  4106.       if index == 5
  4107.         Sound.play_equip
  4108.         actor.optimize_equipments
  4109.         @statusWindows[@equipsIndex].refresh
  4110.         @equipsWindow.refresh
  4111.         @equipsWindow.index = @equipsWindow.index
  4112.         return
  4113.       end
  4114.      
  4115.       unless actor.equip_change_ok?(index)
  4116.         Sound.play_buzzer
  4117.         self.show_message(MRM::ExtremeMenu::Vocab[:FixEquip], :error)
  4118.         return
  4119.       end
  4120.      
  4121.       weapon = [0]
  4122.       weapon << 1 if actor.dual_wield?
  4123.       filter = weapon.include?(@equipsWindow.index) ? 1 : 2
  4124.      
  4125.       @itemsWindow.enableEquipMode(@equipsWindow.index, actor)
  4126.       @itemsWindow.applyFilter(filter)
  4127.       @itemsWindow.make_item_list
  4128.       @itemsWindow.active = true      
  4129.       self.show_inventory_equips
  4130.      
  4131.       @stage = :EquipsTrade
  4132.     #-------------------
  4133.     when :EquipsTrade
  4134.       index = @equipsWindow.index
  4135.       actor = $game_party.members[@equipsIndex]
  4136.       equip = @itemsWindow.info.item
  4137.      
  4138.       Sound.play_equip
  4139.       actor.change_equip(index, equip)
  4140.      
  4141.       @equipsWindow.refresh
  4142.       @statusWindows[@equipsIndex].refresh
  4143.       process_return
  4144.     #-------------------
  4145.     when :Skills
  4146.       @actorsWindows[@skillsIndex].active = false
  4147.       @stypeWindow.actor  = $game_party.members[@skillsIndex]
  4148.       @slistWindow.actor  = $game_party.members[@skillsIndex]
  4149.       @stypeWindow.active = true
  4150.       @slistWindow.index  = -1
  4151.       self.hide_actors_windows
  4152.       self.show_skills_windows
  4153.       @slistWindow.index = 0
  4154.       @stage = :SkillsTSelection
  4155.     #-------------------
  4156.     when :SkillsTSelection
  4157.       self.show_skills_description
  4158.       @stypeWindow.active = false
  4159.       @slistWindow.active = true
  4160.       @slistWindow.index  = 0
  4161.       @stage = :SkillsSelection
  4162.     #-------------------
  4163.     when :SkillsSelection
  4164.       item    = @slistWindow.item
  4165.       return Sound.play_buzzer unless @slistWindow.current_item_enabled?
  4166.       Sound.play_ok
  4167.      
  4168.       targets = item_target_actors(item)
  4169.      
  4170.       if item.for_friend? and item.need_selection? and not targets.empty?
  4171.         @stage = :SkillsActorSelection
  4172.         self.show_actor_selection(targets)
  4173.         @actorSelect.active = true
  4174.       else
  4175.         self.use_item(item, itemUser)
  4176.       end
  4177.     #-------------------
  4178.     when :SkillsActorSelection
  4179.       item    = @slistWindow.item
  4180.       self.use_item(item, itemUser)
  4181.       @slistWindow.refresh
  4182.       process_return
  4183.     #-------------------
  4184.     when :Formation
  4185.       @formationIndex2 = 0
  4186.       self.hide_actors_windows
  4187.       @removedFormationWin = [
  4188.         @formationIndex1,
  4189.         @formationWindows.delete_at(@formationIndex1)
  4190.       ]
  4191.       @actorsWindows[@formationIndex1].active = false
  4192.       @formationWindows.first.active = true
  4193.       self.show_formation_windows
  4194.       self.select_formation_actor(@formationIndex1)
  4195.       @stage = :FormationNextActor
  4196.     #-------------------
  4197.     when :FormationNextActor
  4198.       self.trade_actors_formation
  4199.       Sound.play_ok
  4200.     #-------------------
  4201.     when :Bestiary
  4202.       @monsterWindow.monster = $data_enemies[@monsterList.index + 1]
  4203.       self.switch_monster_windows(false)
  4204.       @stage = :BestiaryDetail
  4205.     #-------------------
  4206.     when :PDist
  4207.       win   = @pdistWindows[@pdistIndex]
  4208.       actor = win.actor
  4209.       sheet = actor.pointsSheet
  4210.       attr  = sheet[sheet.keys[win.index + 1]]
  4211.      
  4212.       if actor.attrPoints < attr.first
  4213.         self.show_message(MRM::ExtremeMenu::Vocab[:InsufPts], :error)
  4214.         return Sound.play_buzzer
  4215.       end
  4216.      
  4217.       Sound.play_ok
  4218.       actor.attrPoints            -= attr.first
  4219.       actor.add_param_plus(win.index, attr.last)
  4220.       win.refresh
  4221.     #-------------------
  4222.     when :Options
  4223.       @optionWindow.barActive ^= true
  4224.       @optionWindow.index = @optionWindow.index
  4225.      
  4226.       unless @optionWindow.barActive
  4227.         [RPG::BGM.last, RPG::BGS.last].each{|audio| audio.replay if audio}
  4228.       end
  4229.      
  4230.       Sound.play_ok
  4231.     #-------------------
  4232.     when :Save
  4233.       unless @saveWindows[@saveIndex].exist
  4234.         Sound.play_save
  4235.         self.create_new_save
  4236.         x, y, w, h = Graphics.width, 0, Graphics.width/3, @cursor.y - 16
  4237.         index = @saveWindows.last.index + 1
  4238.         @saveWindows << Menu_SaveFile_Window.new(x, y, w, h, index, DataManager.load_header(index))
  4239.         @saveWindows.last.contents_opacity = 0
  4240.         Tween.start(@saveWindows.last, @saveEnter[:style], @saveEnter[:time],
  4241.           :contents_opacity => 255
  4242.         )
  4243.         if @saveWindows.size == DataManager.savefile_max + 1
  4244.           Tween.start(@saveWindows.first, @saveEnter[:style], @saveEnter[:time],
  4245.             :x => -@saveWindows.shift.width,
  4246.             :contents_opacity => 0
  4247.           ){|window| window.dispose}
  4248.          
  4249.           @saveWindows.first.active = true
  4250.         end
  4251.        
  4252.         self.move_save_windows
  4253.       else
  4254.         Sound.play_ok
  4255.         if MRM::ExtremeMenu::ConfirmOverwrite
  4256.           self.hide_icons(*@baseIcons)
  4257.           self.show_icons(*@saveIcons)
  4258.           self.select_icon(@saveIcons.last, @saveVocab.last)
  4259.           self.show_message(MRM::ExtremeMenu::Vocab[:SaveOver], :info, :show)
  4260.           @saveOverIndex = 1
  4261.           @stage = :SaveOverWrite
  4262.         else
  4263.           index = @saveIndex - 1
  4264.           self.save_game_on(index)
  4265.           header = DataManager.load_header(index)
  4266.           @saveWindows[@saveIndex].load_data(index, header)
  4267.           @saveWindows[@saveIndex].refresh(true)
  4268.           self.show_message(MRM::ExtremeMenu::Vocab[:Saved], :ok)
  4269.         end
  4270.       end
  4271.     #-------------------
  4272.     when :SaveOverWrite
  4273.       if @saveOverIndex == 0
  4274.         index = @saveIndex - 1
  4275.         self.save_game_on(index)
  4276.         header = DataManager.load_header(index)
  4277.         @saveWindows[@saveIndex].load_data(index, header)
  4278.         @saveWindows[@saveIndex].refresh(true)
  4279.         self.show_message(MRM::ExtremeMenu::Vocab[:Saved], :ok)
  4280.       end      
  4281.       process_return
  4282.     #-------------------
  4283.     when :Exit
  4284.       case @exitIndex
  4285.       when 0 # Título
  4286.         SceneManager.goto(Scene_Title)
  4287.         Sound.play_ok
  4288.       when 1 # Sair
  4289.         SceneManager.exit
  4290.         Sound.play_ok
  4291.       when 2 # Voltar
  4292.         self.hide_icons(*@exitIcons)
  4293.         self.show_icons(*@baseIcons)
  4294.         self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
  4295.         @stage = :Base
  4296.         Sound.play_cancel
  4297.       end
  4298.     end
  4299.   end
  4300.   #-------------------------------------------------------------------------
  4301.   # * Processa movimento
  4302.   #     direction : Direção (:Left, :Right, :Up, :Down)
  4303.   #-------------------------------------------------------------------------
  4304.   def process_move(dir)
  4305.     case @stage
  4306.     when :Base
  4307.       self.processMovement(:@baseIndex, dir, :hor, @baseIcons, @baseVocab)
  4308.     when :Items
  4309.       self.processMovement(:@itemIndex, dir, :hor, @itemIcons, @itemVocab){|i0, i1|
  4310.         break if i0 == i1
  4311.         self.items_filter_animation{
  4312.           @itemsWindow.applyFilter(i1)
  4313.           @itemsWindow.index  = 0
  4314.           @itemsWindow.refresh
  4315.         }
  4316.       }
  4317.     when :ItemsActorSelection, :SkillsActorSelection
  4318.       @tmp = @actorSelect.index
  4319.      
  4320.       self.processBaseMovement(:@tmp, dir, :hor, @actorSelect.maxIndex){|i0, i1|
  4321.         break if i0 == i1
  4322.         Sound.play_cursor
  4323.         @actorSelect.index = i1
  4324.         self.adjustActorSelect
  4325.       }    
  4326.     when :Equips
  4327.       self.processBaseMovement(:@equipsIndex, dir, :hor, @actorsWindows.size){|i0, i1|
  4328.         break if i0 == i1
  4329.         Sound.play_cursor
  4330.         @actorsWindows[i0].active = !@actorsWindows[i1].active = true
  4331.       }
  4332.     when :EquipsSelection
  4333.       @tmp = @equipsWindow.index
  4334.       self.processBaseMovement(:@tmp, dir, :vert, 6){|i0, i1|
  4335.         break if i0 == i1
  4336.         Sound.play_cursor
  4337.         @equipsWindow.index = i1
  4338.       }
  4339.     when :Skills
  4340.       self.processBaseMovement(:@skillsIndex, dir, :hor, @actorsWindows.size){|i0, i1|
  4341.         break if i0 == i1
  4342.         Sound.play_cursor
  4343.         @actorsWindows[i0].active = !@actorsWindows[i1].active = true
  4344.       }
  4345.     when :Formation
  4346.       self.processBaseMovement(:@formationIndex1, dir, :hor, @actorsWindows.size){|i0, i1|
  4347.         break if i0 == i1
  4348.         Sound.play_cursor
  4349.         @actorsWindows[i0].active = !@actorsWindows[i1].active = true
  4350.       }
  4351.     when :FormationNextActor
  4352.       self.processBaseMovement(:@formationIndex2, dir, :vert, @formationWindows.size){|i0, i1|
  4353.         break if i0 == i1
  4354.         Sound.play_cursor
  4355.         @formationWindows[i0].active = !@formationWindows[i1].active = true
  4356.         self.move_formation_windows
  4357.       }
  4358.     when :Status
  4359.       self.processBaseMovement(:@statusIndex, dir, :hor, @statusWindows.size){|i0, i1|
  4360.         break if i0 == i1
  4361.         newDir = dir == :Left ? :Right : :Left
  4362.         self.hide_status_window(i0, newDir)
  4363.         self.show_status_window(i1, newDir)
  4364.       }
  4365.     when :Bestiary
  4366.       win  = @monsterList
  4367.       tmp  = win.index
  4368.       @row = tmp / 3
  4369.       @off = tmp % 3
  4370.      
  4371.       self.processBaseMovement(:@off, dir, :hor, win.columns){|i0, i1|
  4372.         break if i0 == i1
  4373.         Sound.play_cursor
  4374.         win.index = (@row * win.columns) + i1
  4375.       }
  4376.      
  4377.       self.processBaseMovement(:@row, dir, :vert, win.rowMax){|i0, i1|
  4378.         break if i0 == i1
  4379.         Sound.play_cursor
  4380.         win.index = @off + (i1 * win.columns)
  4381.       }
  4382.     when :PDist
  4383.       self.processBaseMovement(:@pdistIndex, dir, :hor, @pdistWindows.size){|i0, i1|
  4384.         break if i0 == i1
  4385.         newDir = dir == :Left ? :Right : :Left
  4386.         self.hide_pdist_window(i0, newDir)
  4387.         self.show_pdist_window(i1, newDir)
  4388.         @pdistWindows[i0].active = !@pdistWindows[i1].active = true
  4389.         @pdistWindows[i1].index  =  @pdistWindows[i0].index
  4390.       }
  4391.      
  4392.       @tmp = @pdistWindows[@pdistIndex].index
  4393.       self.processBaseMovement(:@tmp, dir, :vert, 8){|i0, i1|
  4394.         @pdistWindows[@pdistIndex].index = i1
  4395.       }
  4396.     when :Options
  4397.       unless @optionWindow.barActive
  4398.         self.processBaseMovement(:@optionIndex, dir, :vert, 2){|i0, i1|
  4399.           break if i0 == i1
  4400.           Sound.play_cursor
  4401.           @optionWindow.index = i1
  4402.         }
  4403.       else
  4404.         case @optionIndex
  4405.         when 0; @tmpValue = $game_system.musicRate
  4406.         when 1; @tmpValue = $game_system.soundRate
  4407.         end
  4408.         @tmpValue *= 100
  4409.        
  4410.         self.processBaseMovement(:@tmpValue, dir, :hor, 101){|i0, i1|
  4411.           i1 = 100 if i1 > 100  
  4412.           break    if i0 == i1
  4413.      
  4414.           i1 /= 100.0
  4415.          
  4416.           Sound.play_cursor
  4417.           case @optionIndex
  4418.           when 0; $game_system.musicRate = i1
  4419.           when 1; $game_system.soundRate = i1
  4420.           end
  4421.          
  4422.           @optionWindow.refresh
  4423.         }
  4424.       end
  4425.     when :Save
  4426.       self.processBaseMovement(:@saveIndex, dir, :hor, @saveWindows.size){|i0, i1|
  4427.         break if i0 == i1
  4428.         Sound.play_cursor
  4429.         self.move_save_windows
  4430.         @saveWindows[i0].active = !@saveWindows[i1].active = true
  4431.       }
  4432.     when :SaveOverWrite
  4433.       self.processMovement(:@saveOverIndex, dir, :hor, @saveIcons, @saveVocab)      
  4434.     when :Exit
  4435.       self.processMovement(:@exitIndex, dir, :hor, @exitIcons, @exitVocab)
  4436.     end
  4437.   end
  4438.   #-------------------------------------------------------------------------
  4439.   # * Dispõe fundo
  4440.   #-------------------------------------------------------------------------
  4441.   def dispose_background
  4442.     @background_sprite.dispose
  4443.   end
  4444.   #-------------------------------------------------------------------------
  4445.   # * Dispõe ícones
  4446.   #-------------------------------------------------------------------------
  4447.   def dispose_icons
  4448.     dispose_base_icons
  4449.     dispose_exit_icons
  4450.   end
  4451.   #-------------------------------------------------------------------------
  4452.   # * Dispõe os ícones base
  4453.   #-------------------------------------------------------------------------
  4454.   def dispose_base_icons
  4455.     @baseIcons.each(&:dispose)
  4456.     Tween.remove(@baseIcons)
  4457.   end
  4458.   #-------------------------------------------------------------------------
  4459.   # * Dispões mensagem
  4460.   #-------------------------------------------------------------------------
  4461.   def dispose_message
  4462.     @message.dispose
  4463.     Tween.remove(@message)
  4464.   end
  4465.   #-------------------------------------------------------------------------
  4466.   # * Dispõe os ícones de saída
  4467.   #-------------------------------------------------------------------------
  4468.   def dispose_exit_icons
  4469.     @exitIcons.each(&:dispose)
  4470.     Tween.remove(@exitIcons)
  4471.   end
  4472.   #-------------------------------------------------------------------------
  4473.   # * Dispõe o cursor
  4474.   #-------------------------------------------------------------------------
  4475.   def dispose_cursor
  4476.     @cursor.dispose
  4477.     Tween.remove(@cursor)
  4478.   end
  4479.   #-------------------------------------------------------------------------
  4480.   # * Dispõe as janelas
  4481.   #-------------------------------------------------------------------------
  4482.   def dispose_windows
  4483.     dispose_actors_windows
  4484.     dispose_items_windows
  4485.     dispose_equips_window
  4486.     dispose_status_windows
  4487.     dispose_formation_windows
  4488.     dispose_bestiary_windows
  4489.     dispose_pdist_windows
  4490.     dispose_options_window
  4491.     dispose_save_windows
  4492.     dispose_actor_select_window
  4493.   end
  4494.   #-------------------------------------------------------------------------
  4495.   # * Dispõe as janelas de informação dos atores
  4496.   #-------------------------------------------------------------------------
  4497.   def dispose_actors_windows
  4498.     @actorsWindows.each(&:dispose)
  4499.     Tween.remove(@actorsWindows)
  4500.   end
  4501.   #-------------------------------------------------------------------------
  4502.   # * Dispõe a janela de itens
  4503.   #-------------------------------------------------------------------------
  4504.   def dispose_items_windows
  4505.     @itemsWindow.dispose
  4506.     @itemsInfo.dispose
  4507.     Tween.remove(@itemsWindow)
  4508.     Tween.remove(@itemsInfo)
  4509.   end
  4510.   #-------------------------------------------------------------------------
  4511.   # * Dispõe a janela de equipamentos
  4512.   #-------------------------------------------------------------------------
  4513.   def dispose_equips_window
  4514.     @equipsWindow.dispose
  4515.     Tween.remove(@equipsWindow)
  4516.   end
  4517.   #-------------------------------------------------------------------------
  4518.   # * Dispões as janelas de status
  4519.   #-------------------------------------------------------------------------
  4520.   def dispose_status_windows
  4521.     @statusWindows.each(&:dispose)
  4522.     Tween.remove(@statusWindows)
  4523.   end
  4524.   #-------------------------------------------------------------------------
  4525.   # * Dispõe as janelas de formação
  4526.   #-------------------------------------------------------------------------
  4527.   def dispose_formation_windows
  4528.     @formationWindows.each(&:dispose)
  4529.     Tween.remove(@formationWindows)
  4530.   end
  4531.   #-------------------------------------------------------------------------
  4532.   # * Dispõe as janelas de monstros do bestiário
  4533.   #-------------------------------------------------------------------------
  4534.   def dispose_bestiary_windows
  4535.     @monsterList.dispose
  4536.     @monsterWindow.dispose
  4537.     Tween.remove(@monsterList)
  4538.     Tween.remove(@monsterWindow)
  4539.   end
  4540.   #-------------------------------------------------------------------------
  4541.   # * Dispõe as janelas de distribuição de atributos  
  4542.   #-------------------------------------------------------------------------
  4543.   def dispose_pdist_windows
  4544.     @pdistWindows.each(&:dispose)
  4545.     Tween.remove(@pdistWindows)
  4546.   end
  4547.   #-------------------------------------------------------------------------
  4548.   # * Dispõe a janela de opções
  4549.   #-------------------------------------------------------------------------
  4550.   def dispose_options_window
  4551.     @optionWindow.dispose
  4552.     Tween.remove(@optionWindow)
  4553.   end
  4554.   #-------------------------------------------------------------------------
  4555.   # * Dispõe as janelas de save
  4556.   #-------------------------------------------------------------------------
  4557.   def dispose_save_windows
  4558.     @saveWindows.each(&:dispose)
  4559.     Tween.remove(@saveWindows)
  4560.   end
  4561.   #-------------------------------------------------------------------------
  4562.   # * Dispõe a janela de criação de atores
  4563.   #-------------------------------------------------------------------------
  4564.   def dispose_actor_select_window
  4565.     @actorSelect.dispose
  4566.     Tween.remove(@actor_select)
  4567.   end
  4568.   #-------------------------------------------------------------------------
  4569.   # * Dispõe mini-mapa
  4570.   #-------------------------------------------------------------------------
  4571.   def dispose_minimap
  4572.     @minimap.dispose
  4573.     Tween.remove(@minimap)
  4574.   end
  4575.  
  4576.   protected
  4577.   #-------------------------------------------------------------------------
  4578.   # * Cria novo save
  4579.   #-------------------------------------------------------------------------
  4580.   def create_new_save
  4581.     self.save_game_on(@saveWindows.size - 1)
  4582.   end
  4583.   #-------------------------------------------------------------------------
  4584.   # * Sobreescreve arquivo de save
  4585.   #   index : Identificador do arquivo
  4586.   #-------------------------------------------------------------------------
  4587.   def save_game_on(index)
  4588.     DataManager.save_game(index)
  4589.   end
  4590.   #-------------------------------------------------------------------------
  4591.   # * Aplica opções de fonte no bitmap
  4592.   #     b : Bitmap
  4593.   #-------------------------------------------------------------------------
  4594.   def applyFont(b)
  4595.     b.font.name    = MRM::ExtremeMenu::Font[:Name]
  4596.     b.font.size    = MRM::ExtremeMenu::Font[:Size]
  4597.     b.font.color   = Color.new(*MRM::ExtremeMenu::Font[:Color])
  4598.     b.font.shadow  = MRM::ExtremeMenu::Font[:Shadow]
  4599.     b.font.outline = MRM::ExtremeMenu::Font[:Outline]
  4600.     return b
  4601.   end
  4602.   #--------------------------------------------------------------------------
  4603.   # * Aquisição do usuário do ítem
  4604.   #--------------------------------------------------------------------------
  4605.   def itemUser
  4606.     if @stage == :SkillsSelection or @stage == :SkillsActorSelection # Habilidades
  4607.       $game_party.members[@skillsIndex]
  4608.     else # Itens
  4609.       $game_party.movable_members.max_by{|member| member.pha}
  4610.     end
  4611.   end
  4612.   #--------------------------------------------------------------------------
  4613.   # * Aquisição da lista de heróis válidos como alvos do item
  4614.   #     item : Item que será usado
  4615.   #--------------------------------------------------------------------------
  4616.   def item_target_actors(item)
  4617.     # 0: None
  4618.     # 1: One Enemy
  4619.     # 2: All Enemies
  4620.     # 3: One Random Enemy
  4621.     # 4: Two Random Enemies
  4622.     # 5: Three Random Enemies
  4623.     # 6: Four Random Enemies
  4624.     # 7: One Ally
  4625.     # 8: All Allies
  4626.     # 9: One Ally (Dead)
  4627.     # 10: All Allies (Dead)
  4628.     # 11: The User
  4629.    
  4630.     case item.scope
  4631.     when 7,8
  4632.       data = $game_party.members
  4633.     when 9,10
  4634.       data = $game_party.members.select{|actor| actor.dead?}
  4635.     when 11
  4636.       data = itemUser
  4637.     end
  4638.  
  4639.     user = itemUser
  4640.     return data.select{|actor| actor.item_test(user, item) }
  4641.   end
  4642.   #--------------------------------------------------------------------------
  4643.   # * Usa item
  4644.   #     item : Item
  4645.   #     user : Usuário
  4646.   #--------------------------------------------------------------------------
  4647.   def use_item(item, user)
  4648.     if @stage == :SkillsSelection or @stage == :SkillsActorSelection
  4649.       Sound.play_use_skill
  4650.     else
  4651.       Sound.play_use_item
  4652.     end
  4653.    
  4654.    
  4655.     user.use_item(item)
  4656.    
  4657.     targets = []
  4658.     case item.scope
  4659.     when 7, 9
  4660.       targets << @actorSelect.actor
  4661.     when 8
  4662.       targets += $game_party.members.select{|actor|
  4663.         not actor.dead? and actor.usable?(item)
  4664.       }
  4665.     when 10
  4666.       targets += $game_party.members.select{|actor|  
  4667.         actor.dead? and actor.item_test(user, item)
  4668.       }
  4669.     end
  4670.    
  4671.     targets.each{|target|
  4672.       item.repeats.times{
  4673.         target.item_apply(user, item)
  4674.       }
  4675.     }
  4676.    
  4677.     self.check_common_event
  4678.     self.check_gameover
  4679.    
  4680.     @actorsWindows.each(&:refresh)
  4681.   end
  4682.   #--------------------------------------------------------------------------
  4683.   # * Definição de reserva de evento comun.
  4684.   #    Transição para tela do mapa se a chamada è reservada para o evento
  4685.   #--------------------------------------------------------------------------
  4686.   def check_common_event
  4687.     SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
  4688.   end
  4689.   #--------------------------------------------------------------------------
  4690.   #  * Mostra a janela de atores para seleção
  4691.   #     actors : Atores disponíveis
  4692.   #--------------------------------------------------------------------------
  4693.   def show_actor_selection(actors)
  4694.     @actorSelect.faces = actors
  4695.     Tween.start(@actorSelect, @actorSelEnter[:style], @actorSelEnter[:time],
  4696.       :x => (@itemsWindow.width + Graphics.width - @actorSelect.width)/2,
  4697.       :contents_opacity => 255
  4698.     )
  4699.     self.adjustActorSelect
  4700.   end
  4701.   #-------------------------------------------------------------------------
  4702.   # * Esconde a janela de atores para seleção
  4703.   #-------------------------------------------------------------------------
  4704.   def hide_actor_selection
  4705.     Tween.start(@actorSelect, @actorSelEnter[:style], @actorSelEnter[:time],
  4706.       :x => Graphics.width,
  4707.       :contents_opacity => 0
  4708.     )
  4709.     self.adjustActorSelect
  4710.   end
  4711.   #-------------------------------------------------------------------------
  4712.   # * Ajusta face mostrada
  4713.   #-------------------------------------------------------------------------
  4714.   def adjustActorSelect
  4715.     Tween.start(@actorSelect, @actorSelMove[:style], @actorSelMove[:time],
  4716.       :ox => @actorSelect.trueOx
  4717.     )
  4718.   end
  4719.   #-------------------------------------------------------------------------
  4720.   # * Mostra mensagem
  4721.   #   text : Texto
  4722.   #   type : Tipo (:ok = Ok, :info = Informação, :error = Erro)
  4723.   #   mode : Modo (:blink = Piscar, :show = Mostrar)
  4724.   #-------------------------------------------------------------------------
  4725.   def show_message(text, type = :info, mode = :blink)
  4726.     case type
  4727.     when :ok
  4728.       @message.bitmap.font.color = MRM::ExtremeMenu::ColorOk
  4729.     when :info
  4730.       @message.bitmap.font.color = MRM::ExtremeMenu::ColorInfo
  4731.     when :error
  4732.       @message.bitmap.font.color = MRM::ExtremeMenu::ColorError
  4733.     end
  4734.    
  4735.     @message.bitmap.clear
  4736.     @message.bitmap.draw_text(@message.bitmap.rect, text, 1)
  4737.    
  4738.     block = (mode == :blink) ? ->(*){self.hide_message} : ->(*){}
  4739.    
  4740.     Tween.start(@message, @messageAnim[:style], @messageAnim[:time],
  4741.         :opacity => 255,
  4742.     &block)
  4743.   end
  4744.   #-------------------------------------------------------------------------
  4745.   # * Esconde mensagem
  4746.   #-------------------------------------------------------------------------
  4747.   def hide_message
  4748.     Tween.start(@message, @messageAnim[:style], @messageAnim[:time],
  4749.       :opacity => 0
  4750.     )
  4751.   end
  4752.   #-------------------------------------------------------------------------
  4753.   # * Cria sprites de ícones e os posiciona
  4754.   #     icons : Array com id dos ícones
  4755.   #     anim  : Animar?
  4756.   #-------------------------------------------------------------------------
  4757.   def create_generic_icons(icons, anim=true)
  4758.     iconSpace = Graphics.width / (icons.size == 0 ? 1 : icons.size)
  4759.    
  4760.     sprites = icons.map.with_index{|id, index|    
  4761.       gray = id < 0
  4762.       id   = id.abs
  4763.      
  4764.       icon          = Sprite.new
  4765.       icon.bitmap   = @iconset
  4766.       icon.src_rect = Rect.new(id % 16 * 24, id / 16 * 24, 24, 24)
  4767.       icon.ox       = icon.src_rect.width / 2
  4768.       icon.oy       = icon.src_rect.height / 2
  4769.       icon.x        = (index + 0.5) * iconSpace
  4770.       icon.y        = Graphics.height + icon.oy
  4771.      
  4772.       icon.tone.set(0, 0, 0, 255) if gray
  4773.      
  4774.       icon
  4775.     }
  4776.    
  4777.     self.show_icons(*sprites) if anim
  4778.     return sprites
  4779.   end
  4780.   #-------------------------------------------------------------------------
  4781.   # * Mostra ícones
  4782.   #     icons : Array de ícones
  4783.   #-------------------------------------------------------------------------
  4784.   def show_icons(*icons)
  4785.     motion = @iconsEnter
  4786.     icons.each_with_index{|icon, index|
  4787.       Tween.start(icon, motion[:style], motion[:time], motion[:off] * index,
  4788.         :y => Graphics.height - 24
  4789.       )
  4790.     }
  4791.   end
  4792.   #-------------------------------------------------------------------------
  4793.   # * Esconde ícones
  4794.   #     icons : Array de ícones
  4795.   #-------------------------------------------------------------------------
  4796.   def hide_icons(*icons)
  4797.     motion = @iconsEnter
  4798.     icons.each_with_index{|icon, index|
  4799.       Tween.start(icon, motion[:style], motion[:time], motion[:off] * index,
  4800.         :y => Graphics.height + 12
  4801.       )
  4802.     }
  4803.   end
  4804.   #-------------------------------------------------------------------------
  4805.   # * Seleciona ícone
  4806.   #     icon : Ícone
  4807.   #     name : Vocabulário para o nome
  4808.   #-------------------------------------------------------------------------
  4809.   def select_icon(icon, name)    
  4810.     Tween.start(icon, @iconsMove[:style], @iconsMove[:time],
  4811.       :y => Graphics.height - 36
  4812.     )
  4813.    
  4814.     Tween.start(@cursor, @cursorMove[:style], @cursorMove[:time],
  4815.       :x => icon.x
  4816.     )
  4817.      
  4818.     @cursor.bitmap.clear
  4819.     @cursor.bitmap.draw_text(@cursor.bitmap.rect, name, 1)
  4820.   end
  4821.   #-------------------------------------------------------------------------
  4822.   # * Deseleciona ícone
  4823.   #     icon : Ícone
  4824.   #-------------------------------------------------------------------------
  4825.   def unselect_icon(icon)
  4826.     Tween.start(icon, @iconsMove[:style], @iconsMove[:time],
  4827.       :y => Graphics.height - 24
  4828.     )
  4829.   end
  4830.   #-------------------------------------------------------------------------
  4831.   # * Processa movimento base do cursor
  4832.   #     indexName : Simbolo com nome da variável indexadora
  4833.   #     direction : Direção do movimento
  4834.   #     type      : Horizontal (:hor), Vertical (:vert)
  4835.   #     max       : Valor máximo
  4836.   #-------------------------------------------------------------------------
  4837.   def processBaseMovement(indexName, direction, type, max)
  4838.     index = instance_variable_get(indexName)
  4839.     lastIndex = index
  4840.     hor = (type == :hor)
  4841.     if direction == (hor ? :Left : :Up)
  4842.       index -= 1
  4843.     elsif direction == (hor ? :Right : :Down)
  4844.       index += 1
  4845.     end
  4846.     index %= max
  4847.     self.instance_variable_set(indexName, index)
  4848.     if block_given?
  4849.       yield(lastIndex, index)
  4850.     else
  4851.       return lastIndex, index
  4852.     end
  4853.   end
  4854.   #-------------------------------------------------------------------------
  4855.   # * Processa movimento de cursor e atualiza ícones
  4856.   #     indexName : Simbolo com nome da variável indexadora
  4857.   #     direction : Direção do movimento
  4858.   #     type      : Horizontal (:hor), Vertical (:vert)
  4859.   #     icons     : Array de ícones referentes ao movimento
  4860.   #     vocab     : Array de vocabulário
  4861.   #     cursor    : Executar som de movimento do cursor?
  4862.   #-------------------------------------------------------------------------
  4863.   def processMovement(indexName, direction, type, icons, vocab, cursor = true)
  4864.     processBaseMovement(indexName, direction, type, icons.size){|lastIndex, index|
  4865.       Sound.play_cursor if cursor
  4866.    
  4867.       self.unselect_icon(icons[lastIndex])
  4868.       self.select_icon(icons[index], vocab[index])
  4869.      
  4870.       yield(lastIndex, index) if block_given?
  4871.     }
  4872.   end
  4873.   #-------------------------------------------------------------------------
  4874.   # * Mostra janelas de ator (básica)
  4875.   #-------------------------------------------------------------------------
  4876.   def show_actors_windows
  4877.     @actorsWindows.each_with_index{|window, index|
  4878.       Tween.start(window, @winsMove[:style], @winsMove[:time], @winsMove[:off] * index,
  4879.         :y => 0,
  4880.         :contents_opacity => 255
  4881.       )
  4882.     }
  4883.   end
  4884.   #-------------------------------------------------------------------------
  4885.   # * Esconde janelas de ator (básica)
  4886.   #-------------------------------------------------------------------------
  4887.   def hide_actors_windows
  4888.     @actorsWindows.each_with_index{|window, index|
  4889.       Tween.start(window, @winsMove[:style], @winsMove[:time], @winsMove[:off] * index,
  4890.         :y => -window.height,
  4891.         :contents_opacity => 0
  4892.       )
  4893.     }
  4894.   end
  4895.   #-------------------------------------------------------------------------
  4896.   # * Mostra janela de itens
  4897.   #-------------------------------------------------------------------------
  4898.   def show_items_window
  4899.     Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time],
  4900.       :x => 0,
  4901.       :contents_opacity => 255
  4902.     )
  4903.     Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
  4904.       :x => @itemsInfo.width,
  4905.       :contents_opacity => 255
  4906.     )
  4907.   end
  4908.   #-------------------------------------------------------------------------
  4909.   # * Esconde a janela de itens
  4910.   #-------------------------------------------------------------------------
  4911.   def hide_items_window
  4912.     Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time],
  4913.       :x => Graphics.width,
  4914.       :contents_opacity => 0
  4915.     )
  4916.     Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
  4917.       :x => Graphics.width,
  4918.       :contents_opacity => 0
  4919.     )
  4920.   end
  4921.   #-------------------------------------------------------------------------
  4922.   # * Aplicação de filtro na janela de itens
  4923.   #     &block : Bloco que será iniciado quando a janela estiver com opaci-
  4924.   #              dade mínima.
  4925.   #-------------------------------------------------------------------------
  4926.   def items_filter_animation(&block)
  4927.     Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time] / 4.0,
  4928.       :contents_opacity => 0
  4929.     ){
  4930.       block.call
  4931.       Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time] / 4.0,
  4932.         :contents_opacity => 255
  4933.       )
  4934.     }
  4935.   end
  4936.   #-------------------------------------------------------------------------
  4937.   # * Mostra as janelas de equipamentos
  4938.   #-------------------------------------------------------------------------
  4939.   def show_equips_windows
  4940.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  4941.       :x => 0,
  4942.       :contents_opacity => 255
  4943.     )
  4944.     Tween.start(@itemsInfo, @equipsEnter[:style], @equipsEnter[:time],
  4945.       :x => @equipsWindow.width,
  4946.       :contents_opacity => 255
  4947.     )
  4948.   end
  4949.   #-------------------------------------------------------------------------
  4950.   # * Esconde as janelas de equipamentos
  4951.   #-------------------------------------------------------------------------
  4952.   def hide_equips_windows
  4953.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  4954.       :x => Graphics.width,
  4955.       :contents_opacity => 0
  4956.     )
  4957.     Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
  4958.       :x => Graphics.width,
  4959.       :contents_opacity => 0
  4960.     )
  4961.   end
  4962.   #-------------------------------------------------------------------------
  4963.   # * Mostra a janela de equipamentos disponíveis
  4964.   #-------------------------------------------------------------------------
  4965.   def show_inventory_equips
  4966.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  4967.       :contents_opacity => 0
  4968.     )
  4969.     @itemsWindow.x = 0
  4970.     Tween.start(@itemsWindow, @equipsEnter[:style], @equipsEnter[:time],
  4971.       :contents_opacity => 255
  4972.     )
  4973.   end
  4974.   #-------------------------------------------------------------------------
  4975.   # * Esconde a janela de equipamentos disponíveis
  4976.   #-------------------------------------------------------------------------
  4977.   def hide_inventory_equips
  4978.     Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
  4979.       :contents_opacity => 255
  4980.     )
  4981.     Tween.start(@itemsWindow, @equipsEnter[:style], @equipsEnter[:time],
  4982.       :contents_opacity => 0
  4983.     ){
  4984.       @itemsWindow.x = Graphics.width
  4985.     }
  4986.   end
  4987.   #-------------------------------------------------------------------------
  4988.   # * Mostra as janelas de habilidades
  4989.   #-------------------------------------------------------------------------
  4990.   def show_skills_windows
  4991.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  4992.       :x => 0,
  4993.       :contents_opacity => 255
  4994.     )
  4995.     Tween.start(@slistWindow, @skillsEnter[:style], @skillsEnter[:time],
  4996.       :x => @stypeWindow.width,
  4997.       :contents_opacity => 255
  4998.     )
  4999.   end
  5000.   #-------------------------------------------------------------------------
  5001.   # * Esconde as janelas de habilidades
  5002.   #-------------------------------------------------------------------------
  5003.   def hide_skills_windows
  5004.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5005.       :x => Graphics.width,
  5006.       :contents_opacity => 0
  5007.     )
  5008.     Tween.start(@slistWindow, @skillsEnter[:style], @skillsEnter[:time],
  5009.       :x => Graphics.width,
  5010.       :contents_opacity => 0
  5011.     )
  5012.   end
  5013.   #-------------------------------------------------------------------------
  5014.   # * Mostra a janela de descrição da habilidade
  5015.   #-------------------------------------------------------------------------
  5016.   def show_skills_description
  5017.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5018.       :contents_opacity => 0
  5019.     )
  5020.     @itemsInfo.x = 0
  5021.     Tween.start(@itemsInfo, @equipsEnter[:style], @equipsEnter[:time],
  5022.       :contents_opacity => 255
  5023.     )
  5024.   end
  5025.   #-------------------------------------------------------------------------
  5026.   # * Esconde a janela de descrição da habilidade
  5027.   #-------------------------------------------------------------------------
  5028.   def hide_skills_description
  5029.     Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
  5030.       :contents_opacity => 255
  5031.     )
  5032.     Tween.start(@itemsInfo, @skillsEnter[:style], @skillsEnter[:time],
  5033.       :contents_opacity => 0
  5034.     ){
  5035.       @itemsInfo.x = Graphics.width
  5036.     }
  5037.   end
  5038.   #-------------------------------------------------------------------------
  5039.   # * Mostra janelas de formação
  5040.   #-------------------------------------------------------------------------
  5041.   def show_formation_windows
  5042.     mot = @formationEnter
  5043.     @formationWindows[0,3].each_with_index{|win, index|
  5044.       Tween.start(win, mot[:style], mot[:time], mot[:off] * index,
  5045.         :y => win.height * index,
  5046.         :contents_opacity => 255.0 / (index + 1)
  5047.       )
  5048.     }
  5049.   end
  5050.   #-------------------------------------------------------------------------
  5051.   # * Atualiza posição das janelas de formação
  5052.   #-------------------------------------------------------------------------
  5053.   def move_formation_windows
  5054.     mot = @formationMove
  5055.     windows = @formationWindows[@formationIndex2, @formationWindows.size - @formationIndex2]
  5056.     windows += @formationWindows - windows
  5057.    
  5058.     windows.each_with_index{|win, index|
  5059.       Tween.start(win, mot[:style], mot[:time],
  5060.         :y => win.height * (index > 3 ? 3 : index),
  5061.         :contents_opacity => index.between?(0, 2) ? 255.0 / (index + 1) : 0
  5062.       )
  5063.     }
  5064.   end
  5065.   #-------------------------------------------------------------------------
  5066.   # * Esconde janelas de formação
  5067.   #-------------------------------------------------------------------------
  5068.   def hide_formation_windows
  5069.     mot   = @formationEnter
  5070.    
  5071.     @formationWindows.each_with_index{|win, index|
  5072.       Tween.start(win, mot[:style], mot[:time], mot[:off] * index,
  5073.         :y => Graphics.width,
  5074.         :contents_opacity => 0
  5075.       )
  5076.     }
  5077.   end
  5078.   #-------------------------------------------------------------------------
  5079.   # * Seleciona uma janela de ator (o que será trocado)
  5080.   #     index   : Identificador
  5081.   #     fromPos : Ir para o destino a partir da posição atual?
  5082.   #-------------------------------------------------------------------------
  5083.   def select_formation_actor(index, fromPos=true)
  5084.     win = @actorsWindows[index]
  5085.     win.x = -win.width unless fromPos
  5086.     Tween.start(win,  @winsMove[:style], @winsMove[:time],
  5087.       :x => 0,
  5088.       :y => 0,
  5089.       :contents_opacity => 255
  5090.     )
  5091.   end
  5092.   #-------------------------------------------------------------------------
  5093.   # * Deseleciona uma janela de ator
  5094.   #     index : Identificador
  5095.   #     toPos : Ir para a posição correta?
  5096.   #-------------------------------------------------------------------------
  5097.   def unselect_formation_actor(index, toPos=true)
  5098.     Tween.start(@actorsWindows[index],  @winsMove[:style], @winsMove[:time],
  5099.       :x => (toPos ? index : -1) * @actorsWindows[index].width
  5100.     )
  5101.   end
  5102.   #-------------------------------------------------------------------------
  5103.   # * Troca informações de formação e das janelas de atores
  5104.   #-------------------------------------------------------------------------
  5105.   def trade_actors_formation
  5106.     actor1 = @formationIndex1
  5107.     actor2 = @formationIndex2 + (@formationIndex2 < @formationIndex1 ? 0 : 1)
  5108.    
  5109.     $game_party.swap_order(actor1, actor2)
  5110.     @statusWindows[actor1], @statusWindows[actor2] = @statusWindows[actor2], @statusWindows[actor1]
  5111.     @pdistWindows[actor1], @pdistWindows[actor2] = @pdistWindows[actor2], @pdistWindows[actor1]
  5112.    
  5113.     winActor1 = actor1
  5114.     winActor2 = actor2 < 4 ? actor2 : nil
  5115.    
  5116.     Tween.start(@actorsWindows[winActor1],  @winsMove[:style], @winsMove[:time]/2.0,
  5117.       :x => -@actorsWindows[@formationIndex1].width
  5118.     ){
  5119.       @actorsWindows[winActor1].actor = $game_party.members[actor1]
  5120.       @actorsWindows[winActor2].actor = $game_party.members[actor2] if winActor2
  5121.       Tween.start(@actorsWindows[winActor1],  @winsMove[:style], @winsMove[:time]/2.0,
  5122.         :x => 0
  5123.       )
  5124.     }
  5125.    
  5126.     winForm1 = @formationWindows[@formationIndex2]
  5127.     winForm2 = @removedFormationWin.last
  5128.    
  5129.     winForm1.active = false
  5130.     winForm2.active = true
  5131.    
  5132.     mot              = @formationMove
  5133.    
  5134.     Tween.start(winForm1, mot[:style], mot[:time],
  5135.       :y => winForm1.height * 3,
  5136.       :contents_opacity => 0
  5137.     )
  5138.    
  5139.     Tween.start(winForm2, mot[:style], mot[:time],
  5140.       :y => 0,
  5141.       :contents_opacity => 255
  5142.     )
  5143.    
  5144.     @formationWindows.delete(winForm1)
  5145.     @formationWindows.insert(@formationIndex2, winForm2)
  5146.    
  5147.     @removedFormationWin = [
  5148.       @formationIndex2,
  5149.       winForm1
  5150.     ]
  5151.   end
  5152.   #-------------------------------------------------------------------------
  5153.   # * Mostra janela de informação completa do ator
  5154.   #     index : Identificador
  5155.   #     dir   : Direção de entrada
  5156.   #-------------------------------------------------------------------------
  5157.   def show_status_window(index, dir = :Left)
  5158.     window = @statusWindows[index]
  5159.     window.x = dir == :Left ? Graphics.width : -window.width
  5160.     Tween.start(window, @statusMove[:style], @statusMove[:time],
  5161.       :x => 0,
  5162.       :contents_opacity => 255
  5163.     )
  5164.   end
  5165.   #-------------------------------------------------------------------------
  5166.   # * Esconde janela de informação completa do ator
  5167.   #     index : Identificador
  5168.   #     dir   : Direção de saída
  5169.   #-------------------------------------------------------------------------
  5170.   def hide_status_window(index, dir = :Left)
  5171.     window = @statusWindows[index]
  5172.     Tween.start(window, @statusMove[:style], @statusMove[:time],
  5173.       :x => (dir == :Left ? -window.width : Graphics.width),
  5174.       :contents_opacity => 0
  5175.     )
  5176.   end
  5177.   #-------------------------------------------------------------------------
  5178.   # * Mostra lista de monstros do bestiário
  5179.   #-------------------------------------------------------------------------
  5180.   def show_bestiary_list
  5181.     window = @monsterList
  5182.     Tween.start(window, @bestiaryEnter[:style], @bestiaryEnter[:time],
  5183.       :x => 0,
  5184.       :contents_opacity => 255
  5185.     )
  5186.   end
  5187.   #-------------------------------------------------------------------------
  5188.   # * Esconde lista de monstros do bestiário
  5189.   #-------------------------------------------------------------------------
  5190.   def hide_bestiary_list
  5191.     window = @monsterList
  5192.     Tween.start(window, @bestiaryEnter[:style], @bestiaryEnter[:time],
  5193.       :x => Graphics.width,
  5194.       :contents_opacity => 0
  5195.     )
  5196.   end
  5197.   #-------------------------------------------------------------------------
  5198.   # * Move janelas de monstros do bestiário
  5199.   #     back : Voltando?
  5200.   #-------------------------------------------------------------------------
  5201.   def switch_monster_windows(back)
  5202.     window = @monsterList
  5203.     Tween.start(window, @bestiaryMove[:style], @bestiaryMove[:time],
  5204.       :x => back ? 0 : -window.width,
  5205.       :contents_opacity => back ? 255 : 0
  5206.     )
  5207.     window = @monsterWindow
  5208.     Tween.start(window, @bestiaryMove[:style], @bestiaryMove[:time],
  5209.       :x => back ? Graphics.width : 0,
  5210.       :contents_opacity => back ? 0 : 255
  5211.     )
  5212.   end
  5213.   #-------------------------------------------------------------------------
  5214.   # * Mostra janela de distribuição de pontos
  5215.   #     index : Identificador
  5216.   #     dir   : Direção de entrada
  5217.   #-------------------------------------------------------------------------
  5218.   def show_pdist_window(index, dir = :Left)
  5219.     window = @pdistWindows[index]
  5220.     window.x = dir == :Left ? Graphics.width : -window.width
  5221.     Tween.start(window, @pdistMove[:style], @pdistMove[:time],
  5222.       :x => 0,
  5223.       :contents_opacity => 255
  5224.     )
  5225.   end
  5226.   #-------------------------------------------------------------------------
  5227.   # * Esconde janela de distribuição de pontos
  5228.   #     index : Identificador
  5229.   #     dir   : Direção de saída
  5230.   #-------------------------------------------------------------------------
  5231.   def hide_pdist_window(index, dir = :Left)
  5232.     window = @pdistWindows[index]
  5233.     Tween.start(window, @pdistMove[:style], @pdistMove[:time],
  5234.       :x => (dir == :Left ? -window.width : Graphics.width),
  5235.       :contents_opacity => 0
  5236.     )
  5237.   end
  5238.   #-------------------------------------------------------------------------
  5239.   # * Mostra mini-mapa
  5240.   #-------------------------------------------------------------------------
  5241.   def show_minimap
  5242.     Tween.start(@minimap, @minimapEnter[:style], @minimapEnter[:time],
  5243.       :x => 0,
  5244.       :opacity => 255
  5245.     )
  5246.   end
  5247.   #-------------------------------------------------------------------------
  5248.   # * Esconde o mini-mapa
  5249.   #-------------------------------------------------------------------------
  5250.   def hide_minimap
  5251.     Tween.start(@minimap, @minimapEnter[:style], @minimapEnter[:time],
  5252.       :x => Graphics.width,
  5253.       :opacity => 0
  5254.     )
  5255.   end
  5256.   #-------------------------------------------------------------------------
  5257.   # * Mostra janela de opções
  5258.   #-------------------------------------------------------------------------
  5259.   def show_options_window
  5260.     Tween.start(@optionWindow, @optionEnter[:style], @optionEnter[:time],
  5261.       :x => 0,
  5262.       :contents_opacity => 255
  5263.     )
  5264.   end
  5265.   #-------------------------------------------------------------------------
  5266.   # * Esconde janela de opções
  5267.   #-------------------------------------------------------------------------
  5268.   def hide_options_window
  5269.     Tween.start(@optionWindow, @optionEnter[:style], @optionEnter[:time],
  5270.       :x => Graphics.width,
  5271.       :contents_opacity => 0
  5272.     )
  5273.   end
  5274.   #-------------------------------------------------------------------------
  5275.   # * Mostra janelas de save
  5276.   #-------------------------------------------------------------------------
  5277.   def show_save_windows
  5278.     baseX = (Graphics.width - @saveWindows.first.width) / 2
  5279.    
  5280.     @saveWindows.each_with_index{|window, index|
  5281.       Tween.start(window, @saveEnter[:style], @saveEnter[:time], @saveEnter[:off] * index,
  5282.         :x => baseX - ((@saveIndex - index) * window.width),
  5283.         :contents_opacity => 255
  5284.       )
  5285.     }
  5286.   end
  5287.   #-------------------------------------------------------------------------
  5288.   # * Esconde janelas de save
  5289.   #-------------------------------------------------------------------------
  5290.   def hide_save_windows
  5291.     @saveWindows.each_with_index{|window, index|
  5292.       Tween.start(window, @saveEnter[:style], @saveEnter[:time], @saveEnter[:off] * index,
  5293.         :x => Graphics.width,
  5294.         :contents_opacity => 0
  5295.       )
  5296.     }
  5297.   end
  5298.   #-------------------------------------------------------------------------
  5299.   # * Move janelas de save
  5300.   #-------------------------------------------------------------------------
  5301.   def move_save_windows
  5302.     baseX = (Graphics.width - @saveWindows.first.width) / 2
  5303.    
  5304.     @saveWindows.each_with_index{|window, index|
  5305.       Tween.start(window, @saveMove[:style], @saveMove[:time],
  5306.         :x => baseX - ((@saveIndex - index) * window.width)
  5307.       )
  5308.     }
  5309.   end
  5310. end
  5311.  
  5312.  
  5313. #=============================================================================
  5314. # Tweening [Scripter's Tool]
  5315. #---------------------------------------------------------------------------
  5316. # Formulas by: Robert Penner
  5317. # Compiled to Ruby by: UziMonkey
  5318. # Modified by: Gab!
  5319. #=============================================================================
  5320.  
  5321. class Tween
  5322.  
  5323.   @@__current  = {}
  5324.  
  5325.   def self.start(obj, style = Tween::Linear, time = 1, offset = 0, prop, &block)
  5326.     @@__current[obj] ||= {}
  5327.     prop.each_pair{|pr, final|
  5328.       act = obj.method(pr).call
  5329.       @@__current[obj][pr] = {
  5330.         tween: Tween.new(act, final, style, time),
  5331.         set: obj.method((pr.to_s + "=").to_sym),
  5332.         lfr: Time.new,
  5333.         tfr: 0,
  5334.         off: (offset / 100.0),
  5335.         blk: block
  5336.       }
  5337.     }
  5338.   end
  5339.  
  5340.   def self.update
  5341.     remove = []
  5342.    
  5343.     @@__current.each_pair{|obj, prop|
  5344.       done = true
  5345.       prop.each_value{|property|
  5346.         next if property[:tween].done
  5347.         done = false
  5348.        
  5349.         property[:tfr] = Time.new
  5350.         delta = (property[:tfr] - property[:lfr]).round(3)
  5351.         property[:lfr] = property[:tfr]
  5352.        
  5353.         if property[:off] > 0
  5354.           property[:off] -= delta
  5355.           next if property[:off] >= 0
  5356.           delta = -property[:off]
  5357.         end
  5358.          
  5359.         property[:tween].update(delta)
  5360.         property[:set].call(property[:tween].value) rescue nil
  5361.        
  5362.         property[:blk].call(obj) if property[:tween].done && property[:blk]
  5363.       }
  5364.      
  5365.       @@__current.delete(obj) if done
  5366.     }
  5367.   end
  5368.  
  5369.   def self.remove(obj, prop = nil)
  5370.     return obj.each{|object|
  5371.       Tween.remove(*(object.is_a?(Array) ? object : [object]))
  5372.     } if obj.is_a?(Array)
  5373.      
  5374.     if (@@__current.has_key?(obj))
  5375.       if (prop.nil?)
  5376.         @@__current.delete(obj)
  5377.       elsif @@__current[obj].has_key?(prop)
  5378.         @@__current[obj].delete(prop)
  5379.       end
  5380.     end
  5381.   end
  5382.  
  5383.   def self.ready?(obj)
  5384.     return !@@__current.has_key?(obj)
  5385.   end
  5386.  
  5387.  
  5388.   attr_reader :done
  5389.   attr_reader :easer
  5390.  
  5391.   def initialize(start, finish, easer, duration)
  5392.     @start, @finish = start, finish
  5393.     @delta = @finish - @start
  5394.     @easer, @duration = easer, duration
  5395.     @time = 0
  5396.     @done = false
  5397.   end
  5398.  
  5399.   def update(delta)
  5400.     @time += delta
  5401.     if @time > @duration
  5402.       @time = @duration
  5403.       @done = true
  5404.     end
  5405.   end
  5406.  
  5407.   def value
  5408.     @easer.ease(@time, @start, @delta, @duration)
  5409.   end
  5410.  
  5411.   module Linear
  5412.     def self.ease(t, st, ch, d)
  5413.       ch * t / d + st
  5414.     end
  5415.   end
  5416.  
  5417.   module Sine
  5418.     HALF_PI = Math::PI / 2
  5419.    
  5420.     module In
  5421.       def self.ease(t, st, ch, d)
  5422.         -ch * Math.cos(t / d * HALF_PI) + ch + st
  5423.       end
  5424.     end
  5425.    
  5426.     module Out
  5427.       def self.ease(t, st, ch, d)
  5428.         ch * Math.sin(t / d * HALF_PI) + st
  5429.       end
  5430.     end
  5431.    
  5432.     module InOut
  5433.       def self.ease(t, st, ch, d)
  5434.         -ch / 2 * (Math.cos(Math::PI * t / d) - 1) + st
  5435.       end
  5436.     end
  5437.   end
  5438.  
  5439.   module Circ
  5440.     module In
  5441.       def self.ease(t, st, ch, d)
  5442.         rate = t/d
  5443.         -ch * (Math.sqrt(1 - rate * rate) - 1) + st
  5444.       end
  5445.     end
  5446.    
  5447.     module Out
  5448.       def self.ease(t, st, ch, d)
  5449.         t = t/d - 1
  5450.         ch * Math.sqrt(1 - t * t) + st
  5451.       end
  5452.     end
  5453.    
  5454.     module InOut
  5455.       def self.ease(t, st, ch, d)
  5456.         if (t /= d/2.0) < 1
  5457.           return -ch / 2 * (Math.sqrt(1 - t*t) - 1) + st
  5458.         else
  5459.           return ch / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + st
  5460.         end
  5461.       end
  5462.     end
  5463.   end
  5464.  
  5465.   module Bounce
  5466.     module Out
  5467.       def self.ease(t, st, ch, d)
  5468.         if (t /= d) < (1/2.75)
  5469.           ch * (7.5625 * t * t) + st
  5470.         elsif t < (2 / 2.75)
  5471.           ch * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + st
  5472.         elsif t < (2.5 / 2.75)
  5473.           ch * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + st
  5474.         else
  5475.           ch * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + st
  5476.         end
  5477.       end
  5478.     end
  5479.    
  5480.     module In
  5481.       def self.ease(t, st, ch, d)
  5482.         ch - Tween::Bounce::Out.ease(d-t, 0, ch, d) + st
  5483.       end
  5484.     end
  5485.    
  5486.     module InOut
  5487.       def self.ease(t, st, ch, d)
  5488.         t *= 2
  5489.         if t < d
  5490.           Tween::Bounce::In.ease(t, 0, ch, d) * 0.5 + st
  5491.         else
  5492.           Tween::Bounce::Out.ease(t - d, 0, ch, d) * 0.5 + ch * 0.5 + st
  5493.         end
  5494.       end
  5495.     end
  5496.   end
  5497.  
  5498.   module Back
  5499.     module In
  5500.       def self.ease(t, st, ch, d, s=1.70158)      
  5501.         ch * (t/=d) * t * ((s+1) * t - s) + st
  5502.       end
  5503.     end
  5504.    
  5505.     module Out
  5506.       def self.ease(t, st, ch, d, s=1.70158)
  5507.         ch * ((t=t/d-1) * t * ((s+1) * t + s) + 1) + st
  5508.       end
  5509.     end
  5510.    
  5511.     module InOut
  5512.       def self.ease(t, st, ch, d, s=1.70158)
  5513.         if (t /= d/2.0) < 1
  5514.           ch / 2.0 * (t * t * (((s *= 1.525) + 1) * t - s)) + st
  5515.         else
  5516.           ch / 2.0 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + st
  5517.         end
  5518.       end
  5519.     end
  5520.   end
  5521.        
  5522.   module Cubic
  5523.     module In
  5524.       def self.ease(t, st, ch, d)
  5525.         ch * (t /= d) * t * t + st
  5526.       end
  5527.     end
  5528.    
  5529.     module Out
  5530.       def self.ease(t, st, ch, d)
  5531.         ch * ((t = t / d.to_f - 1) * t * t + 1) + st
  5532.       end
  5533.     end
  5534.    
  5535.     module InOut
  5536.       def self.ease(t, st, ch, d)
  5537.         if (t /= d / 2.0) < 1
  5538.           ch / 2.0 * t * t * t + st
  5539.         else
  5540.           ch / 2.0 * ((t -= 2) * t * t + 2) + st
  5541.         end
  5542.       end
  5543.     end
  5544.   end
  5545.  
  5546.   module Expo
  5547.     module In
  5548.       def self.ease(t, st, ch, d)
  5549.         if t == 0
  5550.           st
  5551.         else
  5552.           ch * (2 ** (10 * (t / d.to_f - 1))) + st
  5553.         end
  5554.       end
  5555.     end
  5556.    
  5557.     module Out
  5558.       def self.ease(t, st, ch, d)
  5559.         if t == d
  5560.           st + ch
  5561.         else
  5562.           ch * (1 - (2 ** (-10 * t / d.to_f))) + st
  5563.         end
  5564.       end
  5565.     end
  5566.    
  5567.     module InOut
  5568.       def self.ease(t, st, ch, d)
  5569.         if t == 0
  5570.           st
  5571.         elsif t == d
  5572.           st + ch
  5573.         elsif (t /= d / 2.0) < 1
  5574.           ch / 2.0 * (2 ** (10 * (t - 1))) + st
  5575.         else
  5576.           ch / 2.0 * (-(2 ** (-10 * (t -= 1))) + 2) + st
  5577.         end
  5578.       end
  5579.     end
  5580.   end
  5581.  
  5582.   module Quad
  5583.     module In
  5584.       def self.ease(t, st, ch, d)
  5585.         ch * (t /= d.to_f) * t + st
  5586.       end
  5587.     end
  5588.    
  5589.     module Out
  5590.       def self.ease(t, st, ch, d)
  5591.         -ch * (t /= d.to_f) * (t - 2) + st
  5592.       end
  5593.     end
  5594.    
  5595.     module InOut
  5596.       def self.ease(t, st, ch, d)
  5597.         if (t /= d / 2.0) < 1
  5598.           ch / 2.0 * t * t + st
  5599.         else
  5600.           -ch / 2.0 * ((t -= 1) * (t - 2) - 1) + st
  5601.         end
  5602.       end
  5603.     end
  5604.   end
  5605.  
  5606.   module Quart
  5607.     module In
  5608.       def self.ease(t, st, ch, d)
  5609.         ch * (t /= d.to_f) * t * t * t + st
  5610.       end
  5611.     end
  5612.    
  5613.     module Out
  5614.       def self.ease(t, st, ch, d)
  5615.         -ch * ((t = t / d.to_f - 1) * t * t * t - 1) + st
  5616.       end
  5617.     end
  5618.    
  5619.     module InOut
  5620.       def self.ease(t, st, ch, d)
  5621.         if (t /= d / 2.0) < 1
  5622.           ch / 2.0 * t * t * t * t + st
  5623.         else
  5624.           -ch / 2.0 * ((t -= 2) * t * t * t - 2) + st
  5625.         end
  5626.       end
  5627.     end
  5628.   end
  5629.  
  5630.   module Quint
  5631.     module In
  5632.       def self.ease(t, st, ch, d)
  5633.         ch * (t /= d.to_f) * t * t * t * t + st
  5634.       end
  5635.     end
  5636.    
  5637.     module Out
  5638.       def self.ease(t, st, ch, d)
  5639.         ch * ((t = t / d.to_f - 1) * t * t * t * t + 1) + st
  5640.       end
  5641.     end
  5642.    
  5643.     module InOut
  5644.       def self.ease(t, st, ch, d)
  5645.         ch /= 2.0
  5646.         if (t /= d / 2.0) < 1
  5647.           ch * t * t * t * t * t + st
  5648.         else
  5649.           ch * ((t -= 2) * t * t * t * t + 2) + st
  5650.         end
  5651.       end
  5652.     end
  5653.   end
  5654.  
  5655.   module Elastic
  5656.     DOUBLE_PI = 2 * Math::PI
  5657.    
  5658.     module In
  5659.       def self.ease(t, st, ch, d, a = 5, p = 0)
  5660.         s = 0
  5661.        
  5662.         if t == 0
  5663.           return st
  5664.         elsif (t /= d.to_f) >= 1
  5665.           return st + ch
  5666.         end
  5667.        
  5668.         p = d * 0.3 if p == 0
  5669.        
  5670.         if (a == 0) || (a < ch.abs)
  5671.           a = ch
  5672.           s = p / 4.0
  5673.         else
  5674.           s = p / DOUBLE_PI * Math.asin(ch / a.to_f)
  5675.         end
  5676.        
  5677.         -(a * (2 ** (10 * (t -= 1))) * Math.sin((t * d - s) * DOUBLE_PI / p)) + st
  5678.       end
  5679.     end
  5680.    
  5681.     module Out
  5682.       def self.ease(t, st, ch, d, a = 0.1, p = 0)
  5683.         s = 0
  5684.        
  5685.         if t == 0
  5686.           return st
  5687.         elsif (t /= d.to_f) >= 1
  5688.           return st + ch
  5689.         end
  5690.        
  5691.         p = d * 0.3 if p == 0
  5692.        
  5693.         if (a == 0) || (a < ch.abs)
  5694.           a = ch
  5695.           s = p / 4.0
  5696.         else
  5697.           s = p / DOUBLE_PI * Math.asin(ch / a.to_f)
  5698.         end
  5699.        
  5700.         a * (2 ** (-10 * t)) * Math.sin((t * d - s) * DOUBLE_PI / p.to_f) + ch + st
  5701.       end
  5702.     end
  5703.   end
  5704.          
  5705.   EASERS = [
  5706.     Linear,
  5707.    
  5708.     Sine::In,
  5709.     Sine::Out,
  5710.     Sine::InOut,
  5711.    
  5712.     Circ::In,
  5713.     Circ::Out,
  5714.     Circ::InOut,
  5715.    
  5716.     Bounce::Out,
  5717.     Bounce::In,
  5718.     Bounce::InOut,
  5719.    
  5720.     Back::In,
  5721.     Back::Out,
  5722.     Back::InOut,
  5723.    
  5724.     Cubic::In,
  5725.     Cubic::Out,
  5726.     Cubic::InOut,
  5727.    
  5728.     Expo::In,
  5729.     Expo::Out,
  5730.     Expo::InOut,
  5731.    
  5732.     Quad::In,
  5733.     Quad::Out,
  5734.     Quad::InOut,
  5735.    
  5736.     Quart::In,
  5737.     Quart::Out,
  5738.     Quart::InOut,
  5739.    
  5740.     Quint::In,
  5741.     Quint::Out,
  5742.     Quint::InOut,
  5743.    
  5744.     Elastic::In,
  5745.     Elastic::Out
  5746.   ]
  5747. end
Advertisement
Add Comment
Please, Sign In to add comment