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!