Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Simple Quit
- # Author: Nicke
- # Created: 27/12/2011
- # Edited: 30/12/2011
- # Version: 1.0
- #==============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- #
- # A simple end scene with a few features. No need for explaining how it works.
- #==============================================================================
- ($imported ||= {})["NICKE-SIMPLE-QUIT"] = true
- module NICKE
- module QUIT
- #--------------------------------------------------------------------------#
- # * Settings
- #--------------------------------------------------------------------------#
- # When adding a new item make sure you edit in quit_command method as well.
- # Right now it supports 5 items with the appropriated methods to it.
- # CMDS ['STRING 1', 'STRING 2'] etc.
- CMDS = ['Quit', 'Save', 'Load', 'Title', 'Back']
- # If you use CMDS.size the items will be pushed horizontal.
- # Bare in mind that if you add too many they will eventually go off screen.
- # WINDOW [ columns, x, y, z, opacity, center window]
- WINDOW = [CMDS.size, 0, 0, 200, 255, false]
- # CONFIRM_WINDOW [ columns, x, y, z, opacity, center window ]
- CONFIRM_WINDOW = [2, 200, 200, 200, 255, true]
- # Transition, nil to use default.
- # TRANSITION [ SPEED, TRANSITION, OPACITY ]
- # TRANSITION = [40, "Graphics/Transitions/1", 50]
- TRANSITION = nil
- # BACKGROUND IMAGE (System folder)
- # Set to nil to use default.
- BACK = nil
- # Return to map instead?
- RETURN_TO_MAP = false
- RETURN_INDEX = 7
- # Font and positioning settings for confirm text.
- # CONFIRM_TEXT = [ name, size, color, bold, shadow, x, y, text ]
- CONFIRM_TEXT = ["Rockwell", 24, Color.new(255,200,200), true, true,
- 0, 156, "Confirm"]
- end
- end
- # *** Don't edit below unless you know what you are doing. ***
- #==============================================================================#
- # ** Scene_End
- #------------------------------------------------------------------------------
- # New Scene :: Scene_End
- #==============================================================================#
- class Scene_End < Scene_Base
- def initialize(index = 0)
- @command_index = index
- end
- alias nicke_end_start start unless $@
- def start(*args, &block)
- super
- nicke_end_start(*args, &block)
- end
- alias nicke_end_terminate terminate unless $@
- def terminate(*args, &block)
- super
- nicke_end_terminate(*args, &block)
- end
- def create_menu_background
- @menuback_sprite = Sprite.new
- if NICKE::QUIT::BACK.nil?
- @menuback_sprite.bitmap = $game_temp.background_bitmap
- @menuback_sprite.color.set(16, 16, 16, 128)
- else
- @menuback_sprite.bitmap = Cache.system(NICKE::QUIT::BACK)
- end
- update_menu_background
- end
- def create_command_window
- @end_menu = []
- for i in NICKE::QUIT::CMDS
- next unless NICKE::QUIT::CMDS.include?(i) ; @end_menu << i
- end
- @command_window = Window_Command.new(Graphics.width, @end_menu, NICKE::QUIT::WINDOW[0])
- @command_window.index = @command_index
- if NICKE::QUIT::WINDOW[5]
- @command_window.x = (Graphics.width - @command_window.width) / 2
- else
- @command_window.x = NICKE::QUIT::WINDOW[1]
- end
- @command_window.y = NICKE::QUIT::WINDOW[2]
- @command_window.z = NICKE::QUIT::WINDOW[3]
- @command_window.opacity = NICKE::QUIT::WINDOW[4]
- # // Turn off save if save disabled.
- if $game_system.save_disabled
- @command_window.draw_item(1, false)
- end
- # // Turn off load if no save files found.
- if !check_continue
- @command_window.draw_item(2, false)
- end
- @command_window.open
- end
- def create_message_window
- @message_window = Window_Text.new
- @message_window.opacity = 0
- end
- def create_confirm_window
- @command_window.active = false
- @confirm_window = Window_Command.new(300, ['Yes', 'No'], NICKE::QUIT::CONFIRM_WINDOW[0])
- if NICKE::QUIT::CONFIRM_WINDOW[5]
- @confirm_window.x = (Graphics.width - @confirm_window.width) / 2
- else
- @confirm_window.x = NICKE::QUIT::CONFIRM_WINDOW[1]
- end
- @confirm_window.y = NICKE::QUIT::CONFIRM_WINDOW[2]
- @confirm_window.z = NICKE::QUIT::CONFIRM_WINDOW[3]
- @confirm_window.opacity = NICKE::QUIT::CONFIRM_WINDOW[4]
- @confirm_window.open
- end
- def close_confirm_window
- @confirm_window.dispose unless @confirm_window.nil?
- @confirm_window = nil
- @message_window.dispose unless @message_window.nil?
- @message_window = nil
- @command_window.active = true
- end
- def return_scene
- if NICKE::QUIT::RETURN_TO_MAP
- $scene = Scene_Map.new
- else
- $scene = Scene_Menu.new(NICKE::QUIT::RETURN_INDEX)
- end
- end
- def dispose_command_window
- @command_window.dispose unless @command_window.nil?
- @command_window = nil
- end
- def dispose_menu_background
- @menuback_sprite.dispose unless @menuback_sprite.nil?
- @menuback_sprite = nil
- end
- def update
- update_input
- update_windows
- end
- def update_input
- if !@confirm_window.nil?
- update_confirm_window
- return
- end
- if @command_window.active ; update_command end
- end
- def update_windows
- @command_window.update
- if !@message_window.nil?
- @message_window.update
- end
- if !@confirm_window.nil?
- @confirm_window.update
- end
- end
- def update_command # Main Command
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- end
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0...NICKE::QUIT::CMDS.size
- # // Save (If you change positioning, change this)
- if @command_window.index == 1
- if $game_system.save_disabled
- Sound.play_buzzer
- return
- end
- end
- # // Load (If you change positioning, change this)
- if @command_window.index == 2
- if !check_continue
- Sound.play_buzzer
- return
- end
- end
- # // Back (If you add more, change this)
- if @command_window.index == 4
- Sound.play_cancel
- return_scene
- return
- end
- # // Confirm dialog.
- Sound.play_decision
- create_confirm_window
- create_message_window
- end
- end
- end
- def update_confirm_window # Confirm Command
- if Input.trigger?(Input::B)
- close_confirm_window
- Sound.play_cancel
- end
- if Input.trigger?(Input::C)
- case @confirm_window.index
- when 0 # Yes
- Sound.play_decision
- close_confirm_window
- quit_command(@command_window.index)
- when 1 # No
- Sound.play_cancel
- close_confirm_window
- end
- end
- end
- def check_continue
- # // Check if any save data is available.
- @continue_enabled = (Dir.glob('Save*.rvdata').size > 0)
- end
- def quit_command(index)
- # // Note: Changes should be made here if you wish to add more items to CMDS.
- case index
- when 0 ; command_shutdown # Quit
- when 1
- if !$game_system.save_disabled
- command_save # Save
- @command_window.draw_item(1, false)
- end
- when 2
- if check_continue
- command_load # Load
- @command_window.index = 2
- else
- @command_window.draw_item(2, false)
- end
- when 3 ; command_to_title # Title
- when 4 ; return_scene # Back
- end
- end
- def command_save
- # // Save command.
- Sound.play_decision
- close_command_window
- $scene = Scene_File.new(true, false, false)
- end
- def command_load
- # // Load command.
- Sound.play_decision
- close_command_window
- $scene = Scene_File.new(false, false, false)
- end
- def command_to_title
- # // Title command.
- Sound.play_decision
- close_command_window
- RPG::BGM.fade(800)
- RPG::BGS.fade(800)
- RPG::ME.fade(800)
- $scene = Scene_Title.new
- Graphics.fadeout(60)
- end
- def command_shutdown
- # // Quit command.
- Sound.play_decision
- close_command_window
- Graphics.fadeout(60)
- RPG::BGM.fade(800)
- RPG::BGS.fade(800)
- RPG::ME.fade(800)
- $scene = nil
- end
- def perform_transition
- if NICKE::QUIT::TRANSITION.nil?
- Graphics.transition(30)
- else
- Graphics.transition(NICKE::QUIT::TRANSITION[0],NICKE::QUIT::TRANSITION[1],NICKE::QUIT::TRANSITION[2])
- end
- end
- end
- #==============================================================================#
- # ** Window_Text
- #------------------------------------------------------------------------------
- # Class for drawing text.
- #==============================================================================#
- class Window_Text < Window_Base
- def initialize
- super(0, 0, Graphics.width, Graphics.height)
- refresh
- end
- def refresh
- self.contents.clear
- draw_confirm_text
- end
- def self_rect
- # Return the value of contents rect.
- return self.contents.rect
- end
- def draw_text(x, y, text, align)
- # Method for drawing the text.
- title = self_rect
- title.x = x
- title.y = y
- title.height = 28
- self.contents.draw_text(title,text,align)
- end
- def draw_confirm_text
- contents.font.name = NICKE::QUIT::CONFIRM_TEXT[0]
- contents.font.size = NICKE::QUIT::CONFIRM_TEXT[1]
- contents.font.color = NICKE::QUIT::CONFIRM_TEXT[2]
- contents.font.bold = NICKE::QUIT::CONFIRM_TEXT[3]
- contents.font.shadow = NICKE::QUIT::CONFIRM_TEXT[4]
- self.contents.draw_text(NICKE::QUIT::CONFIRM_TEXT[5], NICKE::QUIT::CONFIRM_TEXT[6], self.contents.width - 16, WLH, NICKE::QUIT::CONFIRM_TEXT[7], 1)
- end
- end # END OF FILE
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement