Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Sleek Item Popup v1.4
- #----------#
- #
- #Como usarlo:
- # Se pone el evento "Llamar script" y se completa el siguiente cuadro
- # popup(Categoria, Item , Cantidad, Tiempo)
- #
- # Categoria varia entre 0, 1 y 2 (0 = Items, 1 = Armas, 2 = Armaduras)
- # Item: Se pone el ID del item que queramos que aparezca
- # Cantidad: Se pone la cantidad de items que se consiguen
- # Tiempo: Es el tiempo que quieren que dure el popup (esto es opcional)
- #
- #Ejemplos:
- # popup(1,1,1) Va a aparecer el icono y nombre de la pocion +1
- # popup(1,1,1,120) lo mismo que antes nada mas que ahora el popup dura 120frames
- #
- #
- #Customization: Just the Sound Effect, set to nil for no sound effect
- #
- #----------#
- #-- Script by: V.M of D.T
- #--- Free to use in any non-commercial project with credit given
- #Sound effect played on popup: # "Filename", Volume(0-100), Pitch(50-150)
- PU_SOUND_EFFECT = ["Item3",100,50]
- #Duration in frames of Item Popup fadein and fadeout
- PU_FADEIN_TIME = 30
- PU_FADEOUT_TIME = 30
- #Default duration of the popup
- PU_DEFAULT_DURATION = 90
- #Whether to use a custom or default font
- PU_USE_CUSTOM_FONT = false
- #Settings for custom item popup font
- PU_DEFAULT_FONT_NAME = ["Verdana"]
- PU_DEFAULT_FONT_SIZE = 24
- PU_DEFAULT_FONT_COLOR = Color.new(255,255,255,255)
- PU_DEFAULT_FONT_BOLD = false
- PU_DEFAULT_FONT_ITALIC = false
- PU_DEFAULT_FONT_SHADOW = false
- PU_DEFAULT_FONT_OUTLINE = true
- class Item_Popup < Window_Base
- def initialize(item, amount, duration, nosound)
- super(0,0,100,96)
- Audio.se_play('Audio/SE/' + PU_SOUND_EFFECT[0],PU_SOUND_EFFECT[1],PU_SOUND_EFFECT[2]) unless PU_SOUND_EFFECT.nil? or nosound
- self.opacity = 0
- self.x = $game_player.screen_x - 16
- self.y = $game_player.screen_y - 80
- @duration = 90
- @item = item
- @amount = amount
- @amount = "+" + @amount.to_s if @amount > 0
- @name = item.name.clone
- @text = ""
- @timer = 0
- @split = (PU_FADEIN_TIME) / @name.size
- @split = 2 if @split < 2
- amount > 0 ? @red = false : @red = true
- contents.font.size = 16
- textsize = text_size(@name)
- self.width = textsize.width + 54
- self.height = textsize.height + 54
- self.x -= self.width / 4
- create_contents
- if PU_USE_CUSTOM_FONT
- contents.font.name = PU_DEFAULT_FONT_NAME
- contents.font.size = PU_DEFAULT_FONT_SIZE
- contents.font.color = PU_DEFAULT_FONT_COLOR
- contents.font.bold = PU_DEFAULT_FONT_BOLD
- contents.font.italic = PU_DEFAULT_FONT_ITALIC
- contents.font.shadow = PU_DEFAULT_FONT_SHADOW
- contents.font.outline = PU_DEFAULT_FONT_OUTLINE
- end
- self.contents_opacity = 0
- update
- end
- def update
- super
- self.visible = true if !self.visible
- self.x = $game_player.screen_x - 16
- self.y = $game_player.screen_y - 80
- self.x -= self.width / 4
- open if @timer < (PU_FADEIN_TIME)
- close if @timer > (PU_FADEOUT_TIME + @duration)
- @timer += 1
- @text += @name.slice!(0,1) if @timer % @split == 0
- contents.clear
- contents.font.size = 16
- @red ? color = Color.new(255,0,0) : color = Color.new(0,255,0)
- contents.font.color = color
- draw_text(contents.width / 4 + 16,24,36,24,@amount)
- contents.font.color = Font.default_color
- contents.font.size = 14
- draw_text(0,0,contents.width,contents.height,@text)
- draw_icon(102,contents.width / 4 - 12,24)
- draw_icon(@item.icon_index,contents.width / 4 - 12,24)
- end
- def close
- self.contents_opacity -= (255 / (PU_FADEOUT_TIME))
- end
- def open
- self.contents_opacity += (255 / (PU_FADEIN_TIME))
- end
- end
- class Game_Interpreter
- def popup(type,item,amount,duration = PU_DEFAULT_DURATION,nosound = false)
- data = $data_items[item] if type == 0
- data = $data_weapons[item] if type == 1
- data = $data_armors[item] if type == 2
- $popupwindow = Item_Popup.new(data,amount,duration,nosound)
- end
- end
- class Scene_Map
- alias popup_update update
- alias popup_preterminate pre_terminate
- def update
- popup_update
- return if $popupwindow.nil?
- $popupwindow.update
- $popupwindow = nil if $popupwindow.opacity < 0
- end
- def pre_terminate
- popup_preterminate
- $popupwindow.visible = false unless $popupwindow.nil?
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment