Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** SceneFile_Confirmation
- #------------------------------------------------------------------------------
- # Author: JohnBolton
- # www.centrorpgmaker.com
- #==============================================================================
- # Adds a confirnation window on Scene_File, whose options are:
- #
- # - Save/Load/Rewrite
- # - Delete
- # - Cancel
- #
- #==============================================================================
- module Bolton92
- module Save_load_delete_confirmation
- Options = {
- #--------------------------------------------------------------------------
- # * Settings
- #--------------------------------------------------------------------------
- "Option1_tosave" => "Save",
- "Option1_torewrite" => "Rewrite",
- "Option1_toload" => "Load",
- "Option2" => "Delete",
- "Option3" => "Cancel"
- }
- Width_Window = 160
- end
- end
- #----------------------------------------------------------------------------
- # ** Game_System
- #----------------------------------------------------------------------------
- #============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # * Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :delete_enabled
- attr_accessor :index_save_confirmation
- #--------------------------------------------------------------------------
- # * Modification of the initialize method
- #--------------------------------------------------------------------------
- alias bolton92_system_initialize initialize
- def initialize
- bolton92_system_initialize
- @delete_enabled = 1
- @index_save_confirmation = 1
- end
- end
- #----------------------------------------------------------------------------
- # ** Window_Confirmation
- #----------------------------------------------------------------------------
- #============================================================================
- class Window_Confirmation < Window_Command
- include Bolton92::Save_load_delete_confirmation
- #--------------------------------------------------------------------------
- # * Starting the process
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- update_placement
- self.openness = 0
- open
- end
- #--------------------------------------------------------------------------
- # * Acquisition of the window width
- #--------------------------------------------------------------------------
- def window_width
- return Width_Window
- end
- #--------------------------------------------------------------------------
- # x : coordinate X
- # y : coordinate Y
- #--------------------------------------------------------------------------
- def update_placement
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2
- end
- #--------------------------------------------------------------------------
- # * Creating the list of commands
- #--------------------------------------------------------------------------
- def make_command_list
- if $game_system.delete_enabled and $game_system.index_save_confirmation
- add_command(Options["Option1_torewrite"], :confirm)
- elsif $game_system.delete_enabled == false and $game_system.index_save_confirmation
- add_command(Options["Option1_tosave"], :confirm)
- elsif $game_system.index_save_confirmation == false
- add_command(Options["Option1_toload"], :confirm, $game_system.delete_enabled)
- end
- add_command(Options["Option2"], :delete, $game_system.delete_enabled)
- add_command(Options["Option3"], :cancel)
- end
- end
- #==============================================================================
- # ** Scene_File
- #------------------------------------------------------------------------------
- #==============================================================================
- class Scene_File
- #--------------------------------------------------------------------------
- # * Modification of the start method
- #--------------------------------------------------------------------------
- alias bolton92_start start
- def start
- bolton92_start
- create_window_confirmation
- check_scene
- end
- #--------------------------------------------------------------------------
- # * Check Scene
- #--------------------------------------------------------------------------
- def check_scene
- if self.to_s.include?("Scene_Load")
- $game_system.index_save_confirmation = false
- else
- $game_system.index_save_confirmation = true
- end
- end
- #--------------------------------------------------------------------------
- # * Modification of the update method
- #--------------------------------------------------------------------------
- alias bolton92_update update
- def update
- check_delete
- bolton92_update
- end
- #--------------------------------------------------------------------------
- # * Check delete
- #--------------------------------------------------------------------------
- def check_delete
- index = sprintf("Save%02d.rvdata2", @index + 1)
- if File.exist?(index.to_s)
- $game_system.delete_enabled = true
- else
- $game_system.delete_enabled = false
- end
- end
- #--------------------------------------------------------------------------
- # * Update the selection of the selected files
- #--------------------------------------------------------------------------
- def update_savefile_selection
- unless @window_confirmation.active
- if Input.trigger?(:C)
- active_window_confirmation
- elsif Input.trigger?(:B)
- Sound.play_cancel
- return_scene
- end
- return update_cursor
- end
- end
- #--------------------------------------------------------------------------
- # * Declaration of Window_Confirmation
- #--------------------------------------------------------------------------
- def create_window_confirmation
- @window_confirmation = Window_Confirmation.new
- @window_confirmation.set_handler(:confirm, method(:on_savefile_ok))
- @window_confirmation.set_handler(:delete, method(:delete))
- @window_confirmation.set_handler(:cancel, method(:on_savefile_cancel))
- restore_savefile_window
- end
- #--------------------------------------------------------------------------
- # * Cancel
- #--------------------------------------------------------------------------
- def on_savefile_cancel
- restore_savefile_window
- end
- #--------------------------------------------------------------------------
- # * Delete
- #--------------------------------------------------------------------------
- def delete
- if DataManager.delete_save_file(@index)
- restore_savefile_window
- end
- end
- #--------------------------------------------------------------------------
- # * Activation of Window_Confirmation
- #--------------------------------------------------------------------------
- def active_window_confirmation
- Sound.play_ok
- create_window_confirmation
- @window_confirmation.active = true
- @window_confirmation.visible = true
- @window_confirmation.select_symbol(:confirm)
- @savefile_windows[@index].active = false
- @window_confirmation.refresh
- end
- #--------------------------------------------------------------------------
- # * Activation of the file list
- #--------------------------------------------------------------------------
- def restore_savefile_window
- @window_confirmation.active = false
- @window_confirmation.visible = false
- @savefile_windows[@index].active = true
- @savefile_windows[@index].refresh
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement