mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
156 lines
4.5 KiB
Ruby
156 lines
4.5 KiB
Ruby
def pbSave(safesave=false)
|
|
$Trainer.metaID=$PokemonGlobal.playerID
|
|
begin
|
|
File.open(RTP.getSaveFileName("Game.rxdata"),"wb") { |f|
|
|
Marshal.dump($Trainer,f)
|
|
Marshal.dump(Graphics.frame_count,f)
|
|
if $data_system.respond_to?("magic_number")
|
|
$game_system.magic_number = $data_system.magic_number
|
|
else
|
|
$game_system.magic_number = $data_system.version_id
|
|
end
|
|
$game_system.save_count+=1
|
|
Marshal.dump($game_system,f)
|
|
Marshal.dump($PokemonSystem,f)
|
|
Marshal.dump($game_map.map_id,f)
|
|
Marshal.dump($game_switches,f)
|
|
Marshal.dump($game_variables,f)
|
|
Marshal.dump($game_self_switches,f)
|
|
Marshal.dump($game_screen,f)
|
|
Marshal.dump($MapFactory,f)
|
|
Marshal.dump($game_player,f)
|
|
$PokemonGlobal.safesave=safesave
|
|
Marshal.dump($PokemonGlobal,f)
|
|
Marshal.dump($PokemonMap,f)
|
|
Marshal.dump($PokemonBag,f)
|
|
Marshal.dump($PokemonStorage,f)
|
|
}
|
|
Graphics.frame_reset
|
|
rescue
|
|
return false
|
|
end
|
|
return true
|
|
end
|
|
|
|
def pbEmergencySave
|
|
oldscene=$scene
|
|
$scene=nil
|
|
pbMessage(_INTL("The script is taking too long. The game will restart."))
|
|
return if !$Trainer
|
|
if safeExists?(RTP.getSaveFileName("Game.rxdata"))
|
|
File.open(RTP.getSaveFileName("Game.rxdata"), 'rb') { |r|
|
|
File.open(RTP.getSaveFileName("Game.rxdata.bak"), 'wb') { |w|
|
|
while s = r.read(4096)
|
|
w.write s
|
|
end
|
|
}
|
|
}
|
|
end
|
|
if pbSave
|
|
pbMessage(_INTL("\\se[]The game was saved.\\me[GUI save game] The previous save file has been backed up.\\wtnp[30]"))
|
|
else
|
|
pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
|
|
end
|
|
$scene=oldscene
|
|
end
|
|
|
|
|
|
|
|
class PokemonSave_Scene
|
|
def pbStartScreen
|
|
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
|
@viewport.z=99999
|
|
@sprites={}
|
|
totalsec = Graphics.frame_count / Graphics.frame_rate
|
|
hour = totalsec / 60 / 60
|
|
min = totalsec / 60 % 60
|
|
mapname=$game_map.name
|
|
textColor = ["0070F8,78B8E8","E82010,F8A8B8","0070F8,78B8E8"][$Trainer.gender]
|
|
locationColor = "209808,90F090" # green
|
|
loctext=_INTL("<ac><c3={1}>{2}</c3></ac>",locationColor,mapname)
|
|
loctext+=_INTL("Player<r><c3={1}>{2}</c3><br>",textColor,$Trainer.name)
|
|
if hour>0
|
|
loctext+=_INTL("Time<r><c3={1}>{2}h {3}m</c3><br>",textColor,hour,min)
|
|
else
|
|
loctext+=_INTL("Time<r><c3={1}>{2}m</c3><br>",textColor,min)
|
|
end
|
|
loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,$Trainer.numbadges)
|
|
if $Trainer.pokedex
|
|
loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3>",textColor,$Trainer.pokedexOwned,$Trainer.pokedexSeen)
|
|
end
|
|
@sprites["locwindow"]=Window_AdvancedTextPokemon.new(loctext)
|
|
@sprites["locwindow"].viewport=@viewport
|
|
@sprites["locwindow"].x=0
|
|
@sprites["locwindow"].y=0
|
|
@sprites["locwindow"].width=228 if @sprites["locwindow"].width<228
|
|
@sprites["locwindow"].visible=true
|
|
end
|
|
|
|
def pbEndScreen
|
|
pbDisposeSpriteHash(@sprites)
|
|
@viewport.dispose
|
|
end
|
|
end
|
|
|
|
|
|
|
|
class PokemonSaveScreen
|
|
def initialize(scene)
|
|
@scene=scene
|
|
end
|
|
|
|
def pbDisplay(text,brief=false)
|
|
@scene.pbDisplay(text,brief)
|
|
end
|
|
|
|
def pbDisplayPaused(text)
|
|
@scene.pbDisplayPaused(text)
|
|
end
|
|
|
|
def pbConfirm(text)
|
|
return @scene.pbConfirm(text)
|
|
end
|
|
|
|
def pbSaveScreen
|
|
ret=false
|
|
@scene.pbStartScreen
|
|
if pbConfirmMessage(_INTL("Would you like to save the game?"))
|
|
if safeExists?(RTP.getSaveFileName("Game.rxdata"))
|
|
confirm=""
|
|
if $PokemonTemp.begunNewGame
|
|
pbMessage(_INTL("WARNING!"))
|
|
pbMessage(_INTL("There is a different game file that is already saved."))
|
|
pbMessage(_INTL("If you save now, the other file's adventure, including items and Pokémon, will be entirely lost."))
|
|
if !pbConfirmMessageSerious(
|
|
_INTL("Are you sure you want to save now and overwrite the other save file?"))
|
|
pbSEPlay("GUI save choice")
|
|
@scene.pbEndScreen
|
|
return false
|
|
end
|
|
end
|
|
end
|
|
$PokemonTemp.begunNewGame=false
|
|
pbSEPlay("GUI save choice")
|
|
if pbSave
|
|
pbMessage(_INTL("\\se[]{1} saved the game.\\me[GUI save game]\\wtnp[30]",$Trainer.name))
|
|
ret=true
|
|
else
|
|
pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
|
|
ret=false
|
|
end
|
|
else
|
|
pbSEPlay("GUI save choice")
|
|
end
|
|
@scene.pbEndScreen
|
|
return ret
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def pbSaveScreen
|
|
scene = PokemonSave_Scene.new
|
|
screen = PokemonSaveScreen.new(scene)
|
|
ret = screen.pbSaveScreen
|
|
return ret
|
|
end |