Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # SIMPLE STUPID EXIT & OVERWRITE CONFIRMATION ver.0.61
- # by HBK
- # Requires: N/A
- # Rewrites method (if Confirmation enabled):
- # Scene_End.command_to_title
- # Scene_End.command_shutdown
- # Scene_Save.on_savefile_ok
- # Aliases method: N/A
- #==============================================================================
- # CHANGELOG
- # - ver0.61 2012.01.03 starting script and finished
- #==============================================================================
- # INTRODUCTION
- # - Script ini memberikan warning kepada player saat akan balik ke title menu,
- # exit game, dan overwrite save file yang telah ada
- #==============================================================================
- # INSTRUCTION
- # - Utak atik aja module HBK.
- # - Bisa jadi ini script konflik KALAU konfirmasi enabled = true dan
- # ada script lain yang juga me-rewrite 3 method yang sudah saya sebut di atas.
- #==============================================================================
- module HBK
- # Ganti jadi false buat bagian yang dirasa ga perlu konfirmasi
- ENABLE_TITLE_CONFIRMATION = true
- ENABLE_SHUTDOWN_CONFIRMATION = true
- ENABLE_OVERWRITE_CONFIRMATION = true
- # Atur lebar judul menu konfirmasi
- CONFIRM_TITLE_WIDTH = 220
- module VOCAB
- CONFIRM_TO_TITLE = "Back to Title?"
- CONFIRM_SHUTDOWN = "Exit Game?"
- CONFIRM_OVERWRITE = "Overwrite Data?"
- end
- end
- # Jangan dirubah kecuali anda yakin dengan apa yang anda lakukan :P
- #==============================================================================
- class Scene_Base; include HBK;end
- class Window_Base; include HBK;end
- class Scene_End < Scene_MenuBase
- alias hbk_sseoc_command_to_title command_to_title
- def command_to_title
- if HBK::ENABLE_TITLE_CONFIRMATION
- SceneManager.call(Scene_ConfirmTitle)
- else
- hbk_sseoc_command_to_title
- end
- end
- alias hbk_sseoc_command_shutdown command_shutdown
- def command_shutdown
- if HBK::ENABLE_SHUTDOWN_CONFIRMATION
- SceneManager.call(Scene_ConfirmShutdown)
- else
- hbk_sseoc_command_shutdown
- end
- end
- end
- class Scene_Save < Scene_File
- alias hbk_sseoc_on_savefile_ok on_savefile_ok
- def on_savefile_ok
- @index < 9 ? str = "0" + (@index+1).to_s : str = (@index+1).to_s
- if HBK::ENABLE_OVERWRITE_CONFIRMATION && !Dir.glob("Save"+str+".rvdata2").empty?
- SceneManager.call(Scene_ConfirmSave)
- else
- hbk_sseoc_on_savefile_ok
- end
- end
- end
- class Scene_ConfirmSave < Scene_Save
- def start
- super
- create_background
- create_command_window
- end
- def pre_terminate
- super
- close_command_window
- end
- def terminate
- super
- dispose_background
- end
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- def dispose_background
- @background_sprite.dispose
- end
- def create_command_window
- @command_window = Window_ConfirmOverwrite.new
- @command_window.set_handler(:overwrite, method(:command_overwrite))
- @command_window.set_handler(:cancel, method(:return_scene))
- @title_window = Window_ConfirmOverwriteTitle.new
- end
- def close_command_window
- @command_window.close
- update until @command_window.close?
- end
- def command_overwrite
- if DataManager.save_game(@index)
- on_save_success
- else
- Sound.play_buzzer
- end
- end
- end
- class Window_ConfirmOverwriteTitle < Window_Base
- def initialize
- super(0,0,window_width,fitting_height(1))
- refresh
- end
- def window_width;return HBK::CONFIRM_TITLE_WIDTH;end
- def refresh
- contents.clear
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2 - fitting_height(2)
- draw_title(4,0,contents.width-8)
- end
- def draw_title(x,y,width)
- text=HBK::VOCAB::CONFIRM_OVERWRITE
- draw_text(x,y,width,line_height,text,1)
- end
- def open;refresh;super;end
- end
- class Window_ConfirmOverwrite < Window_Command
- def initialize
- super(0,0)
- update_placement
- end
- def window_width;return 80;end
- def update_placement
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2
- end
- def make_command_list
- add_command("Yes", :overwrite)
- add_command("No", :cancel)
- end
- end
- class Scene_ConfirmTitle < Scene_End
- def create_command_window
- @command_window = Window_ConfirmTitle.new
- @command_window.set_handler(:to_title, method(:command_to_title))
- @command_window.set_handler(:cancel, method(:return_scene))
- @title_window = Window_ConfirmTitleTitle.new
- end
- def command_to_title
- close_command_window
- fadeout_all
- SceneManager.goto(Scene_Title)
- end
- end
- class Scene_ConfirmShutdown < Scene_End
- def create_command_window
- @command_window = Window_ConfirmShutdown.new
- @command_window.set_handler(:shutdown, method(:command_shutdown))
- @command_window.set_handler(:cancel, method(:return_scene))
- @title_window = Window_ConfirmShutdownTitle.new
- end
- def command_shutdown
- close_command_window
- fadeout_all
- SceneManager.exit
- end
- end
- class Window_ConfirmTitleTitle < Window_Base
- def initialize
- super(0,0,window_width,fitting_height(1))
- refresh
- end
- def window_width;return HBK::CONFIRM_TITLE_WIDTH;end
- def refresh
- contents.clear
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2 - fitting_height(2)
- draw_title(4,0,contents.width-8)
- end
- def draw_title(x,y,width)
- text=HBK::VOCAB::CONFIRM_TO_TITLE
- draw_text(x,y,width,line_height,text,1)
- end
- def open;refresh;super;end
- end
- class Window_ConfirmShutdownTitle < Window_Base
- def initialize
- super(0,0,window_width,fitting_height(1))
- refresh
- end
- def window_width;return HBK::CONFIRM_TITLE_WIDTH;end
- def refresh
- contents.clear
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2 - fitting_height(2)
- draw_title(4,0,contents.width-8)
- end
- def draw_title(x,y,width)
- text=HBK::VOCAB::CONFIRM_SHUTDOWN
- draw_text(x,y,width,line_height,text,1)
- end
- def open;refresh;super;end
- end
- class Window_ConfirmTitle < Window_GameEnd
- def window_width;return 80;end
- def make_command_list
- add_command("Yes", :to_title)
- add_command("No", :cancel)
- end
- end
- class Window_ConfirmShutdown < Window_GameEnd
- def window_width;return 80;end
- def make_command_list
- add_command("Yes", :shutdown)
- add_command("No", :cancel)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment