IceDragon200

FRV-SaveMenu

Jun 4th, 2011
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.61 KB | None | 0 0
  1. # // Last Modified :10/29/2011
  2. #==============================================================================#
  3. # Window_SaveFile
  4. #==============================================================================#
  5. class Window_SaveFile < Window_Base
  6.  
  7.   #--------------------------------------------------------------------------#
  8.   # * overwrite method :initialize
  9.   #--------------------------------------------------------------------------#
  10.   def initialize(file_index, filename)
  11.     super( 16, 32 + file_index % 4 * (96 + 32), Graphics.width-32, 96+32 )
  12.     @file_index = file_index
  13.     @filename = filename
  14.     load_gamedata()
  15.     refresh()
  16.     @selected = false
  17.   end
  18.    
  19.   #--------------------------------------------------------------------------#
  20.   # * overwrite method :refresh
  21.   #--------------------------------------------------------------------------#  
  22.   def refresh
  23.     self.contents.clear()
  24.     self.contents.font.color = normal_color
  25.     name = Vocab::File + " #{@file_index + 1}"
  26.     @name_width = contents.text_size(name).width
  27.     self.contents.font.color = normal_color
  28.     if @file_exist
  29.       draw_party_faces( 32, 24 )
  30.       #draw_party_characters(152, 58)
  31.       draw_location( 96, 0 )
  32.       draw_playtime(0, 0, contents.width - 4, 2)
  33.     end
  34.     self.contents.font.color = system_color
  35.     self.contents.draw_text( 4, 0, 200, WLH, name )
  36.   end
  37.  
  38.   #--------------------------------------------------------------------------#
  39.   # * overwrite method :draw_face
  40.   #--------------------------------------------------------------------------#  
  41.   def draw_face( face_name, face_index, x, y, wsize = 96, hsize = 96 )
  42.     bitmap = Cache.face(face_name)
  43.     rect = Rect.new( 0, 0, 0, 0 )
  44.     rect.x = face_index % 4 * 96 + (96 - wsize) / 2
  45.     rect.y = face_index / 4 * 96 + (96 - hsize) / 2
  46.     rect.width = wsize
  47.     rect.height = hsize
  48.     self.contents.blt(x, y, bitmap, rect)
  49.     bitmap.dispose
  50.   end
  51.  
  52.   #--------------------------------------------------------------------------#
  53.   # * overwrite method :draw_party_faces
  54.   #--------------------------------------------------------------------------#  
  55.   def draw_party_faces( x, y )
  56.     for i in 0...@characters.size
  57.       draw_face( @characters[i][2], @characters[i][3], x+(i*112), y, 96, 72 )
  58.     end  
  59.   end
  60.  
  61.   #--------------------------------------------------------------------------#
  62.   # * overwrite method :draw_location
  63.   #--------------------------------------------------------------------------#  
  64.   def draw_location( x, y )
  65.     self.contents.font.size = Font.default_size - 2
  66.     self.contents.font.color = system_color
  67.     rect = Rect.new( x+64, y, self.contents.width-x, WLH )
  68.     self.contents.draw_text( rect, @game_system.last_location_name )
  69.     self.contents.font.size = Font.default_size - 4
  70.     self.contents.font.color = normal_color
  71.     rect = Rect.new( x, y, self.contents.width-x, WLH )
  72.     self.contents.draw_text( rect, Vocab.location )
  73.     self.contents.font.size  = Font.default_size
  74.   end
  75.  
  76.   #--------------------------------------------------------------------------#
  77.   # * overwrite method :draw_playtime
  78.   #--------------------------------------------------------------------------#
  79.   def draw_playtime( x, y, width, align )
  80.     hour = @total_sec / 60 / 60
  81.     min = @total_sec / 60 % 60
  82.     sec = @total_sec % 60
  83.     time_string = sprintf( "%02d:%02d:%02d", hour, min, sec )
  84.     self.contents.font.size  = 18
  85.     self.contents.font.color = system_color
  86.     self.contents.draw_text( x, y, width, WLH, time_string, 2 )
  87.     self.contents.font.size  = Font.default_size
  88.   end
  89.  
  90. end
  91.  
  92. #==============================================================================#
  93. # Window_FileHelp
  94. #==============================================================================#
  95. class Window_FileHelp < IRS::Sprite_Help ; end
  96.  
  97. #==============================================================================#
  98. # Scene_File
  99. #==============================================================================#
  100. class Scene_File < Scene_Base
  101.  
  102.   #--------------------------------------------------------------------------#
  103.   # * overwrite method :start
  104.   #--------------------------------------------------------------------------#
  105.   def start()
  106.     super()
  107.     create_menu_background()
  108.     @help_window = Window_FileHelp.new( 0, 0, Graphics.width, 32 )
  109.     create_savefile_windows()
  110.     if @saving
  111.       @index = $game_temp.last_file_index
  112.       @help_window.set_text(Vocab::SaveMessage)
  113.     else
  114.       @index = self.latest_file_index
  115.       @help_window.set_text(Vocab::LoadMessage)
  116.     end
  117.     @savefile_windows[@index].selected = true
  118.     # // ----------------------------------------------------------------- // #
  119.     @menuback_sprite.bitmap = Cache.system( "Menu_background" )
  120.     @menuback_sprite.opacity= 255
  121.   end
  122.  
  123.   #--------------------------------------------------------------------------#
  124.   # * overwrite method :create_savefile_windows
  125.   #--------------------------------------------------------------------------#
  126.   def create_savefile_windows
  127.     @savefile_windows = []
  128.     @item_max = 3
  129.     for i in 0...@item_max
  130.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
  131.     end
  132.   end
  133.  
  134.   #--------------------------------------------------------------------------#
  135.   # * overwrite method :write_save_data
  136.   #--------------------------------------------------------------------------#
  137.   def write_save_data(file)
  138.     characters = []
  139.     for actor in $game_party.members
  140.       characters.push([actor.character_name, actor.character_index,
  141.                        actor.face_name, actor.face_index])
  142.     end
  143.     $game_system.save_count += 1
  144.     $game_system.version_id = $data_system.version_id
  145.     @last_bgm = RPG::BGM::last
  146.     @last_bgs = RPG::BGS::last
  147.     Marshal.dump(characters,           file)
  148.     Marshal.dump(Graphics.frame_count, file)
  149.     Marshal.dump(@last_bgm,            file)
  150.     Marshal.dump(@last_bgs,            file)
  151.     Marshal.dump($game_system,         file)
  152.     Marshal.dump($game_message,        file)
  153.     Marshal.dump($game_switches,       file)
  154.     Marshal.dump($game_variables,      file)
  155.     Marshal.dump($game_self_switches,  file)
  156.     Marshal.dump($game_actors,         file)
  157.     Marshal.dump($game_party,          file)
  158.     Marshal.dump($game_troop,          file)
  159.     Marshal.dump($game_map,            file)
  160.     Marshal.dump($game_player,         file)
  161.   end
  162.  
  163. end  
  164. #=*==========================================================================*=#
  165. # ** END OF FILE
  166. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment