赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1342 |
最后登录 | 2019-9-24 |
在线时间 | 17 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 17 小时
- 注册时间
- 2008-9-18
- 帖子
- 14
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 第二疯子 于 2009-8-14 22:10 编辑
为了美化遂将window窗弄成背景透明,但在Title里读取游戏的时候十分难看。
能不能将“存档/读取”框单独使用一个window窗呢?
或者还原成系统默认那种读取时淡化背景。
再或者有没有办法用事件调取读取框?貌似只能打开存档界面。。。
...
截图存档脚本:- #==============================================================================
- # ■ Window_SaveFile
- #==============================================================================
- class Window_SaveFile < Window_Base
- #--------------------------------------------------------------------------
- # ◎ 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :filename # 文件名
- attr_reader :file_exist # 文件存在标志
- #--------------------------------------------------------------------------
- # ◎ 初始化对象
- # file_index : 存档文件索引 (0~3)
- # filename : 文件名
- #--------------------------------------------------------------------------
- def initialize(file_index, filename)
- super(176, 59, 304, 298)
- @file_index = file_index
- @filename = filename
- make_dir(SAVE_DIR) if SAVE_DIR != nil
- load_gamedata
- refresh(@file_index)
- end
- #--------------------------------------------------------------------------
- # ◎ 读取部分游戏数据
- #--------------------------------------------------------------------------
- def load_gamedata
- @file_exist = FileTest.exist?(SAVE_DIR + @filename)
- if @file_exist
- file = File.open(SAVE_DIR + @filename, "r")
- 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)
- @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)
- # 读取截图
- @file_bitmap = Marshal.load(file)
- @total_sec = @frame_count / Graphics.frame_rate
- rescue
- @file_exist = false
- ensure
- file.close
- end
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 刷新
- # index : 索引
- #--------------------------------------------------------------------------
- def refresh(index)
- file_index = index
- self.contents.clear
- self.contents.font.color = normal_color
- if @file_exist
- # 描绘底部阴影
- self.contents.fill_rect(0, 0, 272,210, Color.new(0,0,64))
- # 描绘截图
- draw_snap_bitmap(0, 0)
- draw_map_name(0, 180)
- draw_party_characters(108, 232)
- draw_gold(0, 240)
- draw_playtime(0, 240, contents.width, 2)
- else
- self.contents.draw_text(0, 288-56, contents.width-4,WLH, "- 无此存档 -", 1)
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 更改索引
- # index : 索引
- #--------------------------------------------------------------------------
- def file_index=(file_index)
- @file_index = file_index
- end
- #--------------------------------------------------------------------------
- # ◎ 描绘游戏人物
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_party_characters(x, y)
- for i in [email protected]
- name = @characters[i][0]
- index = @characters[i][1]
- actor_id = @game_party.members[i].id
- level = @game_actors[actor_id].level
- draw_character(name, index, x + i * 48, y)
- self.contents.font.size = 14
- self.contents.draw_text(x + i * 48, y-16, WLH-8, WLH, level.to_s, 2)
- self.contents.font.size = Font.default_size
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 描绘游戏时间
- # x : 描绘目标 X 坐标
- # y : 描绘目标 Y 坐标
- # width : 宽
- # align : 配置
- #--------------------------------------------------------------------------
- def draw_playtime(x, y, width, align)
- self.contents.font.color = system_color
- self.contents.font.size = 16
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
- cx = contents.text_size(time_string).width
- self.contents.draw_text(x, y, width, WLH, "游戏时间")
- self.contents.font.color = normal_color
- self.contents.draw_text(x+cx+4, y, width-cx-4, WLH, time_string)
- self.contents.font.size = Font.default_size
- end
- #--------------------------------------------------------------------------
- # ◎ 描绘地图名称
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_map_name(x, y)
- mapinfo = load_data("Data/MapInfos.rvdata")
- result = mapinfo[@game_map.map_id].name
- map_name = result.split(/,/)[0]
- # 地图名包含@时不描绘
- return if map_name =~ /@/
- color1 = Color.new(0,0,0,96)
- color2 = Color.new(0,0,0,32)
- self.contents.gradient_fill_rect(x, y, width, 18, color1, color2)
- self.contents.font.color = system_color
- self.contents.font.size = 16
- self.contents.font.shadow = false
- self.contents.draw_text(x+4, y-4, width, WLH, "◎ " + map_name)
- self.contents.font.color = normal_color
- self.contents.font.size = Font.default_size
- self.contents.font.shadow = Font.default_shadow
- end
- #--------------------------------------------------------------------------
- # ◎ 描绘金钱
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_gold(x, y)
- self.contents.font.size = 16
- cx = contents.text_size(Vocab::gold).width
- self.contents.font.color = normal_color
- value = @game_party.gold
- width = self.contents.width
- self.contents.draw_text(x, y, width-cx-2, WLH, value, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, width, WLH, Vocab::gold, 2)
- self.contents.font.size = Font.default_size
- end
- #--------------------------------------------------------------------------
- # ◎ 生成保存路径
- # path : 路径
- #--------------------------------------------------------------------------
- def make_dir(path)
- dir = path.split("/")
- for i in 0...dir.size
- unless dir == "."
- add_dir = dir[0..i].join("/")
- begin
- Dir.mkdir(add_dir)
- rescue
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ◎ 生成文件名
- # file_index : 存档文件索引 (0~3)
- #--------------------------------------------------------------------------
- def make_filename(file_index)
- return "Save#{file_index + 1}.rvdata"
- end
- #--------------------------------------------------------------------------
- # ◎ 描绘截图
- # x : 描画先 X 座標
- # y : 描画先 Y 座標
- #--------------------------------------------------------------------------
- def draw_snap_bitmap(x, y)
- bitmap = @file_bitmap
- if bitmap == nil
- self.contents.draw_text(0, 112, 384-32, WLH, "- 找不到截图文件 -", 1)
- else
- self.contents.blur
- rect = Rect.new(0, 0, 0, 0)
- rect.width = bitmap.width
- rect.height = bitmap.height
- self.contents.blt(x, y, bitmap, rect)
- end
- end
- end
复制代码 |
|