Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Kingdom Animated Pop-up
- # por King Gerar
- #------------------------------------------------------------------------------
- # Este script cria uma janela de pop-up. Esta janela tem a função de, ao ganhar
- # algum item, habilidade, ou qualquer rápida informação, seja mostrado
- # rapidamente na tela.
- # Requere Kingdom Módulo v 1.0 ou mais recente.
- #==============================================================================
- # Kingdom - Módulo
- # por King Gerar
- # v 1.0
- #------------------------------------------------------------------------------
- # Este script serve somente para configurar os demais scripts de nome "Kingdom"
- # e feitos pelo mesmo autor (King Gerar). É para simplificar para, no caso de
- # se usar dois ou mais scripts meus, não tenha que congigurar mais de uma vez
- # a mesma coisa.
- # Mas mesmo configurando aqui, sempre olhe o cabaçalho dos outros scripts, pois
- # existem configurações específicas para cada script.
- # Caso esteja usando somente um script "Kingdom", este módulo pode ser colado
- # nele (geramente tem a opção de tudo em só um script, no tópico).
- #==============================================================================
- module KMain_Config
- # Gráfico da janela a ser utilizado.
- Window_Main = "KWindow"
- # Nome da fonte principal.
- Font_Main = "Aerolite"
- #Tamanho da fonte.
- Font_Size = 20
- # Cor dos textos principais.
- Color_MainText = Color.new(255, 255, 0, 255)
- # Cor dos textos normais.
- Color_AltText = Color.new(255, 255, 255, 255)
- end
- #==============================================================================
- # Módulo KConfig_12
- #------------------------------------------------------------------------------
- # - Este módulo serve para você fazer as configurações específicas e restritas
- # à este script.
- #==============================================================================
- module KConfig_12
- # Largura da janela de pop-up.
- Wdw_Widht = 128
- # Distância base que a animação percorre.
- Anim_Distance = 50
- # Tempo em que a primeira animação ocorre.
- # Valor em frames.
- Anim_Time = 20
- # Tempo em que o pop-up fica estático na tela.
- # Valor em frames.
- Anim_Wait = 90
- # Valor de correção da posição da janela na altura.
- Move_Y = 0
- #------------------------------------------------------------------------------
- # Este pop-up não é ativado automaticamente. É preciso que você o chame,
- # utilizando o comando por eventos "Chamar script", usando este código:
- #
- # kpopup(event, icon, text, arg, anim)
- #
- # Substituindo as palavras pelo que você deseja colocar.
- # event = ID do evento em que será exibido o pop-up.
- # icon = ID do ícone que será exibido no pop-up.
- # text = Nome do item, habilidade ou do que deseja colocar.
- # arg = Caso for usado para mostrar que ganhou item, coloque somente a
- # quantidade desse item. Caso seja para escrever "ganhou", "aprendeu", ou
- # qualquer outra coisa, coloque o texto ou palavra.
- # anim = Animação que o pop-up terá, sendo:
- # 0 - Aparece gradativamente e some gradativamente.
- # 1 - Aparece gradativamente de baixo para cima e some gradativamente.
- # 2 - Aparece gradativamente de baixo para cima e some gradativamente
- # subindo.
- #
- # Exemplos:
- # kpopup(5, 240, "Chave", 1, 0)
- # kpopup(3, 112, "Curar", "Aprendeu!", 1)
- #------------------------------------------------------------------------------
- end
- #==============================================================================
- class Game_Interpreter
- def kpopup(event, icon, text, arg, anim)
- $kpopup_window.begin(event, icon, text, arg, anim)
- end
- end
- #==============================================================================
- class Window_KPopup < Window_Base
- include KConfig_12
- #--------------------------------------------------------------------------
- # * Inicialização do objeto
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, Wdw_Widht, 64)
- self.windowskin = Cache.system(KMain_Config::Window_Main)
- self.change_color(KMain_Config::Color_MainText)
- self.contents.font.name = KMain_Config::Font_Main
- self.contents.font.size = KMain_Config::Font_Size
- self.opacity = 0
- self.contents_opacity = 0
- @current_time = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Atualização das informações.
- #--------------------------------------------------------------------------
- def begin(event, icon, text, arg, anim)
- @event = event
- @icon = icon
- @text = text
- @arg = arg
- @anim = anim
- @show_time = Anim_Time + Anim_Wait
- create
- end
- #--------------------------------------------------------------------------
- # * criação das informações.
- #--------------------------------------------------------------------------
- def create
- self.contents.clear
- draw_icon(@icon, 0, 0)
- self.change_color(KMain_Config::Color_MainText)
- draw_text(24, 0, self.width - 48, line_height, @text, 1)
- self.change_color(KMain_Config::Color_AltText)
- if @arg.is_a?(Integer)
- draw_text(0, 0, self.width - 24, (line_height * 2) + 14, "x" + @arg.to_s, 1)
- else
- draw_text(0, 0, self.width - 24, (line_height * 2) + 14, @arg.to_s, 1)
- end
- end
- #--------------------------------------------------------------------------
- # * Atualização do Pop-up e animação.
- #--------------------------------------------------------------------------
- def refresh
- case @anim
- when 0
- if @current_time == 0
- self.x = $game_map.events[@event].screen_x - (self.width / 2)
- self.y = $game_map.events[@event].screen_y - (self.height * 2) + Move_Y
- @current_time += 1
- elsif @current_time > 0 && @current_time < Anim_Time
- self.opacity += (255 / Anim_Time)
- self.contents_opacity += (255 / Anim_Time)
- @current_time += 1
- elsif @current_time >= Anim_Time && @current_time < @show_time
- @current_time += 1
- elsif @current_time >= @show_time && @current_time < @show_time + 10
- self.opacity -= 26
- self.contents_opacity -= 26
- @current_time += 1
- else
- self.contents.clear
- end
- when 1
- if @current_time == 0
- self.x = $game_map.events[@event].screen_x - (self.width / 2)
- self.y = $game_map.events[@event].screen_y - self.height + Move_Y
- @current_time += 1
- elsif @current_time > 0 && @current_time < Anim_Time
- self.y -= (Anim_Distance / Anim_Time)
- self.opacity += (255 / Anim_Time)
- self.contents_opacity += (255 / Anim_Time)
- @current_time += 1
- elsif @current_time >= Anim_Time && @current_time < @show_time
- @current_time += 1
- elsif @current_time >= @show_time && @current_time < @show_time + 10
- self.y -= 3
- self.opacity -= 26
- self.contents_opacity -= 26
- @current_time += 1
- else
- self.contents.clear
- end
- when 2
- if @current_time == 0
- self.x = $game_map.events[@event].screen_x - (self.width / 2)
- self.y = $game_map.events[@event].screen_y - self.height + Move_Y
- @current_time += 1
- elsif @current_time > 0 && @current_time < Anim_Time
- self.y -= (Anim_Distance / Anim_Time)
- self.opacity += (255 / Anim_Time)
- self.contents_opacity += (255 / Anim_Time)
- @current_time += 1
- elsif @current_time >= Anim_Time && @current_time < @show_time
- @current_time += 1
- elsif @current_time >= @show_time && @current_time < @show_time + 10
- self.opacity -= 26
- self.contents_opacity -= 26
- @current_time += 1
- else
- self.contents.clear
- end
- end
- end
- end
- #==============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # * Inicialização do processo
- #--------------------------------------------------------------------------
- alias kpopup_start start
- def start
- kpopup_start
- $kpopup_window = Window_KPopup.new
- end
- #--------------------------------------------------------------------------
- # * Atualização da tela
- #--------------------------------------------------------------------------
- alias kpopup_update update
- def update
- kpopup_update
- $kpopup_window.refresh
- end
- #--------------------------------------------------------------------------
- # * Finalização do processo
- #--------------------------------------------------------------------------
- alias kpopup_terminate terminate
- def terminate
- kpopup_terminate
- $kpopup_window.dispose
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement