赞 | 0 |
VIP | 4 |
好人卡 | 9 |
积分 | 1 |
经验 | 2373 |
最后登录 | 2012-10-1 |
在线时间 | 161 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 57
- 在线时间
- 161 小时
- 注册时间
- 2011-2-2
- 帖子
- 469
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 坚强的羁绊 于 2011-2-7 14:18 编辑
- #==============================================================================
- # ■ 存取档合并脚本
- #------------------------------------------------------------------------------
- # BY:美兽
- #插入main之前,地图呼出方式$scene = Scene_Loadsave.new,主菜单里默认的也是该界面
- #不与默认的存取档功能冲突,方便个别地方只需存或者取的功能,虽然很简单,实际做起
- #来,考虑的地方还是比较多。
- #==============================================================================
- #==============================================================================
- # ■ Scene_Load
- #------------------------------------------------------------------------------
- # 处理读档画面的类。
- #==============================================================================
- class Scene_Load < Scene_File
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- # 再生成临时对像
- $game_temp = Game_Temp.new
- # 选择存档时间最新的文件
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..3
- filename = make_filename(i)
- if FileTest.exist?(filename)
- file = File.open(filename, "r")
- if file.mtime > latest_time
- latest_time = file.mtime
- $game_temp.last_file_index = i
- end
- file.close
- end
- end
- super("要载入哪个文件?")
- end
- #--------------------------------------------------------------------------
- # ● 确定时的处理
- #--------------------------------------------------------------------------
- def on_decision(filename)
- # 文件不存在的情况下
- unless FileTest.exist?(filename)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $menu_call = false
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 写入存档数据
- file = File.open(filename, "rb")
- read_save_data(file)
- file.close
- # 还原 BGM、BGS
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 取消时的处理
- #--------------------------------------------------------------------------
- def on_cancel
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到标题画面
- $scene = Scene_Title.new
- end
- #--------------------------------------------------------------------------
- # ● 读取存档数据
- # file : 读取用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- # 读取描绘存档文件用的角色数据
- characters = Marshal.load(file)
- # 读取测量游戏时间用画面计数
- Graphics.frame_count = Marshal.load(file)
- # 读取各种游戏对像
- $game_system = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_screen = 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.magic_number != $data_system.magic_number
- # 重新装载地图
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- # 刷新同伴成员
- $game_party.refresh
- end
- end
- #==============================================================================
- # ■ Window_LoadHelp
- #------------------------------------------------------------------------------
- # 存取档画面帮助信息的显示窗口。
- #==============================================================================
- class Window_LoadHelp < Window_Base
- #--------------------------------------------------------------------------
- # 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 320, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "黑体"
- self.contents.font.size = 18
- end
- #--------------------------------------------------------------------------
- # 刷新文本
- #--------------------------------------------------------------------------
- def set_text(text, align = 1)
- if text != @text or align != @align
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
- @text = text
- @align = align
- @actor = nil
- end
- self.visible = true
- end
- end
- #==============================================================================
- # Window_LoadCommand
- #------------------------------------------------------------------------------
- # 存取档画面选择按钮窗口
- #==============================================================================
- class Window_LoadCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(320, 0, 320, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.name = "黑体"
- self.contents.font.size = 18
- @item_max = 2
- @column_max = 2
- @commands = ["读取", "存储"]
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # 描画按钮文字
- #--------------------------------------------------------------------------
- def draw_item(index)
- x = 4 + index * 160
- self.contents.draw_text(x, 0, 144, 32, @commands[index])
- end
- #--------------------------------------------------------------------------
- # ● 项目无效化
- # index : 项目编号
- #--------------------------------------------------------------------------
- def disable_item(index)
- draw_item(index, disabled_color)
- end
- end
- #==============================================================================
- # ■ Scene_Menu
- #------------------------------------------------------------------------------
- # 处理菜单画面的类。
- #==============================================================================
- class Scene_Menu
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # menu_index : 命令光标的初期位置
- #--------------------------------------------------------------------------
- def initialize(menu_index = 0)
- @menu_index = menu_index
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- @spriteset = Spriteset_Map.new
- # 生成命令窗口
- s1 = $data_system.words.item
- s2 = $data_system.words.skill
- s3 = $data_system.words.equip
- s4 = "状态"
- s5 = "记录"
- s6 = "任务"
- s7 = "队列"
- s8 = "结束"
- @cmd = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8])
- @cmd.index = @menu_index
- # 同伴人数为 0 的情况下
- if $game_party.actors.size == 0
- # 物品、特技、装备、状态无效化
- @cmd.disable_item(0)
- @cmd.disable_item(1)
- @cmd.disable_item(2)
- @cmd.disable_item(3)
- end
- # 生成游戏时间窗口
- @playtime_window = Window_PlayTime.new
- @playtime_window.x = 0
- @playtime_window.y = 320
- # 生成步数窗口
- #@steps_window = Window_Steps.new
- #@steps_window.x = 0
- #@steps_window.y = 320
- # 生成金钱窗口
- @gold_window = Window_Gold.new
- @gold_window.x = 0
- @gold_window.y = 416
- # 生成状态窗口
- @status_window = Window_MenuStatus.new
- @status_window.x = 160
- @status_window.y = 0
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果切换画面就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @cmd.dispose
- @playtime_window.dispose
- @spriteset.dispose
- # @steps_window.dispose
- @gold_window.dispose
- @status_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @cmd.update
- @playtime_window.update
- #@steps_window.update
- @gold_window.update
- @status_window.update
- # 命令窗口被激活的情况下: 调用 update_command
- if @cmd.active
- update_command
- return
- end
- # 状态窗口被激活的情况下: 调用 update_status
- if @status_window.active
- update_status
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面 (命令窗口被激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换的地图画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 同伴人数为 0、存档、游戏结束以外的场合
- if $game_party.actors.size == 0 and @cmd.index < 4
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 命令窗口的光标位置分支
- case @cmd.index
- when 0 # 物品
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到物品画面
- $scene = Scene_Item.new
- when 1 # 特技
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 激活状态窗口
- @cmd.active = false
- @status_window.active = true
- @status_window.index = 0
- when 2 # 装备
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 激活状态窗口
- @cmd.active = false
- @status_window.active = true
- @status_window.index = 0
- when 3 # 状态
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 激活状态窗口
- @cmd.active = false
- @status_window.active = true
- @status_window.index = 0
- when 4 # 记录
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到存取档画面
- $menu_call = true
- $scene = Scene_Loadsave.new
- when 5 # 任务
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 切换到任务画面
- $scene = Scene_Task.new
- when 6 # 队列
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- #切换到队列画面
- $scene = Scene_Change_Turn.new
- end
- return
- end
- end
- end
- #==============================================================================
- # Scene_Loadsave
- #------------------------------------------------------------------------------
- # 处理存取档画面的类。
- #==============================================================================
- class Scene_Loadsave
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # $last_savefile_index : 记录光标位置
- #--------------------------------------------------------------------------
- def initialize
- $last_savefile_index = 0 if $last_savefile_index == nil
- end
- #--------------------------------------------------------------------------
- # 主处理
- #--------------------------------------------------------------------------
- def main
- @savestate = 0
- # 生成窗口
- @help_window = Window_LoadHelp.new
- @help_window.set_text("请选择.")
- @option_window = Window_LoadCommand.new
- @savefile_windows = []
- for i in 0..3
- @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
- end
- @option_window.index = $last_savefile_index
- @file_index = 0
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @option_window.dispose
- for i in @savefile_windows
- i.dispose
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @option_window.update
- for i in @savefile_windows
- i.update
- end
-
- case @savestate
- when 0
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- # 淡入淡出 BGM
- Audio.bgm_fade(800)
- # 返回地图
- if $menu_call == false
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $menu_call = false
- $scene = Scene_Menu.new(4)
- end
- if Input.trigger?(Input::C)
- case @option_window.index
- when 0
- @savefile_windows[@file_index].selected = true
- @option_window.active = false
- @help_window.set_text("请选择一个文件进行读取.")
- @savestate = 1
- return
- when 1
- @savefile_windows[@file_index].selected = true
- @option_window.active = false
- @help_window.set_text("请选择一个文件进行存储.")
- @savestate = 2
- return
- return
- end
- end
- when 1,2
- if Input.trigger?(Input::C)
- if @savestate == 1
- $menu_call = false
- load_file(make_filename(@file_index))
- return
- else
- # 禁止存档的情况下
- if $game_system.save_disabled
- @help_window.set_text("抱歉,这里禁止存储.")
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- $last_savefile_index = @option_window.index
- save_file(make_filename(@file_index))
- return
- end
- end
- # 取消
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @savefile_windows[@file_index].selected = false
- @help_window.set_text("请选择.")
- @savestate = 0
- @option_window.active = true
- return
- end
- # 向下选择
- if Input.repeat?(Input::DOWN)
- $game_system.se_play($data_system.cursor_se)
- @savefile_windows[@file_index].selected = false
- @file_index = (@file_index + 1) % 4
- @savefile_windows[@file_index].selected = true
- return
- end
- # 向上选择
- if Input.repeat?(Input::UP)
- $game_system.se_play($data_system.cursor_se)
- @savefile_windows[@file_index].selected = false
- @file_index = (@file_index + 3) % 4
- @savefile_windows[@file_index].selected = true
- return
- end
-
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @savestate = 2
- @savefile_windows[@file_index].selected = true
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- # 建立记录文件索引
- #--------------------------------------------------------------------------
- def make_filename(file_index)
- return "Save#{file_index + 1}.rxdata"
- end
- #--------------------------------------------------------------------------
- # 读取记录文件
- # filename : 被读取文件
- #--------------------------------------------------------------------------
- def load_file(filename)
- # 文件不存在的情况下
- unless FileTest.exist?(filename)
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 以二进制方式打开文件
- # 写入存档数据
- file = File.open(filename, "rb")
- read_save_data(file)
- file.close
- # 演奏 BGM 与 BGS
- $game_system.bgm_play($game_system.playing_bgm)
- $game_system.bgs_play($game_system.playing_bgs)
- # 刷新地图 (执行并行事件)
- $game_map.update
- # 切换到地图画面
- $menu_call == false
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # ● 读取存档数据
- # file : 读取用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- # 读取描绘存档文件用的角色数据
- characters = Marshal.load(file)
- # 读取测量游戏时间用画面计数
- Graphics.frame_count = Marshal.load(file)
- # 读取各种游戏对像
- $game_system = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_screen = 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.magic_number != $data_system.magic_number
- # 重新装载地图
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- # 刷新同伴成员
- $game_party.refresh
- end
- #--------------------------------------------------------------------------
- # ● 写入存档文件
- #--------------------------------------------------------------------------
- def save_file(filename)
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
- file = File.open(filename, "wb")
- write_save_data(file)
- file.close
- # 切换到菜单画面
- $scene = Scene_Loadsave.new
- end
- #--------------------------------------------------------------------------
- # ● 写入存档数据
- # file : 写入用文件对像 (已经打开)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- # 生成描绘存档文件用的角色图形
- characters = []
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- characters.push([actor.character_name, actor.character_hue])
- end
- # 写入描绘存档文件用的角色数据
- Marshal.dump(characters, file)
- # 写入测量游戏时间用画面计数
- Marshal.dump(Graphics.frame_count, file)
- # 增加 1 次存档次数
- $game_system.save_count += 1
- # 保存魔法编号
- # (将编辑器保存的值以随机值替换)
- $game_system.magic_number = $data_system.magic_number
- # 写入各种游戏对像
- Marshal.dump($game_system, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_screen, 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
- end
复制代码 我想把它放到结束菜单里面,怎样才能把它给加进去
就是想把这个添加到结束菜单中,应该怎样改Scene_End脚本? |
|