Popup Windows
#1
Popup Windows
Allows you to display popup-windows to the player with your text in. Support for custom background will be added soon.

Script
Code:
#==============================================================================
# ** Popup windows
#------------------------------------------------------------------------------
# Written by Valdred
#==============================================================================
class Scene_Map
alias old_update_valdred update
def update
$game_temp.popup_waiting -= 1 if $game_temp.popup_waiting > 0# and @popup != nil
# Alias
if $game_temp.popup_calling
call_popup
end
if Input.press?(Input::B) and @popup != nil
# Initiate buffer
$game_temp.popup_waiting = 2
$game_system.text_popup = []
$game_temp.popup_title = ""
@popup.dispose
@popup = nil
end
return if $game_temp.popup_waiting > 0 or @popup != nil
old_update_valdred
end
def call_popup
@popup = Window_Popup.new($game_system.text_popup)
$game_temp.popup_calling = false
end
alias old_call_menu_valdred call_menu
def call_menu
old_call_menu_valdred
end
end

class Window_Popup
attr_reader :disposed
def initialize(text, background = nil)
@disposed = false
@background = Sprite.new
@background.x = 120
@background.y = 140
@background.bitmap = Bitmap.new(400, 200)
@background.bitmap.font.name = "Tahoma"
# Draw background
@background.bitmap.fill_rect(0,0,400,200, Color.new(0,0,0))
@background.bitmap.fill_rect(2,2,396,196, Color.new(102,17,17))
# Draw top bar
for i in 1..20
@background.bitmap.fill_rect(2,2+i,396,1, Color.new(102-i,17,17))
end
# Draw icons
c = Color.new(125-i,125-i,125-i)
@background.bitmap.font.color = c
for i in 1..11
@background.bitmap.set_pixel(380+i, 5+i, c)
@background.bitmap.set_pixel(392-i, 5+i, c)
end
# Draw text
y = 0
@background.bitmap.font.color = Color.new(225,225,225)
for i in $game_system.text_popup
@background.bitmap.draw_text(5, 30 + y, 400, 22, i, 1)
y += 22
end
@background.bitmap.font.size = 14
@background.bitmap.draw_text(5, 170, 400, 22, "[ Press X to close ]", 1)
#$game_system.text_popup = []
@background.bitmap.font.bold = true
@background.bitmap.draw_text(5, 0, 350, 20, $game_temp.popup_title, 0)
end

def dispose
@background.bitmap.dispose
@background.dispose
@dispose = true
end
end

class Interpreter
alias exec_command_valdred execute_command
def execute_command
# Run old method
exec_command_valdred
# Extract text
return if @list == nil
for i in @list[@index].parameters
$game_system.text_popup.push(i.gsub(/&(.*)/,""))
end
if @list[@index].parameters[0].scan(/&(.*+)/).size > 0
$game_temp.popup_title = $1
$game_temp.popup_calling = true
end
end
end

class Game_Temp
attr_accessor :popup_calling
attr_accessor :popup_waiting
attr_accessor :popup_title
alias old_init_valdred initialize
def initialize
@popup_calling = false
@popup_waiting = 0
@popup_title = ""
old_init_valdred
end
end

class Game_System
attr_accessor :text_popup
alias old_init_valdred initialize
def initialize
@text_popup = []
old_init_valdred
end
end

Instructions
Pictures say more than thousand words:
[Image: Skjermbilde.png]
[Image: Skjermbilde.png]

Put the text you want to show in a comment and call upon the popup with &title. So to display "This is a popup" in a window with the title "newpopup", you would do this:

this is a popup
&newpopup
Valdred
Tech Administrator of Save-Point
Reply }
#2
Looks cool, but couldn't you just pop up a text box?
[Image: style7,Kristovski.png]
Reply }
#3
How boring is that? :P A good game uses a variety of visual styles for different messages for easy recognizition by the user ;)
Valdred
Tech Administrator of Save-Point
Reply }
#4
kind of a nice idea actually...me likes!

where is teh updates? :o

Reply }
#5
One, your code could use some serious indenting.
Two, I think you should add some customization options. Let the creators be able to easily set up some color schemes for the popup box.
Three, haven't tested out your code yet but I think a script call would be a lot more effective than a comment.

Just my two cents, I guess. But still, I'm liking it.
Reply }
#6
The indention happened because something in the copy paste I think. I'll try to add some updates.
Valdred
Tech Administrator of Save-Point
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   DerVV's Simple Popup System DerVVulfman 4 12,284 10-08-2017, 04:53 PM
Last Post: DerVVulfman
   Auto-Sizing Text Windows RPG Advocate 9 19,005 06-11-2011, 06:18 PM
Last Post: sagam12
   Command Windows - Animated Text Selwyn 0 4,342 03-03-2008, 06:18 AM
Last Post: Selwyn
   Moving Windows Trickster 0 4,118 03-02-2008, 06:10 AM
Last Post: Trickster



Users browsing this thread: 1 Guest(s)