+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: DerVV's Simple Popup System (/thread-6157.html)
DerVV's Simple Popup System - DerVVulfman - 09-09-2016
DerVV's Simple Popup System
Version: 1.2
Introduction
Seriously, this is a simple popup screen that can be used to generate windows that popup on the screen witn important texts. But I posted it as a skeleton for would-be script users to show how to make pop-up windows for their own systems.
Script
The Script
Code:
#==============================================================================
# ** DerVV's Simple Popup System
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.2
# 10-08-2017 (mmddyy)
# RGSS / RPGMaker XP
#------------------------------------------------------------------------------
# Seriously, this is a simple popup screen that can be used to generate
# windows that popup on the screen witn important texts. But I posted
# it as a skeleton for would-be script users to show how to make pop-up
# windows for their own systems.
#
# This version includes a module so you can position the popup window
# where you want on the screen and decide if the popup freezes the map.
#
# Also, it includes a feature so you can use a timer system to make the
# popup automatically vanish instead of relying upon player input. It
# is based on seconds passed. If the Timer value is set to any value
# than 0, then the popup will stay on the screen for the number of sec-
# onds indicated. But if set to 0, then it will rely on button input.
#
#
#==============================================================================
module Popup
# HEIGHT POSITION & CENTERED WIDTH
#
Y_Pos = 50 # Height of window
Width = 250 # Window Width
# POP FUNCTIONS
#
Timer = 0 # if 0, uses button. Otherwise it is seconds passed
Button = "OK" # Button text
Interrupt = false # Does map freeze when pop is on (recommended true)
end
#==============================================================================
# ** Window_Popup
#------------------------------------------------------------------------------
# This window generates a pop-up window.
#==============================================================================
class Window_Popup < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Compute window height from command quantity
super(0, 0, Popup::Width, 32 + 32)
end
#--------------------------------------------------------------------------
# * Refresh
# text_lines : text string array
#--------------------------------------------------------------------------
def refresh(text_lines)
# Get number of lines of text for window size
@item_max = text_lines.size
# If we have no timer, using button
if Popup::Timer == 0
# Set window height and contents bitmap with extra 'button' line
self.height = 32 * (@item_max + 2)
self.contents = Bitmap.new(width - 32, (@item_max + 1) * 32)
# Otherwise, if timer is used
else
# Set window height and contents bitmap without extra line
self.height = 32 * (@item_max + 1)
self.contents = Bitmap.new(width - 32, @item_max * 32)
end
# Clear contents
self.contents.clear
# Cycle through and draw the text
for i in 0...@item_max
draw_item(i, text_lines[i], normal_color)
end
# Draw Button text if timer is 0
if Popup::Timer == 0
draw_item(@item_max, Popup::Button, normal_color)
end
# Set index position depending on timer or not
self.index = (Popup::Timer == 0) ? @item_max : 0
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# text : rendered text
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, text, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, text)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
return if Input.repeat?(Input::UP)
return if Input.repeat?(Input::DOWN)
super
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# Don't draw cursor rect if using a timer
return unless Popup::Timer == 0
# Otherwise, draw cursor rect on button
super()
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias scene_map_pop_main main
alias scene_map_pop_update update
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Setup the popup window
@pop_window = Window_Popup.new
@pop_window.visible = false
@pop_window.active = false
@pop_window.x = (640-Popup::Width)/2
@pop_window.y = Popup::Y_Pos
@pop_window.z = 1500
# Perform the original call
scene_map_pop_main
# Dispose of the window
@pop_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update the Hotkey Popup Window if active
@pop_window.update if @pop_window.active == true
# If popup interrupts actions
if Popup::Interrupt == true
# Exit the Hotkey Popup Window if active
return update_pop if @pop_window.active == true &&
!$game_temp.message_window_showing
end
# The original call
scene_map_pop_update
# If popup doesn't interrupt
if Popup::Interrupt == false
# Exit the Hotkey Popup Window if active
return update_pop if @pop_window.active == true
end
end
#--------------------------------------------------------------------------
# * Frame Update Testing Popup Condition
#--------------------------------------------------------------------------
def update_pop
# If using timer
return update_timer unless Popup::Timer == 0
# Otherwise, must be keyed
return update_button
end
#--------------------------------------------------------------------------
# * Frame Update Popup Timer Testing
#--------------------------------------------------------------------------
def update_timer
# If waiting
if @pwait_count > 0
# Decrease wait count
@pwait_count -= 1
# End Method
return
end
# Hide Hotkey Popup
@pop_window.active = @pop_window.visible = false
end
#--------------------------------------------------------------------------
# * Frame Update Popup Key Testing
#--------------------------------------------------------------------------
def update_button
# Return if Enter isn't pressed
return if !Input.trigger?(Input::C)
# Play decision
$game_system.se_play($data_system.decision_se)
# Hide Hotkey Popup
@pop_window.active = @pop_window.visible = false
end
#--------------------------------------------------------------------------
# * Passed call
# added_text : text string array
#--------------------------------------------------------------------------
def begin_pop(added_text=nil)
# Set the wait count to seconds (value * game frame rate)
@pwait_count = (Popup::Timer).abs * Graphics.frame_rate
# Ensure no invalid text. Must be string (even empty) if set to nil.
added_text = [""] if added_text.nil?
# Refresh pop window with new text
@pop_window.refresh(added_text)
# Make pop window visible and active
@pop_window.active = @pop_window.visible = true
end
end
Instructions
Basically paste it below Scene_Debug and above Main.
When you want to run it, make a script call of $scene.begin_pop. The syntax is: $scene.begin_pop( array_of_text )
where an array of text could be like [ "One line of text here.", "Another line of text" ]
The window will close either by player input or will close by itself if the timer setting is put to use.
Compatibility
Just for RPGMaker XP, though principles would work in other engines.
Terms and Conditions
Oh, this is a simple skeleton script. Nothing needed by me for its use. Heck, other people probably figured this routine out in no time.
RE: DerVV's Simple Popup System - Siletrea - 09-10-2016
(09-09-2016, 03:43 AM)DerVVulfman Wrote:
DerVV's Simple Popup System
Version: 1.0
Introduction
Seriously, this is a simple popup screen that can be used to generate windows that popup on the screen witn important texts. But I posted it as a skeleton for would-be script users to show how to make pop-up windows for their own systems.
Script
The Script
Code:
#==============================================================================
# ** DerVV's Simple Popup System
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.0
# 09-08-2016 (mmddyy)
# RGSS / RPGMaker XP
#------------------------------------------------------------------------------
# Seriously, this is a simple popup screen that can be used to generate
# windows that popup on the screen witn important texts. But I posted
# it as a skeleton for would-be script users to show how to make pop-up
# windows for their own systems.
#
# This version includes a module so you can position the popup window
# where you want on the screen and decide if the popup freezes the map.
#
#
#==============================================================================
module Popup
# HEIGHT POSITION & CENTERED WIDTH
#
Y_Pos = 50 # Height of window
Width = 250 # Window Width
# POP FUNCTIONS
#
Button = "OK" # Button text
Interrupt = true # Does map freeze when pop is on (recommended true)
end
#==============================================================================
# ** Window_Popup
#------------------------------------------------------------------------------
# This window generates a pop-up window.
#==============================================================================
class Window_Popup < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Compute window height from command quantity
super(0, 0, Popup::Width, 32 + 32)
end
#--------------------------------------------------------------------------
# * Refresh
# text_lines : text string array
#--------------------------------------------------------------------------
def refresh(text_lines)
@item_max = text_lines.size
self.height = 32 * (@item_max + 2)
self.contents = Bitmap.new(width - 32, (@item_max + 1) * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i, text_lines[i], normal_color)
end
draw_item(@item_max, Popup::Button, normal_color)
self.index = @item_max
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# text : rendered text
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, text, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, text)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
return if Input.repeat?(Input::UP)
return if Input.repeat?(Input::DOWN)
super
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias scene_map_pop_main main
alias scene_map_pop_update update
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Setup the popup window
@pop_window = Window_Popup.new
@pop_window.visible = false
@pop_window.active = false
@pop_window.x = (640-Popup::Width)/2
@pop_window.y = Popup::Y_Pos
@pop_window.z = 1500
# Perform the original call
scene_map_pop_main
# Dispose of the window
@pop_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update the Hotkey Popup Window if active
@pop_window.update if @pop_window.active == true
# If popup interrupts actions
if Popup::Interrupt == true
# Exit the Hotkey Popup Window if active
return update_pop if @pop_window.active == true
end
# The original call
scene_map_pop_update
# If popup doesn't interrupt
if Popup::Interrupt == false
# Exit the Hotkey Popup Window if active
return update_pop if @pop_window.active == true
end
end
#--------------------------------------------------------------------------
# * Frame Update Popup Key Testing
#--------------------------------------------------------------------------
def update_pop
# Return if Enter isn't pressed
return if !Input.trigger?(Input::C)
# Play decision
$game_system.se_play($data_system.decision_se)
# Dispose of Hotkey Popup
@pop_window.active = @pop_window.visible = false
end
#--------------------------------------------------------------------------
# * Passed call
# added_text : text string array
#--------------------------------------------------------------------------
def begin_pop(added_text=nil)
added_text = [""] if added_text.nil?
@pop_window.refresh(added_text)
@pop_window.active = @pop_window.visible = true
end
end
[i]
Instructions
Basically paste it below Scene_Debug and above Main.
When you want to run it, make a script call of $scene.begin_pop. The syntax is: $scene.begin_pop( [i]array_of_text )
where an array of text could be like [ "One line of text here.", "Another line of text" ]
Compatibility
Just for RPGMaker XP, though principles would work in other engines.
Terms and Conditions
Oh, this is a simple skeleton script. Nothing needed by me for its use. Heck, other people probably figured this routine out in no time.
[/i][/i]
WAH WOAH WOAH *WHOAH*
DOES THIS ACTUALLY CREATE A FULL POPUP WINDOW SEPERATE TO THE GAME!!!! (and can you add pictures/animation!)
THIS COULD BE SO USEFUL!
RE: DerVV's Simple Popup System - DerVVulfman - 09-10-2016
It's a basic system, the Scene_Map mechanics being the basis of the Hotkey popups I use for the Lycan system. I modeled the Window class from the Window_Command class. But it's basic, so no graphics. I leave that to scripters. But you can enter one or more lines of text for things.
RE: DerVV's Simple Popup System - DerVVulfman - 09-11-2016
Minor fix BUMP time.
Nothing much.... I just added a condition so the message pop doesn't interrupt or halt the display of normal messages. Previously, it would, and that could make things look weird if a 'fading' messagebox was stuck on the screen for a time.
I didn't have to worry about that with Lycan as I used it only in the Item & Skill menus...
RE: DerVV's Simple Popup System - DerVVulfman - 10-08-2017
Well, I'm back at work on a system that includes popup text, so I figure I might as well give this skeletal script a little
BUMP!
Version 1.2 now includes a new timer system. Rather than just relying on the player to press a key to close the popup, the end-user may decide to instead make messages last a couple of seconds.
Again, this is merely a skeleton system, designed for script-users to learn. Nothing like custom or variable popup delays per message were added. And it is an either/or option. You either use the timer to make messages vanish by themselves, OR you force the player to close the popup instead.