#============================================================================== # • Zion Popup #============================================================================== # Autor: Dax # Requerimento: Dax Core # Versão: 1.0 # Site: www.dax-soft.weebly.com #============================================================================== # • Descrição: #------------------------------------------------------------------------------ # Um sistem da linha Zion. Esse sistema consiste em popups seja de números, # ícones, imagens ou textos. Os popups podem ocorrer livremente na tela, # sobre o personagem, sobre os seguidores ou sobre os eventos. #============================================================================== # • Como usar: CHAMAR SCRIPTS #------------------------------------------------------------------------------ # ******************************** GERAL ************************************** # *[Alterar a velocidade] # popup: X # * X = Velocidade. # ****************************** Livres na Tela ******************************* # *[Popup de texto] # popup: , T # * x, y = Coordenadas no mapa. # * T = Texto. # *[Popup de ícone] # popup: , I # * x, y = Coordenadas no mapa. # * I = ID do ícone. # *[Popup de imagem] A IMAGEM DEVE ESTAR NA PASTA 'Graphics/Pictures'. # popup: , F # * x, y = Coordenadas no mapa. # * F = Nome da imagem. # ******************************* No personagem ******************************* # *[Popup de texto] # popup_player: , T # * T = Texto. # *[Popup de ícone] # popup_player: , I # * I = ID do ícone. # *[Popup de imagem] A IMAGEM DEVE ESTAR NA PASTA 'Graphics/Pictures'. # popup_player: , F # * F = Nome da imagem. # ******************************* No evento *********************************** # *[Popup de texto] # popup: , T # * id = ID do evento do mapa. # * T = Texto. # *[Popup de ícone] # popup: , I # * id = ID do evento do mapa. # * I = ID do ícone. # *[Popup de imagem] A IMAGEM DEVE ESTAR NA PASTA 'Graphics/Pictures'. # popup: , F # * id = ID do evento do mapa. # * F = Nome da imagem. # ******************************* No seguidor ********************************* # *[Popup de texto] # popup: , T # * id = ID do seguidor. # * T = Texto. # *[Popup de ícone] # popup: , I # * id = ID do seguidor. # * I = ID do ícone. # *[Popup de imagem] A IMAGEM DEVE ESTAR NA PASTA 'Graphics/Pictures'. # popup: , F # * id = ID do seguidor. # * F = Nome da imagem. #============================================================================== Dax.register(:zion_popup, "Dax", 1.0, "16/03/14") #============================================================================== # • Configurador. #============================================================================== module (Zion ||= Module.new)::Popup extend self class << self attr_value :speed, 1 # Velocidade na qual irá sumir. end #---------------------------------------------------------------------------- # • Constantes e variáveis. #---------------------------------------------------------------------------- @popup ||= Array.new #FontArray = ["name", "size", "bold", "italic", "shadow", "outline", "color"] # Configuração dos strings GERAL = { # Largura do Sprite de texto. width: 320, # Tamanho da fonte. size: 20, # Nome da fonte. name: "Trebuchet MS", # Negrito na fonte? bold: true, # Sombra na fonte? shadow: true, # Itálico na fonte? italic: false, # Contorno na fonte? outline: true, # Cor da fonte color: "ffffff".color, # Até onde o popup irá max: 5, # Altura dos eventos e personagem height: 48, # Tamanho do sprite dos eventos e personagem width_sprite: 32 } #---------------------------------------------------------------------------- # • Adicionar um popup. #---------------------------------------------------------------------------- def add(*args) @popup << Zion_Popup.new(*args) end #---------------------------------------------------------------------------- # • Atualização. #---------------------------------------------------------------------------- def update_popup return if @popup.nil? @popup.each_with_index { |popup, index| next if popup.nil? popup.update unless popup.visible popup.dispose @popup.delete_at(index) end } end end #============================================================================== # • Zion_Popup #============================================================================== class Zion_Popup < Sprite include Zion::Popup #---------------------------------------------------------------------------- # • Inicialização dos objetos. #---------------------------------------------------------------------------- def initialize(tt, type, target, popup) @y = 0 @target = target @popup = DString.backslash(popup.to_s).gsub("\n", "") @type = type.symbol @tt = tt if @tt == :map case @type when :string super([GERAL[:width], GERAL[:size]+2, @target[0], @target[1], 200]) Dax::FontArray.each { |v| eval("self.bitmap.font.#{v} = GERAL[:#{v}]") } self.bitmap.draw_text_rect(@popup) when :icon super([24, 24, @target[0], @target[1], 200]) self.bitmap.draw_icon(@popup.to_i, 0, 0) when :picture bitmap = Cache.picture(@popup.to_s) super([bitmap.width, bitmap.height, @target[0], @target[1], 200]) self.bitmap = bitmap end else @tt == :player or @tt == :event case @type when :string @target[0] -= GERAL[:width] / 2 @target[1] -= GERAL[:height] super([GERAL[:width], GERAL[:size]+2, @target[0], @target[1], 200]) Dax::FontArray.each { |v| eval("self.bitmap.font.#{v} = GERAL[:#{v}]") } self.bitmap.draw_text_rect(@popup, 1) when :icon @target[0] -= GERAL[:width_sprite] / 2 @target[1] -= GERAL[:height] super([24, 24, @target[0], @target[1], 200]) self.bitmap.draw_icon(@popup.to_i, 0, 0) when :picture bitmap = Cache.picture(@popup.to_s) @target[0] -= bitmap.width / 2 @target[1] -= GERAL[:height] super([bitmap.width, bitmap.height, @target[0], @target[1], 200]) self.bitmap = bitmap end end end #---------------------------------------------------------------------------- # • Renovação dos objetos. #---------------------------------------------------------------------------- def dispose self.bitmap.dispose unless self.bitmap.disposed? super end #---------------------------------------------------------------------------- # • Atualização dos objetos. #---------------------------------------------------------------------------- def update super @y += Zion::Popup.speed unless @y >= GERAL[:max] self.y -= @y unless @y >= GERAL[:max] self.opacity -= Zion::Popup.speed * 10 self.visible = false if self.opacity <= 0 end end #============================================================================== # • Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # * Chamar script #-------------------------------------------------------------------------- alias :zion_popup_command_355 :command_355 def command_355(*args, &block) dscript = @list[@index].parameters[0] + "\n" while next_event_code == 655 @index += 1 dscript += @list[@index].parameters[0] + "\n" end if dscript.match(/popup: <(\w+), (\d+), (\d+)> ([^>]*)/m) return Zion::Popup.add(:map, $1.to_s, [$2.to_i, $3.to_i], $4.to_s) elsif dscript.match(/popup_event: <(\w+), (\d+)> ([^>]*)/m) return Zion::Popup.add(:event, $1.to_s, [$game_map.events[$2.to_i].screen_x, $game_map.events[$2.to_i].screen_y], $3.to_s) elsif dscript.match(/popup_player: <(\w+)> ([^>]*)/m) return Zion::Popup.add(:player, $1.to_s, [$game_player.screen_x, $game_player.screen_y], $2.to_s) elsif dscript.match(/popup: (\d+)/) return Zion::Popup.speed = $1.to_i || 1 else zion_popup_command_355(*args, &block) end end end #============================================================================== # • Scene_Map #============================================================================== class Scene_Base alias :zion_popup_update :update def update zion_popup_update Zion::Popup.update_popup end end