赞 | 153 |
VIP | 10 |
好人卡 | 39 |
积分 | 93 |
经验 | 146191 |
最后登录 | 2024-5-6 |
在线时间 | 2504 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9280
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 帖子
- 15389
|
参考一下吧···不过存档的时候也要存进去才行,否则是不显示的- #==============================================================================
- # ■ Window_SaveFile
- #------------------------------------------------------------------------------
- # 显示存档以及读档画面、保存文件的窗口。
- #==============================================================================
- class Window_SaveFile < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :filename # 文件名
- attr_reader :selected # 选择状态
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # file_index : 存档文件的索引 (0~3)
- # filename : 文件名
- #--------------------------------------------------------------------------
- def initialize(file_index, filename)
- super(0, 64 + file_index % 4 * 104, 640, 104)
- self.contents = Bitmap.new(width - 32, height - 32)
- @file_index = file_index
- @filename = "Save/Save#{@file_index + 1}.rxdata"
- @time_stamp = Time.at(0)
- @file_exist = FileTest.exist?(@filename)
- if @file_exist
- file = File.open(@filename, "r")
- @time_stamp = file.mtime
- @characters = Marshal.load(file)
- @scenename = Marshal.load(file)
- @frame_count = Marshal.load(file)
- @game_system = Marshal.load(file)
- @game_switches = Marshal.load(file)
- @game_variables = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- file.close
- end
- refresh
- @selected = false
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- # 描绘文件编号
- self.contents.font.size=15
- self.contents.font.color = normal_color
- name = "记录 #{@file_index + 1}"
- self.contents.draw_text(4, 0, 600, 32, name)
- @name_width = contents.text_size(name).width
- self.contents.font.size=12
- # 存档文件存在的情况下
- if @file_exist
- actor_level = []
- # 描绘角色
- y=0
- for i in [email protected]
- bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
- bitmap = Bitmap.new("Graphics/Heads/Actors/#{@characters[i][0]}.png")
- src_rect = Rect.new(0, 0, 32, 32)
- x = 160+i * 32
- if x>=608
- x-=448
- y=32*(i-i%14)/14
- end
- self.contents.blt(x, 13+y, bitmap, src_rect)
- actor_level[i] = @characters[i][2]
- end
- al = 0
- al=actor_level.average(false)
- self.contents.draw_text(0, 3, 115, 15, "队伍人数:", 2)
- self.contents.draw_text(0, 3, 151, 15, @characters.size.to_s, 2)
- self.contents.draw_text(0, 18, 115, 15, "平均等级:", 2)
- self.contents.draw_text(0, 18, 151, 15, al.to_s, 2)
- self.contents.draw_text(0, 0, 220, 15, "所在位置:", 2)
- self.contents.draw_text(0, 0, 290, 15, @scenename.to_s, 2)
- # 描绘游戏时间
- 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(0, 32, 60, 15, "游戏时长:", 2)
- self.contents.draw_text(0, 32, 103, 15, time_string, 2)
- # 描绘时间标记
- self.contents.font.color = normal_color
- time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
- self.contents.draw_text(0, 44, 60, 15, "保存时间:", 2)
- self.contents.draw_text(0, 44, 151, 15, time_string, 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置选择状态
- # selected : 新的选择状态 (true=选择 false=不选择)
- #--------------------------------------------------------------------------
- def selected=(selected)
- @selected = selected
- update_cursor_rect
- end
- #--------------------------------------------------------------------------
- # ● 刷新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- if @selected
- self.cursor_rect.set(0, 0, @name_width + 8, 32)
- else
- self.cursor_rect.empty
- end
- end
- end
复制代码 |
|