From 1750dc7c98dd9734a8648e0777c7f9b39c3f35ab Mon Sep 17 00:00:00 2001 From: Michael Shirt Date: Mon, 17 Oct 2016 15:34:45 -0600 Subject: [PATCH] Changes to how the game handles quitting With these changes the game technically never "allows" you to quit, and instead the input is handled by Scene_Map. This lets us run an event before they quit. --- scripts/Main.rb | 2 ++ scripts/RPG.rb | 10 +++++----- scripts/SaveLoad.rb | 5 ++--- scripts/Scene_Map.rb | 18 ++++++++++++++++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/scripts/Main.rb b/scripts/Main.rb index e256317..77471ef 100644 --- a/scripts/Main.rb +++ b/scripts/Main.rb @@ -24,12 +24,14 @@ begin $GDC = false # Make scene object (title screen) $scene = Scene_Title.new + Oneshot.allow_exit false # Call main method as long as $scene is effective while $scene != nil $scene.main end # Fade out Graphics.transition(20) + Oneshot.allow_exit true rescue Errno::ENOENT # Supplement Errno::ENOENT exception # If unable to open file, display message and end diff --git a/scripts/RPG.rb b/scripts/RPG.rb index 1eeb29b..8a22b22 100644 --- a/scripts/RPG.rb +++ b/scripts/RPG.rb @@ -38,11 +38,11 @@ module Graphics class << self alias_method :update_native, :update def update - if $game_map.map_id == 97 - Oneshot.allow_exit false - elsif $game_system.map_interpreter - Oneshot.allow_exit !$game_system.map_interpreter.running? - end + #if $game_map.map_id == 97 + # Oneshot.allow_exit false + #elsif $game_system.map_interpreter + # Oneshot.allow_exit ($scene == nil) + #end update_native end end diff --git a/scripts/SaveLoad.rb b/scripts/SaveLoad.rb index 630476e..e95ffb4 100644 --- a/scripts/SaveLoad.rb +++ b/scripts/SaveLoad.rb @@ -70,7 +70,7 @@ def real_load # Restore BGM and BGS # switch 181 or 183 or 186 means its time for a dream, so no BGM - if !($game_switches[181] || $game_switches[183] || $game_switches[186] || $game_switches[188]) + if !($game_switches[181] || $game_switches[183] || $game_switches[186] || $game_switches[188] || $game_switches[190]) $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) end @@ -92,6 +92,5 @@ end def quit_game_bed $game_system.map_interpreter.index += 1 save - Oneshot.allow_exit true - exit + $scene = nil end diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index 3b68f1c..9ae8eb5 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -89,8 +89,16 @@ class Scene_Map # * Frame Update #-------------------------------------------------------------------------- def update - if Input.quit? && $game_map.map_id == 97 - $game_temp.common_event_id = 33 + if Input.quit? + # put in dialogue boxes here for player + # either telling them they can't quit during a cutscene + # or telling them they're saving and quitting + if $game_system.map_interpreter.running? + EdText.info("You cannot perform this action during cutscenes.") + return + else + $game_temp.common_event_id = 35 + end end # Loop loop do @@ -100,6 +108,9 @@ class Scene_Map # to run any event, and the player isn't provided the opportunity to # move in an instant) $game_map.update + if $scene == nil + return + end $game_system.map_interpreter.update $game_player.update if !@menu.visible && !@item_menu.visible && !@fast_travel.visible $game_followers.each{|f| f.update} @@ -463,6 +474,9 @@ class Scene_Map def new_footsplash(direction, x, y) @spriteset.new_footsplash(direction, x, y) end + def fix_footsplashes(xDelt, yDelt) + @spriteset.fix_footsplashes(xDelt, yDelt) + end def menu_open? @menu.visible || @item_menu.visible end