RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Window Pause Sprite Hijacked

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

Code: [Select]
#==============================================================================
#    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


  • modern algebra

Thanks

  • phlim2, for the request

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.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Just for clarification, I take it that the pause sprite your referring to is the little arrow that shows up when your waiting for user input in message windows?

If that's the case, this seems like a nice way to customize and make your own special windows. Nice Work MA.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
yeah, that's the one.

**
Rep: +0/-0Level 75
Kreaven
Is there anything you didn't do? Seriously. I've been looking for it for hours, maybe a little less. Anyway, thanks a bunch.

I felt hopeless when looking at this little, primitive, hardly animated pause graphic of mine. It sure did look pathetic. I guess this script may solve the problem...?

Edit:
Worked wondrous.
« Last Edit: August 20, 2010, 02:03:18 AM by kreavenkreaven »

***
Rep:
Level 75
Minor bug report, pardon the necropost.

A fraction of second before animating properly, the pause graphics appears fully (all four frames, like they appear in the Window image). It's quick but noticeable.
In conjunction with ATS, this happens every time the message is loaded, in a blank project, just the first time.