赞 | 0 |
VIP | 2 |
好人卡 | 0 |
积分 | 1 |
经验 | 11270 |
最后登录 | 2016-9-21 |
在线时间 | 207 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 207 小时
- 注册时间
- 2014-8-16
- 帖子
- 132
|
3楼
楼主 |
发表于 2015-5-29 13:15:03
|
只看该作者
kuerlulu 发表于 2015-5-29 12:08
module Screen # 名为Screen的模块
@screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p ...
谢谢!这段代码是从一个存取档脚本里提取的,实际上这个脚本是鼠标右键单击存档,可是怎么也找不到有关右键的设置,我想把它改成其他键。附上脚本,大家帮我看看在哪里改?谢谢!- class Window_File < Window_Base
- attr_accessor :index
- def initialize(index = 0)
- @backsp = Sprite.new
- @backsp.bitmap = Bitmap.new("Graphics/Pictures/物品栏.jpg")
- @backsp.z = 100
- super(160,64,480,416)
- #这行可以不用
- self.contents = Bitmap.new(width - 32, height - 32)
- @index = index
- #这里我要说明一句,之所以用sprite是为了放缩图片
- @sprite = Sprite.new
- @sprite.visible = false
- @sprite.z = 100
- @sp_ch = []
- @sp_ch[0] = Sprite.new
- refresh
- end
- def refresh
- self.contents.clear
- for i in @sp_ch
- i.visible = false
- end
- @sprite.visible = false
- if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.rxdata")
- @sprite.visible = true
- if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.jpg")
- @sprite.bitmap = Bitmap.new(DIR+$username.to_s+"Save#{@index}.jpg")
- else
- self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?
- ")
- end
- @sprite.x = 162
- @sprite.y = 60
- @sprite.z = 998
- @sprite.zoom_x = 0.75
- @sprite.zoom_y = 0.7
- file = File.open(DIR+$username.to_s+"Save#{@index}.rxdata", "r")
- @time_stamp = file.mtime
- @characters = 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
- for i in [email protected]
- @sp_ch[i] = Sprite.new
- @sp_ch[i].visible = true
-
- end
- # 描绘游戏时间
- 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(4, 326, 420, 32, time_string, 2)
- # 描绘时间标记
- self.contents.font.color = normal_color
- time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
- self.contents.draw_text(4, 356, 420, 32, time_string, 2)
- else
- self.contents.draw_text(32,32,420,32,"这个存档是空的")
- end
- end
- def dispose
- super
- @sprite.dispose
- @backsp.dispose
- for i in @sp_ch
- i.dispose
- end
- end
- end
- class Window_File2 < Window_Base
- attr_accessor :index
- def initialize(index = 0)
- @backsp = Sprite.new
- @backsp.bitmap = Bitmap.new("Graphics/Pictures/物品栏.jpg")
- @backsp.z = 100
- super(160,0,480,480)
- #这行可以不用
- self.contents = Bitmap.new(width - 32, height - 32)
- @index = index
- #这里我要说明一句,之所以用sprite是为了放缩图片
- @sprite = Sprite.new
- @sprite.visible = false
- @sprite.z = 100
- @sp_ch = []
- @sp_ch[0] = Sprite.new
- refresh
- end
- def refresh
- self.contents.clear
- for i in @sp_ch
- i.visible = false
- end
- @sprite.visible = false
- if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.rxdata")
- @sprite.visible = true
- if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.jpg")
- @sprite.bitmap = Bitmap.new(DIR+$username.to_s+"Save#{@index}.jpg")
- else
- self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?
- ###########################################
- ")
- end
- @sprite.x = 162
- @sprite.y = 0
- @sprite.z = 998
- @sprite.zoom_x = 0.75
- @sprite.zoom_y = 0.7
- file = File.open(DIR+$username.to_s+"Save#{@index}.rxdata", "r")
- @time_stamp = file.mtime
- @characters = 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
- for i in [email protected]
- @sp_ch[i] = Sprite.new
- @sp_ch[i].visible = true
-
- end
- # 描绘游戏时间
- 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(4, 390, 420, 32, time_string, 2)
- # 描绘时间标记
- self.contents.font.color = normal_color
- time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
- self.contents.draw_text(4, 420, 420, 32, time_string, 2)
- else
- self.contents.draw_text(32,32,420,32,"这个存档是空的")
- end
- end
- def dispose
- super
- @sprite.dispose
- @backsp.dispose
- for i in @sp_ch
- i.dispose
- end
- end
- end
- $打开自动存档用的开关编号 = 700
- $自动存档位置 = 0
- #$按下F5之后的自动存档的音效 = " "#Audio/SE/007-System07
- #$按下F5之后禁止存档时候的音效 = " "#Audio/Se/003-System03
- DIR = "Graphics/SCENE/数据/"
- $打开自动存档开关之后调用的公共事件 = 0 #——默认未定义
- $按下F5之后可以存档调用的公共事件 = 0 #——默认未定义
- $按下F5之后禁止存档调用的公共事件 = 0 #——默认未定义
- class Scene_Map
- alias auto_update update
- def update
- auto_update
- #——按下F5的时候自动存档,可以修改为F5,F6,F7,F8,也可以修改成默认按键但是不推荐。
- #——注意在不可存档的时候是无效的
- if Input.trigger?(Input::B)
-
-
- unless $game_system.map_interpreter.running?
- if $game_system.save_disabled
- #Audio.se_play($按下F5之后禁止存档时候的音效)
- $game_temp.common_event_id = $按下F5之后禁止存档调用的公共事件
- else
- # Audio.se_play($按下F5之后的自动存档的音效)
- $game_temp.common_event_id = $按下F5之后可以存档调用的公共事件
- auto_save
- end
-
- end
- end
- #——当BOSS战之前打开一下定义的开关,即可自动存档
- if $game_switches[$打开自动存档用的开关编号] == true
- $game_switches[$打开自动存档用的开关编号] = false
- $game_temp.common_event_id = $打开自动存档开关之后调用的公共事件
- auto_save
- end
- end
-
-
-
-
-
-
-
-
-
- def auto_save
- #——这里定义了储存的文件,如果不希望用Save4可以自己修改编号
- # 写入存档数据
- Screen::shot
- file = File.open( DIR+$username.to_s+"Save#{$自动存档位置}.rxdata", "wb")
- auto_save_data(file)
- if FileTest.exist?( DIR+$username.to_s+"shot.jpg")
- File.rename( DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{$自动存档位置}.jpg")
- end
- file.close
- end
- def auto_save_data(file)
- #——以下定义内容和Scene_Save的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, actor])
- 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)
-
-
-
-
-
-
-
-
-
- Marshal.dump($data_items, file)
- Marshal.dump($newitem, file)
- Marshal.dump($newitemx, file)
- Marshal.dump($newitemy, file)
- Marshal.dump($newitemm, file)
-
-
-
-
- Marshal.dump($data_weapons, file)
- Marshal.dump($data_armors, file)
- Marshal.dump($data_classes, file)
-
-
-
-
-
-
-
- end
- end
- ##############################################
- class Scene_Dzz
- alias auto_update update
- def update
- auto_update
- #——按下F5的时候自动存档,可以修改为F5,F6,F7,F8,也可以修改成默认按键但是不推荐。
- #——注意在不可存档的时候是无效的
- if Input.trigger?(Input::C)
-
-
- unless $game_system.map_interpreter.running?
- if $game_system.save_disabled
- #Audio.se_play($按下F5之后禁止存档时候的音效)
- $game_temp.common_event_id = $按下F5之后禁止存档调用的公共事件
- else
- # Audio.se_play($按下F5之后的自动存档的音效)
- $game_temp.common_event_id = $按下F5之后可以存档调用的公共事件
- auto_save
- end
-
- end
- end
- #——当BOSS战之前打开一下定义的开关,即可自动存档
- if $game_switches[$打开自动存档用的开关编号] == true
- $game_switches[$打开自动存档用的开关编号] = false
- $game_temp.common_event_id = $打开自动存档开关之后调用的公共事件
- auto_save
- end
- end
-
-
-
-
-
-
-
-
-
- def auto_save
- #——这里定义了储存的文件,如果不希望用Save4可以自己修改编号
- # 写入存档数据
- Screen::shot
- file = File.open( DIR+$username.to_s+"Save#{$自动存档位置}.rxdata", "wb")
- auto_save_data(file)
- if FileTest.exist?( DIR+$username.to_s+"shot.jpg")
- File.rename( DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{$自动存档位置}.jpg")
- end
- file.close
- end
- def auto_save_data(file)
- #——以下定义内容和Scene_Save的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, actor])
- 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)
-
-
-
-
-
-
-
-
-
- Marshal.dump($data_items, file)
- Marshal.dump($newitem, file)
- Marshal.dump($newitemx, file)
- Marshal.dump($newitemy, file)
- Marshal.dump($newitemm, file)
-
-
-
-
- Marshal.dump($data_weapons, file)
- Marshal.dump($data_armors, file)
- Marshal.dump($data_classes, file)
-
-
-
-
-
-
-
- end
- end
-
-
- DIR = "Cundang/"
- module Screen
- @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
- @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l
- p), 'l'
- @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
- module_function
- def shot(file = "shot", typ = 1)
- # to add the right extension...
- if typ == 0
- typname = ".bmp"
- elsif typ == 1
- typname = ".jpg"
- elsif typ == 2
- typname = ".png"
- end
- file_index = 0
-
-
-
- dir = "Cundang/"
-
-
-
- # make the filename....
- file_name = dir+$username.to_s + file.to_s + typname.to_s
- # make the screenshot.... Attention dont change anything from here on....
- @screen.call(0,0,640,480,file_name,handel,typ)
- end
- # find the game window...
- def handel
- game_name = "\0" * 256
- @readini.call('Game','Title','',game_name,255,".\\Game.ini")
- game_name.delete!("\0")
- return @findwindow.call('RGSS Player',game_name)
- end
- end
- class Scene_Menu
- alias shotsave_main main
- def main
- if @menu_index == 0
- Screen::shot
- end
- shotsave_main
- end
- end
- class Interpreter
- #--------------------------------------------------------------------------
- # ● 调用存档画面
- #--------------------------------------------------------------------------
- def command_352
- # 设置战斗中断标志
- $game_temp.battle_abort = true
- # 设置调用存档标志
- $game_temp.save_calling = true
- # 推进索引
- @index += 1
- # 结束
- Screen::shot
- return false
- end
- end
- #==============================================================================
- # ■ Scene_Load
- #------------------------------------------------------------------------------
- # 处理读档画面的类。
- #==============================================================================
- class Scene_Load
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- # 再生成临时对像
- $game_temp = Game_Temp.new
- # 选择存档时间最新的文件
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..51
- filename = DIR+$username.to_s+"Save#{i}.rxdata"
- 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
- end
-
-
-
-
-
-
-
-
- def main
-
-
- @command_window = Window_Command.new(160,["自动存档","备份存档",
- ])
- @command_window.y = 0
- @command_window.height = 480
- @command_window.index = $game_temp.last_file_index
- @content_window = Window_File2.new($game_temp.last_file_index)
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- @command_window.dispose
- @content_window.dispose
- end
- def update
- @command_window.update
- if @command_window.index != @content_window.index
- @content_window.index = @command_window.index
- @content_window.refresh
- end
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 写入存档数据
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata",
- "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
- # 切换到地图画面
-
- # Game_Help.start("")
-
-
-
- # $a = {}
- # $game_map.update
-
-
-
-
-
-
-
-
-
-
- $scene = Scene_Map.new
- end
- #———————————————————————#
- 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)
-
-
-
-
- $data_items = Marshal.load(file)
- $newitem = Marshal.load(file)
- $newitemx = Marshal.load(file)
- $newitemy = Marshal.load(file)
- $newitemm = Marshal.load(file)
-
-
-
- $data_weapons = Marshal.load(file)
- $data_armors = Marshal.load(file)
- $data_classes = 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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- # if Input.trigger?(Input::C)
- # 文件不存在的情况下
-
- #end
- #==============================================================================
- # Window_LoadCommand
- #------------------------------------------------------------------------------
- # 存取档画面选择按钮窗口
- #==============================================================================
- class Window_LoadCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(320, 0, 320, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- @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_Loadsave
- #------------------------------------------------------------------------------
- # 处理存取档画面的类。
- #==============================================================================
- class Scene_Loadsave
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # $last_savefile_index : 记录光标位置
- #--------------------------------------------------------------------------
- def initialize
- $last_savefile_index = 0 if $last_savefile_index == nil
- # 再生成临时对像
- $game_temp = Game_Temp.new
- # 选择存档时间最新的文件
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..51
- filename = DIR+$username.to_s+"Save#{i}.rxdata"
- 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
- end
- #--------------------------------------------------------------------------
- # 主处理
- #--------------------------------------------------------------------------
- def main
- @savestate = 0
- # 生成窗口
- @help_window = Window_LoadHelp.new
- @help_window.set_text("小提示:在游戏中按下F5键自动存档.")
- @option_window = Window_LoadCommand.new
- @option_window.index = $last_savefile_index
-
- ########################################################
- @command_window = Window_Command.new(160,["自动存档","进度一","进度二",
- "进度三","进度四","进度五","进度六","进度七","进度八","进度九","进度十",
- ])
- @command_window.y = 64
- @command_window.height = 416
- @command_window.index = $game_temp.last_file_index
- @content_window = Window_File.new($game_temp.last_file_index)
- @command_window.active = false
- ###############覆盖存档
- @confirm_window = Window_Base.new(120, 188, 400, 64)
- @confirm_window.contents = Bitmap.new(368, 32)
- string = "确定要覆盖这个进度吗?"
- @confirm_window.contents.font.name = "黑体"
- @confirm_window.contents.font.size = 24
- @confirm_window.contents.draw_text(4, 0, 368, 32, string)
- @yes_no_window = Window_Command.new(100, ["覆盖", "取消"])
- @confirm_window.z = 1500
- @yes_no_window.index = 1
- @yes_no_window.x = 270
- @yes_no_window.y = 252
- @yes_no_window.z = 1500
- @confirm_window.visible = false
- @yes_no_window.visible = false
- @yes_no_window.active = false
-
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @command_window.dispose
- @content_window.dispose
- @confirm_window.dispose
- @yes_no_window.dispose
- @help_window.dispose
- @option_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @option_window.update
- # @content_window.update
- @command_window.update
- if @yes_no_window.active
- confirm_update
- return
- end
- @content_window.index = @command_window.index
- @content_window.refresh
- 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(7)
- end
- if Input.trigger?(Input::C)
- case @option_window.index
- when 0
- @command_window.active = true
- @option_window.active = false
- $game_system.se_play($data_system.decision_se)
- @help_window.set_text("请选择一个文件进行读取.")
- @savestate = 1
- return
- when 1
- @command_window.active = true
- @option_window.active = false
- $game_system.se_play($data_system.decision_se)
- @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
- 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
- return
- end
- end
- # 取消
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.active = false
- @help_window.set_text("小提示:在游戏中按下F5键自动存档..")
- @savestate = 0
- @option_window.active = true
- return
- end
-
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @savestate = 2
- @command_window.active = true
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- # 建立记录文件索引
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # 读取记录文件
- # filename : 被读取文件
- #--------------------------------------------------------------------------
- def load_file
- # 文件不存在的情况下
- unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 写入存档数据
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "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
- # 切换到地图画面
-
-
-
-
-
-
- # $a = {}
- # $game_map.update
-
-
-
-
-
- $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)
-
-
-
-
- $data_items = Marshal.load(file)
- $newitem = Marshal.load(file)
- $newitemx = Marshal.load(file)
- $newitemy = Marshal.load(file)
- $newitemm = Marshal.load(file)
-
-
-
- $data_weapons = Marshal.load(file)
- $data_armors = Marshal.load(file)
- $data_classes = 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
- if Input.trigger?(Input::C)
- unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
- # 演奏冻结 SE
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
-
-
-
-
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "wb")
- write_save_data(file)
- if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
- File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
- end
-
-
-
-
- file.close
- $game_temp.last_file_index = @command_window.index
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- @confirm_window.dispose
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Map.new
- end
- @yes_no_window.active = true
- @command_window.active = false
- end
- #———————————————————————#
- end
- #-------------------------------------------------------------------
- def confirm_update
- @command_index = @command_window.index
- @confirm_window.visible = true
- @confirm_window.z = 1500
- @yes_no_window.visible = true
- @yes_no_window.active = true
- @yes_no_window.z = 1500
- @yes_no_window.update
- if Input.trigger?(Input::C)
- if @yes_no_window.index == 0
- #######################################################
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata",
- "wb")
- write_save_data(file)
- if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
- File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
- end
- file.close
- $game_temp.last_file_index = @command_window.index
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- @confirm_window.dispose
- @content_window.dispose
- # 切换到地图画面
- $scene = Scene_Map.new
-
- return
- end
- # 切换到菜单画面
- $scene = Scene_Map.new
- else
- $game_system.se_play($data_system.cancel_se)
- @yes_no_window.active = false
- @command_window.active = true
- end
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @yes_no_window.active = false
- @command_window.active = true
- end
- 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, actor])
- 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)
-
-
-
-
-
- Marshal.dump($data_items, file)
- Marshal.dump($newitem, file)
- Marshal.dump($newitemx, file)
- Marshal.dump($newitemy, file)
- Marshal.dump($newitemm, file)
-
-
- Marshal.dump($data_weapons, file)
- Marshal.dump($data_armors, file)
- Marshal.dump($data_classes, file)
-
-
-
-
-
-
- end
- end
- #==============================================================================
- # ■ Window_LoadHelp
- #------------------------------------------------------------------------------
- # 存取档画面帮助信息的显示窗口。
- #==============================================================================
- class Window_LoadHelp < Window_Base
- #--------------------------------------------------------------------------
- # 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 320, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- 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
- #==============================================================================
- # Scene_Loadsave
- #------------------------------------------------------------------------------
- # 处理存取档画面的类。
- #==============================================================================
- class Scene_Loadsave
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # $last_savefile_index : 记录光标位置
- #--------------------------------------------------------------------------
- def initialize
- $last_savefile_index = 0 if $last_savefile_index == nil
- # 再生成临时对像
- $game_temp = Game_Temp.new
- # 选择存档时间最新的文件
- $game_temp.last_file_index = 0
- latest_time = Time.at(0)
- for i in 0..51
- filename = DIR+$username.to_s+"Save#{i}.rxdata"
- 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
- end
- #--------------------------------------------------------------------------
- # 主处理
- #--------------------------------------------------------------------------
- def main
- @savestate = 0
- # 生成窗口
- @help_window = Window_LoadHelp.new
- @help_window.set_text("小提示:在游戏中按下F5键自动存档.")
- @option_window = Window_LoadCommand.new
- @option_window.index = $last_savefile_index
-
- ########################################################
- @command_window = Window_Command.new(160,["自动存档","进度一","进度二",
- "进度三","进度四","进度五","进度六","进度七","进度八","进度九","进度十",
- ])
- @command_window.y = 64
- @command_window.height = 416
- @command_window.index = $game_temp.last_file_index
- @content_window = Window_File.new($game_temp.last_file_index)
- @command_window.active = false
- ###############覆盖存档
- @confirm_window = Window_Base.new(120, 188, 400, 64)
- @confirm_window.contents = Bitmap.new(368, 32)
- string = "确定要覆盖这个进度吗?"
- @confirm_window.contents.font.name = "黑体"
- @confirm_window.contents.font.size = 24
- @confirm_window.contents.draw_text(4, 0, 368, 32, string)
- @yes_no_window = Window_Command.new(100, ["覆盖", "取消"])
- @confirm_window.z = 1500
- @yes_no_window.index = 1
- @yes_no_window.x = 270
- @yes_no_window.y = 252
- @yes_no_window.z = 1500
- @confirm_window.visible = false
- @yes_no_window.visible = false
- @yes_no_window.active = false
-
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @command_window.dispose
- @content_window.dispose
- @confirm_window.dispose
- @yes_no_window.dispose
- @help_window.dispose
- @option_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @option_window.update
- # @content_window.update
- @command_window.update
- if @yes_no_window.active
- confirm_update
- return
- end
- @content_window.index = @command_window.index
- @content_window.refresh
- 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(7)
- end
- if Input.trigger?(Input::C)
- case @option_window.index
- when 0
- @command_window.active = true
- @option_window.active = false
- $game_system.se_play($data_system.decision_se)
- @help_window.set_text("请选择一个文件进行读取.")
- @savestate = 1
- return
- when 1
- @command_window.active = true
- @option_window.active = false
- $game_system.se_play($data_system.decision_se)
- @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
- 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
- return
- end
- end
- # 取消
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.active = false
- @help_window.set_text("小提示:在游戏中按下F5键自动存档..")
- @savestate = 0
- @option_window.active = true
- return
- end
-
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @savestate = 2
- @command_window.active = true
- return
- end
- end
- end
- #--------------------------------------------------------------------------
- # 建立记录文件索引
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # 读取记录文件
- # filename : 被读取文件
- #--------------------------------------------------------------------------
- def load_file
- # 文件不存在的情况下
- unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # 演奏读档 SE
- $game_system.se_play($data_system.load_se)
- # 写入存档数据
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #--------------------------------------------------------------------------
- # ● 读取存档数据
- # 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)
-
-
- $data_items = Marshal.load(file)
- $newitem = Marshal.load(file)
- $newitemx = Marshal.load(file)
- $newitemy = Marshal.load(file)
- $newitemm = Marshal.load(file)
-
-
- $data_weapons = Marshal.load(file)
- $data_armors = Marshal.load(file)
- $data_classes = 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
- if Input.trigger?(Input::C)
- unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
- # 演奏冻结 SE
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "wb")
- write_save_data(file)
- if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
- File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
- end
- file.close
- $game_temp.last_file_index = @command_window.index
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- @confirm_window.dispose
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 切换到菜单画面
- $scene = Scene_Map.new
- end
- @yes_no_window.active = true
- @command_window.active = false
- end
- #———————————————————————#
- end
- #-------------------------------------------------------------------
- def confirm_update
- @command_index = @command_window.index
- @confirm_window.visible = true
- @confirm_window.z = 1500
- @yes_no_window.visible = true
- @yes_no_window.active = true
- @yes_no_window.z = 1500
- @yes_no_window.update
- if Input.trigger?(Input::C)
- if @yes_no_window.index == 0
- #######################################################
- # 演奏存档 SE
- $game_system.se_play($data_system.save_se)
- # 写入存档数据
- file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "wb")
- write_save_data(file)
- if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
- File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
- end
- file.close
- $game_temp.last_file_index = @command_window.index
- # 如果被事件调用
- if $game_temp.save_calling
- # 清除存档调用标志
- $game_temp.save_calling = false
- @confirm_window.dispose
- @content_window.dispose
- # 切换到地图画面
- $scene = Scene_Map.new
-
- return
- end
- # 切换到菜单画面
- $scene = Scene_Map.new
- else
- $game_system.se_play($data_system.cancel_se)
- @yes_no_window.active = false
- @command_window.active = true
- end
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @yes_no_window.active = false
- @command_window.active = true
- end
- 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, actor])
- 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)
-
-
-
-
-
- Marshal.dump($data_items, file)
- Marshal.dump($newitem, file)
- Marshal.dump($newitemx, file)
- Marshal.dump($newitemy, file)
- Marshal.dump($newitemm, file)
-
-
- Marshal.dump($data_weapons, file)
- Marshal.dump($data_armors, file)
- Marshal.dump($data_classes, file)
-
-
-
-
-
-
- end
- end
复制代码 |
|