04-17-2011, 08:21 PM
Popup Windows
Allows you to display popup-windows to the player with your text in. Support for custom background will be added soon.
Script
Instructions
Pictures say more than thousand words:
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
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:
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
Tech Administrator of Save-Point