Advertisement
xCamero

Untitled

Jul 18th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. #=====================================================================================
  2. # * Pokemon Save Screen adapted to the BW2 interfaces.
  3. #===================================================================================
  4. class PokemonSaveScene
  5. def pbStartScreen
  6. @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
  7. @viewport.z=99999
  8. @sprites={}
  9. totalsec = Graphics.frame_count / Graphics.frame_rate
  10. hour = totalsec / 60 / 60
  11. min = totalsec / 60 % 60
  12. mapname=$game_map.name
  13. time=_ISPRINTF("{1:02d}:{2:02d}",hour,min)
  14. datenow=_ISPRINTF("{1:s} {2:d}, {3:d}",
  15. pbGetAbbrevMonthName($PokemonGlobal.pbGetTimeNow.mon),
  16. $PokemonGlobal.pbGetTimeNow.day,
  17. $PokemonGlobal.pbGetTimeNow.year)
  18. @sprites["bg"]=IconSprite.new(0,0,@viewport)
  19. @sprites["bg"].setBitmap("Graphics/Pictures/Save/background")
  20. # Creating Party Icons.
  21. if $Trainer
  22. if $Trainer.party.length>0
  23. for i in 0...$Trainer.party.length
  24. @sprites["pokemon#{i}"]=PokemonIconSprite.new($Trainer.party[i],@viewport)
  25. @sprites["pokemon#{i}"].x = 64+64*(i)
  26. @sprites["pokemon#{i}"].y = 180
  27. end
  28. end
  29. end
  30. @sprites["overlay"]=BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
  31. overlay = @sprites["overlay"].bitmap
  32. overlay.clear
  33. baseColor = Color.new(231,231,231)
  34. shadowColor = Color.new(140,140,140)
  35. pbSetSystemFont(@sprites["overlay"].bitmap)
  36. textos=[]
  37. textos.push([_ISPRINTF("{1:02d} : {2:02d}", Time.now.hour, Time.now.min),226,116,false,baseColor,shadowColor])
  38. textos.push([_INTL("BADGES:"),48,260,false,baseColor,shadowColor])
  39. textos.push([_INTL("{1}",$Trainer.numbadges),133,260,false,baseColor,shadowColor])
  40. textos.push([_INTL("POKÉDEX:"),256,260,false,baseColor,shadowColor])
  41. textos.push([_INTL("{1}",$game_map.name),48,143,false,baseColor,shadowColor]) #48,148
  42. textos.push([_INTL("{1}", $Trainer.pokedexSeen),358,260,false,baseColor,shadowColor])
  43. textos.push([_INTL("TIME:", $Trainer.pokedexSeen),48,292,false,baseColor,shadowColor])
  44. textos.push([_INTL("{1}", time),174,292,false,baseColor,shadowColor])
  45. textos.push([_INTL("{1}", datenow),48,111,false,baseColor,shadowColor])
  46. #if $game_system.save_count>0 && $game_system.last_saved!=nil
  47. # textos.push([_INTL("Last saved on {1}", $game_system.last_saved),82,344,false,baseColor,shadowColor])
  48. # end
  49. pbDrawTextPositions(overlay,textos)
  50. end
  51.  
  52. def pbGetTimeNow
  53. return Time.now
  54. end
  55.  
  56. def pbEndScreen
  57. pbDisposeSpriteHash(@sprites)
  58. @viewport.dispose
  59. end
  60. end
  61.  
  62.  
  63. def pbEmergencySave
  64. oldscene=$scene
  65. $scene=nil
  66. Kernel.pbMessage(_INTL("The script is taking too long. The game will restart."))
  67. return if !$Trainer
  68. $game_system.save_count+=1
  69. $game_system.last_saved=retTimeFormatOne
  70. if safeExists?(RTP.getSaveFileName("Game.rxdata"))
  71. File.open(RTP.getSaveFileName("Game.rxdata"), 'rb') {|r|
  72. File.open(RTP.getSaveFileName("Game.rxdata.bak"), 'wb') {|w|
  73. while s = r.read(4096)
  74. w.write s
  75. end
  76. }
  77. }
  78. end
  79. if pbSave
  80. Kernel.pbMessage(_INTL("\\se[]The game was saved.\\se[save]\\wtnp[30]"))
  81. else
  82. Kernel.pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
  83. end
  84. $scene=oldscene
  85. end
  86.  
  87. def pbSave(safesave=false)
  88. $Trainer.metaID=$PokemonGlobal.playerID
  89. $game_system.save_count+=1
  90. #$game_system.last_saved=retTimeFormatOne
  91. $PokemonGlobal.safesave=safesave
  92. begin
  93. File.open(RTP.getSaveFileName("Game.rxdata"),"wb"){|f|
  94. Marshal.dump($Trainer,f)
  95. Marshal.dump(Graphics.frame_count,f)
  96. if $data_system.respond_to?("magic_number")
  97. $game_system.magic_number = $data_system.magic_number
  98. else
  99. $game_system.magic_number = $data_system.version_id
  100. end
  101. Marshal.dump($game_system,f)
  102. Marshal.dump($PokemonSystem,f)
  103. Marshal.dump($game_map.map_id,f)
  104. Marshal.dump($game_switches,f)
  105. Marshal.dump($game_variables,f)
  106. Marshal.dump($game_self_switches,f)
  107. Marshal.dump($game_screen,f)
  108. Marshal.dump($MapFactory,f)
  109. Marshal.dump($game_player,f)
  110. Marshal.dump($PokemonGlobal,f)
  111. Marshal.dump($PokemonMap,f)
  112. Marshal.dump($PokemonBag,f)
  113. Marshal.dump($PokemonStorage,f)
  114. }
  115. Graphics.frame_reset
  116. rescue
  117. return false
  118. end
  119. return true
  120. end
  121.  
  122. class PokemonSave
  123. def initialize(scene)
  124. @scene=scene
  125. end
  126.  
  127. def pbDisplay(text,brief=false)
  128. @scene.pbDisplay(text,brief)
  129. end
  130.  
  131. def pbDisplayPaused(text)
  132. @scene.pbDisplayPaused(text)
  133. end
  134.  
  135. def pbConfirm(text)
  136. return @scene.pbConfirm(text)
  137. end
  138.  
  139. def pbSaveScreen
  140. default_message_positon=$game_system.message_position
  141. $game_system.message_position=0 # Text is at the top.
  142. ret=false
  143. @scene.pbStartScreen
  144. if Kernel.pbConfirmMessage(_INTL("Would you like to save the game?"))
  145. if safeExists?(RTP.getSaveFileName("Game.rxdata"))
  146. confirm=""
  147. if $PokemonTemp.begunNewGame
  148. Kernel.pbMessage(_INTL("WARNING!"))
  149. Kernel.pbMessage(_INTL("There is a different game file that is already saved."))
  150. Kernel.pbMessage(_INTL("If you save now, the other file's adventure, including items and Pokémon, will be entirely lost."))
  151. if !Kernel.pbConfirmMessageSerious(
  152. _INTL("Are you sure you want to save now and overwrite the other save file?"))
  153. @scene.pbEndScreen
  154. $game_system.message_position=default_message_positon
  155. return false
  156. end
  157. else
  158. if !Kernel.pbConfirmMessage(
  159. _INTL("There is already a saved file. Is it OK to overwrite it?"))
  160. @scene.pbEndScreen
  161. $game_system.message_position=default_message_positon
  162. return false
  163. end
  164. end
  165. end
  166. $PokemonTemp.begunNewGame=false
  167. if pbSave
  168. Kernel.pbMessage(_INTL("\\se[]{1} saved the game.\\se[save]\\wtnp[30]",$Trainer.name))
  169. ret=true
  170. else
  171. Kernel.pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
  172. ret=false
  173. end
  174. end
  175. $game_system.message_position=2
  176. @scene.pbEndScreen
  177. #$game_system.message_position=default_message_positon
  178. return ret
  179. end
  180. end
  181.  
  182. # Adding "last Saved" variable to the Game_System class.
  183. class Game_System
  184. attr_accessor :last_saved
  185. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement