mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Autosave
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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("")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user