Project1
标题: 请教该怎么在存档信息加上存档的地图名称 [打印本页]
作者: timmyyayaya 时间: 2012-1-27 19:03
标题: 请教该怎么在存档信息加上存档的地图名称
本帖最后由 timmyyayaya 于 2012-1-27 20:48 编辑
在下的选单脚本有修改过,
请问哪位大大可以帮在下修一下,
让存盘的信息多一个存盘时的地图名称吗?
X Y可以先随意填,在下再来调整就好,感谢。- #==============================================================================
- # ■ Window_SaveFile
- #------------------------------------------------------------------------------
- #==============================================================================
- class Window_SaveFile < Window_Selectable
-
-
- attr_reader :file_exist
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, offset = 70)
- super(x, y, width, height, offset)
- #super(260, 110, 360, 300)
- # cursorOffset(70) # 游標大小70
- @item_max = $SAVE_FILE_MAX_NUM
- @column_max = 1 #只有兩列
- self.index = 0
- #確認檔案是否存在
- @file_exist = []
- for i in 0..($SAVE_FILE_MAX_NUM - 1)
- filename = "Save/Save#{i + 1}.rxdata"
- file_exist_temp = FileTest.exist?(filename)
- if file_exist_temp
- @file_exist[i] = 1
- else
- @file_exist[i] = 0
- end
- end
- @filename = []
- @time_stamp = []
- @characters = []
- @frame_count = []
- @game_system = []
- @game_switches = []
- @game_variables = []
- @total_sec = []
- #打開檔案讀資料
- for i in 0..($SAVE_FILE_MAX_NUM - 1)
- @time_stamp[i] = Time.at(0)
- if @file_exist[i] == 1
- filename = "Save/Save#{i + 1}.rxdata"
- file = File.open(filename, "r")
- @filename[i] = filename
- @time_stamp[i] = file.mtime
- @characters[i] = Marshal.load(file)
- @frame_count[i] = Marshal.load(file)
- @game_system[i] = Marshal.load(file)
- @game_switches[i] = Marshal.load(file)
- @game_variables[i] = Marshal.load(file)
- @total_sec[i] = @frame_count[i] / Graphics.frame_rate
- file.close
- end
- end
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 更新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- # self.contents = Bitmap.new(width - 32, $SAVE_FILE_MAX_NUM * 72)
- self.contents = Bitmap.new(width - 32, ($SAVE_FILE_MAX_NUM-1) * 75-32)
- for i in 0..($SAVE_FILE_MAX_NUM - 1)
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 描繪項目
- # index : 項目編號
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 0
- y = index * 70#75
- rect = Rect.new(x, y, 200, 36)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.font.color = system_color
- #描繪文件編號
- if index + 1 < 11
- name = "DATA 0#{index}"
- self.contents.draw_text(x, y, 80, 32, name)
- else
- name = "DATA #{index}"
- self.contents.draw_text(x, y, 80, 32, name)
- end
- if @file_exist[index] == 1
- # 描繪角色
- for i in 0...@characters[index].size
- first_one_pos = 160
- stand_distance = 32
- height_of_ground = 22
- bitmap = RPG::Cache.character(@characters[index][i][0], @characters[index][i][1])
- cw = bitmap.rect.width / 4
- ch = bitmap.rect.height / 4
- src_rect = Rect.new(0, 0, cw, ch)
- cx = first_one_pos - @characters[index].size * stand_distance + i * 32 - cw / 2
- self.contents.blt(cx, y+height_of_ground, bitmap, src_rect)
- #cw = bitmap.rect.width / 4
- #h = bitmap.rect.height / 4
- #rect = Rect.new(x + 60 + (cw * index), y + 36, cw, ch)
- #cx = 300 - @characters[index].size * 32 + index * 64 - cw / 2
- #self.contents.blt(cx, 68 - ch, bitmap, rect)
- end
- # 描繪遊戲時間
- hour = @total_sec[index] / 60 / 60
- min = @total_sec[index] / 60 % 60
- time_string = sprintf("%02d:%02d", hour,min)
-
- self.contents.draw_text(x+150, y + 22, 160, 32, time_string, 2)
- # 描繪時間標記
- time_string = @time_stamp[index].strftime("%Y/%m/%d %H:%M")
- self.contents.draw_text(x+150, y + 44, 160, 32, time_string, 2)
- end
- end
- def save_window_update
- #update_cursor_rect
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切換到選單畫面
- $scene = Scene_Menu.new(5)
- return
- end
- # 按下C鍵的場合下
- #if Input.trigger?(Input::C)
- # 命令視窗游標位置分歧
- # case self.index
- # when 0 # 返回標題畫面
- # command_to_title
- # when 1 # 退出
- # command_shutdown
- # end
- # return
- #end
- end
-
- def make_filename(file_index)
- return "Save/Save#{file_index + 1}.rxdata"
- end
-
-
- def update
- if Input.press?(Input::UP) and self.index == 0
- return
- end
- if Input.press?(Input::DOWN) and self.index == $SAVE_FILE_MAX_NUM-1
- return
- end
- super
- end
-
-
- end
- class Window_SaveFile < Window_Selectable
- def page_row_max
- return 4
- end
- end
复制代码