[XP] F12 Pause with image script

Started by Zeriab, May 22, 2009, 05:08:26 am

Previous topic - Next topic

Zeriab

Probably not, but the fact that some of you are makes me happy ^_^
I enjoy doing it, so it's a win-win situation

Calintz

That's really all that matters ... =D

phcs666

Can the key be changed ? to ESC or PauseBreak for example ?

ForeverZer0

If you need that, you can probably quickly add the feature in to be called when a key is pressed. As it is, the script captures the Reset feature that is built into RMXP, and prevents the game from being reset.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

phcs666

Got it, the game must be reseted when my defined key is pressed, but with the reset feature captured by the pause feature, it will pause the game instead of reseting it, right ?

So what do i have to put into my key condition to make the game reset ( pause )

Zeriab

I'd suggest finding an input script which supports checking for those keys and modifying this version which uses F6: http://forum.chaos-project.com/index.php/topic,3613.msg72096.html#msg72096

*hugs*

phcs666

Oh =O, i havent noticed that post of yours, thank you Zeriab, thats what i need \o

Futendra

Quote from: Zeriab on December 17, 2010, 02:14:14 pm
I'd suggest finding an input script which supports checking for those keys and modifying this version which uses F6: http://forum.chaos-project.com/index.php/topic,3613.msg72096.html#msg72096

*hugs*



Finally I got the spam verification code workign for my registration, I had some bgu ore something...

FINALLY I can ask you my questiond :D

How do I make the pause picture slightly transparent?

Im dutch so srry for my suckywucky english :D

stripe103

Since it only shows the image I'd guess it is enough with making the image file itself slightly transparent.. Just use PhotoShop or Gimp or anything like them.

Futendra

Quote from: stripe103 on December 29, 2010, 07:33:47 am
Since it only shows the image I'd guess it is enough with making the image file itself slightly transparent.. Just use PhotoShop or Gimp or anything like them.


well since my photoshop expired and my download limit is extremely limited, it will be hard (thats why i come to this forum, the scripts arent in downloads but just in script spoilers :D :)

stripe103

Okay..
In the script, go to line 87 ( @sprite.z = 9999 ) and add a new line after, before the line begin and write
@sprite.opacity = NUMBER

and that should work.

Change the NUMBER to a value from 0(invisible) to 255(totally visible) that you want.

World Eater

I've been toying with this but I'm a little over my head at the moment.
Would it be possible to make the pause script have animation functionality?

If so, how would one go about doing so?

Thanks for the awesome script by the way.

Zeriab

Certainly it is. Here is a quick and dirty modification where you can have both a start animation (which plays just once) and a loop animations which continues to play until the player unpauses the game.

#==============================================================================
# ** Pausing with F12
#------------------------------------------------------------------------------
# Zeriab
# Version 1.2
# 2011-08-08 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1.0 -------------------------------------------------- (2009-05-22)
#   - First release
#
#   Version 1.1 -------------------------------------------------- (2009-05-25)
#   - The pause image now appears immediately when F12 is pressed.
#   - Transitions are cut short rather than restarted when F12 is pressed.
#
#   Version 1.2 -------------------------------------------------- (2011-08-08)
#   - Allowed a start and loop animation to be played
#------------------------------------------------------------------------------
# * Description :
#
#   This script changes the functionality of pressing F12 during the game
#   from resetting the game to (un)pausing the game. A picture is displayed
#   while the game is paused. (Having a picture is optional)
#------------------------------------------------------------------------------
# * License :
#
#   Copyright (C) 2009  Zeriab
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Lesser Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser Public License for more details.
#
#   For the full license see <http://www.gnu.org/licenses/>
#   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
#   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
#------------------------------------------------------------------------------
# * Compatibility :
#
#   Is most likely not compatible with other F12 prevention scripts.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place this script anywhere above main.
#   The image file 'pause' present in Graphics/Pictures is used.
#   Note: No picture is shown if there is no 'pause' in Graphics/Pictures.
#==============================================================================

#=============================================================================
# ** Reset class (because it won't be defined until F12 is pressed otherwise)
#=============================================================================
class Reset < Exception
 
end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
  class << self
    START_ANIMATION_ID = 99
    LOOP_ANIMATION_ID  = 94
    WAIT_BEFORE_LOOP = 30 # Amount of frames before the loop animation starts
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_f12_pause_update)
      alias_method(:zeriab_f12_pause_update, :update)
      alias_method(:zeriab_f12_pause_transition, :transition)
    end
    #-------------------------------------------------------------------------
    # Change the update method so F12 toggles pause
    #-------------------------------------------------------------------------
    def update(*args)
      # Try to update normally
      begin
        zeriab_f12_pause_update(*args)
        return
      rescue Reset
        # Do nothing
      end
      # F12 has been pressed
      done = false
      # Store frame count
      frame_count = Graphics.frame_count
      # Show pause image
      @sprite = RPG::Sprite.new
      @sprite.z = 9999
      if $data_animations && $data_animations[START_ANIMATION_ID]
        @sprite.animation($data_animations[START_ANIMATION_ID], false)
      end
      begin
        @sprite.bitmap = RPG::Cache.picture('pause')
      rescue
        @sprite.bitmap = Bitmap.new(32,32)
      end
      # Keep trying to do the update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do Nothing
        end
      end
      # F12 has been released, update until it is pressed again
      counter = 0
      while done
        begin
          counter += 1
          if counter >= WAIT_BEFORE_LOOP && $data_animations && $data_animations[LOOP_ANIMATION_ID]
            @sprite.loop_animation($data_animations[LOOP_ANIMATION_ID])
          end
          @sprite.update
          zeriab_f12_pause_update(*args)
        rescue Reset
          done = false
        end
      end
      # F12 has been pressed, keep trying to update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
      # F12 has been released, dispose pause image
      @sprite.dispose
      # Set proper frame count
      Graphics.frame_count = frame_count
    end
    #-------------------------------------------------------------------------
    # Changes the transition so it is cut short if F12 is pressed
    #-------------------------------------------------------------------------
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_pause_transition(*args)
          done = true
        rescue Reset
          # Set transition length to 0 frames.
          args[0] = 0
        end
      end
    end
  end
end


*hugs*