Код:
#==============================================================================
# ** Game Over Enhanced
#------------------------------------------------------------------------------
# Author : puppeto4 (puppeto5@hotmail.com)
# Version : 1.1 revision 1
# Date : 06 / 06 / 2008
# Note : Order Pizza Hut, support the rebellion.
# Check RPG RPG Revolution(http://www.rpgrevolution.com) for support
#------------------------------------------------------------------------------
# Function :
# This script will enable the player to resume the game or return to title
# from GameOver screen.When resume option is choosen, the game will
# automatically load the newest saved game file. Resume option won't
# show if there is no save file available.This script is best used with
# my force save script ^^.
#==============================================================================
#==============================================================================
# ** GameOverEnhanced : Configuration
#==============================================================================
#==============================================================================
# ** Puppeto
#------------------------------------------------------------------------------
# This module handles setup for any script writen by me ^^.
#==============================================================================
module Puppeto
#==============================================================================
# ** GameOver
#------------------------------------------------------------------------------
# This module handles setup for the game over enhanced script.
#==============================================================================
module GameOver
# Resume text
Resume_Text = "Загрузить"
# Return to title screen text
Return_To_Title_Text = "Главное меню"
# Path + Filename for GameOver transition.
GameOver_Transition = "Graphics/System/BattleStart"
#==============================================================================
# ** End of GameOver module
#------------------------------------------------------------------------------
end
#==============================================================================
# ** End of Puppeto module
#------------------------------------------------------------------------------
end
#==============================================================================
# ** End of GameOverEnhanced : Configuration
#==============================================================================
#==============================================================================
# ** GameOverEnhanced : Script
#------------------------------------------------------------------------------
# ** Class Alias
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Class(es) : Scene_File, Scene_Gameover, Game_Interpreter
#----------------------------------------------------------------------------
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This class performs the save and load screen processing.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : main
# * New Method(s) : resume_load
#----------------------------------------------------------------------------
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
# If @new_stack is empty
if @new_stack.nil?
# Aliasing main method; hidden method(to avoid SystemStackError)
alias puppet_resume_main main
# Set @new_stack to true
@new_stack = true
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
if $RESUME # If resume
resume_load # Call resume_load method
else # If normal play
puppet_resume_main # Usual main processing
end
end
#--------------------------------------------------------------------------
# * Load From Game Over Screen
#--------------------------------------------------------------------------
def resume_load
# Call start method
start
# Set @index to the latest file index
@index = self.latest_file_index
# Loading sound
Sound.play_load
# Call do_load method
do_load
# Set $RESUME to false to prevent looping
$RESUME = false
# Call terminate method
terminate
end
end
#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
# This class performs game over screen processing.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Method(s) : start, terminate
# * New Method(s) : check_continue, create_command_window,
# dispose_command_window, open_command_window,
# close_command_window, command_gameover, resume_scene,
# perform_gameover_transition
#----------------------------------------------------------------------------
class Scene_Gameover < Scene_Base
#--------------------------------------------------------------------------
# * Include Puppeto::GameOver modules
#--------------------------------------------------------------------------
include Puppeto::GameOver
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias puppet_resume_start start
alias puppet_resume_terminate terminate
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
# Check if save file exist or not
check_continue
# Create menu background
create_menu_background
# Create command window
create_command_window
# The usual
puppet_resume_start
end
#--------------------------------------------------------------------------
# * Post-Start Processing
#--------------------------------------------------------------------------
def post_start
super
# Call open_command_window method
open_command_window
end
#--------------------------------------------------------------------------
# * Pre-termination Processing
#--------------------------------------------------------------------------
def pre_terminate
super
# Call close_command_window method
close_command_window
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
# The usual
puppet_resume_terminate
# Dispose command window
dispose_command_window
# Dispose menu background
dispose_menu_background
# If next scene is Scene_File
if $scene.is_a?(Scene_File)
# Call perform_gameover_transition method
perform_gameover_transition
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Update menu background
update_menu_background
# Update command window
@command_window.update
# If Input::C is triggered
if Input.trigger?(Input::C)
case @command_window.index
when 0
# If save file exist
if @continue_enabled
# Create [resume] command
command_gameover(true)
else
# Create [to title] command
command_gameover(false)
end
# Create [to title] command
when 1; command_gameover(false)
end
end
end
#--------------------------------------------------------------------------
# * Update Background for Menu Screen
#--------------------------------------------------------------------------
def update_menu_background
super
# Set tome for menuback_sprite
@menuback_sprite.tone.set(0, 0, 0, 128)
end
#--------------------------------------------------------------------------
# * Determine if Continue is Enabled
#--------------------------------------------------------------------------
def check_continue
# Check the availablity of save file
@continue_enabled = (Dir.glob('Save*.rvdata').size > 0)
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = Resume_Text
s2 = Return_To_Title_Text
# If save file exist
if @continue_enabled
# Include s1 and s2 in the option
@command_window = Window_Command.new(172, [s1, s2])
else
# Include s2 in the option
@command_window = Window_Command.new(172, [s2])
end
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
# Draw item with center alignment
@command_window.draw_item(0,true, 1)
@command_window.draw_item(1,true, 1)
# Set openness to 0
@command_window.openness = 0
@command_window.open
end
#--------------------------------------------------------------------------
# * Dispose of Command Window
#--------------------------------------------------------------------------
def dispose_command_window
@command_window.dispose
end
#--------------------------------------------------------------------------
# * Open Command Window
#--------------------------------------------------------------------------
def open_command_window
@command_window.open
begin
@command_window.update
Graphics.update
end until @command_window.openness == 255
end
#--------------------------------------------------------------------------
# * Close Command Window
#--------------------------------------------------------------------------
def close_command_window
@command_window.close
begin
@command_window.update
Graphics.update
end until @command_window.openness == 0
end
#--------------------------------------------------------------------------
# * Process When Choosing [Resume] or [To Title] Command
#--------------------------------------------------------------------------
def command_gameover(resume = false)
# Set resume to @resume
@resume = resume
# Call resume_scene method
resume_scene
Sound.play_decision
RPG::BGM.fade(800)
RPG::BGS.fade(800)
RPG::ME.fade(800)
close_command_window
end
#--------------------------------------------------------------------------
# * Resume Scene
#--------------------------------------------------------------------------
def resume_scene
# If @resume is true
if @resume
# Go to Scene_File(load type)
$scene = Scene_File.new(false, true, false)
# Set $RESUME to true to enable Scene_File to initialize resume_load
$RESUME = true
else
# Go to Scene_Title
$scene = Scene_Title.new
Graphics.fadeout(60)
end
end
#--------------------------------------------------------------------------
# * Execute Pre-battle Transition
#--------------------------------------------------------------------------
def perform_gameover_transition
@trans_name = GameOver_Transition
Graphics.transition(80, @trans_name, 80)
Graphics.freeze
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
#----------------------------------------------------------------------------
# * Aliased Class(es) : command_353
#----------------------------------------------------------------------------
class Game_Interpreter
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias puppet_resume_command_353 command_353
#--------------------------------------------------------------------------
# * Game Over
#--------------------------------------------------------------------------
def command_353
# The usual
puppet_resume_command_353
# Add 1 to @index
@index += 1
end
end
#==============================================================================
# ** End of Class Alias
#------------------------------------------------------------------------------
# ** Class Rewrite
#==============================================================================
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
#----------------------------------------------------------------------------
# * Rewrite Method(s) : draw_item(Adding alignment function)
#----------------------------------------------------------------------------
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
# align : alignment flag.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true, align = 0)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
@align = align
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
if @align == 0
self.contents.draw_text(rect, @commands[index])
elsif @align == 1
self.contents.draw_text(rect, @commands[index], 1)
else
self.contents.draw_text(rect, @commands[index], 2)
end
end
end
#==============================================================================
# ** End of Class Rewrite
#------------------------------------------------------------------------------
# ** End of GameOverEnhanced : Script
#==============================================================================
Социальные закладки