Window Pause Sprite Hijacked
Version: 1.0
Author: modern algebra
Date: August 18, 2010
Version History
- <Version 1.0> 08.18.2010 - Original Release
Description
This script has no effect on its own. It is meant for scripters who wish to vary aspects about the pause graphic.The pause graphic for windows is extraordinarily boring and, worse still, the sprite that shows pause graphics on instances of the Window class is, by default, unaccessible. This means that you have no control over its opacity, its position, its speed, etc... the only thing a scripter has control over, with regard to the pause graphic, is whether or not it is visible. The purpose of this script is to change that by hiding the original pause graphic and replacing it with a normal sprite over which the scripter has total control. So, if a scripter wants to make the pause graphic bigger, play an animation on it, change its position or speed with which it animates, this script allows him/her to do so. Moreover, the scripter can do this only for certain windows and leave other windows as default. However, the script is engineered so that the default behaviour of the pause sprite is the exact same, so non-scripters will not notice a difference by including this script in their game.
Features
- Hides the original pause graphic and replaces it with an open sprite, effectively opening the pause sprite of Windows and making it easy for a scripter to alter it
Instructions
Simply paste the script below the default scripts but above Main and any custom scripts that use it.
If you want to use this script, I suggest you simply take the time to learn the whole script. It is short and the design is simple enough that most scripters should, I think, understand it pretty quickly and easily. However, time is hard to come by and so the methods that are most important for a scripter who might want to use this are probably:
- Sprite_WindowPause: #set_graphic
- Window_Base: #windowskin=
#reset_pause_position
If you use this script, please alias the methods you want to change - do not overwrite without a good reason.
Script
NB: If you are using
Internet Explorer, you will not be able to copy the script from the code box. Download the
attached text document instead.
#==============================================================================
# Window Pause Sprite Hijacked
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: August 18, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script has no effect on its own. It is meant for scripters who wish
# to vary aspects about the pause graphic.
#
# The pause graphic for windows is extraordinarily boring and, worse still,
# the sprite that shows pause graphics on instances of the Window class is,
# by default, unaccessible. This means that you have no control over its
# opacity, its position, its speed, etc... the only thing a scripter has
# control over, with regard to the pause graphic, is whether or not it is
# visible. The purpose of this script is to change that by hiding the
# original pause graphic and replacing it with a normal sprite over which the
# scripter has total control. So, if a scripter wants to make the pause
# graphic bigger, play an animation on it, change its position or speed with
# which it animates, this script allows him/her to do so. Moreover, the
# scripter can do this only for certain windows and leave other windows as
# default. However, the script is engineered so that the default behaviour of
# the pause sprite is the exact same, so non-scripters will not notice a
# difference by including this script in their game.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Simply paste the script below the default scripts but above Main and any
# custom scripts that use it.
#
# If you want to use this script, I suggest you simply take the time to
# learn the whole script. It is short and the design is simple enough that
# most scripters should, I think, understand it pretty quickly and easily.
# However, time is hard to come by and so the methods that are most important
# for a scripter who might want to use this are probably:
#
# Sprite_WindowPause: #set_graphic
# Window_Base: #windowskin=
# #reset_pause_position
#
# If you use this script, please alias the methods you want to change - do
# not overwrite without a good reason.
#==============================================================================
#==============================================================================
# ** Sprite_WindowPause
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This class shows the Pause graphic
#==============================================================================
class Sprite_WindowPause < Sprite_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_reader :pw
attr_reader :ph
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (*args)
super (*args)
set_graphic (Bitmap.new (32, 32))
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update (*args)
if self.visible
if @frame_count % @update_frames == 0
@pause_pattern = (@pause_pattern + 1) % 4
@frame_count = 0
x = (@pause_pattern % 2)*@pw
y = (@pause_pattern / 2)*@ph
self.src_rect.set (x, y, @pw, @ph)
end
@frame_count += 1
end
super (*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Graphic
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_graphic (pause_graphic, update_speed = 16)
self.bitmap = pause_graphic
@pw, @ph = self.bitmap.width / 2, self.bitmap.height / 2
@update_frames = update_speed
@pause_pattern = -1
@frame_count = 0
end
end
#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - initialize; update; windowskin=; pause=
# new method - reset_pause_position
#==============================================================================
class Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mrna_wphiniz_3uk9 initialize
def initialize (*args)
@pause_sprite = Sprite_WindowPause.new
mrna_wphiniz_3uk9 (*args) # Run Original Method
reset_pause_position
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias odral_wph_updt_7cx2 update
def update (*args)
odral_wph_updt_7cx2 (*args) # Run Original Method
@pause_sprite.update
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Reset Pause Position
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def reset_pause_position
@pause_sprite.visible = self.pause
@pause_sprite.x = self.x + ((self.width - @pause_sprite.pw) / 2)
@pause_sprite.y = self.y + self.height - @pause_sprite.ph
@pause_sprite.z = self.z + 1
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Windowskin
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_wph_stwindow_6ya3 windowskin= unless self.method_defined? (:malg_wph_stwindow_6ya3)
def windowskin= (bitmap, *args)
pause_graphic = Bitmap.new (32, 32)
pause_graphic.blt (0, 0, bitmap, Rect.new (96, 64, 32, 32))
@pause_sprite.set_graphic (pause_graphic)
reset_pause_position
bitmap_2 = bitmap.dup
bitmap_2.clear_rect (96, 64, 32, 32)
malg_wph_stwindow_6ya3 (bitmap_2, *args) # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Pause
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias moda_wph_stpse_5th3 pause= unless self.method_defined? (:moda_wph_stpse_5th3)
def pause= (*args)
moda_wph_stpse_5th3 (*args) # Run Original Method
reset_pause_position
end
end
Credit
Thanks
Support
Please post in this topic at RMRK for support, no matter how old the topic is. Do not PM me.
Known Compatibility Issues
No currently known compatibility issues. The script is written for Window_Base, so this script will not apply to any windows that use Window as a superclass instead. Also, the pause graphic will not adjust its position if a window is resized while the pause sprite is visible. This is because I could not forsee any situation where it would make sense to resize a window while the pause sprite is visible. Both could lead to compatibility issues, but I think that those issues will be very rare.
Author's Notes
Feel free to share a link to any scripts you write using this script as a base. I will include a link to it in this topic.