Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 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 }


Messages In This Thread
Popup Windows - by deValdr - 04-17-2011, 08:21 PM
RE: Popup Windows - by Kristovski - 04-18-2011, 08:46 PM
RE: Popup Windows - by deValdr - 04-18-2011, 08:52 PM
RE: Popup Windows - by xnadvance - 06-02-2011, 05:13 AM
RE: Popup Windows - by PK8 - 06-02-2011, 06:28 AM
RE: Popup Windows - by deValdr - 06-02-2011, 09:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   DerVV's Simple Popup System DerVVulfman 4 10,969 10-08-2017, 04:53 PM
Last Post: DerVVulfman
   Yanfly Damage Popup Helladen 0 5,004 04-25-2013, 03:50 PM
Last Post: Helladen
   Victor Engine - Sprites in Windows Victor Sant 2 6,358 03-24-2012, 12:19 AM
Last Post: MetalRenard
   Victor Engine - Damage Popup Victor Sant 0 5,058 12-21-2011, 07:56 AM
Last Post: Victor Sant
   Auto-Sizing Text Windows RPG Advocate 9 16,906 06-11-2011, 06:18 PM
Last Post: sagam12
   Remove Battle Windows DerVVulfman 0 4,704 03-06-2008, 04:28 AM
Last Post: DerVVulfman
   Command Windows - Animated Text Selwyn 0 3,894 03-03-2008, 06:18 AM
Last Post: Selwyn
   Moving Windows Trickster 0 3,706 03-02-2008, 06:10 AM
Last Post: Trickster



Users browsing this thread: