Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Base
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● Draw Help Layout
- #--------------------------------------------------------------------------
- def draw_face_save(name,x,y,type)
- if type == 0
- image_name = name + "_0"
- elsif type == 1
- image_name = name + "_1"
- else
- image_name = name + "_2"
- end
- image = Cache.face(image_name)
- cw = image.width
- ch = image.height
- src_rect = Rect.new(0, 0, cw, ch)
- self.contents.blt(x , y , image, src_rect)
- image.dispose
- end
- end
- #==============================================================================
- # ** Window_SaveFile
- #==============================================================================
- class Window_SaveFile < Window_Base
- attr_reader :filename
- attr_reader :file_exist
- attr_reader :time_stamp
- attr_reader :selected
- attr_reader :file_index
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(file_index, filename)
- super(0, 56 + file_index % 4 * 90, 544, 90)
- @file_index = file_index
- @filename = filename
- load_gamedata
- refresh
- @selected = false
- end
- #--------------------------------------------------------------------------
- # * Load Partial Game Data
- #--------------------------------------------------------------------------
- def load_gamedata
- @time_stamp = Time.at(0)
- @file_exist = FileTest.exist?(@filename)
- if @file_exist
- file = File.open(@filename, "r")
- @time_stamp = file.mtime
- begin
- @characters = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_message = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- rescue
- @file_exist = false
- ensure
- file.close
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = normal_color
- name = Vocab::File + " #{@file_index + 1}"
- self.contents.draw_text(4, 0, 200, WLH, name)
- @name_width = contents.text_size(name).width
- if @file_exist
- draw_party_characters(152, 58)
- draw_playtime(0, 34, contents.width - 4, 2)
- draw_face_save(40,0)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Face
- #--------------------------------------------------------------------------
- def draw_face_save(x,y)
- face_name = @characters[0][3]
- face_index = @characters[0][4]
- draw_face(face_name, face_index , x, y, 96)
- end
- #--------------------------------------------------------------------------
- # * Draw Party Characters
- #--------------------------------------------------------------------------
- def draw_party_characters(x, y)
- for i in [email protected]
- name = @characters[i][0]
- index = @characters[i][1]
- draw_character(name, index, x + i * 48, y)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Play Time
- #--------------------------------------------------------------------------
- def draw_playtime(x, y, width, align)
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width, WLH, time_string, 2)
- end
- #--------------------------------------------------------------------------
- # * Set Selected
- #--------------------------------------------------------------------------
- def selected=(selected)
- @selected = selected
- update_cursor
- end
- #--------------------------------------------------------------------------
- # * Update cursor
- #--------------------------------------------------------------------------
- def update_cursor
- if @selected
- self.cursor_rect.set(0, 0, @name_width + 8, WLH)
- else
- self.cursor_rect.empty
- end
- end
- end
- #==============================================================================
- # ** Scene_File
- #==============================================================================
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------
- # * Write_Save_Data
- #--------------------------------------------------------------------------
- def write_save_data(file)
- characters = []
- for actor in $game_party.members
- characters.push([actor.character_name, actor.character_index,
- actor.face_name, actor.face_index])
- end
- $game_system.save_count += 1
- $game_system.version_id = $data_system.version_id
- map_name = $game_map.name
- @last_bgm = RPG::BGM::last
- @last_bgs = RPG::BGS::last
- Marshal.dump(characters, file)
- Marshal.dump(map_name, file)
- Marshal.dump(Graphics.frame_count, file)
- Marshal.dump(@last_bgm, file)
- Marshal.dump(@last_bgs, file)
- Marshal.dump($game_system, file)
- Marshal.dump($game_message, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- end
- #--------------------------------------------------------------------------
- # * read_save_data
- #--------------------------------------------------------------------------
- def read_save_data(file)
- characters = Marshal.load(file)
- map_name = Marshal.load(file)
- Graphics.frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- $game_system = Marshal.load(file)
- $game_message = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file)
- $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file)
- $game_player = Marshal.load(file)
- if $game_system.version_id != $data_system.version_id
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment