(sorry if this is the wrong board, wasn't sure if this should go here or learning rgss. or something.)
howdy! i'm trying to setup a simple popup window- currently for tutorials, but the script will probably have other applications elsewhere- and i'm struggling to get the nice little window opening animation that's used for the messages and most other built-in game windows to appear on mine.
i currently have this (ft. placeholder text for testing):
(definitely not as neat as it could be, but it works fine for what i'm using it for)
and the windows just kind of pop in and out of existence. i was under the impression
any assistance would be greatly appreciated!
howdy! i'm trying to setup a simple popup window- currently for tutorials, but the script will probably have other applications elsewhere- and i'm struggling to get the nice little window opening animation that's used for the messages and most other built-in game windows to appear on mine.
i currently have this (ft. placeholder text for testing):
Ruby:
#------------------------------------------------------------------------------
# WINDOWPOP
#------------------------------------------------------------------------------
# manages popup boxes in the upper left corner
#
# called with
# AO_Windowpop.new(#,:{text source})
# with the # being the style id for the type of window,
# and the :{text_source} being the symbol key for the text.
#------------------------------------------------------------------------------
class AO_Windowpop
#------------------------------------------------------------------------------
def initialize(style,ref)
reset_all
source(ref)
draw_dummy_window
get_window_dimensions(style)
end # init
def reset_all
# resets all class and global variables
$winpop_dummy_width = 0
@src = nil
@ref = nil
end # reset_all
def source(ref)
# defines text source
loc = AO::SAMPLETEXT
@src = loc[ref]
@ref = ref
end # source
def draw_dummy_window
# makes an invisible window to determine how wide the real one has to be
width = Windowpop_dummy.new
width.get(@ref)
end
def get_window_dimensions(style)
#defines the style of the window (may break into multiple blocks l8r)
tally = 0
case style
when 1
# unlock window; 1 line, appears for 2 sec & vanishes
x = $winpop_dummy_width + 36
y = 48
input = false
center = true
when 2
# tutorial window; multiple lines, stays open until a button is pressed
@src.each {|k,v|
x = $winpop_dummy_width + 24
tally += 1
y = (24*tally)+(tally*8)
input = true
center = false}
end # case
call_window(x,y,input,center)
end # get_window_dimensions
def call_window(x,y,input,center)
# makes window
window = AO_Windowpop_Window.new(100,60,x,y)
window.direct(input,center,@ref)
end # call_window
#------------------------------------------------------------------------------
end #Windowpop
#------------------------------------------------------------------------------
class AO_Windowpop_Window < Window_Base
#------------------------------------------------------------------------------
def initialize(x,y,width,height)
super(x,y,width,height)
self.back_opacity = 255
reset_all
end # init
def reset_all
#resets all class variables
@src = nil
end # reset_all
def direct(input,center,ref)
# calls building processes w/ their requisite arguments
update_open
source_text(ref)
tp_draw_text(center)
input == true ? input_pause : hold_two_seconds
update_close
dispose
end # direct
def source_text(ref)
# sets the text source
loc = AO::SAMPLETEXT
@src = loc[ref]
end # source_text
def tp_draw_text(center)
# draws the text
@src.each {|k,v|
txt = v
center == true ? x = contents_width/2-text_size(txt).width/2 : x = 0
y = line_height*k
draw_text_ex(x,y,txt)}
end # tp_draw_text
def input_pause
# pauses until a button is pressed
self.pause = true
wait(10)
Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
Input.update
self.pause = false
end # input_update
def wait(duration)
# defines what a pause is
duration.times { Fiber.yield }
end # wait
def hold_two_seconds
# pauses for 2 seconds
wait(120)
end
#------------------------------------------------------------------------------
end #Windowpop_window
#------------------------------------------------------------------------------
class Windowpop_dummy < Window_Base
#------------------------------------------------------------------------------
def initialize
super(0,0,0,0)
hide
end # init
def get(ref)
# compares the size of each line & sets the variable to the largest one
src = AO::SAMPLETEXT[ref]
max = 0
src.each{|k,v|
current = text_size(v).width
max = current if current > max}
$winpop_dummy_width = max
end # get
#------------------------------------------------------------------------------
end # Windowpop_dummy
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
module AO
#------------------------------------------------------------------------------
SAMPLETEXT = {
:unlock => {0 => "Unlocked Something!"},
:tutorial => {0=> "SOMETHING:",1 => "- How to do it",2 => "- When to do it"},
} # sampletext
#------------------------------------------------------------------------------
end # AO
#------------------------------------------------------------------------------
(definitely not as neat as it could be, but it works fine for what i'm using it for)
and the windows just kind of pop in and out of existence. i was under the impression
update_open and update_close were what performed that, which is why i specifically called them while building the window, but either i completely misunderstood, or i just did it wrong.any assistance would be greatly appreciated!