# Window Popup By Black Mage (Credit required to use) # https://burningwizard.wordpress.com/2014/03/05/rgss-popup-window-script/ class Window_Popup < Window_Base # The initialize method. # Called when the Window_About window is created. def initialize(popup,width,name) @name = name @text = popup # First set the window size by calling the initialize # method of window base with a size of 640 * 480 super(640-width, 0, width, 64) # Then create the contents bitmap. The width and # height are set to window width - 32 and height - 32 self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 @countdown = 110 # Call the refresh method to draw text $appear = true refresh update end # The refresh method. # Called to draw stuff on the contentsbitmap. def refresh # Clear any existing contents. self.contents.clear # Drawing something self.contents_opacity = 0 self.contents.clear self.contents.font.color = normal_color x = y = 0 if @name == "" else bitmap = RPG::Cache.icon(@name) self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24)) x += 32 end # If waiting for a message to be displayed text = @text # Control text processing text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } text.gsub!(/\\[Nn]\[([0-9]+)\]/) do $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" end text.gsub!(/\\[Ii]\[([0-9]+)\]/) do $data_items[$1.to_i] != nil ? $data_items[$1.to_i].name : "" end text.gsub!(/\\[Ww]\[([0-9]+)\]/) do $data_weapons[$1.to_i] != nil ? $data_weapons[$1.to_i].name : "" end text.gsub!(/\\[Aa]\[([0-9]+)\]/) do $data_armors[$1.to_i] != nil ? $data_armors[$1.to_i].name : "" end # Change "\\\\" to "\000" for convenience text.gsub!(/\\\\/) { "\000" } # Get 1 text character in c (loop until unable to get text) while ((c = text.slice!(/./m)) != nil) # If \\ if c == "\000" # Return to original text c = "\\" end if c == "\n" c = " " end # Draw text self.contents.draw_text(x, 0, 600, 32, c) x += self.contents.text_size(c).width end end def update @countdown -= 1 if @countdown > 0 if $appear == true self.opacity += 10 self.contents_opacity += 10 if @countdown == 85 $appear = false $stop = true end end if $stop == true if @countdown == 25 $stop = false $disappear = true end end if $disappear == true self.opacity -= 10 self.contents_opacity -= 10 if @countdown ==0 $disappear = false end end end #This end closes the class definition block end class Spriteset_Map alias popup_update update def update popup_update if !$popup.nil? && $appear == true $popup.update end if !$popup.nil? && $stop == true $popup.update end if !$popup.nil? && $disappear == true $popup.update end end end