#=====================================================================================
# * Pokemon Save Screen adapted to the BW2 interfaces.
#===================================================================================
class PokemonSaveScene
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
time=_ISPRINTF("{1:02d}:{2:02d}",hour,min)
datenow=_ISPRINTF("{1:s} {2:d}, {3:d}",
pbGetAbbrevMonthName($PokemonGlobal.pbGetTimeNow.mon),
$PokemonGlobal.pbGetTimeNow.day,
$PokemonGlobal.pbGetTimeNow.year)
@sprites["bg"]=IconSprite.new(0,0,@viewport)
@sprites["bg"].setBitmap("Graphics/Pictures/Save/background")
# Creating Party Icons.
if $Trainer
if $Trainer.party.length>0
for i in 0...$Trainer.party.length
@sprites["pokemon#{i}"]=PokemonIconSprite.new($Trainer.party,@viewport)
@sprites["pokemon#{i}"].x = 64+64*(i)
@sprites["pokemon#{i}"].y = 180
end
end
end
@sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
overlay = @sprites["overlay"].bitmap
overlay.clear
baseColor = Color.new(231,231,231)
shadowColor = Color.new(140,140,140)
pbSetSystemFont(@sprites["overlay"].bitmap)
textos=[]
textos.push([_ISPRINTF("{1:02d} : {2:02d}", Time.now.hour, Time.now.min),226,116,false,baseColor,shadowColor])
textos.push([_INTL("BADGES:"),48,260,false,baseColor,shadowColor])
textos.push([_INTL("{1}",$Trainer.numbadges),133,260,false,baseColor,shadowColor])
textos.push([_INTL("POKÉDEX:"),256,260,false,baseColor,shadowColor])
textos.push([_INTL("{1}",$game_map.name),48,143,false,baseColor,shadowColor]) #48,148
textos.push([_INTL("{1}", $Trainer.pokedexSeen),358,260,false,baseColor,shadowColor])
textos.push([_INTL("TIME:", $Trainer.pokedexSeen),48,292,false,baseColor,shadowColor])
textos.push([_INTL("{1}", time),174,292,false,baseColor,shadowColor])
textos.push([_INTL("{1}", datenow),48,111,false,baseColor,shadowColor])
if $game_system.save_count>0 && $game_system.last_saved!=nil
textos.push([_INTL("Last saved on {1}", $game_system.last_saved),82,344,false,baseColor,shadowColor])
end
pbDrawTextPositions(overlay,textos)
end
def pbGetTimeNow
return Time.now
end
def pbEndScreen
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end
def pbEmergencySave
oldscene=$scene
$scene=nil
Kernel.pbMessage(_INTL("The script is taking too long. The game will restart."))
return if !$Trainer
$game_system.save_count+=1
$game_system.last_saved=retTimeFormatOne
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
Kernel.pbMessage(_INTL("\\se[]The game was saved.\\se[save]\\wtnp[30]"))
else
Kernel.pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
end
$scene=oldscene
end
def pbSave(safesave=false)
$Trainer.metaID=$PokemonGlobal.playerID
$game_system.save_count+=1
$game_system.last_saved=retTimeFormatOne
$PokemonGlobal.safesave=safesave
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
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)
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
class PokemonSave
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
default_message_positon=$game_system.message_position
$game_system.message_position=0 # Text is at the top.
ret=false
@scene.pbStartScreen
if Kernel.pbConfirmMessage(_INTL("Would you like to save the game?"))
if safeExists?(RTP.getSaveFileName("Game.rxdata"))
confirm=""
if $PokemonTemp.begunNewGame
Kernel.pbMessage(_INTL("WARNING!"))
Kernel.pbMessage(_INTL("There is a different game file that is already saved."))
Kernel.pbMessage(_INTL("If you save now, the other file's adventure, including items and Pokémon, will be entirely lost."))
if !Kernel.pbConfirmMessageSerious(
_INTL("Are you sure you want to save now and overwrite the other save file?"))
@scene.pbEndScreen
$game_system.message_position=default_message_positon
return false
end
else
if !Kernel.pbConfirmMessage(
_INTL("There is already a saved file. Is it OK to overwrite it?"))
@scene.pbEndScreen
$game_system.message_position=default_message_positon
return false
end
end
end
$PokemonTemp.begunNewGame=false
if pbSave
Kernel.pbMessage(_INTL("\\se[]{1} saved the game.\\se[save]\\wtnp[30]",$Trainer.name))
ret=true
else
Kernel.pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
ret=false
end
end
@scene.pbEndScreen
$game_system.message_position=default_message_positon
return ret
end
end
# Adding "last Saved" variable to the Game_System class.
class Game_System
attr_accessor :last_saved
end