Gabz

MRM Extreme Menu

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