diff --git a/Data/MapInfos.rxdata b/Data/MapInfos.rxdata index 71592ebfa..83844d866 100644 Binary files a/Data/MapInfos.rxdata and b/Data/MapInfos.rxdata differ diff --git a/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb b/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb index 62cfb3108..d359f235e 100644 --- a/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb +++ b/Data/Scripts/011_Battle/003_Battle/001_PokeBattle_BattleCommon.rb @@ -56,6 +56,10 @@ module PokeBattle_BattleCommon pbPlayer.pokedex.set_shadow_pokemon_owned(pkmn.species) if pkmn.shadowPokemon? # Store caught Pokémon pbStorePokemon(pkmn) + if $game_switches[AUTOSAVE_CATCH_SWITCH] + Kernel.tryAutosave() + end + end @caughtPokemon.clear end diff --git a/Data/Scripts/011_Battle/003_Battle/003_Battle_StartAndEnd.rb b/Data/Scripts/011_Battle/003_Battle/003_Battle_StartAndEnd.rb index bdfacdba6..65abcf5b4 100644 --- a/Data/Scripts/011_Battle/003_Battle/003_Battle_StartAndEnd.rb +++ b/Data/Scripts/011_Battle/003_Battle/003_Battle_StartAndEnd.rb @@ -417,6 +417,10 @@ class PokeBattle_Battle pbGainMoney if @decision!=4 # Hide remaining trainer @scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length>0 + if $game_switches[AUTOSAVE_WIN_SWITCH] + Kernel.tryAutosave() + end + ##### LOSE, DRAW ##### when 2, 5 PBDebug.log("") diff --git a/Data/Scripts/016_UI/015_UI_Options.rb b/Data/Scripts/016_UI/015_UI_Options.rb index 4eeb851db..3842ef7bf 100644 --- a/Data/Scripts/016_UI/015_UI_Options.rb +++ b/Data/Scripts/016_UI/015_UI_Options.rb @@ -339,6 +339,10 @@ class PokemonOption_Scene end end + def initialize + @autosave_menu=false + end + def initUIElements @sprites["title"] = Window_UnformattedTextPokemon.newWithSize( _INTL("Options"), 0, 0, Graphics.width, 64, @viewport) @@ -454,8 +458,14 @@ class PokemonOption_Scene if $game_switches options << EnumOption.new(_INTL("Autosave"),[_INTL("On"),_INTL("Off")], - proc { $game_switches[AUTOSAVE_ENABLED_SWITCH] ? 0 : 1}, - proc {|value| $game_switches[AUTOSAVE_ENABLED_SWITCH]=value==0 }, + proc { $game_switches[AUTOSAVE_ENABLED_SWITCH] ? 0 : 1 }, + proc { |value| + if !$game_switches[AUTOSAVE_ENABLED_SWITCH] && value == 0 + @autosave_menu = true + openAutosaveMenu() + end + $game_switches[AUTOSAVE_ENABLED_SWITCH] = value == 0 + }, "Automatically saves when healing at Pokémon centers" ) end @@ -543,6 +553,15 @@ class PokemonOption_Scene return options end + def openAutosaveMenu() + return if !@autosave_menu + pbFadeOutIn { + scene = AutosaveOptionsScene.new + screen = PokemonOptionScreen.new(scene) + screen.pbStartScreen + } + @autosave_menu = false + end def pbOptions diff --git a/Data/Scripts/050_AddOns/Autosave.rb b/Data/Scripts/050_AddOns/Autosave.rb index 412bdde94..7708f5bdb 100644 --- a/Data/Scripts/050_AddOns/Autosave.rb +++ b/Data/Scripts/050_AddOns/Autosave.rb @@ -5,6 +5,7 @@ AUTOSAVE_CATCH_SWITCH = 782 AUTOSAVE_WIN_SWITCH = 783 AUTOSAVE_STEPS_SWITCH = 784 AUTOSAVE_STEPS_VAR = 236 +DEFAULT_AUTOSAVE_STEPS = 500 def pbSetPokemonCenter $PokemonGlobal.pokecenterMapId = $game_map.map_id @@ -39,4 +40,91 @@ if AUTOSAVE_STEPS_SWITCH end end } -end \ No newline at end of file +end + + +class AutosaveOptionsScene < PokemonOption_Scene + def initialize + @changedColor = false + end + + def pbStartScene(inloadscreen = false) + super + @sprites["option"].nameBaseColor = Color.new(35, 130, 200) + @sprites["option"].nameShadowColor = Color.new(20, 75, 115) + @changedColor = true + for i in 0...@PokemonOptions.length + @sprites["option"][i] = (@PokemonOptions[i].get || 0) + end + @sprites["title"]=Window_UnformattedTextPokemon.newWithSize( + _INTL("Autosave settings"),0,0,Graphics.width,64,@viewport) + @sprites["textbox"].text=_INTL("Customize the autosave settings") + + + pbFadeInAndShow(@sprites) { pbUpdate } + end + + def pbFadeInAndShow(sprites, visiblesprites = nil) + return if !@changedColor + super + end + + def pbGetOptions(inloadscreen = false) + options = [ + EnumOption.new(_INTL("When healing"), [_INTL("On"), _INTL("Off")], + proc { $game_variables[AUTOSAVE_HEALING_VAR]}, + proc { |value| + $game_variables[AUTOSAVE_HEALING_VAR]=value + }, + "Autosave when healing at a Pokémon Center" + ), + EnumOption.new(_INTL("When catching Pokémon"), [_INTL("On"), _INTL("Off")], + proc { $game_switches[AUTOSAVE_CATCH_SWITCH] ? 0 : 1 }, + proc { |value| + $game_switches[AUTOSAVE_CATCH_SWITCH] = value == 0 + }, + "Autosave everytime a new Pokémon is caught" + ), + EnumOption.new(_INTL("After trainer battles"), [_INTL("On"), _INTL("Off")], + proc { $game_switches[AUTOSAVE_WIN_SWITCH] ? 0 : 1 }, + proc { |value| + $game_switches[AUTOSAVE_WIN_SWITCH] = value == 0 + }, + "Autosave after each trainer battle" + ), + EnumOption.new(_INTL("Every x steps"), [_INTL("On"), _INTL("Off")], + proc { $game_switches[AUTOSAVE_STEPS_SWITCH] ? 0 : 1 }, + proc { |value| + if !$game_switches[AUTOSAVE_STEPS_SWITCH] && value == 0 + @set_steps = true + selectAutosaveSteps() + end + $game_switches[AUTOSAVE_STEPS_SWITCH] = value == 0 + }, "Autosave after a defined amount of steps" + ) + ] + return options + end + + + def selectAutosaveSteps() + if pbGet(AUTOSAVE_STEPS_VAR) == 0 + pbSet(AUTOSAVE_STEPS_VAR,DEFAULT_AUTOSAVE_STEPS) + end + params=ChooseNumberParams.new + params.setRange(20,999999) + params.setInitialValue(pbGet(AUTOSAVE_STEPS_VAR)) + params.setCancelValue(0) + val = Kernel.pbMessageChooseNumber(_INTL("Autosave every how many steps?"),params) + if val < 200 + Kernel.pbMessage("Warning: Choosing a low number of steps may decrease performance.") + end + if val == 0 + val = 1 + end + pbSet(AUTOSAVE_STEPS_VAR,val) + end + +end + + diff --git a/Data/System.rxdata b/Data/System.rxdata index 0172c574b..ca6d89068 100644 Binary files a/Data/System.rxdata and b/Data/System.rxdata differ