Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=============================================================================
- # * Mundo RPG Maker Extreme Menu
- #---------------------------------------------------------------------------
- # Autor: Gab!
- # Data: 22/12/12 ~ 20/12/12
- #---------------------------------------------------------------------------
- # Créditos:
- # * Tweening:
- # - Robert Penner
- # - UziMonkey
- # * CogWheel Bars:
- # - Syvkal
- # * Base da classe StaticMiniMap:
- # - SheolShade
- # * Janela de descrição de itens/equipamentos:
- # - Yanfly
- #--------------------------------------------------------------------------
- # Instruções de instalação:
- # - Cole acima do script 'Main', preferencialmente abaixo do indicador
- # "Scripts Adicionais"
- #
- # - Leia as instruções de uso
- #
- # - Configure abaixo
- #
- #--------------------------------------------------------------------------
- # Instruções de uso:
- #
- # * Para remover uma opção do menu, use o comando seguinte em 'chamar script':
- # MRM::ExtremeMenu.disable(opção)
- #
- # 'opção' é o ícone que será desativado, deve ser um do termos abaixo:
- # - :Items # Itens
- # - :Equips # Equipamentos
- # - :Skills # Habilidades
- # - :Formation # Formação
- # - :Status # Estado
- # - :Bestiary # Bestiário
- # - :PDist # Distribuição de pontos
- # - :MiniMap # Mini-Mapa
- # - :Options # Opções
- # - :Save # Salvar jogo
- # - :Exit # Sair do jogo
- #
- # #=====================================================================#
- #
- # * Para adicionar novamente uma opção removida, basta chamar o comando:
- # MRM::ExtremeMenu.enable(opção)
- #
- # 'opção' se refere ao ícone que será adicionado novamente.
- #
- # #=====================================================================#
- #
- # * Para verificar se uma opção está ativa no menu, pela opção de scripts
- # das condições nos eventos, use:
- # MRM::ExtremeMenu.enabled?(opção)
- #
- # 'opção' novamente se refere ao ícone que será checado.
- #
- # #=====================================================================#
- #
- # * Os personagens ganham pontos automaticamente ao passar de nível, porém
- # se houver necessidade de adicionar ou retirar pontos, usa-se:
- #
- # Adicionar: MRM::ExtremeMenu.giveActorPoints(ator, qt)
- # Remover: MRM::ExtremeMenu.removeActorPoints(ator, qt)
- #
- # Em ambos 'ator' se refere ao ID do ator *na database* e 'qt' será a
- # quantidade de pontos adicionados ou removidos.
- #
- # #=====================================================================#
- #
- # * Para adicionar ou remover monstros do bestiário:
- #
- # Adicionar: MRM::ExtremeMenu.bestiaryAddMonster(id)
- # Remover: MRM::ExtremeMenu.bestiaryRemoveMonster(id)
- #
- # Nos dois casos 'id' indica o ID do monstro na database.
- #
- #=============================================================================
- module (MRM ||= Module.new)::ExtremeMenu
- #===========================================================================
- # ** CONFIGURAÇÃO
- #===========================================================================
- Use = { # Marque com true as opções que deve ser ativas no início do jogo
- # false caso contrário.
- Items: true, # Itens
- Equips: true, # Equipamentos
- Skills: true, # Habilidades
- Formation: true, # Formação
- Status: true, # Estado
- Bestiary: true, # Bestiário
- PDist: true, # Distribuição de pontos
- MiniMap: true, # Mini-Mapa
- Options: true, # Opções (Som)
- Save: true, # Salvar Jogo
- Exit: true, # Sair do Jogo
- }
- Vocab = { # Vocabulário
- Items: "Itens", # Itens
- Equips: "Equipamentos", # Equipamentos
- Skills: "Habilidades", # Habilidades
- Status: "Estado", # Estado
- Formation: "Formação", # Formação
- Bestiary: "Bestiário", # Bestiário
- PDist: "Pontos", # Distribuição de pontos
- MiniMap: "Mini-Mapa", # Mini-Mapa
- Options: "Opções", # Opções
- Save: "Salvar", # Salvar jogo
- Exit: "Sair", # Deixar jogo
- #==========================
- Item: "Item Comum", # Item Comum
- Weapon: "Arma", # Armas
- Armor: "Armadura", # Armaduras
- KeyItem: "Item Chave", # Itens chave
- Empty: "---", # Quando nada é mostrado
- HPRecover: "Recup. de HP", # Recuperação de HP
- MPRecover: "Recup. de MP", # Recuperação de MP
- TPRecover: "Recup. de TP", # Recuperação de TP
- TPGain: "Ganho de TP", # Ganho de TP
- Applies: "Provoca", # Estados provacados
- Removes: "Remove", # Estados removidos
- #==========================
- FixEquip: "Equipamento fixo!", # Equipamento fixo
- Optimize: "Melhor Equipamento", # Otimizar equipamentos e selecionar
- # os melhores
- #==========================
- InsufActs: "Apenas um membro no grupo!", # Membros insuficientes para abrir
- # o menu de formação
- #==========================
- ZeroMonster: "Bestiário vazio!", # Não existem monstros no bestiário
- BComplete: "Progresso: {c}%", # Progresso. ({c} será substituido pela
- # porcentagem de progresso.)
- Experience: "Experiência", # Experiência
- Loot: "Recompensas", # Recompensas
- #==========================
- InsufPts: "Pontos insuficientes", # Pontos insuficientes
- #==========================
- OptionsSFX: "Efeitos Sonoros", # Efeitos sonoros
- OptionsMsc: "Música", # Música (BGM, ME)
- OptionsSnd: "Som", # Som (BGS, SE)
- #==========================
- SaveBlock: "Save Bloqueado", # Salvar desabilitado
- FreeSlot: "Slot vazio", # Slot de save vazio
- NewSave: "Novo save", # Criar novo save
- PlayTime: "Tempo de Jogo:", # Tempo de jogo
- Party: "Grupo", # Grupo
- SaveOver: "Sobrescrever?", # Confirmação de sobresctrita
- SaveYes: "Sim", # Confirmação de Sobrescrita (Sim)
- SaveNo: "Não", # Confirmação de Sobrescrita (Não)
- Saved: "Jogo salvo!", # Jogo salvo
- #==========================
- ExitTitle: "Tela de Título", # Voltar ao título
- ExitGame: "Deixar Jogo", # Sair do jogo
- ExitCanc: "Cancelar", # Cancelar Saída
- }
- Font = { # Definições de fonte
- Name: "Trebuchet MS", # Nome
- Size: 18, # Tamanho
- Color: [255, 255, 255, 255], # Cor (R, G, B, A)
- Shadow: true, # Usar sombra?
- Outline: false, # Usar outline?
- }
- Icon = { # ID dos ícones
- Items: 194, # Itens
- Equips: 115, # Equipamentos
- Skills: 116, # Skills
- Status: 10, # Estado
- Formation: 11, # Formação
- Bestiary: 9, # Bestiário
- PDist: 125, # Distribuição de pontos
- MiniMap: 231, # Mini-Mapa
- Options: 185, # Opções (Som)
- Save: 230, # Salvar jogo
- Exit: 121, # Sair
- #=============================
- Item: 197, # Itens comuns
- Weapon: 148, # Armas
- Armor: 169, # Armadura
- KeyItem: 243, # Item Chave
- #=============================
- SaveYes: 113, # Confirmação de Sobrescrita (Sim)
- SaveNo: 114, # Confirmação de Sobrescrita (Não)
- #=============================
- ExitTitle: 16, # Voltar ao título
- ExitGame: 1, # Sair do jogo
- ExitCanc: 114, # Cancelar Saída
- #=============================
- Gold: 361, # Ouro
- }
- DisabledIcon = { # Ícones desabilitados
- # Use -1 para usar o mesmo ícone porém escurecido
- Formation: -1, # Ícone de formação quando não é possível modificá-la
- Bestiary: -1, # Ícone do bestiário quando não existem monstros novos
- PDist: 126, # Ícone de distribuição de pontos quando não existem
- # pontos para ser distribuidos
- Save: 368, # Ícone de save desabilitado
- }
- # Velocidade de atualização dos sprites dos atores
- ActorsSpeed = 25
- # Confirmar sobreescrita em slot de save?
- ConfirmOverwrite = true
- # Adicionar monstros ao bestiário automaticamente após as batalhas ganhas?
- # (Pode não funcionar quando utilizando um sistema de batalha diferente)
- AutoBestiaryAdd = true
- # Número máximo de efeitos adicionados/removidos que são mostrados nos
- # itens do inventário
- MaxIconsDrawn = 5
- # Barras de HP e MP
- BarColor1 = [ 0, 0, 0, 192] # Borda exterior
- BarColor2 = [255, 255, 192, 192] # Borda interior
- BarColor3 = [ 0, 0, 0, 12] # Metade do sombreamento
- BarColor4 = [ 64, 0, 0, 92] # Metade do sombreamento
- # Cores de mensagens
- MsgOk = [204, 255, 0, 230] # Mensagem Ok
- MsgInfo = [ 0, 204, 255, 230] # Mensagem de informação/pergunta
- MsgError = [255, 0, 68, 250] # Mensagem de erro
- #-------------------------------------------------------------------------
- # DISTRIBUIÇÃO DE PONTOS
- #-------------------------------------------------------------------------
- # É possível determinar, para cada classe, quantos pontos serão ganhos por
- # nível e quantos serão requeridos para cada atributo.
- #
- # Existe uma notação [X,Y] que indica o seguinte:
- # X é a quantidade de pontos que serão necessário para aumentar em Y
- # o atributo indicado.
- #
- # A quantidade de pontos ganhos por nível PODE ser um valor decimal. Porém
- # só será considerado um valor inteiro. Logo, se PPN = 3.5, o ator ganhará
- # 3 pontos no primeiro e no segundo nível, porém no terceiro ganhará 4.
- #-------------------------------------------------------------------------
- PDistPoints = {
- # Siga este padrão, caso existam mais classes:
- # ID DA CLASSE => {
- # PPN: Pontos ganhos por nível,
- # HPM: [X, Y], # HP Máximo
- # MPM: [X, Y], # MP Máximo
- # ATK: [X, Y], # Ataque
- # DEF: [X, Y], # Defesa
- # ATM: [X, Y], # Ataque Mágico (Inteligência)
- # DEM: [X, Y], # Defesa Mágica (Resistência)
- # AGI: [X, Y], # Agilidade
- # SOR: [X, Y], # Sorte
- # },
- 1 => { # Guerreiro
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 5], # Ataque
- DEF: [1, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 2 => { # Monge
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [2, 10], # Ataque
- DEF: [1, 8], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [2, 5], # Defesa Mágica (Resistência)
- AGI: [1, 5], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 3 => { # Cavaleiro
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 8], # Ataque
- DEF: [1, 7], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 4 => { # Espadachim
- PPN: 5,
- HPM: [1, 15], # HP Máximo
- MPM: [2, 15], # MP Máximo
- ATK: [1, 8], # Ataque
- DEF: [1, 7], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 5 => { # Samurai
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 5], # Ataque
- DEF: [1, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 7], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 6 => { # Arqueiro
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 5], # Ataque
- DEF: [1, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 7 => { # Ladino
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 5], # Ataque
- DEF: [1, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 8 => { # Sacerdote
- PPN: 4,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 5], # Ataque
- DEF: [1, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 9 => { # Mago
- PPN: 4,
- HPM: [1, 7], # HP Máximo
- MPM: [1, 20], # MP Máximo
- ATK: [2, 5], # Ataque
- DEF: [2, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [1, 5], # Defesa Mágica (Resistência)
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- 10 => { # Sábio
- PPN: 6,
- HPM: [1, 10], # HP Máximo
- MPM: [1, 10], # MP Máximo
- ATK: [1, 5], # Ataque
- DEF: [1, 5], # Defesa
- ATM: [2, 5], # Ataque Mágico (Inteligência)
- DEM: [3, 5], # Defesa Mágica
- AGI: [1, 3], # Agilidade
- SOR: [3, 1], # Sorte
- },
- }
- #------------------------------------------------------------------------
- # Diálogo que alerta o jogador sobre a quantidade de pontos necessários
- # para aprimorar determinado atributo.
- #
- # Separe as linhas por vírgula.
- #
- # As mudanças de cor, substituições de variáveis, nomes de personagens
- # da equipe, etc, serão serão aceitas. Certifique-se de usar barras duplas
- # para que possa funcionar.
- #
- # Existem substituições que o sistema fará:
- # {actorName} será substituido pelo nome do ator.
- # {actorPoints} será substituido pela quantidade de pontos que o ator tem.
- # {attrName} será substituido pelo nome do atributo.
- # {attrNPoints} será substituido pela quantidade de pontos que o atributo
- # precisa para ser aprimorado.
- # {attrGPoints} será substituido pela quantia que o ator ganhará no
- # atributo selecionado.
- #-------------------------------------------------------------------------
- PDistDiag = [
- "\\c[1]Pontos de {actorName}: \\c[0]{actorPoints}",
- "\\c[1]Pontos necessários: \\c[0]{attrNPoints}",
- "\\c[1]Ganhos: \\c[0]{attrGPoints} de {attrName}",
- "",
- "Pressione \\c[10][Enter]\\c[0] para confirmar."
- ]
- #-------------------------------------------------------------------------
- # MINI-MAPA
- #-------------------------------------------------------------------------
- # O principal foco aqui são as cores. Perceba que estão todas no formato
- # RGBA, ou seja, você terá quatro campos para preencher: [R, G, B, A]
- # Onde:
- # R = Vermelho
- # G = Verde
- # B = Azul
- # A = Opacidade
- # Cada um pode ir de 0 até 255.
- #-------------------------------------------------------------------------
- # Tamanho dos tiles
- TileSize = 8
- # Dependendo do tamanho dos tiles, pode exister necessidade de fazer um
- # ajuste de posições.
- MapOffset = -4
- # Cor do player
- PlayerColor = [255, 0, 0, 255]
- # Cor dos eventos
- ObjectColor = {
- # Esta configuração permite que você adicione
- # diferentes cores para cada tipo de evento.
- #
- # Para que um evento apareça no mini-map você
- # deve colocar um comentário com uma das
- # opções abaixo.
- #
- # Utilize este padrão:
- # "comentário" => [R, G, B, A],
- "npc" => [ 0, 255, 0, 255],
- "door" => [ 0, 0, 255, 255],
- "chest" => [100, 100, 100, 255],
- }
- # Cor da borda dos eventos e do player
- BorderColor = [ 0, 0, 0, 255]
- # Cor dos obstáculos
- MapColor = [ 0, 0, 0, 255]
- # Cor da borda dos obstáculos
- MapBorderColor = [ 50, 50, 50, 255]
- # Opacidade da camada de eventos
- ObjectLayerOpacity = 255
- #-------------------------------------------------------------------------
- # ANIMAÇÕES
- #-------------------------------------------------------------------------
- # O menu permite a configuração das animações, deve-se usar um número de 0
- # até 29 para selecionar a animação que você quer. Sendo que:
- #
- # 0 = Linear | 15 = Cúbica (Entrada e Saída)
- # 1 = Senoidal (Entrada) | 16 = Exponencial (Entrada)
- # 2 = Senoidal (Saída) | 17 = Exponencial (Saída)
- # 3 = Senoidal (Entrada e Saída) | 18 = Exponencial (Entrada e Saída)
- # 4 = Circular (Entrada) | 19 = Quadrática (Entrada)
- # 5 = Circular (Saída) | 20 = Quadrática (Saída)
- # 6 = Circular (Entrada e Saída) | 21 = Quadrática (Entrada e Saída)
- # 7 = Mola (Entrada) | 22 = Quártica (Entrada)
- # 8 = Mola (Saída) | 23 = Quártica (Saída)
- # 9 = Mola (Entrada e Saída) | 24 = Quártica (Entrada e Saída)
- # 10 = Retorno (Entrada) | 25 = Quíntica (Entrada)
- # 11 = Retorno (Saída) | 26 = Quíntica (Saída)
- # 12 = Retorno (Entrada e Saída) | 27 = Quíntica (Entrada e Saída)
- # 13 = Cúbico (Entrada) | 28 = Elástica (Entrada)
- # 14 = Cúbica (Saída) | 29 = Elástica (Saída)
- #
- # Todos os campos "Duração" são referentes ao tempo da animação em segundos
- # Todos os campos "Atraso" são referentes ao atraso da animação em centésimos
- #-------------------------------------------------------------------------
- Animation = {
- # Animação de entrada dos ícones
- IconsEnter: [
- 9, # ID da animação
- 1, # Duração
- 5, # Atraso
- ],
- # Animação de movimendo dos ícones
- IconsMove: [
- 12, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada do Cursor
- CursorEnter: [
- 13, # ID da animação
- 1, # Duração
- ],
- # Animação de movimento do Cursor
- CursorMove: [
- 29, # ID da animação
- 0.5, # Duração
- ],
- # Animação da mensagem
- Message: [
- 21, # ID da animação
- 1, # Duração
- ],
- # Animação de entrada das informações (básicas) dos atores
- WindowsEnter: [
- 27, # ID da animação
- 2, # Duração
- 5, # Atraso
- ],
- # Animação de movimento das informações (básicas) dos atores
- WindowsMove: [
- 16, # ID da animação
- 1, # Duração
- 1, # Atraso
- ],
- # Animação de entrada da janela de seleção de atores
- ActorSelEnter: [
- 4, # ID da animação
- 1, # Duração
- ],
- # Animação de movimento da janela de seleção de atores
- ActorSelMove: [
- 24, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada das janelas de itens
- ItemsEnter: [
- 9, # ID da animação
- 1, # Duração
- ],
- # Animação de movimento das janelas de itens
- ItemsMove: [
- 12, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada das janelas de equipamentos
- EquipsEnter: [
- 9, # ID da animação
- 1, # Duração
- ],
- # Animação de movimento das janelas de equipamentos
- EquipsMove: [
- 12, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada das janelas de habilidades
- SkillsEnter: [
- 12, # ID da animação
- 1, # Duração
- ],
- # Animação de movimento das janelas de habilidades
- SkillsMove: [
- 15, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada das janelas de formação
- FormationEnter: [
- 29, # ID da animação
- 1.5, # Duração
- 1, # Atraso
- ],
- # Animação de movimento das janelas de formação
- FormationMove: [
- 12, # ID da animação
- 1.5, # Duração
- ],
- # Animação de entrada das janelas de informações completas
- StatusEnter: [
- 29, # ID da animação
- 2, # Duração
- ],
- # Animação de movimento das janelas de informações completas
- StatusMove: [
- 3, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada das janelas de monstros do bestiário
- BestiaryEnter: [
- 22, # ID da animação
- 1, # Duração
- 1, # Atraso
- ],
- # Animação de movimento das janelas de monstros do bestiário
- BestiaryMove: [
- 15, # ID da animação
- 0.3, # Duração
- ],
- # Animação de entrada das janelas de informações completas
- PDistEnter: [
- 29, # ID da animação
- 2, # Duração
- ],
- # Animação de movimento das janelas de informações completas
- PDistMove: [
- 3, # ID da animação
- 0.5, # Duração
- ],
- # Animação de entrada do mini-mapa
- MiniMapEnter: [
- 9, # ID da animação
- 1, # Duração
- ],
- # Animação de movimento do mini-mapa
- MiniMapMove: [
- 9, # ID da animação
- 1, # Duração
- ],
- # Animação de entrada da janela de opções
- OptionEnter: [
- 29, # ID da animação
- 2, # Duração
- ],
- # Animação de entrada das janelas de save
- SaveEnter: [
- 27, # ID da animação
- 1.5, # Duração
- 1, # Atraso
- ],
- # Animação de movimento das janelas de save
- SaveMove: [
- 1, # ID da animação
- 0.25, # Duração
- ],
- }
- #===========================================================================
- # ** FIM DA CONFIGURAÇÃO
- #===========================================================================
- ColorOk = Color.new(*MsgOk )
- ColorInfo = Color.new(*MsgInfo )
- ColorError = Color.new(*MsgError)
- #---
- @enabled = []
- @cache = false
- Use.each_pair{|key, value| @enabled << key if value}
- module_function
- #-------------------------------------------------------------------------
- # * Ativa uma opção do menu durante o jogo (Chamada por eventos)
- # option : Chave que identifica o comando
- #-------------------------------------------------------------------------
- def enable(option)
- if Use.keys.include?(option) and not @enabled.include?(option)
- @enabled.push(option)
- end
- end
- #-------------------------------------------------------------------------
- # * Desativa uma opção do menu durante o jogo (Chamada por eventos)
- # option : Chave que identifica o comando
- #-------------------------------------------------------------------------
- def disable(option)
- @enabled.delete(option) if Use.keys.include?(option)
- end
- #-------------------------------------------------------------------------
- # * Verifica se um comando está ativado
- # option : Chave que identifica o comando
- #-------------------------------------------------------------------------
- def enabled?(option)
- return @enabled.include?(option)
- end
- #-------------------------------------------------------------------------
- # * Dá pontos de atributo à um ator
- # id : ID do ator na database
- # qt : Quantidade de pontos
- #-------------------------------------------------------------------------
- def giveActorPoints(id, qt)
- members = $game_party.members
- index = members.map{|actor| actor.id}.index(id)
- return unless index
- members[index].attrPoints += qt
- members[index].attrPoints = 0 if members[index].attrPoints < 0
- end
- #-------------------------------------------------------------------------
- # * Dá pontos de atributo de um ator
- # id : ID do ator na database
- # qt : Quantidade de pontos
- #-------------------------------------------------------------------------
- def removeActorPoints(id, qt)
- giveActorsPoints(id, -qt)
- end
- #-------------------------------------------------------------------------
- # * Adiciona monstro ao bestiário
- # id : ID do monstro na database
- #-------------------------------------------------------------------------
- def bestiaryAddMonster(id)
- $game_system.bestiaryAddMonster(id)
- end
- #-------------------------------------------------------------------------
- # * Remove monstro do bestiário
- # id : ID do monstro na database
- #-------------------------------------------------------------------------
- def bestiaryRemoveMonster(id)
- $game_system.bestiaryRemoveMonster(id)
- end
- #================
- #-------------------------------------------------------------------------
- # * Retorna todas as opções ativas
- #-------------------------------------------------------------------------
- def enabled
- return @enabled
- end
- #-------------------------------------------------------------------------
- # * Retorna todas as opções ativas
- #-------------------------------------------------------------------------
- def enabledOptions(ret = :none)
- options = @enabled.dup
- return options if ret == :none
- case ret
- when :icon
- options.map!{|key|
- base = Icon[key]
- if (key == :Formation) and ($game_party.members.size < 2)
- base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
- end
- if (key == :Bestiary) and (!$game_system.new_monsters)
- base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
- end
- if (key == :PDist) and ($game_party.members.all?{|ac| ac.attrPoints == 0})
- base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
- end
- if (key == :Save) and ($game_system.save_disabled)
- base = DisabledIcon[key] < 0 ? -base : DisabledIcon[key]
- end
- base
- }
- when :name
- options.map!{|key| Vocab[key]}
- end
- end
- #-------------------------------------------------------------------------
- # * Retorna todas as subopções ativas
- #-------------------------------------------------------------------------
- def enabledSubOption(option = :none, type = :none)
- case option
- when :Items
- keys = [:Item, :Weapon, :Armor, :KeyItem]
- when :Save
- keys = [:SaveYes, :SaveNo]
- when :Exit
- keys = [:ExitTitle, :ExitGame, :ExitCanc]
- end
- return keys if type == :none
- return keys.map{|key| type == :Names ? Vocab[key] : Icon[key] }
- end
- end
- #==============================================================================
- # ** Numeric
- #------------------------------------------------------------------------------
- # Classe que rege as instâncias numéricas
- #==============================================================================
- class Numeric
- #-------------------------------------------------------------------------
- # * Converte o numérico para string
- #-------------------------------------------------------------------------
- def group
- self.to_s
- end
- end
- #==============================================================================
- # ** String
- #------------------------------------------------------------------------------
- # Classe que rege todas as instâncias de strings
- #==============================================================================
- class String
- UPCASE_ISOTAB = 'ÀÁÂÃÄÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÇÑÝŸ'
- DOWNCASE_ISOTAB = 'àáâãäèéêëÍíîïòóôõöùúûüçñýÿ'
- #-------------------------------------------------------------------------
- # * Faz com que caracteres especiais também sejam colocado em caixa-alta
- #-------------------------------------------------------------------------
- def isoUpcase
- return upcase.tr(DOWNCASE_ISOTAB, UPCASE_ISOTAB)
- end
- end
- #==============================================================================
- # ** Audio
- #------------------------------------------------------------------------------
- # Módulo que coordena toda operação sonora do jogo
- #==============================================================================
- class << Audio
- alias mrm_extrememenu_bgm_play bgm_play
- alias mrm_extrememenu_me_play me_play
- alias mrm_extrememenu_bgs_play bgs_play
- alias mrm_extrememenu_se_play se_play
- def bgm_play(name, volume, pitch, pos)
- volume *= $game_system.musicRate if defined?($game_system)
- mrm_extrememenu_bgm_play(name, volume, pitch, pos)
- end
- def me_play(name, volume, pitch)
- volume *= $game_system.musicRate if defined?($game_system)
- mrm_extrememenu_bgm_play(name, volume, pitch)
- end
- def bgs_play(name, volume, pitch, pos)
- volume *= $game_system.soundRate if defined?($game_system)
- mrm_extrememenu_bgs_play(name, volume, pitch, pos)
- end
- def se_play(name, volume, pitch)
- volume *= $game_system.soundRate if defined?($game_system)
- mrm_extrememenu_se_play(name, volume, pitch)
- end
- end
- #==============================================================================
- # ** Bitmap
- #------------------------------------------------------------------------------
- # Classe que rege as informações sobre bitmaps na memória
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # Constantes
- #--------------------------------------------------------------------------
- RtlMoveMemory1 = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
- RtlMoveMemory2 = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
- #--------------------------------------------------------------------------
- # * Preenche a informação de cores
- # data : Blob
- # width : Largura
- #--------------------------------------------------------------------------
- def self.new_from_data(data, width)
- b = Bitmap.new(width, data.length/(4 * width))
- RtlMoveMemory2.call(b.address, data, data.length)
- return b
- end
- #--------------------------------------------------------------------------
- # * Retorna a informação de cores
- #--------------------------------------------------------------------------
- def get_color_data
- data = "bgra" * width * height
- RtlMoveMemory1.call(data, self.address, data.length)
- return data
- end
- #--------------------------------------------------------------------------
- # * Endereço na memória da informação de cores:
- # *(*(*(bitmap << 1 + 16) + 8) + 16)
- #--------------------------------------------------------------------------
- def address
- buffer = "xxxx"
- ad = self.object_id * 2 + 16
- RtlMoveMemory1.call(buffer, ad, 4); ad = buffer.unpack("L").first + 8
- RtlMoveMemory1.call(buffer, ad, 4); ad = buffer.unpack("L").first + 16
- RtlMoveMemory1.call(buffer, ad, 4); return buffer.unpack("L").first
- end
- end
- #==============================================================================
- # ** RPG::BaseItem
- #------------------------------------------------------------------------------
- # Classe mãe de
- #==============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # Variáveis de instância públicas
- #--------------------------------------------------------------------------
- attr_accessor :image
- #--------------------------------------------------------------------------
- # * Carrega informação necessária das notas do item
- #--------------------------------------------------------------------------
- def load_notetags_aso
- self.note.split(/[\r\n]+/).each{|line|
- if line =~ /<(?:IMAGE|image):[ ](.*)>/i
- @image = $1.to_s
- end
- }
- end
- end
- #==============================================================================
- # ** DataManager
- #------------------------------------------------------------------------------
- # Este módulo gerencia o jogo e objetos do banco de dados utilizados no jogo.
- # Quase todas as variáveis globais são inicializadas no módulo.
- #==============================================================================
- class << DataManager
- alias mrm_extrememenu_init init
- alias mrm_extrememenu_msh make_save_header
- alias mrm_extrememenu_lg load_game
- alias mrm_extrememenu_sg save_game
- alias mrm_extrememenu_ldb load_database
- @last_menu_saveindex = nil
- #--------------------------------------------------------------------------
- # * Inicialização
- # *args, &block : Argumentos
- #--------------------------------------------------------------------------
- def init(*args, &block)
- mrm_extrememenu_init(*args, &block)
- load_config_data
- @last_menu_saveindex = nil
- end
- #--------------------------------------------------------------------------
- # * Carregamento do Banco de Dados
- # *args, &block : Argumentos
- #--------------------------------------------------------------------------
- def load_database(*args, &block)
- mrm_extrememenu_ldb(*args, &block)
- load_notetags_aso unless $BTEST
- end
- #--------------------------------------------------------------------------
- # * Salva informação de configuração (Última configuração salva)
- #--------------------------------------------------------------------------
- def save_config_data
- File.open("Config.rvdata2", "wb") { |f|
- Marshal.dump($game_system.musicRate, f)
- Marshal.dump($game_system.soundRate, f)
- }
- end
- #--------------------------------------------------------------------------
- # * Carrega informação de configuração
- #--------------------------------------------------------------------------
- def load_config_data
- return unless File.exist?("Config.rvdata2")
- File.open("Config.rvdata2", "rb"){|f|
- $game_system.musicRate = Marshal.load(f)
- $game_system.soundRate = Marshal.load(f)
- }
- end
- #--------------------------------------------------------------------------
- # * Salvar a criação de cabeçalho
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def make_save_header(*args, &block)
- header = mrm_extrememenu_msh(*args, &block)
- bmap = Bitmap.new(157, 120)
- ss = SceneManager.background_bitmap
- bmap.stretch_blt(bmap.rect, ss, ss.rect)
- header[:preview] = bmap.get_color_data
- return header
- end
- #--------------------------------------------------------------------------
- # * Salvar Jogo
- # index : índice
- #--------------------------------------------------------------------------
- def save_game(index)
- result = mrm_extrememenu_sg(index)
- save_config_data
- @last_menu_saveindex = index if result
- return result
- end
- #--------------------------------------------------------------------------
- # * Carregamento do Jogo
- # index : índice
- #--------------------------------------------------------------------------
- def load_game(index)
- result = mrm_extrememenu_lg(index)
- @last_menu_saveindex = index if result
- return result
- end
- #--------------------------------------------------------------------------
- # * Última index carregada
- #--------------------------------------------------------------------------
- def last_menu_saveindex
- return (@last_menu_saveindex || -1) + 1
- end
- #--------------------------------------------------------------------------
- # * Carrega notas dos itens
- #--------------------------------------------------------------------------
- def load_notetags_aso
- [$data_items, $data_weapons, $data_armors].each{|group| group.each{|obj|
- next unless obj
- obj.load_notetags_aso
- }}
- end
- end
- #==============================================================================
- # ** BattleManager
- #------------------------------------------------------------------------------
- # Este módulo gerencia o andamento da batalha.
- #==============================================================================
- if MRM::ExtremeMenu::AutoBestiaryAdd
- class << BattleManager
- alias mrm_extrememenu_process_victory process_victory
- #------------------------------------------------------------------------
- # * Processar vitória
- # *args // &block : Argumentos
- #------------------------------------------------------------------------
- def process_victory(*args, &block)
- mrm_extrememenu_process_victory
- $game_troop.troop.members.map{|member| member.enemy_id}.uniq.each{|id|
- $game_system.bestiaryAddMonster(id)
- }
- end
- end
- end
- #==============================================================================
- # ** Game_System
- #------------------------------------------------------------------------------
- # Esta classe gerencia os dados relacionados ao sistema. Também gerencia
- # veículos, BGM, etc.
- # A instância desta classe é referenciada por $game_system.
- #==============================================================================
- class Game_System
- attr_accessor :musicRate
- attr_accessor :soundRate
- attr_accessor :new_monsters
- attr_reader :monsters
- alias mrm_extrememenu_initialize initialize
- #-------------------------------------------------------------------------
- # * Inicialização
- # *args // &block : Argumentos
- #-------------------------------------------------------------------------
- def initialize(*args, &block)
- mrm_extrememenu_initialize(*args, &block)
- if defined?($game_system)
- @musicRate = $game_system.musicRate
- @soundRate = $game_system.soundRate
- else
- @musicRate = 1.0
- @soundRate = 1.0
- end
- @monsters = []
- @new_monsters = false
- end
- #-------------------------------------------------------------------------
- # * Adiciona monstros ao bestiário
- # id : Identificação do monstro (ID no banco de dados)
- #-------------------------------------------------------------------------
- def bestiaryAddMonster(id)
- return unless id.between?(1, $data_enemies.size - 1)
- return if @monsters.include?(id)
- @monsters << id
- @new_monsters = true
- end
- #-------------------------------------------------------------------------
- # * Retira monstros do bestiário
- # id : Identificação do monstro (ID no banco de dados)
- #-------------------------------------------------------------------------
- def bestiaryRemoveMonster(id)
- @monsters.delete(id)
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # Esta classe gerencia os heróis. Ela é utilizada internamente pela classe
- # Game_Actors ($game_actors). A instância desta classe é referenciada
- # pela classe Game_Party ($game_party).
- #==============================================================================
- class Game_Actor
- alias mrm_extrememenu_initialize initialize
- alias mrm_extrememenu_level_up level_up
- alias mrm_extrememenu_change_class change_class
- attr_writer :attrPoints
- attr_reader :pointsSheet
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def initialize(*args, &block)
- mrm_extrememenu_initialize(*args, &block)
- @attrPoints = 0
- update_points_sheet
- end
- #--------------------------------------------------------------------------
- # * Aumento de nível
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def level_up(*args, &block)
- mrm_extrememenu_level_up(*args, &block)
- @attrPoints += @pointsSheet[:PPN]
- end
- #--------------------------------------------------------------------------
- # * Leitura dos pontos de atributo
- #--------------------------------------------------------------------------
- def attrPoints
- return @attrPoints.to_i
- end
- #--------------------------------------------------------------------------
- # * Mudança de classe
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def change_class(*args, &block)
- mrm_extrememenu_change_class(*args, &block)
- update_points_sheet
- end
- #--------------------------------------------------------------------------
- # * Adiciona pontos de atributos
- # index : Identificação do atributo
- # qt : Quantidade
- #--------------------------------------------------------------------------
- def add_param_plus(index, qt)
- @param_plus[index] += qt
- end
- #--------------------------------------------------------------------------
- # * Atualiza tabela de pontos da classe
- #--------------------------------------------------------------------------
- def update_points_sheet
- @pointsSheet = MRM::ExtremeMenu::PDistPoints[@class_id]
- # Se não for definida uma configuração, anula distribuição de pontos
- # para aquela classe.
- if @pointsSheet.nil?
- @pointsSheet = {
- PNN: 0,
- HPM: [0, 0], MPM: [0, 0], ATK: [0, 0], DEF: [0, 0],
- ATM: [0, 0], DEM: [0, 0], AGI: [0, 0], SOR: [0, 0],
- }
- end
- end
- end
- #==============================================================================
- # ** Menu_Base_Window
- #------------------------------------------------------------------------------
- # Classe básica para todas as janelas do menu
- #==============================================================================
- class Menu_Base_Window < Window_Base
- include MRM::ExtremeMenu
- BC1 = Color.new(*BarColor1)
- BC2 = Color.new(*BarColor2)
- BC3 = Color.new(*BarColor3)
- BC4 = Color.new(*BarColor4)
- #--------------------------------------------------------------------------
- # Inicialização do objeto
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def initialize(*args, &block)
- super(*args, &block)
- self.applyFont(self.contents)
- end
- #--------------------------------------------------------------------------
- # * Desenho do HP
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- # width : largura
- #--------------------------------------------------------------------------
- def draw_actor_hp(actor, x, y, width = 124)
- rate = actor.hp_rate
- gc1 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
- gc2 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
- draw_special_gauge(x, y, width, rate, gc1, gc2)
- change_color(system_color)
- draw_text(x, y, 30, line_height, ::Vocab::hp_a)
- draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
- hp_color(actor), normal_color)
- end
- #--------------------------------------------------------------------------
- # * Desenho do MP
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- # width : largura
- #--------------------------------------------------------------------------
- def draw_actor_mp(actor, x, y, width = 124)
- rate = actor.mp_rate
- gc1 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
- gc2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
- draw_special_gauge(x, y, width, rate, gc1, gc2)
- change_color(system_color)
- draw_text(x, y, 30, line_height, ::Vocab::mp_a)
- draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
- mp_color(actor), normal_color)
- end
- #-------------------------------------------------------------------------
- # * Desenha a barra especial estilo Cogwheel
- # x : Posição X
- # y : Posição Y
- # width : Largura
- # rate : Porção de preenchimento
- # gc1 : Cor 1
- # gc2 : Cor 2
- #-------------------------------------------------------------------------
- def draw_special_gauge(x, y, width, rate, gc1, gc2)
- contents.fill_rect(x, y + line_height - 10, width, 10, BC1)
- contents.fill_rect(x + 1, y + line_height - 9, width - 2, 8, BC2)
- contents.gradient_fill_rect(x + 2, y + line_height - 8, width - 4, 6, BC3, BC4)
- contents.gradient_fill_rect(x + 2, y + line_height - 8, (width*rate) - 4, 6, gc1, gc2)
- end
- #-------------------------------------------------------------------------
- # * Desenho de uma linha horizontal
- # y : Posição y de desenho
- #-------------------------------------------------------------------------
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- color = normal_color
- color.alpha = 48
- contents.fill_rect(128, line_y, contents_width - 128, 2, color)
- end
- protected
- #-------------------------------------------------------------------------
- # * Aplica opções de fonte no bitmap
- # b : Bitmap
- #-------------------------------------------------------------------------
- def applyFont(b)
- b.font.name = MRM::ExtremeMenu::Font[:Name]
- b.font.size = MRM::ExtremeMenu::Font[:Size]
- b.font.color = Color.new(*MRM::ExtremeMenu::Font[:Color])
- b.font.shadow = MRM::ExtremeMenu::Font[:Shadow]
- b.font.outline = MRM::ExtremeMenu::Font[:Outline]
- return b
- end
- end
- #==============================================================================
- # ** Menu_ItemInfo_Window
- #------------------------------------------------------------------------------
- # Mostra informações do item selecionado
- #==============================================================================
- class Menu_ItemInfo_Window < Menu_Base_Window
- attr_reader :item
- #-------------------------------------------------------------------------
- # * Inicialização do objeto
- # x : Coordenada X
- # y : Coordenada Y
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(x, y, w, h)
- super(x, y, w, h)
- self.opacity = 0
- @item = nil
- refresh
- end
- #-------------------------------------------------------------------------
- # * Seleciona item e redesenha conteúdo
- # item : Novo item
- #-------------------------------------------------------------------------
- def item=(value)
- @item = value
- refresh
- end
- #-------------------------------------------------------------------------
- # * Desenho do conteúdo da janela
- #-------------------------------------------------------------------------
- def refresh
- contents.clear
- return if @item.nil?
- draw_item_image
- draw_item_stats
- draw_item_effects
- draw_item_description
- end
- #--------------------------------------------------------------------------
- # * Desenha imagem do item
- #--------------------------------------------------------------------------
- def draw_item_image
- colour = Color.new(0, 0, 0, translucent_alpha/2)
- center = (contents_width - 96) / 2
- rect = Rect.new(center + 1, 1, 94, 94)
- if @item.image.nil?
- icon_index = @item.icon_index
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- target = Rect.new(center, 0, 96, 96)
- contents.stretch_blt(target, bitmap, rect)
- else
- bitmap = Cache.picture(@item.image)
- contents.blt(0, 0, bitmap, bitmap.rect, 255)
- end
- end
- #--------------------------------------------------------------------------
- # * Desenha status do item
- #--------------------------------------------------------------------------
- def draw_item_stats
- return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
- dx = 0; dy = 96
- dw = contents.width / 2
- 8.times{|i|
- draw_equip_param(i, dx, dy, dw)
- dx = dx >= dw ? 0 : dw
- dy += line_height if dx == 0
- }
- end
- #--------------------------------------------------------------------------
- # * Desenha parâmetro (nome) do item
- # param_id : Identificação do parâmetro
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_equip_param(param_id, dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, ::Vocab::param(param_id))
- draw_set_param(param_id, dx, dy, dw)
- end
- #--------------------------------------------------------------------------
- # * Desenha parâmetro (valor) do item
- # param_id : Identificação do parâmetro
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_set_param(param_id, dx, dy, dw)
- value = @item.params[param_id]
- change_color(param_change_color(value), value != 0)
- text = value.group
- text = "+" + text if value > 0
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- return text
- end
- #--------------------------------------------------------------------------
- # * Desenha efeitos do ítem
- #--------------------------------------------------------------------------
- def draw_item_effects
- return if @item.is_a?(RPG::EquipItem)
- dx = 0; dy = 96
- if @item.is_a?(RPG::Skill)
- dw = contents.width
- draw_applies(dx, dy + line_height * 0, dw)
- draw_removes(dx, dy + line_height * 1, dw)
- return
- end
- dw = contents.width / 2
- draw_hp_recover(dx, dy + line_height * 0, dw)
- draw_mp_recover(dx, dy + line_height * 1, dw)
- draw_tp_recover(dx + dw, dy + line_height * 0, dw)
- draw_tp_gain(dx + dw, dy + line_height * 1, dw)
- dw = contents.width
- draw_applies(dx, dy + line_height * 2, dw)
- draw_removes(dx, dy + line_height * 3, dw)
- end
- #--------------------------------------------------------------------------
- # * Desenha recuperação de HP
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_hp_recover(dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, Vocab[:HPRecover])
- per = 0
- set = 0
- for effect in @item.effects
- next unless effect.code == 11
- per += (effect.value1 * 100).to_i
- set += effect.value2.to_i
- end
- if per != 0 && set != 0
- change_color(param_change_color(set))
- text = set > 0 ? sprintf("+%s", set.group) : set.group
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- dw -= text_size(text).width
- change_color(param_change_color(per))
- text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- return
- elsif per != 0
- change_color(param_change_color(per))
- text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
- elsif set != 0
- change_color(param_change_color(set))
- text = set > 0 ? sprintf("+%s", set.group) : set.group
- else
- change_color(normal_color, false)
- text = Vocab[:Empty]
- end
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # * Desenha recuperação de MP
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_mp_recover(dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, Vocab[:MPRecover])
- per = 0
- set = 0
- for effect in @item.effects
- next unless effect.code == 12
- per += (effect.value1 * 100).to_i
- set += effect.value2.to_i
- end
- if per != 0 && set != 0
- change_color(param_change_color(set))
- text = set > 0 ? sprintf("+%s", set.group) : set.group
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- dw -= text_size(text).width
- change_color(param_change_color(per))
- text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- return
- elsif per != 0
- change_color(param_change_color(per))
- text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
- elsif set != 0
- change_color(param_change_color(set))
- text = set > 0 ? sprintf("+%s", set.group) : set.group
- else
- change_color(normal_color, false)
- text = Vocab[:Empty]
- end
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # * Desenha recuperação de TP
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_tp_recover(dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, Vocab[:TPRecover])
- set = 0
- for effect in @item.effects
- next unless effect.code == 13
- set += effect.value1.to_i
- end
- if set != 0
- change_color(param_change_color(set))
- text = set > 0 ? sprintf("+%s", set.group) : set.group
- else
- change_color(normal_color, false)
- text = Vocab[:Empty]
- end
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # * Desenha ganho de TP
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_tp_gain(dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, Vocab[:TPGain])
- set = @item.tp_gain
- if set != 0
- change_color(param_change_color(set))
- text = set > 0 ? sprintf("+%s", set.group) : set.group
- else
- change_color(normal_color, false)
- text = Vocab[:Empty]
- end
- draw_text(dx+4, dy, dw-8, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # * Desenha efeito aplicados
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_applies(dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, Vocab[:Applies])
- icons = []
- for effect in @item.effects
- case effect.code
- when 21
- next unless effect.value1 > 0
- next if $data_states[effect.value1].nil?
- icons.push($data_states[effect.value1].icon_index)
- when 31
- icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
- when 32
- icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
- end
- icons.delete(0)
- break if icons.size >= MaxIconsDrawn
- end
- draw_icons(dx, dy, dw, icons)
- end
- #--------------------------------------------------------------------------
- # * Desenha efeitos removidos
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- #--------------------------------------------------------------------------
- def draw_removes(dx, dy, dw)
- change_color(system_color)
- draw_text(dx+4, dy, dw-8, line_height, Vocab[:Removes])
- icons = []
- for effect in @item.effects
- case effect.code
- when 22
- next unless effect.value1 > 0
- next if $data_states[effect.value1].nil?
- icons.push($data_states[effect.data_id].icon_index)
- when 33
- icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
- when 34
- icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
- end
- icons.delete(0)
- break if icons.size >= MaxIconsDrawn
- end
- draw_icons(dx, dy, dw, icons)
- end
- #--------------------------------------------------------------------------
- # * Desenha ícones
- # dx : Posição X
- # dy : Posição Y
- # dw : Largura
- # icons : Array com identificação dos itens
- #--------------------------------------------------------------------------
- def draw_icons(dx, dy, dw, icons)
- dx += dw - 4
- dx -= icons.size * 24
- for icon_id in icons
- draw_icon(icon_id, dx, dy)
- dx += 24
- end
- if icons.size == 0
- change_color(normal_color, false)
- text = Vocab[:Empty]
- draw_text(4, dy, contents.width-8, line_height, text, 2)
- end
- end
- #--------------------------------------------------------------------------
- # * Desenha a descrição do item
- #--------------------------------------------------------------------------
- def draw_item_description
- change_color(normal_color)
- text = @item.description.split(/\s/)
- dy = (@item.is_a?(RPG::Skill) ? line_height * 3 + 96 : 200) - line_height
- word = text.shift
- tlen = contents.text_size(word).width
- phrs = word + " "
- until text.empty?
- word = text.shift
- len = contents.text_size(word).width
- if len + tlen >= contents_width / 1.25
- draw_text(0, dy += line_height, contents_width, line_height, phrs, 1)
- text.unshift(word)
- tlen = 0
- phrs = ''
- else
- tlen += len
- phrs += word + " "
- end
- end
- draw_text(0, dy + line_height, contents_width, line_height, phrs, 1)
- end
- end
- #==============================================================================
- # ** Menu_Item_Window
- #------------------------------------------------------------------------------
- # Janela responsável por mostrar itens filtrados (Itens, Armaduras, etc)
- #==============================================================================
- class Menu_Item_Window < Window_Command
- attr_reader :info
- attr_reader :equipMode
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- # x : Coordenada X
- # y : Coordenada Y
- # w : Largura
- # h : Altura
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h)
- @width = w
- @height = h
- @equipMode = nil
- super(x, y)
- self.applyFont(self.contents)
- self.open
- end
- #--------------------------------------------------------------------------
- # * Definição de uma flag para ativar a seleção de equipamentos
- # index : Novo modo
- # actor : Ator
- #--------------------------------------------------------------------------
- def enableEquipMode(index, actor)
- @equipMode = {index: index, actor: actor}
- end
- #--------------------------------------------------------------------------
- # * Desativa a flag de seleção de equipamentos
- #--------------------------------------------------------------------------
- def disableEquipMode
- @equipMode = nil
- end
- #--------------------------------------------------------------------------
- # * Atualização do cursor
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def update_cursor(*args, &block)
- super(*args, &block)
- @info.item = @data[index] if @data
- end
- #--------------------------------------------------------------------------
- # * Definição de resultado ao pressionar o botão de confirmação
- #--------------------------------------------------------------------------
- def process_ok
- end
- #--------------------------------------------------------------------------
- # * Define janela de informação
- # win : Janela
- #--------------------------------------------------------------------------
- def info=(win)
- @info = win
- win.item = @data[index] if @data
- end
- #--------------------------------------------------------------------------
- # * Aquisição da largura da janela
- #--------------------------------------------------------------------------
- def window_width
- return @width
- end
- #--------------------------------------------------------------------------
- # * Aquisição da altura da janela
- #--------------------------------------------------------------------------
- def window_height
- return @height
- end
- #--------------------------------------------------------------------------
- # * Desenho de um item
- # index : índice do item
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item))
- draw_item_number(rect, item)
- end
- end
- #--------------------------------------------------------------------------
- # * Desenho do número de itens possuido
- # rect : retângulo
- # item : item
- #--------------------------------------------------------------------------
- def draw_item_number(rect, item)
- draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
- end
- #--------------------------------------------------------------------------
- # * Criação da lista de comandos
- #--------------------------------------------------------------------------
- def make_command_list
- return unless @data
- @data.each{|item| add_command(item, :item_select) }
- end
- #------------------------------------------------------------------------
- # * Aplica filtro de itens
- # type : Tipo de filtro
- #------------------------------------------------------------------------
- def applyFilter(type)
- @category = [:item, :weapon, :armor, :key_item][type]
- self.make_item_list
- @info.item = @data[index] if @data
- self.refresh
- end
- #--------------------------------------------------------------------------
- # * Inclusão do item na lista
- # item : item
- #--------------------------------------------------------------------------
- def include?(item)
- if @equipMode
- return true if item.nil?
- return false unless item.is_a?(RPG::EquipItem)
- return false if item.etype_id != @equipMode[:actor].equip_slots[@equipMode[:index]]
- return @equipMode[:actor].equippable?(item)
- end
- case @category
- when :item
- item.is_a?(RPG::Item) && !item.key_item?
- when :weapon
- item.is_a?(RPG::Weapon)
- when :armor
- item.is_a?(RPG::Armor)
- when :key_item
- item.is_a?(RPG::Item) && item.key_item?
- else
- true
- end
- end
- #--------------------------------------------------------------------------
- # * Definição de habilitação do item
- # item : item
- #--------------------------------------------------------------------------
- def enable?(item)
- return true if @equipMode
- return false if not item.is_a?(RPG::Item)
- return false if item.key_item?
- user = $game_party.movable_members.max_by {|member| member.pha }
- case item.scope
- when 0..6
- data = []
- when 7..8
- data = $game_party.members
- when 9..10
- data = $game_party.members.select{|actor| actor.dead?}
- end
- return false if data.empty?
- return data.any?{|actor| actor.item_test(user, item) }
- end
- #--------------------------------------------------------------------------
- # * Definição de habilitação do item selecionado
- #--------------------------------------------------------------------------
- def current_item_enabled?
- return enable?(current_data[:name])
- end
- #--------------------------------------------------------------------------
- # * Criação da lista de itens
- #--------------------------------------------------------------------------
- def make_item_list
- @data = $game_party.all_items.select{|item| include?(item)}
- @data.push(nil) if include?(nil)
- end
- #--------------------------------------------------------------------------
- # * Criação do conteúdo das janelas
- #--------------------------------------------------------------------------
- def create_contents(*args, &block)
- super(*args, &block)
- self.applyFont(contents)
- end
- protected
- #-------------------------------------------------------------------------
- # * Aplica opções de fonte no bitmap
- # b : Bitmap
- #-------------------------------------------------------------------------
- def applyFont(b)
- b.font.name = MRM::ExtremeMenu::Font[:Name]
- b.font.size = MRM::ExtremeMenu::Font[:Size]
- b.font.color = Color.new(*MRM::ExtremeMenu::Font[:Color])
- b.font.shadow = MRM::ExtremeMenu::Font[:Shadow]
- b.font.outline = MRM::ExtremeMenu::Font[:Outline]
- return b
- end
- end
- #==============================================================================
- # ** Menu_Equips_Window
- #------------------------------------------------------------------------------
- # Esta classe mostra as informações de um monstro
- #==============================================================================
- class Menu_Equips_Window < Menu_Base_Window
- attr_reader :index
- attr_reader :info
- #-------------------------------------------------------------------------
- # * Inícialização do objeto
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- #-------------------------------------------------------------------------
- def initialize(x, y, w)
- super(x, y, w, fitting_height(7))
- self.opacity = 0
- self.contents_opacity = 0
- @actor = nil
- @index = 0
- vs = contents_height / 7.0
- @rect = Array.new(6){|i|
- Rect.new(0, (vs * i).round, contents_width, line_height)
- }
- @rect.last.y += vs
- end
- #--------------------------------------------------------------------------
- # * Define janela de informação
- # win : Janela
- #--------------------------------------------------------------------------
- def info=(win)
- @info = win
- end
- #-------------------------------------------------------------------------
- # * Seleção do ator
- # actor : Game_Actor da janela
- #-------------------------------------------------------------------------
- def actor=(actor)
- @actor = actor
- refresh
- end
- #-------------------------------------------------------------------------
- # * Determina estado de atividade
- # state : Ativa ou não a janela
- #-------------------------------------------------------------------------
- def active=(state)
- @active = state
- self.cursor_rect.set(@active ? @rect[@index] : Rect.new)
- end
- #-------------------------------------------------------------------------
- # * Modificação do índice da janela
- # value : Novo índice
- #-------------------------------------------------------------------------
- def index=(value)
- @index = value
- self.cursor_rect.set(@rect[@index])
- @info.item = @actor.equips[@index] if @info
- end
- #-------------------------------------------------------------------------
- # * Desenho do conteúdo
- #-------------------------------------------------------------------------
- def refresh
- contents.clear
- return unless @actor
- dy = 0
- @actor.equips.each_with_index{|item,index|
- if item
- draw_item_name(item, 0, dy, enable?(index), contents_width)
- else
- change_color(system_color)
- index = 0 if @actor.dual_wield? and index == 1
- draw_text(@rect[index], ::Vocab::etype(index).isoUpcase, 1)
- change_color(normal_color)
- end
- dy += line_height
- }
- draw_text(@rect.last, Vocab[:Optimize], 1)
- end
- #--------------------------------------------------------------------------
- # * Definição de habilitação do item
- # item : item
- #--------------------------------------------------------------------------
- def enable?(index)
- @actor ? @actor.equip_change_ok?(index) : false
- end
- #--------------------------------------------------------------------------
- # * Desenho do nome de itens
- # item : objeto
- # x : coordenada X
- # y : coordenada Y
- # enabled : habilitar flag, translucido quando false
- # width : largura
- #--------------------------------------------------------------------------
- def draw_item_name(item, x, y, enabled = true, width = 172)
- return unless item
- draw_icon(item.icon_index, x, y, enabled)
- change_color(normal_color, enabled)
- draw_text(x, y, width, line_height, item.name, 1)
- end
- end
- #==============================================================================
- # ** Menu_SkillCommand_Window
- #------------------------------------------------------------------------------
- # Esta janela exibe a lista de comandos para tela de habilidades
- # (como habilidades especiais e magias).
- #==============================================================================
- class Menu_SkillCommand_Window < Window_Command
- #--------------------------------------------------------------------------
- # * Variáveis públicas
- #--------------------------------------------------------------------------
- attr_reader :skill_window
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- # x : Coordenada X
- # y : Coordenada Y
- # w : Largura
- # h : Altura
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h)
- @width, @height = w, h
- super(x, y)
- self.opacity = 0
- self.active = false
- @actor = nil
- end
- #--------------------------------------------------------------------------
- # * Aquisição da largura da janela
- #--------------------------------------------------------------------------
- def window_width
- @width
- end
- #--------------------------------------------------------------------------
- # * Aquisição da altura da janela
- #--------------------------------------------------------------------------
- def window_height
- @height
- end
- #--------------------------------------------------------------------------
- # * Definição de resultado ao pressionar o botão de confirmação
- #--------------------------------------------------------------------------
- def process_ok
- end
- #--------------------------------------------------------------------------
- # * Alinhamento do texto
- #--------------------------------------------------------------------------
- def alignment
- return 1
- end
- #--------------------------------------------------------------------------
- # * Definição de herói
- # actor : herói
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # * Criação da lista de comandos
- #--------------------------------------------------------------------------
- def make_command_list
- return unless @actor
- @actor.added_skill_types.sort.each do |stype_id|
- name = $data_system.skill_types[stype_id]
- add_command(name, :skill, true, stype_id)
- end
- end
- #--------------------------------------------------------------------------
- # * Atualização da tela
- #--------------------------------------------------------------------------
- def update
- super
- @skill_window.stype_id = current_ext if @skill_window
- end
- #--------------------------------------------------------------------------
- # * Definição da janela de habilidades
- # skill_window : janela de habilidades
- #--------------------------------------------------------------------------
- def skill_window=(skill_window)
- @skill_window = skill_window
- update
- end
- #--------------------------------------------------------------------------
- # * Criação do conteúdo das janelas
- #--------------------------------------------------------------------------
- def create_contents(*args, &block)
- super(*args, &block)
- self.applyFont(contents)
- end
- protected
- #-------------------------------------------------------------------------
- # * Aplica opções de fonte no bitmap
- # b : Bitmap
- #-------------------------------------------------------------------------
- def applyFont(b)
- b.font.name = MRM::ExtremeMenu::Font[:Name]
- b.font.size = MRM::ExtremeMenu::Font[:Size]
- b.font.color = Color.new(*MRM::ExtremeMenu::Font[:Color])
- b.font.shadow = MRM::ExtremeMenu::Font[:Shadow]
- b.font.outline = MRM::ExtremeMenu::Font[:Outline]
- return b
- end
- end
- #==============================================================================
- # ** Menu_SkillList_Window
- #------------------------------------------------------------------------------
- # Esta janela exibe uma lista de habilidades usáveis na tela de habilidades.
- #==============================================================================
- class Menu_SkillList_Window < Window_Command
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- # x : Coordenada X
- # y : Coordenada Y
- # w : Largura
- # h : Altura
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h)
- @width, @height = w, h
- super(x, y)
- self.opacity = 0
- self.active = false
- @actor = nil
- @stype_id = 0
- @data = []
- end
- #--------------------------------------------------------------------------
- # * Aquisição da largura da janela
- #--------------------------------------------------------------------------
- def window_width
- @width
- end
- #--------------------------------------------------------------------------
- # * Aquisição da altura da janela
- #--------------------------------------------------------------------------
- def window_height
- @height
- end
- #--------------------------------------------------------------------------
- # * Atualização do cursor
- # *args // &block : Argumentos
- #--------------------------------------------------------------------------
- def update_cursor(*args, &block)
- super(*args, &block)
- @info.item = @data[index] if @data && @info
- end
- #--------------------------------------------------------------------------
- # * Definição de resultado ao pressionar o botão de confirmação
- #--------------------------------------------------------------------------
- def process_ok
- end
- #--------------------------------------------------------------------------
- # * Define janela de informação
- # win : Janela
- #--------------------------------------------------------------------------
- def info=(win)
- @info = win
- win.item = @data[index] if @data
- end
- #--------------------------------------------------------------------------
- # * Máximo de itens desenhados
- #--------------------------------------------------------------------------
- def item_max
- @data ? @data.size : 0
- end
- #--------------------------------------------------------------------------
- # * Definição de herói
- # actor : herói
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- self.oy = 0
- end
- #--------------------------------------------------------------------------
- # * Definição da ID do tipo de habilidade
- # stype_id : ID do tipo de habilidade
- #--------------------------------------------------------------------------
- def stype_id=(stype_id)
- return if @stype_id == stype_id
- @stype_id = stype_id
- refresh
- self.oy = 0
- end
- #--------------------------------------------------------------------------
- # * Aquisição das informações da skill
- #--------------------------------------------------------------------------
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- #--------------------------------------------------------------------------
- # * Definição de habilitação de seleção
- #--------------------------------------------------------------------------
- def current_item_enabled?
- enable?(@data[index])
- end
- #--------------------------------------------------------------------------
- # * Inclusão do item na lista
- # item : item
- #--------------------------------------------------------------------------
- def include?(item)
- item && item.stype_id == @stype_id
- end
- #--------------------------------------------------------------------------
- # * Definição de habilitação do item
- # item : item
- #--------------------------------------------------------------------------
- def enable?(item)
- @actor && @actor.usable?(item)
- end
- #--------------------------------------------------------------------------
- # * Criação da lista de itens
- #--------------------------------------------------------------------------
- def make_item_list
- @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
- end
- #--------------------------------------------------------------------------
- # * Desenho de um item
- # index : índice do item
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if skill
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(skill, rect.x, rect.y, enable?(skill))
- draw_skill_cost(rect, skill)
- end
- end
- #--------------------------------------------------------------------------
- # * Desenho do custo das habilidades
- # rect : retângulo
- # skill : habilidade
- #--------------------------------------------------------------------------
- def draw_skill_cost(rect, skill)
- if @actor.skill_tp_cost(skill) > 0
- change_color(tp_cost_color, enable?(skill))
- draw_text(rect, @actor.skill_tp_cost(skill), 2)
- elsif @actor.skill_mp_cost(skill) > 0
- change_color(mp_cost_color, enable?(skill))
- draw_text(rect, @actor.skill_mp_cost(skill), 2)
- end
- end
- #--------------------------------------------------------------------------
- # * Renovação
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- #--------------------------------------------------------------------------
- # * Criação do conteúdo das janelas
- #--------------------------------------------------------------------------
- def create_contents(*args, &block)
- super(*args, &block)
- self.applyFont(contents)
- end
- protected
- #-------------------------------------------------------------------------
- # * Aplica opções de fonte no bitmap
- # b : Bitmap
- #-------------------------------------------------------------------------
- def applyFont(b)
- b.font.name = MRM::ExtremeMenu::Font[:Name]
- b.font.size = MRM::ExtremeMenu::Font[:Size]
- b.font.color = Color.new(*MRM::ExtremeMenu::Font[:Color])
- b.font.shadow = MRM::ExtremeMenu::Font[:Shadow]
- b.font.outline = MRM::ExtremeMenu::Font[:Outline]
- return b
- end
- end
- #==============================================================================
- # ** Menu_ActorBase_Window
- #------------------------------------------------------------------------------
- # Esta classe mostra as informações simples do ator
- #==============================================================================
- class Menu_ActorBase_Window < Menu_Base_Window
- #-------------------------------------------------------------------------
- # * Inícialização do objeto
- # actor : Ator
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(actor, x, y, w, h)
- super(x, y, w, h)
- self.opacity = 0
- self.contents_opacity = 0
- self.actor = actor
- end
- #-------------------------------------------------------------------------
- # * Seleção do ator
- # actor : Game_Actor da janela
- #-------------------------------------------------------------------------
- def actor=(actor)
- @actor = actor
- @charBitmap = Cache.character(@actor.character_name)
- sign = @actor.character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- @cw = @charBitmap.width / 3
- @ch = @charBitmap.height / 4
- else
- @cw = @charBitmap.width / 12
- @ch = @charBitmap.height / 8
- end
- @pattern = 1
- refresh
- end
- #-------------------------------------------------------------------------
- # * Desenho do conteúdo
- #-------------------------------------------------------------------------
- def refresh
- half_width = contents.width/2
- contents.clear
- # FACE
- draw_actor_face(@actor, half_width - 48, line_height * 2)
- # NOME
- change_color(hp_color(@actor))
- draw_text(0, 0, contents_width, line_height, @actor.name, 1)
- # LINHA HORIZONTAL
- draw_horz_line(line_height * 1)
- # LINHA HORIZONTAL
- draw_horz_line(line_height * 6)
- # LEVEL
- rect = Rect.new(half_width - 44, line_height * 7, 88, line_height)
- change_color(system_color)
- draw_text(rect, ::Vocab::level_a)
- change_color(normal_color)
- draw_text(rect, @actor.level, 2)
- # ÍCONES
- icons = (@actor.state_icons + @actor.buff_icons)[0, contents_width / 24]
- bx = half_width - (icons.size * 12)
- icons.each_with_index{|n, i| draw_icon(n, bx + 24 * i, line_height * 8) }
- # HP
- draw_actor_hp(@actor, 3, line_height * 10, contents_width - 6)
- # MP
- draw_actor_mp(@actor, 3, line_height * 11, contents_width - 6)
- end
- #-------------------------------------------------------------------------
- # * Determina estado de atividade
- # state : Ativa ou não a janela
- #-------------------------------------------------------------------------
- def active=(state)
- @active = state
- self.cursor_rect.set(@active ? contents.rect : Rect.new)
- end
- end
- #==============================================================================
- # ** Menu_Formation_Window
- #------------------------------------------------------------------------------
- # Exibe informações do personagem para 'cena' de formação
- #==============================================================================
- class Menu_Formation_Window < Menu_ActorBase_Window
- #-------------------------------------------------------------------------
- # * Desenho do conteúdo
- #-------------------------------------------------------------------------
- def refresh
- contents.clear
- half_height = contents_height / 2
- # FACE
- draw_actor_face(@actor, 4, half_height - 48)
- # NOME
- change_color(hp_color(@actor))
- draw_text(156, 0, contents_width - 156, line_height, @actor.name, 0)
- # LINHA HORIZONTAL
- draw_horz_line(line_height / 2 - 4)
- # LEVEL
- rect = Rect.new(156, line_height * 2.5, 88, line_height)
- change_color(system_color)
- draw_text(rect, ::Vocab::level_a)
- change_color(normal_color)
- draw_text(rect, @actor.level, 2)
- # ÍCONES
- states = (@actor.state_icons + @actor.buff_icons)
- num = (contents_width - 260) / 24
- [
- states[ 0, num],
- states[num, num]
- ].each_with_index{|icons, i|
- next unless icons
- icons.each_with_index{|n, j|
- draw_icon(n, 260 + 24 * j, line_height + i * 26)
- }
- }
- # HP
- draw_actor_hp(@actor, 156, line_height * 0.75, 100)
- # MP
- draw_actor_mp(@actor, 156, line_height * 1.65, 100)
- end
- end
- #==============================================================================
- # ** Menu_ActorSelect_Window
- #------------------------------------------------------------------------------
- # Janela que exibe a face dos atores para seleção
- #==============================================================================
- class Menu_ActorSelect_Window < Menu_Base_Window
- attr_reader :faces
- attr_reader :index
- #-------------------------------------------------------------------------
- # * Inícialização do objeto
- # actor : Ator
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(x, y, w, h)
- super(x, y, w, h)
- self.opacity = 0
- @faces = []
- @index = 0
- end
- #-------------------------------------------------------------------------
- # * Retorna o ator selecionado
- #-------------------------------------------------------------------------
- def actor
- @faces[@index]
- end
- #-------------------------------------------------------------------------
- # * Índice máximo
- #-------------------------------------------------------------------------
- def maxIndex
- @faces.size
- end
- #-------------------------------------------------------------------------
- # * Modificação do índice da janela
- # value : Novo índice
- #-------------------------------------------------------------------------
- def index=(value)
- @index = value % @faces.size
- end
- #-------------------------------------------------------------------------
- # * Ajuste do cursor de acordo com a posição ox
- # value : Nova posição ox
- #-------------------------------------------------------------------------
- def ox=(value)
- super(value)
- self.cursor_rect.x = value
- end
- #-------------------------------------------------------------------------
- # * Posição ox correta (para animação)
- #-------------------------------------------------------------------------
- def trueOx
- @index * (standard_padding + 96)
- end
- #-------------------------------------------------------------------------
- # * Modificação das faces
- # nfs : Novas faces
- #-------------------------------------------------------------------------
- def faces=(value)
- @faces = value
- self.index = @index
- contents.dispose
- self.contents = Bitmap.new(
- @faces.size * (96 + standard_padding) - standard_padding,
- contents_height
- )
- self.applyFont(contents)
- refresh
- end
- #-------------------------------------------------------------------------
- # * Determina se a janela está ou não ativa
- # value : Atividade
- #-------------------------------------------------------------------------
- def active=(value)
- @active = value
- rect = contents.rect
- rect.x += 1
- rect.width = width - 2 * standard_padding - 2
- self.cursor_rect.set(@active ? rect : Rect.new)
- end
- #-------------------------------------------------------------------------
- # * Desenho da janela
- #-------------------------------------------------------------------------
- def refresh
- self.contents.clear
- faceW = 96 + standard_padding
- ax = (contents_width - 96) / 2 - faceW
- ay = (contents_height - 96) / 2
- @faces.each{|actor| draw_actor_face(actor, ax += faceW, ay) }
- end
- end
- #==============================================================================
- # ** Menu_ActorFull_Window
- #------------------------------------------------------------------------------
- # Esta janela exibe as especificações completas na janela de atributos.
- #==============================================================================
- class Menu_ActorFull_Window < Menu_Base_Window
- #-------------------------------------------------------------------------
- # * Início
- # actor : Ator
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(actor, x, y, w, h)
- super(x, y, w, h)
- self.opacity = 0
- @actor = actor
- end
- #--------------------------------------------------------------------------
- # * Definição de herói
- # actor : herói
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # * Renovação
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_block1 (line_height * 0)
- draw_horz_line(line_height * 1)
- draw_block2 (line_height * 2)
- draw_horz_line(line_height * 6)
- draw_block3 (line_height * 7)
- end
- #--------------------------------------------------------------------------
- # * Desenho do bloco 1
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_block1(y)
- draw_actor_name(@actor, 4, y)
- draw_actor_class(@actor, 128, y)
- draw_actor_nickname(@actor, 288, y)
- end
- #--------------------------------------------------------------------------
- # * Desenho do bloco 1
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_block2(y)
- draw_actor_face(@actor, 8, y)
- draw_basic_info(136, y)
- draw_exp_info(304, y)
- end
- #--------------------------------------------------------------------------
- # * Desenho do bloco 3
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_block3(y)
- draw_parameters(32, y)
- draw_equipments(288, y)
- end
- #--------------------------------------------------------------------------
- # * Desenho das informações básicas
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_basic_info(x, y)
- draw_actor_level(@actor, x, y + line_height * 0)
- draw_actor_icons(@actor, x, y + line_height * 1)
- draw_actor_hp(@actor, x, y + line_height * 2)
- draw_actor_mp(@actor, x, y + line_height * 3)
- end
- #--------------------------------------------------------------------------
- # * Desenho dos parâmetros
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_parameters(x, y)
- 6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
- end
- #--------------------------------------------------------------------------
- # * Desenho das informações de experiência
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_exp_info(x, y)
- s1 = @actor.max_level? ? "-------" : @actor.exp
- s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
- s_next = sprintf(::Vocab::ExpNext, ::Vocab::level)
- change_color(system_color)
- draw_text(x, y + line_height * 0, 180, line_height, ::Vocab::ExpTotal)
- draw_text(x, y + line_height * 2, 180, line_height, s_next)
- change_color(normal_color)
- draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
- draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
- end
- #--------------------------------------------------------------------------
- # * Desenho dos equipamentos
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_equipments(x, y)
- @actor.equips.each_with_index do |item, i|
- draw_item_name(item, x, y + line_height * i)
- end
- end
- #--------------------------------------------------------------------------
- # * Desenho da descrição
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_description(x, y)
- draw_text_ex(x, y, @actor.description)
- end
- end
- #==============================================================================
- # ** Menu_PDist_Window
- #------------------------------------------------------------------------------
- # Esta janela exibe os pontos e controla a adição de novos pontos de atribu-
- # tos aos atores.
- #==============================================================================
- class Menu_PDist_Window < Menu_ActorFull_Window
- attr_reader :actor
- attr_reader :index
- attr_reader :active
- attr_reader :drawn
- #-------------------------------------------------------------------------
- # * Início
- # actor : Ator
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(actor, x, y, w, h)
- @index = 0
- @active = false
- @drawn = false
- ay = line_height
- @rects = Array.new(8){|i|
- Rect.new(300, ay += line_height, 171, line_height)
- }
- @actorSheet = actor.pointsSheet
- super(actor, x, y, w, h)
- end
- #--------------------------------------------------------------------------
- # * Redesenho da janela
- #--------------------------------------------------------------------------
- def refresh
- super
- @drawn = true
- end
- #--------------------------------------------------------------------------
- # * Definição de atividade de janela
- # value : Novo valor
- #--------------------------------------------------------------------------
- def active=(value)
- @active = value
- if @active
- self.cursor_rect.set(@rects[@index])
- else
- self.cursor_rect.set(0, 0, 0, 0)
- end
- end
- #--------------------------------------------------------------------------
- # * Definição do índice da janela
- # value : Novo valor
- #--------------------------------------------------------------------------
- def index=(value)
- @index = value
- self.cursor_rect.set(@rects[@index])
- refresh
- end
- #--------------------------------------------------------------------------
- # * Desenho dos parâmetros
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_parameters(x, y)
- 8.times {|i| draw_actor_param(@actor, x, y + line_height * i, i) }
- end
- #--------------------------------------------------------------------------
- # * Desenho do bloco 2
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_block2(y)
- draw_actor_face(@actor, 8, y)
- draw_basic_info(136, y)
- draw_parameters(304, y)
- end
- #--------------------------------------------------------------------------
- # * Desenho do bloco 3
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_block3(y)
- draw_actor_sheetInfo(32, y)
- end
- #--------------------------------------------------------------------------
- # * Desenho dos parâmetros
- # actor : herói
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_actor_param(actor, x, y, param_id)
- plus = actor.param_plus(param_id)
- change_color(system_color)
- draw_text(x, y, 120, line_height, ::Vocab::param(param_id))
- change_color(normal_color)
- draw_text(x + 90, y, 36, line_height, actor.param(param_id) - plus, 2)
- if plus >= 0
- clr = plus == 0 ? normal_color : power_up_color
- sym = "+"
- elsif plus < 0
- clr = power_down_color
- sym = "-"
- end
- change_color(clr)
- draw_text(x + 132, y, 10, line_height, sym, 1)
- draw_text(x + 142, y, 23, line_height, actor.param_plus(param_id).abs, 2)
- change_color(normal_color)
- end
- #--------------------------------------------------------------------------
- # * Desenha mensagem de distribuição de pontos
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_actor_sheetInfo(x, y)
- PDistDiag.each_with_index{|line, i|
- draw_text_ex(x, y + line_height * i, parseDiag(line))
- }
- end
- #--------------------------------------------------------------------------
- # * Desenho de uma linha horzontal
- #--------------------------------------------------------------------------
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- color = normal_color
- color.alpha = 48
- contents.fill_rect(0, line_y, 275, 2, color)
- end
- #--------------------------------------------------------------------------
- # * Desenho do texto com caracteres de controle
- # x : coordenada X
- # y : coordenada Y
- # text : string de texto
- #--------------------------------------------------------------------------
- def draw_text_ex(x, y, text)
- text = convert_escape_characters(text)
- pos = {x: x, y: y, new_x: x, height: calc_line_height(text)}
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- protected
- #--------------------------------------------------------------------------
- # * Trata a linha para substituir as informações do ator
- # line : String
- #--------------------------------------------------------------------------
- def parseDiag(line)
- paramSym = @actorSheet.keys[@index + 1]
- line
- .gsub("{actorName}" , @actor.name)
- .gsub("{actorPoints}", @actor.attrPoints.to_s)
- .gsub("{attrName}", ::Vocab::param(@index))
- .gsub("{attrNPoints}", @actorSheet[paramSym].first.to_s)
- .gsub("{attrGPoints}", @actorSheet[paramSym].last.to_s)
- end
- end
- #==============================================================================
- # ** Menu_MonsterList_Window
- #------------------------------------------------------------------------------
- # Janela que mostra informações de monstros descobertos
- #==============================================================================
- class Menu_MonsterList_Window < Menu_Base_Window
- attr_reader :columns
- attr_reader :index
- attr_reader :rowMax
- #-------------------------------------------------------------------------
- # * Inicialização
- # monsters : Lista de Monstros
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(monsters, x, y, w, h)
- super(x, y, w, h)
- self.opacity = 0
- @rects = []
- @columns = 3
- @monsters = monsters
- @index = 0
- @rowMax = 1
- refresh
- end
- #-------------------------------------------------------------------------
- # * Define atividade da janela
- # value : Nova definição
- #-------------------------------------------------------------------------
- def active=(value)
- @active = value
- if @active
- self.cursor_rect.set(@rects[@index])
- else
- self.cursor_rect.set(0,0,0,0)
- end
- end
- #-------------------------------------------------------------------------
- # * Define índice
- # value : Novo índice
- #-------------------------------------------------------------------------
- def index=(value)
- @index = value
- self.cursor_rect.set(@rects[@index])
- end
- #-------------------------------------------------------------------------
- # Desenho da janela
- #-------------------------------------------------------------------------
- def refresh
- contents.clear
- monsters = $data_enemies
- rate = (@monsters.size.to_f / (monsters.size - 1))
- text = Vocab[:BComplete].gsub("{c}", (100 * rate).round(1).to_s)
- gc1 = Color.new( 80 * rate, 14 * rate, 80 - 24 * rate, 192)
- gc2 = Color.new(240 * rate, 62 * rate, 240 - 72 * rate, 192)
- draw_special_gauge(0, 0, contents_width, rate, gc1, gc2)
- draw_text(0, 0, contents_width, line_height, text, 1)
- x, y, i, cw = 0, line_height * 1.5, 0, contents_width / @columns
- @monsters.each_with_index{|id, index|
- @rects << Rect.new(x, y, cw, line_height)
- draw_text(x + 4, y, cw - 8, line_height, "#{index + 1}.")
- draw_text(@rects.last, monsters[id].name, 1)
- x += cw
- if (i += 1) == @columns
- i = x = 0
- y += line_height
- end
- }
- @rowMax = @monsters.size / @columns
- end
- end
- #==============================================================================
- # ** Menu_Monster_Window
- #------------------------------------------------------------------------------
- # Esta classe mostra as informações de um monstro
- #==============================================================================
- class Menu_Monster_Window < Menu_Base_Window
- attr_reader :monster
- #-------------------------------------------------------------------------
- # * Inicialização
- # monster : Monstro (RPG::Enemy)
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(monster, x, y, w, h)
- super(x, y, w, h)
- self.applyFont(self.contents)
- self.opacity = 0
- @fill = Bitmap.new(276, contents_height)
- @fill.fill_rect(@fill.rect, Color.new(0, 0, 0, 127))
- self.monster = monster
- end
- #-------------------------------------------------------------------------
- # * Determina inimigo que deverá ser mostrado
- # monster : Novo inimigo (RPG::Enemy)
- #-------------------------------------------------------------------------
- def monster=(monster)
- @monster = monster
- return unless @monster
- @battler = Cache.battler(@monster.battler_name, @monster.battler_hue)
- refresh
- end
- #-------------------------------------------------------------------------
- # Desenho da janela
- #-------------------------------------------------------------------------
- def refresh
- contents.clear
- contents.blt(
- contents_width - @battler.width,
- contents_height - @battler.height,
- @battler, @battler.rect
- )
- contents.blt(0, 0, @fill, @fill.rect)
- lh = line_height
- ay = lh * 4
- change_color(system_color)
- draw_text(6, 0, 124, line_height, @monster.name, 1)
- draw_text(6, ay += lh, 124, line_height, Vocab[:Experience])
- draw_text(6, ay += lh + lh, 124, line_height, Vocab[:Loot], 1)
- change_color(normal_color)
- ay = lh
- draw_hp(6, ay += lh)
- draw_mp(6, ay += lh)
- draw_text(6, ay += lh * 2, 124, line_height, @monster.exp, 2)
- ay += lh * 2
- draw_icon(Icon[:Gold], 6, ay += lh)
- draw_text(30, ay, 80, line_height, @monster.gold, 1)
- if @monster.drop_items.any?{|item| item.kind != 0}
- @monster.drop_items.each{|item|
- next if item.kind.zero?
- draw_item_name(item_object(item.kind, item.data_id), 6, ay += lh)
- }
- end
- ay = -lh
- 6.times{|index| draw_param(144, ay += lh, index + 2) }
- end
- #--------------------------------------------------------------------------
- # * Aquisição das informações do item
- # kind : tipo do item
- # data_id : ID do item
- #--------------------------------------------------------------------------
- def item_object(kind, data_id)
- return $data_items [data_id] if kind == 1
- return $data_weapons[data_id] if kind == 2
- return $data_armors [data_id] if kind == 3
- return nil
- end
- #--------------------------------------------------------------------------
- # * Desenho do HP
- # x : coordenada X
- # y : coordenada Y
- # width : largura
- #--------------------------------------------------------------------------
- def draw_hp(x, y, width = 124)
- gc1 = Color.new( 56, 80, 14, 192)
- gc2 = Color.new(168, 240, 62, 192)
- draw_special_gauge(x, y, width, 1, gc1, gc2)
- change_color(system_color)
- draw_text(x + width/2 - 20, y, 30, line_height, ::Vocab::hp_a)
- change_color(normal_color)
- draw_text(x + width/2 + 5, y, width/2, line_height, @monster.params[0])
- end
- #--------------------------------------------------------------------------
- # * Desenho do MP
- # x : coordenada X
- # y : coordenada Y
- # width : largura
- #--------------------------------------------------------------------------
- def draw_mp(x, y, width = 124)
- gc1 = Color.new(14, 56, 80, 192)
- gc2 = Color.new(62, 168, 240, 192)
- draw_special_gauge(x, y, width, 1, gc1, gc2)
- change_color(system_color)
- draw_text(x + width/2 - 20, y, 30, line_height, ::Vocab::mp_a)
- change_color(normal_color)
- draw_text(x + width/2 + 5, y, width/2, line_height, @monster.params[1])
- end
- #--------------------------------------------------------------------------
- # * Desenho dos parâmetros
- # x : coordenada X
- # y : coordenada Y
- # param_id : ID do parâmetro
- #--------------------------------------------------------------------------
- def draw_param(x, y, param_id)
- change_color(system_color)
- draw_text(x, y, 120, line_height, ::Vocab::param(param_id))
- change_color(normal_color)
- draw_text(x + 90, y, 36, line_height, @monster.params[param_id], 2)
- change_color(normal_color)
- end
- end
- #==============================================================================
- # ** Menu_SaveFile_Window
- #------------------------------------------------------------------------------
- # Mostra a informação de save e criação de novo jogo
- #==============================================================================
- class Menu_SaveFile_Window < Menu_Base_Window
- attr_reader :active
- attr_reader :exist
- attr_reader :index
- #-------------------------------------------------------------------------
- # * Inicialização
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- # index : Index do save
- # exist : Save existe? (Se não, será criada uma janela de "Novo Save"
- #-------------------------------------------------------------------------
- def initialize(x, y, w, h, index, exist)
- super(x, y, w, h)
- self.opacity = 0
- self.applyFont(contents)
- @active = false
- @pattern = 0
- self.load_data(index, exist)
- @blankRect = Rect.new
- refresh(true)
- end
- #-------------------------------------------------------------------------
- # * Carregamento da informação do save
- # index : Index do save
- # header : Save existe? (Se não, será criada uma janela de "Novo Save"
- #-------------------------------------------------------------------------
- def load_data(index, header)
- @index = index
- if header
- @data = header
- @preview = Bitmap.new_from_data(@data[:preview], 157)
- end
- @previewRect = Rect.new(0, line_height, contents_width, line_height)
- end
- #-------------------------------------------------------------------------
- # * Atualização
- #-------------------------------------------------------------------------
- def update
- super
- if (Graphics.frame_count % Graphics.frame_rate) == 0
- refresh
- elsif (Graphics.frame_count % ActorsSpeed) == 0
- @pattern += 1
- @pattern %= 3
- redraw_chars
- end
- end
- #-------------------------------------------------------------------------
- # * Redesenha janela
- # complete : Redesenho completo?
- #-------------------------------------------------------------------------
- def refresh(complete = false)
- if complete
- contents.clear
- if @data
- contents.blt(0, line_height, @preview, @preview.rect)
- @previewRect.y = 86 + 4 * line_height
- draw_text(@previewRect, @data[:playtime_s], 1)
- else
- change_color(system_color)
- draw_text(@previewRect, Vocab[:FreeSlot], 1)
- change_color(normal_color)
- @previewRect.y += line_height
- draw_text(@previewRect, Vocab[:NewSave], 1)
- end
- change_color(system_color)
- @previewRect.y = 86 + 3 * line_height
- draw_text(@previewRect, Vocab[:PlayTime], 1)
- @previewRect.y = 86 + 6 * line_height
- draw_text(@previewRect, Vocab[:Party], 1)
- change_color(normal_color)
- elsif !@data
- @previewRect.y = 86 + 4 * line_height
- contents.clear_rect(@previewRect)
- draw_text(@previewRect, $game_system.playtime_s, 1)
- end
- redraw_chars
- end
- #-------------------------------------------------------------------------
- # * Redesenha atores
- #-------------------------------------------------------------------------
- def redraw_chars
- y = 86 + line_height * 7
- contents.clear_rect(0, y, contents_width, contents_height - y)
- if @data
- space = (contents_width / @data[:characters].size)
- @data[:characters].each_with_index{|data, index|
- draw_character(data[0], data[1], (index + 0.5) * space, y)
- }
- else
- chars = $game_party.battle_members
- space = (contents_width / chars.size)
- chars.each_with_index{|char, index|
- draw_character(char.character_name, char.character_index, (index + 0.5) * space, y)
- }
- end
- end
- #--------------------------------------------------------------------------
- # * Desenho do gráfico do personagem
- # character_name : nome do gráfico do personagem
- # character_index : índice do gráfico de personagem
- # x : coordenada X
- # y : coordenada Y
- #--------------------------------------------------------------------------
- def draw_character(character_name, character_index, x, y)
- return unless character_name
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- src_rect = Rect.new((n%4*3+@pattern)*cw, (n/16)*ch, cw, ch)
- contents.blt(x - cw / 2, y, bitmap, src_rect)
- return cw
- end
- #-------------------------------------------------------------------------
- # * Determina se a janela é de novo save ou já possui um
- #-------------------------------------------------------------------------
- def exist
- return !!@data
- end
- #-------------------------------------------------------------------------
- # * Determina estado de atividade
- # state : Ativa ou não a janela
- #-------------------------------------------------------------------------
- def active=(state)
- @active = state
- self.cursor_rect.set(@active ? contents.rect : @blankRect)
- end
- end
- #==============================================================================
- # ** StaticMiniMap
- #------------------------------------------------------------------------------
- # Classe responsável por gerar um mini-map estático que será usado no menu
- #==============================================================================
- class StaticMiniMap
- include MRM::ExtremeMenu
- attr_reader :viewport
- #-------------------------------------------------------------------------
- # * Inicialização do objeto
- # viewport : Camada de visibilidade
- #-------------------------------------------------------------------------
- def initialize(viewport)
- @viewport = viewport
- @opacity = 255
- precalculus
- refresh
- sx = -$game_player.real_x * TileSize + MapOffset
- sy = -$game_player.real_y * TileSize + MapOffset
- @map.x = @object_layer.x = sx
- @map.y = @object_layer.y = sy
- draw_object_layer
- end
- #-------------------------------------------------------------------------
- # * Realiza pré-calculo
- #-------------------------------------------------------------------------
- def precalculus
- @finalSize = [
- $game_map.width * TileSize + @viewport.rect.width,
- $game_map.height * TileSize + @viewport.rect.height
- ]
- @halfWidth = @viewport.rect.width / 2
- @halfHeight = @viewport.rect.height / 2
- @tsm2 = TileSize - 2
- @objColor = {}
- ObjectColor.each_pair{|key, value|
- @objColor[key] = Color.new(*value)
- }
- @playerColor = Color.new(*PlayerColor)
- @mapColor = Color.new(*MapColor)
- @mapBorderColor = Color.new(*MapBorderColor)
- @borderColor = Color.new(*BorderColor)
- end
- #-------------------------------------------------------------------------
- # * Desenha o conteúdo
- #-------------------------------------------------------------------------
- def refresh
- @map = Sprite.new(@viewport)
- @map.z = 0
- @map.bitmap = draw_map
- @object_layer = Sprite.new(@viewport)
- @object_layer.z = 1
- @object_layer.bitmap = Bitmap.new(*@finalSize)
- @object_layer.opacity = ObjectLayerOpacity
- draw_object_layer
- end
- #-------------------------------------------------------------------------
- # * Desenha a camada com eventos e com o jogador
- #-------------------------------------------------------------------------
- def draw_object_layer
- comment = [108, 408]
- for event in $game_map.events.keys
- next unless $game_map.events[event].list
- $game_map.events[event].list.each{|item|
- next unless comment.include?(item.code)
- type = item.parameters[0]
- next unless @objColor.has_key?(type)
- draw_object($game_map.events[event], @objColor[type])
- }
- end
- draw_object($game_player, @playerColor)
- end
- #-------------------------------------------------------------------------
- # * Desenha um character
- # obj : Game_Character
- # color : Cor de preenchimento
- #-------------------------------------------------------------------------
- def draw_object(obj, color)
- x = obj.real_x * TileSize + @halfWidth
- y = obj.real_y * TileSize + @halfHeight
- @object_layer.bitmap.fill_rect(x + 1, y, @tsm2, TileSize, @borderColor)
- @object_layer.bitmap.fill_rect( x, y + 1, TileSize, @tsm2, @borderColor)
- @object_layer.bitmap.fill_rect(x + 1, y + 1, @tsm2, @tsm2, color)
- end
- #-------------------------------------------------------------------------
- # * Desenha os obstáculos do mapa
- #-------------------------------------------------------------------------
- def draw_map
- front = make_map_bitmap(@mapColor)
- border = make_map_bitmap(@mapBorderColor)
- result = Bitmap.new(*@finalSize)
- result.blt(-1, 0, border, border.rect)
- result.blt( 1, 0, border, border.rect)
- result.blt( 0, -1, border, border.rect)
- result.blt( 0, 1, border, border.rect)
- result.blt( 0, 0, front, front.rect )
- return result
- end
- #-------------------------------------------------------------------------
- # * Desenha os obstáculos do mapa em determinada cor
- # color : Cor de destino
- #-------------------------------------------------------------------------
- def make_map_bitmap(color)
- bitmap = Bitmap.new(*@finalSize)
- $game_map.width.times{|x| $game_map.height.times{|y|
- next if $game_map.passable?(x, y, 4)
- ax = x * TileSize + @halfWidth
- ay = y * TileSize + @halfHeight
- bitmap.fill_rect(ax, ay, TileSize, TileSize, color)
- }}
- return bitmap
- end
- #-------------------------------------------------------------------------
- # * Retorna coordenada X
- #-------------------------------------------------------------------------
- def x
- return @viewport.rect.x
- end
- #-------------------------------------------------------------------------
- # * Redefine a coordenada X
- # value : Nova coordenada
- #-------------------------------------------------------------------------
- def x=(value)
- @viewport.rect.x = value
- end
- #-------------------------------------------------------------------------
- # * Retorna opacidade
- #-------------------------------------------------------------------------
- def opacity
- return @opacity
- end
- #-------------------------------------------------------------------------
- # * Redefine a opacidade
- # value : Nova opacidade
- #-------------------------------------------------------------------------
- def opacity=(value)
- @opacity = value
- @map.opacity = value
- @object_layer.opacity = value * ObjectLayerOpacity / 255.0
- end
- #-------------------------------------------------------------------------
- # * Dispõe o conjunto
- #-------------------------------------------------------------------------
- def dispose
- @map.dispose
- @object_layer.dispose
- end
- end
- #==============================================================================
- # ** Menu_Options_Window
- #------------------------------------------------------------------------------
- # Classe controladora das opções no menu
- #==============================================================================
- class Menu_Options_Window < Menu_Base_Window
- attr_accessor :barActive
- attr_reader :index
- #-------------------------------------------------------------------------
- # * Inicialização
- # x : Posição X inicial da janela
- # y : Posição Y inicial da janela
- # w : Largura
- # h : Altura
- #-------------------------------------------------------------------------
- def initialize(x, y, w, h)
- super(x, y, w, h)
- self.opacity = 0
- self.applyFont(self.contents)
- cx = contents_width/2
- @rect = {
- sfx: Rect.new(0, line_height * 4, cx * 2, line_height * 2),
- music: Rect.new(cx - 140, line_height * 6, 125, line_height ),
- sound: Rect.new(cx - 140, line_height * 7, 125, line_height )
- }
- @barActive = false
- @index = 0
- refresh
- self.index = -1
- end
- #-------------------------------------------------------------------------
- # * Redesenha conteúdo
- #-------------------------------------------------------------------------
- def refresh
- contents.clear
- # Texto
- change_color(system_color)
- contents.font.size *= 1.1
- contents.draw_text(@rect[:sfx], Vocab[:OptionsSFX], 1)
- contents.font.size /= 1.1
- change_color(normal_color)
- contents.draw_text(@rect[:music], Vocab[:OptionsMsc], 1)
- contents.draw_text(@rect[:sound], Vocab[:OptionsSnd], 1)
- # Barras
- drawRect(:music, $game_system.musicRate)
- drawRect(:sound, $game_system.soundRate)
- end
- #-------------------------------------------------------------------------
- # * Desenha Barra
- # type : Tipo
- # rate : Proporção do preenchimento
- #-------------------------------------------------------------------------
- def drawRect(type, rate)
- rect = Rect.new.set(@rect[type])
- rect.x += rect.width + 26
- rect.y += 3
- rect.width -= 6
- rect.height -= 10
- gc1 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
- gc2 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
- draw_special_gauge(rect.x, rect.y, rect.width, rect.height, rate, gc1, gc2)
- change_color(system_color)
- draw_text(rect, "- #{(rate * 100).round}% +", 1)
- change_color(normal_color)
- end
- #-------------------------------------------------------------------------
- # * Desenha a barra especial estilo Cogwheel
- # x : Posição X
- # y : Posição Y
- # width : Largura
- # height : Altura
- # rate : Porção de preenchimento
- # gc1 : Cor 1
- # gc2 : Cor 2
- #-------------------------------------------------------------------------
- def draw_special_gauge(x, y, width, height, rate, gc1, gc2)
- y += line_height/2
- contents.fill_rect(x, y - 10, width, height, BC1)
- contents.fill_rect(x + 1, y - 9, width - 2, height - 2, BC2)
- contents.gradient_fill_rect(x + 2, y - 8, width - 4, height - 4, BC3, BC4)
- contents.gradient_fill_rect(x + 2, y - 8, (width*rate) - 4, height-4, gc1, gc2)
- end
- #-------------------------------------------------------------------------
- # * Atualização do índice
- #-------------------------------------------------------------------------
- def index=(value)
- @index = value
- if (@index == -1)
- self.cursor_rect.set(0,0,0,0)
- else
- _rect = @rect[@index == 0 ? :music : :sound].dup
- if @barActive
- _rect.x += _rect.width + 25
- _rect.y += 4
- _rect.width -= 4
- _rect.height -= 8
- end
- self.cursor_rect.set(_rect)
- end
- end
- end
- # Remove menu anterior
- Object.send(:remove_const, :Scene_Menu)
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # Esta classe executa o processamento da tela de menu.
- #==============================================================================
- class Scene_Menu < Scene_Base
- #-------------------------------------------------------------------------
- # * Início da cena
- #-------------------------------------------------------------------------
- def start
- super
- @stage = :Base
- @baseIndex = 0
- @itemIndex = 0
- @equipsIndex = 0
- @skillsIndex = 0
- @formationIndex1 = 0
- @formationIndex2 = 0
- @statusIndex = 0
- @bestiaryIndex = 0
- @pdistIndex = 0
- @optionIndex = 0
- @saveIndex = 0
- @saveOverIndex = 0
- @exitIndex = 0
- @removedFormationWin = nil
- @iconset = Cache.system("Iconset")
- # Flag necessária para remover lag
- # de inicialização do menu.
- @__NeedRefresh = []
- load_vocabulary
- process_move_data
- create_background
- create_icons
- if @baseIcons.size > 0
- create_cursor
- create_message
- end
- create_windows
- create_minimap if @baseIcons.size > 0
- #RPG::BGM.fade(@winsEnter[:time] * 1000)
- #RPG::BGS.fade(@winsEnter[:time] * 1000)
- end
- #-------------------------------------------------------------------------
- # * Atualização da cena
- #-------------------------------------------------------------------------
- def update
- super
- Tween.update
- if @baseIcons.size == 0
- process_return if Input.trigger?(:B)
- return
- end
- update_input
- # Faz processo de desenho das janelas de distribuição
- # de pontos. Este é um método necessário para remover
- # o lag de inicialização do menu, simulando uma espé-
- # cie de processo paralelo entre os frames. Garante
- # que as janelas existam mas remove o tempo inicial
- # usado para desenho e distribui entre os frames até
- # que todas as janelas tenham sido desenhadas.
- unless @__NeedRefresh.empty?
- if Graphics.frame_count % (Graphics.frame_rate/5) == 0
- @__NeedRefresh.shift.refresh
- end
- end
- case @stage
- when :Base, :Exit, :Formation, :Equips, :Skills
- update_actors_windows
- when :Items, :ItemsSelection, :EquipsTrade
- update_items_window
- when :ItemsActorSelection, :SkillsActorSelection
- @actorSelect.update
- when :EquipsSelection
- update_equips_windows
- when :SkillsTSelection, :SkillsSelection
- update_skills_windows
- when :PDist
- update_pdist_windows
- when :Save, :SaveOverWrite
- update_save_windows
- when :FormationNextActor
- @actorsWindows[@formationIndex1].update
- update_formation_windows
- end
- end
- #-------------------------------------------------------------------------
- # * Finalização da cena
- #-------------------------------------------------------------------------
- def terminate
- super
- dispose_background
- return dispose_actors_windows if @baseIcons.size == 0
- dispose_icons
- dispose_cursor
- dispose_message
- dispose_windows
- end
- #-------------------------------------------------------------------------
- # * Carrega informação de vocabulário
- #-------------------------------------------------------------------------
- def load_vocabulary
- @baseVocab = MRM::ExtremeMenu.enabledOptions(:name)
- @itemVocab = MRM::ExtremeMenu.enabledSubOption(:Items, :Names)
- @saveVocab = MRM::ExtremeMenu.enabledSubOption(:Save, :Names)
- @exitVocab = MRM::ExtremeMenu.enabledSubOption(:Exit, :Names)
- end
- #-------------------------------------------------------------------------
- # * Processa informação de movimento
- #-------------------------------------------------------------------------
- def process_move_data
- [
- [:IconsEnter, :@iconsEnter ],
- [:IconsMove, :@iconsMove ],
- [:CursorEnter, :@cursorEnter ],
- [:CursorMove, :@cursorMove ],
- [:Message, :@messageAnim ],
- [:ActorSelEnter, :@actorSelEnter ],
- [:ActorSelMove, :@actorSelMove ],
- [:ItemsEnter, :@itemsEnter ],
- [:ItemsMove, :@itemsMove ],
- [:EquipsEnter, :@equipsEnter ],
- [:EquipsMove, :@equipsMove ],
- [:SkillsEnter, :@skillsEnter ],
- [:SkillsMove, :@skillsMove ],
- [:WindowsEnter, :@winsEnter ],
- [:WindowsMove, :@winsMove ],
- [:SaveEnter, :@saveEnter ],
- [:SaveMove, :@saveMove ],
- [:StatusEnter, :@statusEnter ],
- [:StatusMove, :@statusMove ],
- [:BestiaryEnter, :@bestiaryEnter ],
- [:BestiaryMove, :@bestiaryMove ],
- [:PDistEnter, :@pdistEnter ],
- [:PDistMove, :@pdistMove ],
- [:MiniMapEnter, :@minimapEnter ],
- [:MiniMapMove, :@minimapMove ],
- [:OptionEnter, :@optionEnter ],
- [:FormationEnter, :@formationEnter],
- [:FormationMove, :@formationMove ],
- ].each{|key, var|
- data = MRM::ExtremeMenu::Animation[key]
- moveData = {
- :style => Tween::EASERS[data[0]] || Tween::Linear,
- :time => data[1]
- }
- moveData[:off] = data[2] if data[2]
- self.instance_variable_set(var, moveData)
- }
- end
- #-------------------------------------------------------------------------
- # * Cria fundo
- #-------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- #-------------------------------------------------------------------------
- # * Cria ícones
- #-------------------------------------------------------------------------
- def create_icons
- create_base_icons
- create_item_icons
- create_save_icons if MRM::ExtremeMenu::ConfirmOverwrite
- create_exit_icons
- end
- #-------------------------------------------------------------------------
- # * Cria ícones base
- #-------------------------------------------------------------------------
- def create_base_icons
- icons = MRM::ExtremeMenu.enabledOptions(:icon)
- @baseIcons = self.create_generic_icons(icons)
- end
- #-------------------------------------------------------------------------
- # * Cria ícones de itens
- #-------------------------------------------------------------------------
- def create_item_icons
- icons = MRM::ExtremeMenu.enabledSubOption(:Items, :Icons)
- @itemIcons = self.create_generic_icons(icons, false)
- end
- #-------------------------------------------------------------------------
- # * Cria ícones de save (confirmação de sobreescrita)
- #-------------------------------------------------------------------------
- def create_save_icons
- icons = MRM::ExtremeMenu.enabledSubOption(:Save, :Icons)
- @saveIcons = self.create_generic_icons(icons, false)
- end
- #-------------------------------------------------------------------------
- # * Cria ícones de saída
- #-------------------------------------------------------------------------
- def create_exit_icons
- icons = MRM::ExtremeMenu.enabledSubOption(:Exit, :Icons)
- @exitIcons = self.create_generic_icons(icons, false)
- end
- #-------------------------------------------------------------------------
- # * Cria cursor
- #-------------------------------------------------------------------------
- def create_cursor
- b = self.applyFont(Bitmap.new(1,1))
- s = (@baseVocab + @exitVocab).inject([0,0]){|max,act|
- v = b.text_size(act)
- [
- v.width > max[0] ? v.width : max[0],
- v.height > max[1] ? v.height : max[1]
- ]
- }
- b.dispose
- @cursor = Sprite.new
- @cursor.opacity = 0
- @cursor.bitmap = self.applyFont(Bitmap.new(*s))
- @cursor.ox = @cursor.width / 2.0
- @cursor.x = Graphics.width / (2 * @baseIcons.size)
- @cursor.y = @baseIcons.first.y - @cursor.height - 60
- @cursor.bitmap.draw_text(0, 0, *s, @baseVocab.first, 1)
- Tween.start(@cursor, @cursorEnter[:style], @cursorEnter[:time],
- :opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Cria mensagem
- #-------------------------------------------------------------------------
- def create_message
- s = self.applyFont(Bitmap.new(1,1))
- sz = s.text_size("www.mundorpgmaker.com")
- @message = Sprite.new
- @message.bitmap = self.applyFont(Bitmap.new(Graphics.width, sz.height))
- @message.y = @cursor.y - sz.height - 8
- @message.opacity = 0
- s.dispose
- end
- #-------------------------------------------------------------------------
- # * Cria janelas
- #-------------------------------------------------------------------------
- def create_windows
- create_actors_windows
- return if @baseIcons.size == 0
- create_items_windows
- create_equips_window
- create_skills_windows
- create_status_windows
- create_formation_windows
- create_bestiary_windows
- create_pdist_windows
- create_options_window
- create_save_windows
- create_actor_select_window
- end
- #-------------------------------------------------------------------------
- # * Cria as janelas de informação base dos atores
- #-------------------------------------------------------------------------
- def create_actors_windows
- size = $game_party.battle_members.size
- width = Graphics.width / size
- height = @cursor ? @cursor.y - 16 : Graphics.width
- baseX = size == 1 ? (width /= 2) / 2 : 0
- @actorsWindows = $game_party.battle_members.map.with_index{|actor, index|
- win = Menu_ActorBase_Window.new(actor, Graphics.width, 0, width, height)
- Tween.start(win, @winsEnter[:style], @winsEnter[:time], @winsEnter[:off] * index,
- :contents_opacity => 255,
- :x => baseX + (width * index)
- )
- win
- }
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de itens
- #-------------------------------------------------------------------------
- def create_items_windows
- x, y, w, h = Graphics.width, 0, Graphics.width/2, @cursor.y - 16
- @itemsWindow = Menu_Item_Window.new(x, y, w, h)
- @itemsWindow.active = false
- @itemsWindow.opacity = 0
- @itemsWindow.contents_opacity = 0
- @itemsInfo = Menu_ItemInfo_Window.new(x, y, Graphics.width - w, h)
- @itemsWindow.info = @itemsInfo
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de equipamentos
- #-------------------------------------------------------------------------
- def create_equips_window
- @equipsWindow = Menu_Equips_Window.new(Graphics.width, 0, Graphics.width/2)
- @equipsWindow.info = @itemsInfo
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de habilidades
- #-------------------------------------------------------------------------
- def create_skills_windows
- x, y, w, h = Graphics.width, 0, Graphics.width / 2, @cursor.y - 16
- @stypeWindow = Menu_SkillCommand_Window.new(x, y, w, h)
- @slistWindow = Menu_SkillList_Window.new(x, y, w, h)
- @stypeWindow.contents_opacity = 0
- @slistWindow.contents_opacity = 0
- @stypeWindow.skill_window = @slistWindow
- @slistWindow.info = @itemsInfo
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de formação
- #-------------------------------------------------------------------------
- def create_formation_windows
- size = $game_party.battle_members.size
- x = Graphics.width / size
- y = Graphics.height
- width = Graphics.width - x
- height = (@cursor.y - 16) / 3
- @formationWindows = $game_party.members.map.with_index{|actor, index|
- win = Menu_Formation_Window.new(actor, x, y, width, height)
- win.contents_opacity = 0
- win
- }
- @__NeedRefresh += @formationWindows
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de informação completa dos atores
- #-------------------------------------------------------------------------
- def create_status_windows
- width = Graphics.width
- height = @cursor.y - 16
- @statusWindows = $game_party.members.map.with_index{|actor, index|
- win = Menu_ActorFull_Window.new(actor, Graphics.width, 0, width, height)
- win.contents_opacity = 0
- win
- }
- @__NeedRefresh += @statusWindows
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de monstros do bestiário
- #-------------------------------------------------------------------------
- def create_bestiary_windows
- x, y, w, h = Graphics.width, 0, Graphics.width, @cursor.y - 16
- @monsterList = Menu_MonsterList_Window.new($game_system.monsters, x, y, w, h)
- @monsterWindow = Menu_Monster_Window.new(nil, x, y, w, h)
- end
- #-------------------------------------------------------------------------
- # * Cria janelas de distribuição de pontos
- #-------------------------------------------------------------------------
- def create_pdist_windows
- width = Graphics.width
- height = @cursor.y - 16
- @pdistWindows = $game_party.members.map.with_index{|actor, index|
- win = Menu_PDist_Window.new(actor, Graphics.width, 0, width, height)
- win.contents_opacity = 0
- win
- }
- @__NeedRefresh += @pdistWindows
- end
- #-------------------------------------------------------------------------
- # * Cria janela de save
- #-------------------------------------------------------------------------
- def create_save_windows
- @saveWindows = []
- index = -1
- continue = false
- x, y, w, h = Graphics.width, 0, Graphics.width/3, @cursor.y - 16
- begin
- @saveWindows << Menu_SaveFile_Window.new(x, y, w, h, index, continue)
- @saveWindows.last.contents_opacity = 0
- continue = DataManager.load_header(index += 1)
- end until not continue or index >= DataManager.savefile_max
- @saveWindows.shift.dispose if @saveWindows.size == DataManager.savefile_max + 1
- end
- #-------------------------------------------------------------------------
- # * Cria janela de opções
- #-------------------------------------------------------------------------
- def create_options_window
- @optionWindow = Menu_Options_Window.new(Graphics.width, 0, Graphics.width, @cursor.y - 16)
- @optionWindow.contents_opacity = 0
- end
- #-------------------------------------------------------------------------
- # * Cria mini-mapa
- #-------------------------------------------------------------------------
- def create_minimap
- viewport = Viewport.new(Graphics.width, 0, Graphics.width, @cursor.y - 16)
- @minimap = StaticMiniMap.new(viewport)
- end
- #-------------------------------------------------------------------------
- # * Cria janela de seleção de atores
- #-------------------------------------------------------------------------
- def create_actor_select_window
- x = Graphics.width
- @actorSelect = Menu_ActorSelect_Window.new(x, @cursor.y - 16 - 128, 128, 128)
- @actorSelect.contents_opacity = 0
- end
- #-------------------------------------------------------------------------
- # * Atualização de Entrada
- #-------------------------------------------------------------------------
- def update_input
- if Input.trigger?(:B)
- process_return
- elsif Input.trigger?(:C)
- process_confirm
- else
- [:LEFT, :RIGHT, :UP, :DOWN].each{|key|
- process_move(key.capitalize) if Input.repeat?(key)
- }
- end
- end
- #-------------------------------------------------------------------------
- # * Desabilita atualização automatica de janelas
- # (Processo desnecessário)
- #-------------------------------------------------------------------------
- def update_all_windows
- end
- #-------------------------------------------------------------------------
- # * Atualização das janelas dos atores
- #-------------------------------------------------------------------------
- def update_actors_windows
- @actorsWindows.each(&:update)
- end
- #-------------------------------------------------------------------------
- # * Atualização da janela de itens
- #-------------------------------------------------------------------------
- def update_items_window
- @itemsWindow.update
- @itemsInfo.update
- end
- #-------------------------------------------------------------------------
- # * Atualização das janelas de equipamentos
- #-------------------------------------------------------------------------
- def update_equips_windows
- @equipsWindow.update
- @itemsInfo.update
- end
- #-------------------------------------------------------------------------
- # * Atualização das janelas de habilidades
- #-------------------------------------------------------------------------
- def update_skills_windows
- @stypeWindow.update
- @slistWindow.update
- @itemsInfo.update
- end
- #-------------------------------------------------------------------------
- # * Atualização das janelas de formação
- #-------------------------------------------------------------------------
- def update_formation_windows
- @formationWindows[@formationIndex2].update
- end
- #-------------------------------------------------------------------------
- # * Atualização da janela de distribuição de pontos
- #-------------------------------------------------------------------------
- def update_pdist_windows
- @pdistWindows.each(&:update)
- end
- #-------------------------------------------------------------------------
- # * Atualização da janela de opções
- #-------------------------------------------------------------------------
- def update_options_window
- @optionWindow.update
- end
- #-------------------------------------------------------------------------
- # * Atualização das janelas de save
- #-------------------------------------------------------------------------
- def update_save_windows
- @saveWindows.each(&:update)
- end
- #-------------------------------------------------------------------------
- # * Processa retorno
- #-------------------------------------------------------------------------
- def process_return
- case @stage
- when :Base
- SceneManager.goto(Scene_Map)
- $game_map.autoplay
- Sound.play_cancel
- when :Items
- self.hide_icons(*@itemIcons)
- self.show_icons(*@baseIcons)
- self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
- self.show_actors_windows
- self.hide_items_window
- @stage = :Base
- Sound.play_cancel
- when :ItemsSelection
- self.items_filter_animation{
- @itemsWindow.applyFilter(0)
- @itemsWindow.active = false
- @itemsWindow.index = -1
- }
- @stage = :Items
- Sound.play_cancel
- when :ItemsActorSelection
- @actorSelect.index = 0
- self.hide_actor_selection
- @stage = :Items
- Sound.play_cancel
- when :Equips
- @actorsWindows[@equipsIndex].active = false
- @stage = :Base
- Sound.play_cancel
- when :EquipsSelection
- @actorsWindows[@equipsIndex].active = true
- @equipsWindow.active = false
- self.show_actors_windows
- self.hide_equips_windows
- @stage = :Equips
- Sound.play_cancel
- when :EquipsTrade
- @itemsWindow.disableEquipMode
- self.hide_inventory_equips
- @stage = :EquipsSelection
- Sound.play_cancel
- when :Skills
- @actorsWindows[@skillsIndex].active = false
- @stage = :Base
- Sound.play_cancel
- when :SkillsTSelection
- @stypeWindow.active = false
- self.hide_skills_windows
- self.show_actors_windows
- @actorsWindows[@skillsIndex].active = true
- @stage = :Skills
- Sound.play_cancel
- when :SkillsSelection
- @stypeWindow.active = true
- @slistWindow.active = false
- @slistWindow.index = -1
- @stage = :SkillsTSelection
- self.hide_skills_description
- Sound.play_cancel
- when :SkillsActorSelection
- @actorSelect.index = 0
- self.hide_actor_selection
- @stage = :SkillsSelection
- Sound.play_cancel
- when :Formation
- @actorsWindows[@formationIndex1].active = false
- @stage = :Base
- Sound.play_cancel
- when :FormationNextActor
- @actorsWindows[@formationIndex1].active = true
- self.show_actors_windows
- self.hide_formation_windows
- self.unselect_formation_actor(@formationIndex1)
- @formationWindows[@formationIndex2].active = false
- @formationWindows.insert(*@removedFormationWin)
- @formationIndex2 = 0
- @stage = :Formation
- Sound.play_cancel
- when :Status
- self.show_actors_windows
- self.hide_status_window(@statusIndex, :Right)
- @statusWindows.each_with_index{|window, index|
- next if index == @statusIndex
- window.x = Graphics.width
- }
- @stage = :Base
- Sound.play_cancel
- when :Bestiary
- self.show_actors_windows
- self.hide_bestiary_list
- @stage = :Base
- Sound.play_cancel
- when :BestiaryDetail
- self.switch_monster_windows(true)
- @stage = :Bestiary
- Sound.play_cancel
- when :PDist
- self.show_actors_windows
- self.hide_pdist_window(@pdistIndex, :Right)
- @pdistWindows[@pdistIndex].active = false
- @pdistWindows.each_with_index{|window, index|
- next if index == @pdistIndex
- window.x = Graphics.width
- }
- @stage = :Base
- Sound.play_cancel
- when :MiniMap
- self.show_actors_windows
- self.hide_minimap
- @stage = :Base
- Sound.play_cancel
- when :Options
- if @optionWindow.barActive
- @optionWindow.barActive ^= true
- @optionWindow.index = @optionWindow.index
- else
- DataManager.save_config_data
- self.show_actors_windows
- self.hide_options_window
- @optionWindow.index = -1
- @stage = :Base
- end
- Sound.play_cancel
- when :Save
- self.show_actors_windows
- self.hide_save_windows
- @saveWindows[@saveIndex].active = false
- @stage = :Base
- Sound.play_cancel
- when :SaveOverWrite
- self.hide_icons(*@saveIcons)
- self.show_icons(*@baseIcons)
- self.hide_message
- self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
- @stage = :Save
- Sound.play_cancel
- when :Exit
- @exitIndex = 2
- process_confirm
- end
- end
- #-------------------------------------------------------------------------
- # * Processa confirmação
- #-------------------------------------------------------------------------
- def process_confirm
- case @stage
- when :Base
- option = MRM::ExtremeMenu.enabledOptions[@baseIndex]
- case option
- when :Items
- Sound.play_ok
- self.hide_icons(*@baseIcons)
- self.show_icons(*@itemIcons)
- self.select_icon(@itemIcons.first, @itemVocab.first)
- self.hide_actors_windows
- self.show_items_window
- @itemIndex = 0
- self.items_filter_animation{
- @itemsWindow.applyFilter(0)
- @itemsWindow.active = true
- @itemsWindow.index = 0
- @itemsWindow.refresh
- }
- when :Equips
- @actorsWindows.first.active = true
- @equipsIndex = 0
- when :Skills
- @actorsWindows.first.active = true
- @skillsIndex = 0
- when :Formation
- if $game_party.members.size == 1
- Sound.play_buzzer
- self.show_message(MRM::ExtremeMenu::Vocab[:InsufActs], :error)
- return
- end
- @actorsWindows.first.active = true
- @formationIndex1 = 0
- when :Status
- self.hide_actors_windows
- self.show_status_window(@statusIndex = 0)
- when :Bestiary
- if $game_system.monsters.size.zero?
- Sound.play_buzzer
- self.show_message(MRM::ExtremeMenu::Vocab[:ZeroMonster], :error)
- return
- end
- $game_system.new_monsters = false
- self.hide_actors_windows
- self.show_bestiary_list
- @monsterList.active = true
- @monsterList.index = 0
- when :PDist
- self.hide_actors_windows
- self.show_pdist_window(@pdistIndex = 0)
- @pdistWindows.first.active = true
- @pdistWindows.first.index = 0
- when :MiniMap
- self.hide_actors_windows
- self.show_minimap
- when :Options
- self.hide_actors_windows
- self.show_options_window
- @optionWindow.index = 0
- @optionIndex = 0
- when :Save
- if $game_system.save_disabled
- Sound.play_buzzer
- self.show_message(MRM::ExtremeMenu::Vocab[:SaveBlock], :error)
- return
- end
- self.hide_actors_windows
- index = DataManager.last_menu_saveindex
- @saveWindows[index].active = true
- @saveIndex = index
- self.show_save_windows
- when :Exit
- Sound.play_ok
- self.hide_icons(*@baseIcons)
- self.show_icons(*@exitIcons)
- self.select_icon(@exitIcons.first, @exitVocab.first)
- @exitIndex = 0
- end
- @stage = option
- #-------------------
- when :Items
- item = @itemsWindow.info.item
- return Sound.play_buzzer unless @itemsWindow.current_item_enabled?
- Sound.play_ok
- targets = item_target_actors(item)
- if item.for_friend? and item.need_selection? and not targets.empty?
- @stage = :ItemsActorSelection
- self.show_actor_selection(targets)
- @actorSelect.active = true
- else
- self.use_item(item, itemUser)
- self.items_filter_animation{
- @itemsWindow.index = 0
- @itemsWindow.make_item_list
- @itemsWindow.refresh
- }
- end
- #-------------------
- when :ItemsActorSelection
- item = @itemsWindow.info.item
- self.use_item(item, itemUser)
- self.items_filter_animation{
- @itemsWindow.index = 0
- @itemsWindow.make_item_list
- @itemsWindow.refresh
- }
- process_return
- #-------------------
- when :Equips
- @actorsWindows[@equipsIndex].active = false
- @equipsWindow.actor = $game_party.members[@equipsIndex]
- @equipsWindow.active = true
- self.hide_actors_windows
- self.show_equips_windows
- @equipsWindow.index = 0
- @stage = :EquipsSelection
- #-------------------
- when :EquipsSelection
- actor = $game_party.members[@equipsIndex]
- index = @equipsWindow.index
- if index == 5
- Sound.play_equip
- actor.optimize_equipments
- @statusWindows[@equipsIndex].refresh
- @equipsWindow.refresh
- @equipsWindow.index = @equipsWindow.index
- return
- end
- unless actor.equip_change_ok?(index)
- Sound.play_buzzer
- self.show_message(MRM::ExtremeMenu::Vocab[:FixEquip], :error)
- return
- end
- weapon = [0]
- weapon << 1 if actor.dual_wield?
- filter = weapon.include?(@equipsWindow.index) ? 1 : 2
- @itemsWindow.enableEquipMode(@equipsWindow.index, actor)
- @itemsWindow.applyFilter(filter)
- @itemsWindow.make_item_list
- @itemsWindow.active = true
- self.show_inventory_equips
- @stage = :EquipsTrade
- #-------------------
- when :EquipsTrade
- index = @equipsWindow.index
- actor = $game_party.members[@equipsIndex]
- equip = @itemsWindow.info.item
- Sound.play_equip
- actor.change_equip(index, equip)
- @equipsWindow.refresh
- @statusWindows[@equipsIndex].refresh
- process_return
- #-------------------
- when :Skills
- @actorsWindows[@skillsIndex].active = false
- @stypeWindow.actor = $game_party.members[@skillsIndex]
- @slistWindow.actor = $game_party.members[@skillsIndex]
- @stypeWindow.active = true
- @slistWindow.index = -1
- self.hide_actors_windows
- self.show_skills_windows
- @slistWindow.index = 0
- @stage = :SkillsTSelection
- #-------------------
- when :SkillsTSelection
- self.show_skills_description
- @stypeWindow.active = false
- @slistWindow.active = true
- @slistWindow.index = 0
- @stage = :SkillsSelection
- #-------------------
- when :SkillsSelection
- item = @slistWindow.item
- return Sound.play_buzzer unless @slistWindow.current_item_enabled?
- Sound.play_ok
- targets = item_target_actors(item)
- if item.for_friend? and item.need_selection? and not targets.empty?
- @stage = :SkillsActorSelection
- self.show_actor_selection(targets)
- @actorSelect.active = true
- else
- self.use_item(item, itemUser)
- end
- #-------------------
- when :SkillsActorSelection
- item = @slistWindow.item
- self.use_item(item, itemUser)
- @slistWindow.refresh
- process_return
- #-------------------
- when :Formation
- @formationIndex2 = 0
- self.hide_actors_windows
- @removedFormationWin = [
- @formationIndex1,
- @formationWindows.delete_at(@formationIndex1)
- ]
- @actorsWindows[@formationIndex1].active = false
- @formationWindows.first.active = true
- self.show_formation_windows
- self.select_formation_actor(@formationIndex1)
- @stage = :FormationNextActor
- #-------------------
- when :FormationNextActor
- self.trade_actors_formation
- Sound.play_ok
- #-------------------
- when :Bestiary
- @monsterWindow.monster = $data_enemies[@monsterList.index + 1]
- self.switch_monster_windows(false)
- @stage = :BestiaryDetail
- #-------------------
- when :PDist
- win = @pdistWindows[@pdistIndex]
- actor = win.actor
- sheet = actor.pointsSheet
- attr = sheet[sheet.keys[win.index + 1]]
- if actor.attrPoints < attr.first
- self.show_message(MRM::ExtremeMenu::Vocab[:InsufPts], :error)
- return Sound.play_buzzer
- end
- Sound.play_ok
- actor.attrPoints -= attr.first
- actor.add_param_plus(win.index, attr.last)
- win.refresh
- #-------------------
- when :Options
- @optionWindow.barActive ^= true
- @optionWindow.index = @optionWindow.index
- unless @optionWindow.barActive
- [RPG::BGM.last, RPG::BGS.last].each{|audio| audio.replay if audio}
- end
- Sound.play_ok
- #-------------------
- when :Save
- unless @saveWindows[@saveIndex].exist
- Sound.play_save
- self.create_new_save
- x, y, w, h = Graphics.width, 0, Graphics.width/3, @cursor.y - 16
- index = @saveWindows.last.index + 1
- @saveWindows << Menu_SaveFile_Window.new(x, y, w, h, index, DataManager.load_header(index))
- @saveWindows.last.contents_opacity = 0
- Tween.start(@saveWindows.last, @saveEnter[:style], @saveEnter[:time],
- :contents_opacity => 255
- )
- if @saveWindows.size == DataManager.savefile_max + 1
- Tween.start(@saveWindows.first, @saveEnter[:style], @saveEnter[:time],
- :x => -@saveWindows.shift.width,
- :contents_opacity => 0
- ){|window| window.dispose}
- @saveWindows.first.active = true
- end
- self.move_save_windows
- else
- Sound.play_ok
- if MRM::ExtremeMenu::ConfirmOverwrite
- self.hide_icons(*@baseIcons)
- self.show_icons(*@saveIcons)
- self.select_icon(@saveIcons.last, @saveVocab.last)
- self.show_message(MRM::ExtremeMenu::Vocab[:SaveOver], :info, :show)
- @saveOverIndex = 1
- @stage = :SaveOverWrite
- else
- index = @saveIndex - 1
- self.save_game_on(index)
- header = DataManager.load_header(index)
- @saveWindows[@saveIndex].load_data(index, header)
- @saveWindows[@saveIndex].refresh(true)
- self.show_message(MRM::ExtremeMenu::Vocab[:Saved], :ok)
- end
- end
- #-------------------
- when :SaveOverWrite
- if @saveOverIndex == 0
- index = @saveIndex - 1
- self.save_game_on(index)
- header = DataManager.load_header(index)
- @saveWindows[@saveIndex].load_data(index, header)
- @saveWindows[@saveIndex].refresh(true)
- self.show_message(MRM::ExtremeMenu::Vocab[:Saved], :ok)
- end
- process_return
- #-------------------
- when :Exit
- case @exitIndex
- when 0 # Título
- SceneManager.goto(Scene_Title)
- Sound.play_ok
- when 1 # Sair
- SceneManager.exit
- Sound.play_ok
- when 2 # Voltar
- self.hide_icons(*@exitIcons)
- self.show_icons(*@baseIcons)
- self.select_icon(@baseIcons[@baseIndex], @baseVocab[@baseIndex])
- @stage = :Base
- Sound.play_cancel
- end
- end
- end
- #-------------------------------------------------------------------------
- # * Processa movimento
- # direction : Direção (:Left, :Right, :Up, :Down)
- #-------------------------------------------------------------------------
- def process_move(dir)
- case @stage
- when :Base
- self.processMovement(:@baseIndex, dir, :hor, @baseIcons, @baseVocab)
- when :Items
- self.processMovement(:@itemIndex, dir, :hor, @itemIcons, @itemVocab){|i0, i1|
- break if i0 == i1
- self.items_filter_animation{
- @itemsWindow.applyFilter(i1)
- @itemsWindow.index = 0
- @itemsWindow.refresh
- }
- }
- when :ItemsActorSelection, :SkillsActorSelection
- @tmp = @actorSelect.index
- self.processBaseMovement(:@tmp, dir, :hor, @actorSelect.maxIndex){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @actorSelect.index = i1
- self.adjustActorSelect
- }
- when :Equips
- self.processBaseMovement(:@equipsIndex, dir, :hor, @actorsWindows.size){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @actorsWindows[i0].active = !@actorsWindows[i1].active = true
- }
- when :EquipsSelection
- @tmp = @equipsWindow.index
- self.processBaseMovement(:@tmp, dir, :vert, 6){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @equipsWindow.index = i1
- }
- when :Skills
- self.processBaseMovement(:@skillsIndex, dir, :hor, @actorsWindows.size){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @actorsWindows[i0].active = !@actorsWindows[i1].active = true
- }
- when :Formation
- self.processBaseMovement(:@formationIndex1, dir, :hor, @actorsWindows.size){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @actorsWindows[i0].active = !@actorsWindows[i1].active = true
- }
- when :FormationNextActor
- self.processBaseMovement(:@formationIndex2, dir, :vert, @formationWindows.size){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @formationWindows[i0].active = !@formationWindows[i1].active = true
- self.move_formation_windows
- }
- when :Status
- self.processBaseMovement(:@statusIndex, dir, :hor, @statusWindows.size){|i0, i1|
- break if i0 == i1
- newDir = dir == :Left ? :Right : :Left
- self.hide_status_window(i0, newDir)
- self.show_status_window(i1, newDir)
- }
- when :Bestiary
- win = @monsterList
- tmp = win.index
- @row = tmp / 3
- @off = tmp % 3
- self.processBaseMovement(:@off, dir, :hor, win.columns){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- win.index = (@row * win.columns) + i1
- }
- self.processBaseMovement(:@row, dir, :vert, win.rowMax){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- win.index = @off + (i1 * win.columns)
- }
- when :PDist
- self.processBaseMovement(:@pdistIndex, dir, :hor, @pdistWindows.size){|i0, i1|
- break if i0 == i1
- newDir = dir == :Left ? :Right : :Left
- self.hide_pdist_window(i0, newDir)
- self.show_pdist_window(i1, newDir)
- @pdistWindows[i0].active = !@pdistWindows[i1].active = true
- @pdistWindows[i1].index = @pdistWindows[i0].index
- }
- @tmp = @pdistWindows[@pdistIndex].index
- self.processBaseMovement(:@tmp, dir, :vert, 8){|i0, i1|
- @pdistWindows[@pdistIndex].index = i1
- }
- when :Options
- unless @optionWindow.barActive
- self.processBaseMovement(:@optionIndex, dir, :vert, 2){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- @optionWindow.index = i1
- }
- else
- case @optionIndex
- when 0; @tmpValue = $game_system.musicRate
- when 1; @tmpValue = $game_system.soundRate
- end
- @tmpValue *= 100
- self.processBaseMovement(:@tmpValue, dir, :hor, 101){|i0, i1|
- i1 = 100 if i1 > 100
- break if i0 == i1
- i1 /= 100.0
- Sound.play_cursor
- case @optionIndex
- when 0; $game_system.musicRate = i1
- when 1; $game_system.soundRate = i1
- end
- @optionWindow.refresh
- }
- end
- when :Save
- self.processBaseMovement(:@saveIndex, dir, :hor, @saveWindows.size){|i0, i1|
- break if i0 == i1
- Sound.play_cursor
- self.move_save_windows
- @saveWindows[i0].active = !@saveWindows[i1].active = true
- }
- when :SaveOverWrite
- self.processMovement(:@saveOverIndex, dir, :hor, @saveIcons, @saveVocab)
- when :Exit
- self.processMovement(:@exitIndex, dir, :hor, @exitIcons, @exitVocab)
- end
- end
- #-------------------------------------------------------------------------
- # * Dispõe fundo
- #-------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- end
- #-------------------------------------------------------------------------
- # * Dispõe ícones
- #-------------------------------------------------------------------------
- def dispose_icons
- dispose_base_icons
- dispose_exit_icons
- end
- #-------------------------------------------------------------------------
- # * Dispõe os ícones base
- #-------------------------------------------------------------------------
- def dispose_base_icons
- @baseIcons.each(&:dispose)
- Tween.remove(@baseIcons)
- end
- #-------------------------------------------------------------------------
- # * Dispões mensagem
- #-------------------------------------------------------------------------
- def dispose_message
- @message.dispose
- Tween.remove(@message)
- end
- #-------------------------------------------------------------------------
- # * Dispõe os ícones de saída
- #-------------------------------------------------------------------------
- def dispose_exit_icons
- @exitIcons.each(&:dispose)
- Tween.remove(@exitIcons)
- end
- #-------------------------------------------------------------------------
- # * Dispõe o cursor
- #-------------------------------------------------------------------------
- def dispose_cursor
- @cursor.dispose
- Tween.remove(@cursor)
- end
- #-------------------------------------------------------------------------
- # * Dispõe as janelas
- #-------------------------------------------------------------------------
- def dispose_windows
- dispose_actors_windows
- dispose_items_windows
- dispose_equips_window
- dispose_status_windows
- dispose_formation_windows
- dispose_bestiary_windows
- dispose_pdist_windows
- dispose_options_window
- dispose_save_windows
- dispose_actor_select_window
- end
- #-------------------------------------------------------------------------
- # * Dispõe as janelas de informação dos atores
- #-------------------------------------------------------------------------
- def dispose_actors_windows
- @actorsWindows.each(&:dispose)
- Tween.remove(@actorsWindows)
- end
- #-------------------------------------------------------------------------
- # * Dispõe a janela de itens
- #-------------------------------------------------------------------------
- def dispose_items_windows
- @itemsWindow.dispose
- @itemsInfo.dispose
- Tween.remove(@itemsWindow)
- Tween.remove(@itemsInfo)
- end
- #-------------------------------------------------------------------------
- # * Dispõe a janela de equipamentos
- #-------------------------------------------------------------------------
- def dispose_equips_window
- @equipsWindow.dispose
- Tween.remove(@equipsWindow)
- end
- #-------------------------------------------------------------------------
- # * Dispões as janelas de status
- #-------------------------------------------------------------------------
- def dispose_status_windows
- @statusWindows.each(&:dispose)
- Tween.remove(@statusWindows)
- end
- #-------------------------------------------------------------------------
- # * Dispõe as janelas de formação
- #-------------------------------------------------------------------------
- def dispose_formation_windows
- @formationWindows.each(&:dispose)
- Tween.remove(@formationWindows)
- end
- #-------------------------------------------------------------------------
- # * Dispõe as janelas de monstros do bestiário
- #-------------------------------------------------------------------------
- def dispose_bestiary_windows
- @monsterList.dispose
- @monsterWindow.dispose
- Tween.remove(@monsterList)
- Tween.remove(@monsterWindow)
- end
- #-------------------------------------------------------------------------
- # * Dispõe as janelas de distribuição de atributos
- #-------------------------------------------------------------------------
- def dispose_pdist_windows
- @pdistWindows.each(&:dispose)
- Tween.remove(@pdistWindows)
- end
- #-------------------------------------------------------------------------
- # * Dispõe a janela de opções
- #-------------------------------------------------------------------------
- def dispose_options_window
- @optionWindow.dispose
- Tween.remove(@optionWindow)
- end
- #-------------------------------------------------------------------------
- # * Dispõe as janelas de save
- #-------------------------------------------------------------------------
- def dispose_save_windows
- @saveWindows.each(&:dispose)
- Tween.remove(@saveWindows)
- end
- #-------------------------------------------------------------------------
- # * Dispõe a janela de criação de atores
- #-------------------------------------------------------------------------
- def dispose_actor_select_window
- @actorSelect.dispose
- Tween.remove(@actor_select)
- end
- #-------------------------------------------------------------------------
- # * Dispõe mini-mapa
- #-------------------------------------------------------------------------
- def dispose_minimap
- @minimap.dispose
- Tween.remove(@minimap)
- end
- protected
- #-------------------------------------------------------------------------
- # * Cria novo save
- #-------------------------------------------------------------------------
- def create_new_save
- self.save_game_on(@saveWindows.size - 1)
- end
- #-------------------------------------------------------------------------
- # * Sobreescreve arquivo de save
- # index : Identificador do arquivo
- #-------------------------------------------------------------------------
- def save_game_on(index)
- DataManager.save_game(index)
- end
- #-------------------------------------------------------------------------
- # * Aplica opções de fonte no bitmap
- # b : Bitmap
- #-------------------------------------------------------------------------
- def applyFont(b)
- b.font.name = MRM::ExtremeMenu::Font[:Name]
- b.font.size = MRM::ExtremeMenu::Font[:Size]
- b.font.color = Color.new(*MRM::ExtremeMenu::Font[:Color])
- b.font.shadow = MRM::ExtremeMenu::Font[:Shadow]
- b.font.outline = MRM::ExtremeMenu::Font[:Outline]
- return b
- end
- #--------------------------------------------------------------------------
- # * Aquisição do usuário do ítem
- #--------------------------------------------------------------------------
- def itemUser
- if @stage == :SkillsSelection or @stage == :SkillsActorSelection # Habilidades
- $game_party.members[@skillsIndex]
- else # Itens
- $game_party.movable_members.max_by{|member| member.pha}
- end
- end
- #--------------------------------------------------------------------------
- # * Aquisição da lista de heróis válidos como alvos do item
- # item : Item que será usado
- #--------------------------------------------------------------------------
- def item_target_actors(item)
- # 0: None
- # 1: One Enemy
- # 2: All Enemies
- # 3: One Random Enemy
- # 4: Two Random Enemies
- # 5: Three Random Enemies
- # 6: Four Random Enemies
- # 7: One Ally
- # 8: All Allies
- # 9: One Ally (Dead)
- # 10: All Allies (Dead)
- # 11: The User
- case item.scope
- when 7,8
- data = $game_party.members
- when 9,10
- data = $game_party.members.select{|actor| actor.dead?}
- when 11
- data = itemUser
- end
- user = itemUser
- return data.select{|actor| actor.item_test(user, item) }
- end
- #--------------------------------------------------------------------------
- # * Usa item
- # item : Item
- # user : Usuário
- #--------------------------------------------------------------------------
- def use_item(item, user)
- if @stage == :SkillsSelection or @stage == :SkillsActorSelection
- Sound.play_use_skill
- else
- Sound.play_use_item
- end
- user.use_item(item)
- targets = []
- case item.scope
- when 7, 9
- targets << @actorSelect.actor
- when 8
- targets += $game_party.members.select{|actor|
- not actor.dead? and actor.usable?(item)
- }
- when 10
- targets += $game_party.members.select{|actor|
- actor.dead? and actor.item_test(user, item)
- }
- end
- targets.each{|target|
- item.repeats.times{
- target.item_apply(user, item)
- }
- }
- self.check_common_event
- self.check_gameover
- @actorsWindows.each(&:refresh)
- end
- #--------------------------------------------------------------------------
- # * Definição de reserva de evento comun.
- # Transição para tela do mapa se a chamada è reservada para o evento
- #--------------------------------------------------------------------------
- def check_common_event
- SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
- end
- #--------------------------------------------------------------------------
- # * Mostra a janela de atores para seleção
- # actors : Atores disponíveis
- #--------------------------------------------------------------------------
- def show_actor_selection(actors)
- @actorSelect.faces = actors
- Tween.start(@actorSelect, @actorSelEnter[:style], @actorSelEnter[:time],
- :x => (@itemsWindow.width + Graphics.width - @actorSelect.width)/2,
- :contents_opacity => 255
- )
- self.adjustActorSelect
- end
- #-------------------------------------------------------------------------
- # * Esconde a janela de atores para seleção
- #-------------------------------------------------------------------------
- def hide_actor_selection
- Tween.start(@actorSelect, @actorSelEnter[:style], @actorSelEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- self.adjustActorSelect
- end
- #-------------------------------------------------------------------------
- # * Ajusta face mostrada
- #-------------------------------------------------------------------------
- def adjustActorSelect
- Tween.start(@actorSelect, @actorSelMove[:style], @actorSelMove[:time],
- :ox => @actorSelect.trueOx
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra mensagem
- # text : Texto
- # type : Tipo (:ok = Ok, :info = Informação, :error = Erro)
- # mode : Modo (:blink = Piscar, :show = Mostrar)
- #-------------------------------------------------------------------------
- def show_message(text, type = :info, mode = :blink)
- case type
- when :ok
- @message.bitmap.font.color = MRM::ExtremeMenu::ColorOk
- when :info
- @message.bitmap.font.color = MRM::ExtremeMenu::ColorInfo
- when :error
- @message.bitmap.font.color = MRM::ExtremeMenu::ColorError
- end
- @message.bitmap.clear
- @message.bitmap.draw_text(@message.bitmap.rect, text, 1)
- block = (mode == :blink) ? ->(*){self.hide_message} : ->(*){}
- Tween.start(@message, @messageAnim[:style], @messageAnim[:time],
- :opacity => 255,
- &block)
- end
- #-------------------------------------------------------------------------
- # * Esconde mensagem
- #-------------------------------------------------------------------------
- def hide_message
- Tween.start(@message, @messageAnim[:style], @messageAnim[:time],
- :opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Cria sprites de ícones e os posiciona
- # icons : Array com id dos ícones
- # anim : Animar?
- #-------------------------------------------------------------------------
- def create_generic_icons(icons, anim=true)
- iconSpace = Graphics.width / (icons.size == 0 ? 1 : icons.size)
- sprites = icons.map.with_index{|id, index|
- gray = id < 0
- id = id.abs
- icon = Sprite.new
- icon.bitmap = @iconset
- icon.src_rect = Rect.new(id % 16 * 24, id / 16 * 24, 24, 24)
- icon.ox = icon.src_rect.width / 2
- icon.oy = icon.src_rect.height / 2
- icon.x = (index + 0.5) * iconSpace
- icon.y = Graphics.height + icon.oy
- icon.tone.set(0, 0, 0, 255) if gray
- icon
- }
- self.show_icons(*sprites) if anim
- return sprites
- end
- #-------------------------------------------------------------------------
- # * Mostra ícones
- # icons : Array de ícones
- #-------------------------------------------------------------------------
- def show_icons(*icons)
- motion = @iconsEnter
- icons.each_with_index{|icon, index|
- Tween.start(icon, motion[:style], motion[:time], motion[:off] * index,
- :y => Graphics.height - 24
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Esconde ícones
- # icons : Array de ícones
- #-------------------------------------------------------------------------
- def hide_icons(*icons)
- motion = @iconsEnter
- icons.each_with_index{|icon, index|
- Tween.start(icon, motion[:style], motion[:time], motion[:off] * index,
- :y => Graphics.height + 12
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Seleciona ícone
- # icon : Ícone
- # name : Vocabulário para o nome
- #-------------------------------------------------------------------------
- def select_icon(icon, name)
- Tween.start(icon, @iconsMove[:style], @iconsMove[:time],
- :y => Graphics.height - 36
- )
- Tween.start(@cursor, @cursorMove[:style], @cursorMove[:time],
- :x => icon.x
- )
- @cursor.bitmap.clear
- @cursor.bitmap.draw_text(@cursor.bitmap.rect, name, 1)
- end
- #-------------------------------------------------------------------------
- # * Deseleciona ícone
- # icon : Ícone
- #-------------------------------------------------------------------------
- def unselect_icon(icon)
- Tween.start(icon, @iconsMove[:style], @iconsMove[:time],
- :y => Graphics.height - 24
- )
- end
- #-------------------------------------------------------------------------
- # * Processa movimento base do cursor
- # indexName : Simbolo com nome da variável indexadora
- # direction : Direção do movimento
- # type : Horizontal (:hor), Vertical (:vert)
- # max : Valor máximo
- #-------------------------------------------------------------------------
- def processBaseMovement(indexName, direction, type, max)
- index = instance_variable_get(indexName)
- lastIndex = index
- hor = (type == :hor)
- if direction == (hor ? :Left : :Up)
- index -= 1
- elsif direction == (hor ? :Right : :Down)
- index += 1
- end
- index %= max
- self.instance_variable_set(indexName, index)
- if block_given?
- yield(lastIndex, index)
- else
- return lastIndex, index
- end
- end
- #-------------------------------------------------------------------------
- # * Processa movimento de cursor e atualiza ícones
- # indexName : Simbolo com nome da variável indexadora
- # direction : Direção do movimento
- # type : Horizontal (:hor), Vertical (:vert)
- # icons : Array de ícones referentes ao movimento
- # vocab : Array de vocabulário
- # cursor : Executar som de movimento do cursor?
- #-------------------------------------------------------------------------
- def processMovement(indexName, direction, type, icons, vocab, cursor = true)
- processBaseMovement(indexName, direction, type, icons.size){|lastIndex, index|
- Sound.play_cursor if cursor
- self.unselect_icon(icons[lastIndex])
- self.select_icon(icons[index], vocab[index])
- yield(lastIndex, index) if block_given?
- }
- end
- #-------------------------------------------------------------------------
- # * Mostra janelas de ator (básica)
- #-------------------------------------------------------------------------
- def show_actors_windows
- @actorsWindows.each_with_index{|window, index|
- Tween.start(window, @winsMove[:style], @winsMove[:time], @winsMove[:off] * index,
- :y => 0,
- :contents_opacity => 255
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Esconde janelas de ator (básica)
- #-------------------------------------------------------------------------
- def hide_actors_windows
- @actorsWindows.each_with_index{|window, index|
- Tween.start(window, @winsMove[:style], @winsMove[:time], @winsMove[:off] * index,
- :y => -window.height,
- :contents_opacity => 0
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Mostra janela de itens
- #-------------------------------------------------------------------------
- def show_items_window
- Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time],
- :x => 0,
- :contents_opacity => 255
- )
- Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
- :x => @itemsInfo.width,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde a janela de itens
- #-------------------------------------------------------------------------
- def hide_items_window
- Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Aplicação de filtro na janela de itens
- # &block : Bloco que será iniciado quando a janela estiver com opaci-
- # dade mínima.
- #-------------------------------------------------------------------------
- def items_filter_animation(&block)
- Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time] / 4.0,
- :contents_opacity => 0
- ){
- block.call
- Tween.start(@itemsWindow, @itemsEnter[:style], @itemsEnter[:time] / 4.0,
- :contents_opacity => 255
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Mostra as janelas de equipamentos
- #-------------------------------------------------------------------------
- def show_equips_windows
- Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
- :x => 0,
- :contents_opacity => 255
- )
- Tween.start(@itemsInfo, @equipsEnter[:style], @equipsEnter[:time],
- :x => @equipsWindow.width,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde as janelas de equipamentos
- #-------------------------------------------------------------------------
- def hide_equips_windows
- Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- Tween.start(@itemsInfo, @itemsEnter[:style], @itemsEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra a janela de equipamentos disponíveis
- #-------------------------------------------------------------------------
- def show_inventory_equips
- Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
- :contents_opacity => 0
- )
- @itemsWindow.x = 0
- Tween.start(@itemsWindow, @equipsEnter[:style], @equipsEnter[:time],
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde a janela de equipamentos disponíveis
- #-------------------------------------------------------------------------
- def hide_inventory_equips
- Tween.start(@equipsWindow, @equipsEnter[:style], @equipsEnter[:time],
- :contents_opacity => 255
- )
- Tween.start(@itemsWindow, @equipsEnter[:style], @equipsEnter[:time],
- :contents_opacity => 0
- ){
- @itemsWindow.x = Graphics.width
- }
- end
- #-------------------------------------------------------------------------
- # * Mostra as janelas de habilidades
- #-------------------------------------------------------------------------
- def show_skills_windows
- Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
- :x => 0,
- :contents_opacity => 255
- )
- Tween.start(@slistWindow, @skillsEnter[:style], @skillsEnter[:time],
- :x => @stypeWindow.width,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde as janelas de habilidades
- #-------------------------------------------------------------------------
- def hide_skills_windows
- Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- Tween.start(@slistWindow, @skillsEnter[:style], @skillsEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra a janela de descrição da habilidade
- #-------------------------------------------------------------------------
- def show_skills_description
- Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
- :contents_opacity => 0
- )
- @itemsInfo.x = 0
- Tween.start(@itemsInfo, @equipsEnter[:style], @equipsEnter[:time],
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde a janela de descrição da habilidade
- #-------------------------------------------------------------------------
- def hide_skills_description
- Tween.start(@stypeWindow, @skillsEnter[:style], @skillsEnter[:time],
- :contents_opacity => 255
- )
- Tween.start(@itemsInfo, @skillsEnter[:style], @skillsEnter[:time],
- :contents_opacity => 0
- ){
- @itemsInfo.x = Graphics.width
- }
- end
- #-------------------------------------------------------------------------
- # * Mostra janelas de formação
- #-------------------------------------------------------------------------
- def show_formation_windows
- mot = @formationEnter
- @formationWindows[0,3].each_with_index{|win, index|
- Tween.start(win, mot[:style], mot[:time], mot[:off] * index,
- :y => win.height * index,
- :contents_opacity => 255.0 / (index + 1)
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Atualiza posição das janelas de formação
- #-------------------------------------------------------------------------
- def move_formation_windows
- mot = @formationMove
- windows = @formationWindows[@formationIndex2, @formationWindows.size - @formationIndex2]
- windows += @formationWindows - windows
- windows.each_with_index{|win, index|
- Tween.start(win, mot[:style], mot[:time],
- :y => win.height * (index > 3 ? 3 : index),
- :contents_opacity => index.between?(0, 2) ? 255.0 / (index + 1) : 0
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Esconde janelas de formação
- #-------------------------------------------------------------------------
- def hide_formation_windows
- mot = @formationEnter
- @formationWindows.each_with_index{|win, index|
- Tween.start(win, mot[:style], mot[:time], mot[:off] * index,
- :y => Graphics.width,
- :contents_opacity => 0
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Seleciona uma janela de ator (o que será trocado)
- # index : Identificador
- # fromPos : Ir para o destino a partir da posição atual?
- #-------------------------------------------------------------------------
- def select_formation_actor(index, fromPos=true)
- win = @actorsWindows[index]
- win.x = -win.width unless fromPos
- Tween.start(win, @winsMove[:style], @winsMove[:time],
- :x => 0,
- :y => 0,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Deseleciona uma janela de ator
- # index : Identificador
- # toPos : Ir para a posição correta?
- #-------------------------------------------------------------------------
- def unselect_formation_actor(index, toPos=true)
- Tween.start(@actorsWindows[index], @winsMove[:style], @winsMove[:time],
- :x => (toPos ? index : -1) * @actorsWindows[index].width
- )
- end
- #-------------------------------------------------------------------------
- # * Troca informações de formação e das janelas de atores
- #-------------------------------------------------------------------------
- def trade_actors_formation
- actor1 = @formationIndex1
- actor2 = @formationIndex2 + (@formationIndex2 < @formationIndex1 ? 0 : 1)
- $game_party.swap_order(actor1, actor2)
- @statusWindows[actor1], @statusWindows[actor2] = @statusWindows[actor2], @statusWindows[actor1]
- @pdistWindows[actor1], @pdistWindows[actor2] = @pdistWindows[actor2], @pdistWindows[actor1]
- winActor1 = actor1
- winActor2 = actor2 < 4 ? actor2 : nil
- Tween.start(@actorsWindows[winActor1], @winsMove[:style], @winsMove[:time]/2.0,
- :x => -@actorsWindows[@formationIndex1].width
- ){
- @actorsWindows[winActor1].actor = $game_party.members[actor1]
- @actorsWindows[winActor2].actor = $game_party.members[actor2] if winActor2
- Tween.start(@actorsWindows[winActor1], @winsMove[:style], @winsMove[:time]/2.0,
- :x => 0
- )
- }
- winForm1 = @formationWindows[@formationIndex2]
- winForm2 = @removedFormationWin.last
- winForm1.active = false
- winForm2.active = true
- mot = @formationMove
- Tween.start(winForm1, mot[:style], mot[:time],
- :y => winForm1.height * 3,
- :contents_opacity => 0
- )
- Tween.start(winForm2, mot[:style], mot[:time],
- :y => 0,
- :contents_opacity => 255
- )
- @formationWindows.delete(winForm1)
- @formationWindows.insert(@formationIndex2, winForm2)
- @removedFormationWin = [
- @formationIndex2,
- winForm1
- ]
- end
- #-------------------------------------------------------------------------
- # * Mostra janela de informação completa do ator
- # index : Identificador
- # dir : Direção de entrada
- #-------------------------------------------------------------------------
- def show_status_window(index, dir = :Left)
- window = @statusWindows[index]
- window.x = dir == :Left ? Graphics.width : -window.width
- Tween.start(window, @statusMove[:style], @statusMove[:time],
- :x => 0,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde janela de informação completa do ator
- # index : Identificador
- # dir : Direção de saída
- #-------------------------------------------------------------------------
- def hide_status_window(index, dir = :Left)
- window = @statusWindows[index]
- Tween.start(window, @statusMove[:style], @statusMove[:time],
- :x => (dir == :Left ? -window.width : Graphics.width),
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra lista de monstros do bestiário
- #-------------------------------------------------------------------------
- def show_bestiary_list
- window = @monsterList
- Tween.start(window, @bestiaryEnter[:style], @bestiaryEnter[:time],
- :x => 0,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde lista de monstros do bestiário
- #-------------------------------------------------------------------------
- def hide_bestiary_list
- window = @monsterList
- Tween.start(window, @bestiaryEnter[:style], @bestiaryEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Move janelas de monstros do bestiário
- # back : Voltando?
- #-------------------------------------------------------------------------
- def switch_monster_windows(back)
- window = @monsterList
- Tween.start(window, @bestiaryMove[:style], @bestiaryMove[:time],
- :x => back ? 0 : -window.width,
- :contents_opacity => back ? 255 : 0
- )
- window = @monsterWindow
- Tween.start(window, @bestiaryMove[:style], @bestiaryMove[:time],
- :x => back ? Graphics.width : 0,
- :contents_opacity => back ? 0 : 255
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra janela de distribuição de pontos
- # index : Identificador
- # dir : Direção de entrada
- #-------------------------------------------------------------------------
- def show_pdist_window(index, dir = :Left)
- window = @pdistWindows[index]
- window.x = dir == :Left ? Graphics.width : -window.width
- Tween.start(window, @pdistMove[:style], @pdistMove[:time],
- :x => 0,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde janela de distribuição de pontos
- # index : Identificador
- # dir : Direção de saída
- #-------------------------------------------------------------------------
- def hide_pdist_window(index, dir = :Left)
- window = @pdistWindows[index]
- Tween.start(window, @pdistMove[:style], @pdistMove[:time],
- :x => (dir == :Left ? -window.width : Graphics.width),
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra mini-mapa
- #-------------------------------------------------------------------------
- def show_minimap
- Tween.start(@minimap, @minimapEnter[:style], @minimapEnter[:time],
- :x => 0,
- :opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde o mini-mapa
- #-------------------------------------------------------------------------
- def hide_minimap
- Tween.start(@minimap, @minimapEnter[:style], @minimapEnter[:time],
- :x => Graphics.width,
- :opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra janela de opções
- #-------------------------------------------------------------------------
- def show_options_window
- Tween.start(@optionWindow, @optionEnter[:style], @optionEnter[:time],
- :x => 0,
- :contents_opacity => 255
- )
- end
- #-------------------------------------------------------------------------
- # * Esconde janela de opções
- #-------------------------------------------------------------------------
- def hide_options_window
- Tween.start(@optionWindow, @optionEnter[:style], @optionEnter[:time],
- :x => Graphics.width,
- :contents_opacity => 0
- )
- end
- #-------------------------------------------------------------------------
- # * Mostra janelas de save
- #-------------------------------------------------------------------------
- def show_save_windows
- baseX = (Graphics.width - @saveWindows.first.width) / 2
- @saveWindows.each_with_index{|window, index|
- Tween.start(window, @saveEnter[:style], @saveEnter[:time], @saveEnter[:off] * index,
- :x => baseX - ((@saveIndex - index) * window.width),
- :contents_opacity => 255
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Esconde janelas de save
- #-------------------------------------------------------------------------
- def hide_save_windows
- @saveWindows.each_with_index{|window, index|
- Tween.start(window, @saveEnter[:style], @saveEnter[:time], @saveEnter[:off] * index,
- :x => Graphics.width,
- :contents_opacity => 0
- )
- }
- end
- #-------------------------------------------------------------------------
- # * Move janelas de save
- #-------------------------------------------------------------------------
- def move_save_windows
- baseX = (Graphics.width - @saveWindows.first.width) / 2
- @saveWindows.each_with_index{|window, index|
- Tween.start(window, @saveMove[:style], @saveMove[:time],
- :x => baseX - ((@saveIndex - index) * window.width)
- )
- }
- end
- end
- #=============================================================================
- # Tweening [Scripter's Tool]
- #---------------------------------------------------------------------------
- # Formulas by: Robert Penner
- # Compiled to Ruby by: UziMonkey
- # Modified by: Gab!
- #=============================================================================
- class Tween
- @@__current = {}
- def self.start(obj, style = Tween::Linear, time = 1, offset = 0, prop, &block)
- @@__current[obj] ||= {}
- prop.each_pair{|pr, final|
- act = obj.method(pr).call
- @@__current[obj][pr] = {
- tween: Tween.new(act, final, style, time),
- set: obj.method((pr.to_s + "=").to_sym),
- lfr: Time.new,
- tfr: 0,
- off: (offset / 100.0),
- blk: block
- }
- }
- end
- def self.update
- remove = []
- @@__current.each_pair{|obj, prop|
- done = true
- prop.each_value{|property|
- next if property[:tween].done
- done = false
- property[:tfr] = Time.new
- delta = (property[:tfr] - property[:lfr]).round(3)
- property[:lfr] = property[:tfr]
- if property[:off] > 0
- property[:off] -= delta
- next if property[:off] >= 0
- delta = -property[:off]
- end
- property[:tween].update(delta)
- property[:set].call(property[:tween].value) rescue nil
- property[:blk].call(obj) if property[:tween].done && property[:blk]
- }
- @@__current.delete(obj) if done
- }
- end
- def self.remove(obj, prop = nil)
- return obj.each{|object|
- Tween.remove(*(object.is_a?(Array) ? object : [object]))
- } if obj.is_a?(Array)
- if (@@__current.has_key?(obj))
- if (prop.nil?)
- @@__current.delete(obj)
- elsif @@__current[obj].has_key?(prop)
- @@__current[obj].delete(prop)
- end
- end
- end
- def self.ready?(obj)
- return !@@__current.has_key?(obj)
- end
- attr_reader :done
- attr_reader :easer
- def initialize(start, finish, easer, duration)
- @start, @finish = start, finish
- @delta = @finish - @start
- @easer, @duration = easer, duration
- @time = 0
- @done = false
- end
- def update(delta)
- @time += delta
- if @time > @duration
- @time = @duration
- @done = true
- end
- end
- def value
- @easer.ease(@time, @start, @delta, @duration)
- end
- module Linear
- def self.ease(t, st, ch, d)
- ch * t / d + st
- end
- end
- module Sine
- HALF_PI = Math::PI / 2
- module In
- def self.ease(t, st, ch, d)
- -ch * Math.cos(t / d * HALF_PI) + ch + st
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- ch * Math.sin(t / d * HALF_PI) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- -ch / 2 * (Math.cos(Math::PI * t / d) - 1) + st
- end
- end
- end
- module Circ
- module In
- def self.ease(t, st, ch, d)
- rate = t/d
- -ch * (Math.sqrt(1 - rate * rate) - 1) + st
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- t = t/d - 1
- ch * Math.sqrt(1 - t * t) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- if (t /= d/2.0) < 1
- return -ch / 2 * (Math.sqrt(1 - t*t) - 1) + st
- else
- return ch / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + st
- end
- end
- end
- end
- module Bounce
- module Out
- def self.ease(t, st, ch, d)
- if (t /= d) < (1/2.75)
- ch * (7.5625 * t * t) + st
- elsif t < (2 / 2.75)
- ch * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + st
- elsif t < (2.5 / 2.75)
- ch * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + st
- else
- ch * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + st
- end
- end
- end
- module In
- def self.ease(t, st, ch, d)
- ch - Tween::Bounce::Out.ease(d-t, 0, ch, d) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- t *= 2
- if t < d
- Tween::Bounce::In.ease(t, 0, ch, d) * 0.5 + st
- else
- Tween::Bounce::Out.ease(t - d, 0, ch, d) * 0.5 + ch * 0.5 + st
- end
- end
- end
- end
- module Back
- module In
- def self.ease(t, st, ch, d, s=1.70158)
- ch * (t/=d) * t * ((s+1) * t - s) + st
- end
- end
- module Out
- def self.ease(t, st, ch, d, s=1.70158)
- ch * ((t=t/d-1) * t * ((s+1) * t + s) + 1) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d, s=1.70158)
- if (t /= d/2.0) < 1
- ch / 2.0 * (t * t * (((s *= 1.525) + 1) * t - s)) + st
- else
- ch / 2.0 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + st
- end
- end
- end
- end
- module Cubic
- module In
- def self.ease(t, st, ch, d)
- ch * (t /= d) * t * t + st
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- ch * ((t = t / d.to_f - 1) * t * t + 1) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- if (t /= d / 2.0) < 1
- ch / 2.0 * t * t * t + st
- else
- ch / 2.0 * ((t -= 2) * t * t + 2) + st
- end
- end
- end
- end
- module Expo
- module In
- def self.ease(t, st, ch, d)
- if t == 0
- st
- else
- ch * (2 ** (10 * (t / d.to_f - 1))) + st
- end
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- if t == d
- st + ch
- else
- ch * (1 - (2 ** (-10 * t / d.to_f))) + st
- end
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- if t == 0
- st
- elsif t == d
- st + ch
- elsif (t /= d / 2.0) < 1
- ch / 2.0 * (2 ** (10 * (t - 1))) + st
- else
- ch / 2.0 * (-(2 ** (-10 * (t -= 1))) + 2) + st
- end
- end
- end
- end
- module Quad
- module In
- def self.ease(t, st, ch, d)
- ch * (t /= d.to_f) * t + st
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- -ch * (t /= d.to_f) * (t - 2) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- if (t /= d / 2.0) < 1
- ch / 2.0 * t * t + st
- else
- -ch / 2.0 * ((t -= 1) * (t - 2) - 1) + st
- end
- end
- end
- end
- module Quart
- module In
- def self.ease(t, st, ch, d)
- ch * (t /= d.to_f) * t * t * t + st
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- -ch * ((t = t / d.to_f - 1) * t * t * t - 1) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- if (t /= d / 2.0) < 1
- ch / 2.0 * t * t * t * t + st
- else
- -ch / 2.0 * ((t -= 2) * t * t * t - 2) + st
- end
- end
- end
- end
- module Quint
- module In
- def self.ease(t, st, ch, d)
- ch * (t /= d.to_f) * t * t * t * t + st
- end
- end
- module Out
- def self.ease(t, st, ch, d)
- ch * ((t = t / d.to_f - 1) * t * t * t * t + 1) + st
- end
- end
- module InOut
- def self.ease(t, st, ch, d)
- ch /= 2.0
- if (t /= d / 2.0) < 1
- ch * t * t * t * t * t + st
- else
- ch * ((t -= 2) * t * t * t * t + 2) + st
- end
- end
- end
- end
- module Elastic
- DOUBLE_PI = 2 * Math::PI
- module In
- def self.ease(t, st, ch, d, a = 5, p = 0)
- s = 0
- if t == 0
- return st
- elsif (t /= d.to_f) >= 1
- return st + ch
- end
- p = d * 0.3 if p == 0
- if (a == 0) || (a < ch.abs)
- a = ch
- s = p / 4.0
- else
- s = p / DOUBLE_PI * Math.asin(ch / a.to_f)
- end
- -(a * (2 ** (10 * (t -= 1))) * Math.sin((t * d - s) * DOUBLE_PI / p)) + st
- end
- end
- module Out
- def self.ease(t, st, ch, d, a = 0.1, p = 0)
- s = 0
- if t == 0
- return st
- elsif (t /= d.to_f) >= 1
- return st + ch
- end
- p = d * 0.3 if p == 0
- if (a == 0) || (a < ch.abs)
- a = ch
- s = p / 4.0
- else
- s = p / DOUBLE_PI * Math.asin(ch / a.to_f)
- end
- a * (2 ** (-10 * t)) * Math.sin((t * d - s) * DOUBLE_PI / p.to_f) + ch + st
- end
- end
- end
- EASERS = [
- Linear,
- Sine::In,
- Sine::Out,
- Sine::InOut,
- Circ::In,
- Circ::Out,
- Circ::InOut,
- Bounce::Out,
- Bounce::In,
- Bounce::InOut,
- Back::In,
- Back::Out,
- Back::InOut,
- Cubic::In,
- Cubic::Out,
- Cubic::InOut,
- Expo::In,
- Expo::Out,
- Expo::InOut,
- Quad::In,
- Quad::Out,
- Quad::InOut,
- Quart::In,
- Quart::Out,
- Quart::InOut,
- Quint::In,
- Quint::Out,
- Quint::InOut,
- Elastic::In,
- Elastic::Out
- ]
- end
Advertisement
Add Comment
Please, Sign In to add comment