设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1546|回复: 4
打印 上一主题 下一主题

[已经解决] 求解释下这段脚本的意思

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
207 小时
注册时间
2014-8-16
帖子
132
跳转到指定楼层
1
发表于 2015-5-29 10:24:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
这是不是全键盘脚本定义某个按键的脚本?请解析下,谢谢!

RUBY 代码复制
  1. module Screen  
  2.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  3.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l
  4.  
  5. p), 'l'
  6.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  7.   module_function

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv1.梦旅人

梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
帖子
1698

开拓者

2
发表于 2015-5-29 12:08:27 | 只看该作者
RUBY 代码复制
  1. module Screen  # 名为Screen的模块
  2.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), '' # 声明截图(Screenshot)api
  3.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l' # 声明读取配置文件(readini)api
  4.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l' # 声明获取窗口句柄(FindWindow)api
  5.   module_function

综上: 这段代码大概是用来截图而且跟全键盘脚本毛关系都没有

评分

参与人数 1星屑 +90 收起 理由
RyanBern + 90 我很赞同

查看全部评分


  -fk: -azogi:
回复 支持 反对

使用道具 举报

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  ...

谢谢!这段代码是从一个存取档脚本里提取的,实际上这个脚本是鼠标右键单击存档,可是怎么也找不到有关右键的设置,我想把它改成其他键。附上脚本,大家帮我看看在哪里改?谢谢!
  1. class Window_File < Window_Base
  2.   attr_accessor :index
  3.   def initialize(index = 0)
  4.     @backsp = Sprite.new
  5.     @backsp.bitmap = Bitmap.new("Graphics/Pictures/物品栏.jpg")
  6.     @backsp.z = 100
  7.     super(160,64,480,416)
  8.     #这行可以不用
  9.     self.contents = Bitmap.new(width - 32, height - 32)
  10.     @index = index
  11.     #这里我要说明一句,之所以用sprite是为了放缩图片
  12.     @sprite = Sprite.new
  13.     @sprite.visible = false
  14.     @sprite.z = 100
  15.     @sp_ch = []
  16.     @sp_ch[0] = Sprite.new
  17.     refresh
  18.   end
  19.   def refresh
  20.     self.contents.clear
  21.     for i in @sp_ch
  22.       i.visible = false
  23.     end
  24.     @sprite.visible = false
  25.     if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.rxdata")
  26.       @sprite.visible = true
  27.       if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.jpg")
  28.         @sprite.bitmap = Bitmap.new(DIR+$username.to_s+"Save#{@index}.jpg")
  29.       else
  30.         self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?

  31. ")
  32.       end
  33.       @sprite.x = 162
  34.       @sprite.y = 60
  35.       @sprite.z = 998
  36.       @sprite.zoom_x = 0.75
  37.       @sprite.zoom_y = 0.7
  38.       file = File.open(DIR+$username.to_s+"Save#{@index}.rxdata", "r")
  39.       @time_stamp = file.mtime
  40.       @characters = Marshal.load(file)
  41.       @frame_count = Marshal.load(file)
  42.       @game_system = Marshal.load(file)
  43.       @game_switches = Marshal.load(file)
  44.       @game_variables = Marshal.load(file)
  45.       @total_sec = @frame_count / Graphics.frame_rate
  46.       file.close
  47.       for i in [email protected]
  48.         @sp_ch[i] = Sprite.new
  49.         @sp_ch[i].visible = true
  50.    
  51.       end
  52.       # 描绘游戏时间
  53.       hour = @total_sec / 60 / 60
  54.       min = @total_sec / 60 % 60
  55.       sec = @total_sec % 60
  56.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  57.       self.contents.font.color = normal_color
  58.       self.contents.draw_text(4, 326, 420, 32, time_string, 2)
  59.       # 描绘时间标记
  60.       self.contents.font.color = normal_color
  61.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  62.       self.contents.draw_text(4, 356, 420, 32, time_string, 2)
  63.     else
  64.       self.contents.draw_text(32,32,420,32,"这个存档是空的")
  65.     end

  66.   end
  67.   def dispose
  68.     super
  69.     @sprite.dispose
  70.     @backsp.dispose
  71.     for i in @sp_ch
  72.       i.dispose
  73.     end
  74.   end
  75. end


  76. class Window_File2 < Window_Base
  77.   attr_accessor :index
  78.   def initialize(index = 0)
  79.     @backsp = Sprite.new
  80.     @backsp.bitmap = Bitmap.new("Graphics/Pictures/物品栏.jpg")
  81.     @backsp.z = 100
  82.     super(160,0,480,480)
  83.     #这行可以不用
  84.     self.contents = Bitmap.new(width - 32, height - 32)
  85.     @index = index
  86.     #这里我要说明一句,之所以用sprite是为了放缩图片
  87.     @sprite = Sprite.new
  88.     @sprite.visible = false
  89.     @sprite.z = 100
  90.     @sp_ch = []
  91.     @sp_ch[0] = Sprite.new
  92.     refresh
  93.   end
  94.   def refresh
  95.     self.contents.clear
  96.     for i in @sp_ch
  97.       i.visible = false
  98.     end
  99.     @sprite.visible = false
  100.     if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.rxdata")
  101.       @sprite.visible = true
  102.       if FileTest.exist?(DIR+$username.to_s+"Save#{@index}.jpg")
  103.         @sprite.bitmap = Bitmap.new(DIR+$username.to_s+"Save#{@index}.jpg")
  104.       else
  105.         self.contents.draw_text(32,64,400,32,"截图似乎有点问题……您搞什么了您?
  106. ###########################################
  107. ")
  108.       end
  109.       @sprite.x = 162
  110.       @sprite.y = 0
  111.       @sprite.z = 998
  112.       @sprite.zoom_x = 0.75
  113.       @sprite.zoom_y = 0.7
  114.       file = File.open(DIR+$username.to_s+"Save#{@index}.rxdata", "r")
  115.       @time_stamp = file.mtime
  116.       @characters = Marshal.load(file)
  117.       @frame_count = Marshal.load(file)
  118.       @game_system = Marshal.load(file)
  119.       @game_switches = Marshal.load(file)
  120.       @game_variables = Marshal.load(file)
  121.       @total_sec = @frame_count / Graphics.frame_rate
  122.       file.close
  123.       for i in [email protected]
  124.         @sp_ch[i] = Sprite.new
  125.         @sp_ch[i].visible = true
  126.       
  127.       end
  128.       # 描绘游戏时间
  129.       hour = @total_sec / 60 / 60
  130.       min = @total_sec / 60 % 60
  131.       sec = @total_sec % 60
  132.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  133.       self.contents.font.color = normal_color
  134.       self.contents.draw_text(4, 390, 420, 32, time_string, 2)
  135.       # 描绘时间标记
  136.       self.contents.font.color = normal_color
  137.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  138.       self.contents.draw_text(4, 420, 420, 32, time_string, 2)
  139.     else
  140.       self.contents.draw_text(32,32,420,32,"这个存档是空的")
  141.     end

  142.   end
  143.   def dispose
  144.     super
  145.     @sprite.dispose
  146.     @backsp.dispose
  147.     for i in @sp_ch
  148.       i.dispose
  149.     end
  150.   end
  151. end



  152. $打开自动存档用的开关编号 = 700
  153. $自动存档位置 = 0
  154. #$按下F5之后的自动存档的音效 = " "#Audio/SE/007-System07
  155. #$按下F5之后禁止存档时候的音效 = " "#Audio/Se/003-System03
  156. DIR = "Graphics/SCENE/数据/"
  157. $打开自动存档开关之后调用的公共事件 = 0 #——默认未定义
  158. $按下F5之后可以存档调用的公共事件 = 0 #——默认未定义
  159. $按下F5之后禁止存档调用的公共事件 = 0 #——默认未定义



  160. class Scene_Map
  161. alias auto_update update
  162. def update
  163. auto_update
  164. #——按下F5的时候自动存档,可以修改为F5,F6,F7,F8,也可以修改成默认按键但是不推荐。
  165. #——注意在不可存档的时候是无效的
  166.     if   Input.trigger?(Input::B)

  167.    
  168.     unless $game_system.map_interpreter.running?
  169.    if $game_system.save_disabled
  170.      #Audio.se_play($按下F5之后禁止存档时候的音效)
  171.      $game_temp.common_event_id = $按下F5之后禁止存档调用的公共事件
  172.    else
  173.     # Audio.se_play($按下F5之后的自动存档的音效)
  174.      $game_temp.common_event_id = $按下F5之后可以存档调用的公共事件
  175.      auto_save
  176.    end
  177.   
  178.    end
  179. end
  180. #——当BOSS战之前打开一下定义的开关,即可自动存档
  181. if $game_switches[$打开自动存档用的开关编号] == true
  182.    $game_switches[$打开自动存档用的开关编号] = false
  183.    $game_temp.common_event_id = $打开自动存档开关之后调用的公共事件
  184.    auto_save
  185. end
  186. end
  187.    
  188.    
  189.    













  190.    
  191.    
  192.    
  193.    
  194.    
  195.    
  196. def auto_save
  197. #——这里定义了储存的文件,如果不希望用Save4可以自己修改编号
  198. # 写入存档数据
  199. Screen::shot
  200.      file = File.open( DIR+$username.to_s+"Save#{$自动存档位置}.rxdata", "wb")
  201.      auto_save_data(file)
  202.      if FileTest.exist?( DIR+$username.to_s+"shot.jpg")
  203.        File.rename( DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{$自动存档位置}.jpg")
  204.      end
  205.      file.close
  206. end
  207. def auto_save_data(file)
  208. #——以下定义内容和Scene_Save的write_save_data(file)完全一样
  209. #——如果你修改过该存档方法,不要忘记用你修改的覆盖这部分内容。
  210. # 生成描绘存档文件用的角色图形
  211. characters = []
  212. for i in 0...$game_party.actors.size
  213.    actor = $game_party.actors[i]
  214.    characters.push([actor.character_name, actor.character_hue, actor])
  215. end
  216. # 写入描绘存档文件用的角色数据
  217. Marshal.dump(characters, file)
  218. # 写入测量游戏时间用画面计数
  219. Marshal.dump(Graphics.frame_count, file)
  220. # 增加 1 次存档次数
  221. $game_system.save_count += 1
  222. # 保存魔法编号
  223. # (将编辑器保存的值以随机值替换)
  224. $game_system.magic_number = $data_system.magic_number
  225. # 写入各种游戏对像
  226. Marshal.dump($game_system, file)
  227. Marshal.dump($game_switches, file)
  228. Marshal.dump($game_variables, file)
  229. Marshal.dump($game_self_switches, file)
  230. Marshal.dump($game_screen, file)
  231. Marshal.dump($game_actors, file)
  232. Marshal.dump($game_party, file)
  233. Marshal.dump($game_troop, file)
  234. Marshal.dump($game_map, file)
  235. Marshal.dump($game_player, file)





  236.    


  237.      
  238.       Marshal.dump($data_items, file)
  239.     Marshal.dump($newitem, file)
  240.     Marshal.dump($newitemx, file)
  241.     Marshal.dump($newitemy, file)
  242.     Marshal.dump($newitemm, file)
  243.    



  244.     Marshal.dump($data_weapons, file)
  245.     Marshal.dump($data_armors, file)
  246.     Marshal.dump($data_classes, file)
  247.    
  248.    

  249.   



  250. end
  251. end

  252. ##############################################
  253. class Scene_Dzz
  254. alias auto_update update
  255. def update
  256. auto_update
  257. #——按下F5的时候自动存档,可以修改为F5,F6,F7,F8,也可以修改成默认按键但是不推荐。
  258. #——注意在不可存档的时候是无效的
  259.     if   Input.trigger?(Input::C)

  260.    
  261.     unless $game_system.map_interpreter.running?
  262.    if $game_system.save_disabled
  263.      #Audio.se_play($按下F5之后禁止存档时候的音效)
  264.      $game_temp.common_event_id = $按下F5之后禁止存档调用的公共事件
  265.    else
  266.     # Audio.se_play($按下F5之后的自动存档的音效)
  267.      $game_temp.common_event_id = $按下F5之后可以存档调用的公共事件
  268.      auto_save
  269.    end
  270.   
  271.    end
  272. end
  273. #——当BOSS战之前打开一下定义的开关,即可自动存档
  274. if $game_switches[$打开自动存档用的开关编号] == true
  275.    $game_switches[$打开自动存档用的开关编号] = false
  276.    $game_temp.common_event_id = $打开自动存档开关之后调用的公共事件
  277.    auto_save
  278. end
  279. end
  280.    
  281.    
  282.    













  283.    
  284.    
  285.    
  286.    
  287.    
  288.    
  289. def auto_save
  290. #——这里定义了储存的文件,如果不希望用Save4可以自己修改编号
  291. # 写入存档数据
  292. Screen::shot
  293.      file = File.open( DIR+$username.to_s+"Save#{$自动存档位置}.rxdata", "wb")
  294.      auto_save_data(file)
  295.      if FileTest.exist?( DIR+$username.to_s+"shot.jpg")
  296.        File.rename( DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{$自动存档位置}.jpg")
  297.      end
  298.      file.close
  299. end
  300. def auto_save_data(file)
  301. #——以下定义内容和Scene_Save的write_save_data(file)完全一样
  302. #——如果你修改过该存档方法,不要忘记用你修改的覆盖这部分内容。
  303. # 生成描绘存档文件用的角色图形
  304. characters = []
  305. for i in 0...$game_party.actors.size
  306.    actor = $game_party.actors[i]
  307.    characters.push([actor.character_name, actor.character_hue, actor])
  308. end
  309. # 写入描绘存档文件用的角色数据
  310. Marshal.dump(characters, file)
  311. # 写入测量游戏时间用画面计数
  312. Marshal.dump(Graphics.frame_count, file)
  313. # 增加 1 次存档次数
  314. $game_system.save_count += 1
  315. # 保存魔法编号
  316. # (将编辑器保存的值以随机值替换)
  317. $game_system.magic_number = $data_system.magic_number
  318. # 写入各种游戏对像
  319. Marshal.dump($game_system, file)
  320. Marshal.dump($game_switches, file)
  321. Marshal.dump($game_variables, file)
  322. Marshal.dump($game_self_switches, file)
  323. Marshal.dump($game_screen, file)
  324. Marshal.dump($game_actors, file)
  325. Marshal.dump($game_party, file)
  326. Marshal.dump($game_troop, file)
  327. Marshal.dump($game_map, file)
  328. Marshal.dump($game_player, file)





  329.    


  330.      
  331.       Marshal.dump($data_items, file)
  332.     Marshal.dump($newitem, file)
  333.     Marshal.dump($newitemx, file)
  334.     Marshal.dump($newitemy, file)
  335.     Marshal.dump($newitemm, file)
  336.    



  337.     Marshal.dump($data_weapons, file)
  338.     Marshal.dump($data_armors, file)
  339.     Marshal.dump($data_classes, file)
  340.    
  341.    

  342.   



  343. end
  344. end


  345.          

  346. DIR = "Cundang/"
















  347. module Screen  
  348.   @screen = Win32API.new 'screenshot', 'Screenshot', %w(l l l l p l l), ''
  349.   @readini = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l

  350. p), 'l'
  351.   @findwindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
  352.   module_function
  353.   def shot(file = "shot", typ = 1)
  354.     # to add the right extension...
  355.     if typ == 0
  356.       typname = ".bmp"
  357.     elsif typ == 1
  358.       typname = ".jpg"
  359.     elsif typ == 2
  360.       typname = ".png"
  361.     end   
  362.     file_index = 0   
  363.    
  364.    

  365. dir = "Cundang/"  

  366.    
  367.    
  368.      
  369.     # make the filename....
  370.     file_name = dir+$username.to_s + file.to_s + typname.to_s   
  371.     # make the screenshot.... Attention dont change anything from here on....
  372.     @screen.call(0,0,640,480,file_name,handel,typ)
  373.   end
  374.   # find the game window...
  375.   def handel
  376.     game_name = "\0" * 256
  377.     @readini.call('Game','Title','',game_name,255,".\\Game.ini")
  378.     game_name.delete!("\0")
  379.     return @findwindow.call('RGSS Player',game_name)
  380.   end
  381. end


  382. class Scene_Menu
  383.   alias shotsave_main main
  384.   def main
  385.     if @menu_index == 0
  386.       Screen::shot
  387.     end   
  388.     shotsave_main
  389.   end
  390. end

  391. class Interpreter
  392.   #--------------------------------------------------------------------------
  393.   # ● 调用存档画面
  394.   #--------------------------------------------------------------------------
  395.   def command_352
  396.     # 设置战斗中断标志
  397.     $game_temp.battle_abort = true
  398.     # 设置调用存档标志
  399.     $game_temp.save_calling = true
  400.     # 推进索引
  401.     @index += 1
  402.     # 结束
  403.     Screen::shot
  404.     return false
  405.   end
  406. end

  407. #==============================================================================
  408. # ■ Scene_Load
  409. #------------------------------------------------------------------------------
  410. #  处理读档画面的类。
  411. #==============================================================================

  412. class Scene_Load
  413.   #--------------------------------------------------------------------------
  414.   # ● 初始化对像
  415.   #--------------------------------------------------------------------------
  416.   def initialize
  417.     # 再生成临时对像
  418.     $game_temp = Game_Temp.new
  419.     # 选择存档时间最新的文件
  420.     $game_temp.last_file_index = 0
  421.     latest_time = Time.at(0)
  422.     for i in 0..51
  423.       filename = DIR+$username.to_s+"Save#{i}.rxdata"
  424.       if FileTest.exist?(filename)
  425.         file = File.open(filename, "r")
  426.         if file.mtime > latest_time
  427.           latest_time = file.mtime
  428.           $game_temp.last_file_index = i
  429.         end
  430.         file.close
  431.       end
  432.     end
  433.   end  
  434.    
  435.    
  436.    
  437.   
  438.   
  439.   
  440.   
  441.   
  442.     def main
  443.   
  444.    
  445.       @command_window = Window_Command.new(160,["自动存档","备份存档",
  446.    ])
  447.     @command_window.y = 0
  448.     @command_window.height = 480
  449.     @command_window.index = $game_temp.last_file_index
  450.     @content_window = Window_File2.new($game_temp.last_file_index)
  451.     # 执行过渡
  452.     Graphics.transition
  453.     # 主循环
  454.     loop do
  455.       # 刷新游戏画面
  456.       Graphics.update
  457.       # 刷新输入信息
  458.       Input.update
  459.       # 刷新画面
  460.       update
  461.       # 如果画面被切换的话就中断循环
  462.       if $scene != self
  463.         break
  464.       end
  465.     end
  466.     # 准备过渡
  467.     Graphics.freeze
  468.     @command_window.dispose
  469.     @content_window.dispose
  470.   end
  471.   def update
  472.     @command_window.update
  473.     if @command_window.index != @content_window.index
  474.       @content_window.index = @command_window.index
  475.       @content_window.refresh
  476.     end   
  477.   
  478.   
  479.   
  480.   
  481.   
  482.   
  483.   
  484.   
  485.   
  486.   
  487.   
  488.   
  489.   
  490.   
  491.   
  492.    
  493.    
  494.    
  495.    
  496.       unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
  497.         # 演奏冻结 SE
  498.         $game_system.se_play($data_system.buzzer_se)
  499.         return
  500.       end
  501.       # 演奏读档 SE
  502.       $game_system.se_play($data_system.load_se)
  503.       # 写入存档数据
  504.       file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata",

  505. "rb")
  506.       read_save_data(file)
  507.       file.close
  508.       # 还原 BGM、BGS
  509.       $game_system.bgm_play($game_system.playing_bgm)
  510.       $game_system.bgs_play($game_system.playing_bgs)
  511.       # 刷新地图 (执行并行事件)
  512.       $game_map.update
  513.       # 切换到地图画面
  514.       
  515.     #  Game_Help.start("")
  516.   
  517.       
  518.       
  519.       # $a = {}
  520.    # $game_map.update
  521.       
  522.       
  523.       
  524.       
  525.       
  526.       
  527.       
  528.       
  529.       
  530.       
  531.       $scene = Scene_Map.new
  532.     end
  533.     #———————————————————————#
  534.   end
  535.   
  536.   
  537.   
  538.   
  539.   
  540.   
  541.   
  542.   
  543.   
  544.   
  545.   
  546.   
  547.   
  548.   
  549.   
  550.   
  551.   
  552.   
  553.   
  554.   
  555.   #--------------------------------------------------------------------------
  556.   # ● 写入存档数据
  557.   #     file : 写入用文件对像 (已经打开)
  558.   #--------------------------------------------------------------------------
  559.   def read_save_data(file)
  560.     # 读取描绘存档文件用的角色数据
  561.     characters = Marshal.load(file)
  562.     # 读取测量游戏时间用画面计数
  563.     Graphics.frame_count = Marshal.load(file)
  564.     # 读取各种游戏对像
  565.     $game_system        = Marshal.load(file)
  566.     $game_switches      = Marshal.load(file)
  567.     $game_variables     = Marshal.load(file)
  568.     $game_self_switches = Marshal.load(file)
  569.     $game_screen        = Marshal.load(file)
  570.     $game_actors        = Marshal.load(file)
  571.     $game_party         = Marshal.load(file)
  572.     $game_troop         = Marshal.load(file)
  573.     $game_map           = Marshal.load(file)
  574.     $game_player        = Marshal.load(file)
  575.    
  576.    
  577.    
  578.    
  579.         $data_items         = Marshal.load(file)
  580.     $newitem            = Marshal.load(file)
  581.     $newitemx           = Marshal.load(file)
  582.     $newitemy           = Marshal.load(file)
  583.     $newitemm           = Marshal.load(file)
  584.    
  585.    
  586.      
  587.     $data_weapons       = Marshal.load(file)
  588.     $data_armors        = Marshal.load(file)
  589.     $data_classes       = Marshal.load(file)
  590.    
  591.    
  592.    
  593.    
  594.    
  595.    
  596.     # 魔法编号与保存时有差异的情况下
  597.     # (加入编辑器的编辑过的数据)
  598.     if $game_system.magic_number != $data_system.magic_number
  599.       # 重新装载地图
  600.       $game_map.setup($game_map.map_id)
  601.       $game_player.center($game_player.x, $game_player.y)
  602.     end
  603.     # 刷新同伴成员
  604.     $game_party.refresh
  605.   end
  606.    
  607.    
  608.    
  609.    
  610.    
  611.    
  612.    
  613.    
  614.    
  615.    
  616.    
  617.    
  618.    
  619.    
  620.    
  621.    
  622.    
  623.    
  624.    
  625.    
  626.    
  627.    
  628.    
  629.    
  630.    
  631.    
  632.    
  633.    
  634.    
  635.    # if Input.trigger?(Input::C)
  636.       # 文件不存在的情况下
  637.    
  638. #end

  639. #==============================================================================
  640. #  Window_LoadCommand
  641. #------------------------------------------------------------------------------
  642. #  存取档画面选择按钮窗口
  643. #==============================================================================



  644. class Window_LoadCommand < Window_Selectable
  645. #--------------------------------------------------------------------------
  646. #  初始化对象
  647. #--------------------------------------------------------------------------
  648. def initialize
  649.   super(320, 0, 320, 64)
  650.   self.contents = Bitmap.new(width - 32, height - 32)
  651.   @item_max = 2
  652.   @column_max = 2
  653.   @commands = ["读取", "存储"]
  654.   refresh
  655.   self.index = 0
  656. end
  657. #--------------------------------------------------------------------------
  658. #  刷新
  659. #--------------------------------------------------------------------------
  660. def refresh
  661.   self.contents.clear
  662.   for i in 0...@item_max
  663.     draw_item(i)
  664.   end
  665. end
  666. #--------------------------------------------------------------------------
  667. #  描画按钮文字
  668. #--------------------------------------------------------------------------
  669. def draw_item(index)
  670.   x = 4 + index * 160
  671.   self.contents.draw_text(x, 0, 144, 32, @commands[index])
  672. end
  673. #--------------------------------------------------------------------------
  674. # ● 项目无效化
  675. #     index : 项目编号
  676. #--------------------------------------------------------------------------
  677.   def disable_item(index)
  678.     draw_item(index, disabled_color)
  679.   end

  680. end


















  681. #==============================================================================
  682. #  Scene_Loadsave
  683. #------------------------------------------------------------------------------
  684. # 处理存取档画面的类。
  685. #==============================================================================

  686. class Scene_Loadsave
  687. #--------------------------------------------------------------------------
  688. # ● 初始化对像
  689. #     $last_savefile_index : 记录光标位置
  690. #--------------------------------------------------------------------------
  691.   def initialize
  692.     $last_savefile_index = 0 if $last_savefile_index == nil
  693.     # 再生成临时对像
  694.     $game_temp = Game_Temp.new
  695.     # 选择存档时间最新的文件
  696.     $game_temp.last_file_index = 0
  697.     latest_time = Time.at(0)
  698.     for i in 0..51
  699.       filename = DIR+$username.to_s+"Save#{i}.rxdata"
  700.       if FileTest.exist?(filename)
  701.         file = File.open(filename, "r")
  702.         if file.mtime > latest_time
  703.           latest_time = file.mtime
  704.           $game_temp.last_file_index = i
  705.         end
  706.         file.close
  707.       end
  708.     end
  709.   end
  710. #--------------------------------------------------------------------------
  711. #  主处理
  712. #--------------------------------------------------------------------------
  713.   def main
  714.     @savestate = 0
  715.     # 生成窗口
  716.     @help_window = Window_LoadHelp.new
  717.     @help_window.set_text("小提示:在游戏中按下F5键自动存档.")
  718.     @option_window = Window_LoadCommand.new
  719.     @option_window.index = $last_savefile_index
  720.    
  721.     ########################################################
  722.     @command_window = Window_Command.new(160,["自动存档","进度一","进度二",
  723.       "进度三","进度四","进度五","进度六","进度七","进度八","进度九","进度十",
  724.       ])
  725.       @command_window.y = 64
  726.       @command_window.height = 416
  727.       @command_window.index = $game_temp.last_file_index
  728.       @content_window = Window_File.new($game_temp.last_file_index)
  729.       @command_window.active = false
  730.         ###############覆盖存档
  731.         @confirm_window = Window_Base.new(120, 188, 400, 64)
  732.         @confirm_window.contents = Bitmap.new(368, 32)
  733.         string = "确定要覆盖这个进度吗?"
  734.         @confirm_window.contents.font.name = "黑体"
  735.         @confirm_window.contents.font.size = 24
  736.         @confirm_window.contents.draw_text(4, 0, 368, 32, string)
  737.         @yes_no_window = Window_Command.new(100, ["覆盖", "取消"])
  738.         @confirm_window.z = 1500
  739.         @yes_no_window.index = 1
  740.         @yes_no_window.x = 270
  741.         @yes_no_window.y = 252
  742.         @yes_no_window.z = 1500
  743.         @confirm_window.visible = false
  744.         @yes_no_window.visible = false
  745.         @yes_no_window.active = false

  746.     # 执行过渡
  747.     Graphics.transition
  748.     # 主循环
  749.     loop do
  750.       # 刷新游戏画面
  751.       Graphics.update
  752.       # 刷新输入信息
  753.       Input.update
  754.       # 刷新画面
  755.       update
  756.       # 如果画面被切换的话就中断循环
  757.       if $scene != self
  758.         break
  759.       end
  760.     end
  761.     # 准备过渡
  762.     Graphics.freeze
  763.     # 释放窗口
  764.     @command_window.dispose
  765.     @content_window.dispose
  766.     @confirm_window.dispose
  767.     @yes_no_window.dispose
  768.     @help_window.dispose
  769.     @option_window.dispose

  770.   end

  771. #--------------------------------------------------------------------------
  772. #  ● 刷新画面
  773. #--------------------------------------------------------------------------
  774.   def update
  775.     # 刷新窗口
  776.     @help_window.update
  777.     @option_window.update
  778. #   @content_window.update
  779.     @command_window.update
  780.     if @yes_no_window.active
  781.         confirm_update
  782.         return
  783.     end
  784.     @content_window.index = @command_window.index
  785.     @content_window.refresh
  786.     case @savestate
  787.     when 0
  788.         if Input.trigger?(Input::B)
  789.         $game_system.se_play($data_system.cancel_se)
  790.         # 淡入淡出 BGM
  791.         Audio.bgm_fade(800)
  792.         # 返回地图
  793.         if $menu_call == false
  794.         # 切换到地图画面
  795.         $scene = Scene_Map.new
  796.           return
  797.         end
  798.         # 切换到菜单画面
  799.         $menu_call = false
  800.         $scene = Scene_Menu.new(7)
  801.      end
  802.       if Input.trigger?(Input::C)
  803.         case @option_window.index
  804.         when 0
  805.           @command_window.active = true
  806.           @option_window.active = false
  807.           $game_system.se_play($data_system.decision_se)
  808.           @help_window.set_text("请选择一个文件进行读取.")
  809.           @savestate  = 1
  810.           return
  811.         when 1
  812.           @command_window.active = true
  813.           @option_window.active = false
  814.           $game_system.se_play($data_system.decision_se)
  815.           @help_window.set_text("请选择一个文件进行存储.")
  816.           @savestate = 2
  817.          
  818.           return
  819.         return
  820.         end
  821.       end
  822.     when 1,2
  823.       if Input.trigger?(Input::C)
  824.         if @savestate == 1
  825.           $menu_call = false
  826.           load_file
  827.           return
  828.         else
  829.           # 禁止存档的情况下
  830.           if $game_system.save_disabled
  831.             @help_window.set_text("抱歉,这里禁止存储.")
  832.             # 演奏冻结 SE
  833.             $game_system.se_play($data_system.buzzer_se)
  834.             return
  835.           end
  836.          $game_system.se_play($data_system.decision_se)
  837.          $last_savefile_index = @option_window.index
  838.   
  839.          save_file
  840.           return
  841.         end
  842.       end
  843.       # 取消
  844.       if Input.trigger?(Input::B)
  845.         $game_system.se_play($data_system.cancel_se)
  846.         @command_window.active = false
  847.         @help_window.set_text("小提示:在游戏中按下F5键自动存档..")
  848.         @savestate = 0
  849.         @option_window.active = true
  850.         return
  851.       end
  852.       
  853.       if Input.trigger?(Input::B)
  854.         $game_system.se_play($data_system.cancel_se)
  855.         @savestate = 2
  856.         @command_window.active = true

  857.         return
  858.       end
  859.     end
  860.   end
  861. #--------------------------------------------------------------------------
  862. # 建立记录文件索引
  863. #--------------------------------------------------------------------------

  864. #--------------------------------------------------------------------------
  865. #  读取记录文件
  866. #     filename  : 被读取文件
  867. #--------------------------------------------------------------------------
  868. def load_file
  869.       # 文件不存在的情况下
  870.       unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
  871.         # 演奏冻结 SE
  872.         $game_system.se_play($data_system.buzzer_se)
  873.         return
  874.       end
  875.       # 演奏读档 SE
  876.       $game_system.se_play($data_system.load_se)
  877.       # 写入存档数据
  878.       file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "rb")
  879.       read_save_data(file)
  880.       file.close
  881.       # 还原 BGM、BGS
  882.       $game_system.bgm_play($game_system.playing_bgm)
  883.       $game_system.bgs_play($game_system.playing_bgs)
  884.       # 刷新地图 (执行并行事件)
  885.       $game_map.update
  886.       # 切换到地图画面
  887.       
  888.       
  889.       
  890.       
  891.       
  892.      
  893.     #   $a = {}
  894.    # $game_map.update
  895.       
  896.       
  897.       
  898.       
  899.       
  900.       $scene = Scene_Map.new
  901. end
  902. #--------------------------------------------------------------------------
  903. # ● 读取存档数据
  904. #     file : 读取用文件对像 (已经打开)
  905. #--------------------------------------------------------------------------
  906.   def read_save_data(file)
  907.     # 读取描绘存档文件用的角色数据
  908.     characters = Marshal.load(file)
  909.     # 读取测量游戏时间用画面计数
  910.     Graphics.frame_count = Marshal.load(file)
  911.     # 读取各种游戏对像
  912.     $game_system        = Marshal.load(file)
  913.     $game_switches      = Marshal.load(file)
  914.     $game_variables     = Marshal.load(file)
  915.     $game_self_switches = Marshal.load(file)
  916.     $game_screen        = Marshal.load(file)
  917.     $game_actors        = Marshal.load(file)
  918.     $game_party         = Marshal.load(file)
  919.     $game_troop         = Marshal.load(file)
  920.     $game_map           = Marshal.load(file)
  921.     $game_player        = Marshal.load(file)
  922.    
  923.    
  924.    
  925.    
  926.         $data_items         = Marshal.load(file)
  927.     $newitem            = Marshal.load(file)
  928.     $newitemx           = Marshal.load(file)
  929.     $newitemy           = Marshal.load(file)
  930.     $newitemm           = Marshal.load(file)
  931.    
  932.    
  933.    
  934.      $data_weapons       = Marshal.load(file)
  935.     $data_armors        = Marshal.load(file)
  936.     $data_classes       = Marshal.load(file)
  937.    
  938.    
  939.    
  940.    
  941.    
  942.    
  943.     # 魔法编号与保存时有差异的情况下
  944.     # (加入编辑器的编辑过的数据)
  945.     if $game_system.magic_number != $data_system.magic_number
  946.       # 重新装载地图
  947.       $game_map.setup($game_map.map_id)
  948.       $game_player.center($game_player.x, $game_player.y)
  949.     end
  950.     # 刷新同伴成员
  951.     $game_party.refresh
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # ● 写入存档文件
  955.   #--------------------------------------------------------------------------
  956.   def save_file
  957.     if Input.trigger?(Input::C)
  958.       unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
  959.         # 演奏冻结 SE
  960.         # 演奏存档 SE
  961.           $game_system.se_play($data_system.save_se)
  962.           # 写入存档数据
  963.          
  964.          
  965.          
  966.          
  967.           file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "wb")
  968.           write_save_data(file)
  969.           if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
  970.             File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
  971.           end
  972.          
  973.          
  974.          
  975.          
  976.           file.close
  977.           $game_temp.last_file_index = @command_window.index
  978.           # 如果被事件调用
  979.           if $game_temp.save_calling
  980.             # 清除存档调用标志
  981.             $game_temp.save_calling = false
  982.             @confirm_window.dispose
  983.             # 切换到地图画面
  984.             $scene = Scene_Map.new   
  985.             return
  986.           end
  987.         # 切换到菜单画面
  988.           $scene = Scene_Map.new  
  989.       end
  990.       @yes_no_window.active = true
  991.       @command_window.active = false            
  992.     end
  993.     #———————————————————————#     
  994.   end
  995.   #-------------------------------------------------------------------
  996.   def confirm_update
  997.     @command_index = @command_window.index
  998.     @confirm_window.visible = true
  999.     @confirm_window.z = 1500
  1000.     @yes_no_window.visible = true
  1001.     @yes_no_window.active = true
  1002.     @yes_no_window.z = 1500
  1003.     @yes_no_window.update
  1004.     if Input.trigger?(Input::C)
  1005.       if @yes_no_window.index == 0
  1006.           #######################################################
  1007.           # 演奏存档 SE
  1008.           $game_system.se_play($data_system.save_se)
  1009.           # 写入存档数据
  1010.           file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata",

  1011. "wb")
  1012.           write_save_data(file)
  1013.           if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
  1014.             File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
  1015.           end
  1016.           file.close
  1017.           $game_temp.last_file_index = @command_window.index
  1018.           # 如果被事件调用
  1019.           if $game_temp.save_calling
  1020.             # 清除存档调用标志
  1021.             $game_temp.save_calling = false
  1022.             @confirm_window.dispose
  1023.             @content_window.dispose
  1024.             # 切换到地图画面
  1025.             $scene = Scene_Map.new
  1026.    
  1027.             return
  1028.           end
  1029.         # 切换到菜单画面
  1030.           $scene = Scene_Map.new        
  1031.         else
  1032.         $game_system.se_play($data_system.cancel_se)
  1033.         @yes_no_window.active = false
  1034.         @command_window.active = true
  1035.         end
  1036.     end
  1037.     if Input.trigger?(Input::B)
  1038.       $game_system.se_play($data_system.cancel_se)
  1039.       @yes_no_window.active = false
  1040.       @command_window.active = true
  1041.     end
  1042.   end
  1043.   #--------------------------------------------------------------------------
  1044.   # ● 写入存档数据
  1045.   #     file : 写入用文件对像 (已经打开)
  1046.   #--------------------------------------------------------------------------
  1047.   def write_save_data(file)
  1048.     # 生成描绘存档文件用的角色图形
  1049.     characters = []
  1050.     for i in 0...$game_party.actors.size
  1051.       actor = $game_party.actors[i]
  1052.       characters.push([actor.character_name, actor.character_hue, actor])
  1053.     end
  1054.     # 写入描绘存档文件用的角色数据
  1055.     Marshal.dump(characters, file)
  1056.     # 写入测量游戏时间用画面计数
  1057.     Marshal.dump(Graphics.frame_count, file)
  1058.     # 增加 1 次存档次数
  1059.     $game_system.save_count += 1
  1060.     # 保存魔法编号
  1061.     # (将编辑器保存的值以随机值替换)
  1062.     $game_system.magic_number = $data_system.magic_number
  1063.     # 写入各种游戏对像
  1064.     Marshal.dump($game_system, file)
  1065.     Marshal.dump($game_switches, file)
  1066.     Marshal.dump($game_variables, file)
  1067.     Marshal.dump($game_self_switches, file)
  1068.     Marshal.dump($game_screen, file)
  1069.     Marshal.dump($game_actors, file)
  1070.     Marshal.dump($game_party, file)
  1071.     Marshal.dump($game_troop, file)
  1072.     Marshal.dump($game_map, file)
  1073.     Marshal.dump($game_player, file)
  1074.    
  1075.    
  1076.    
  1077.    
  1078.      
  1079.       Marshal.dump($data_items, file)
  1080.     Marshal.dump($newitem, file)
  1081.     Marshal.dump($newitemx, file)
  1082.     Marshal.dump($newitemy, file)
  1083.     Marshal.dump($newitemm, file)
  1084.    
  1085.    
  1086.     Marshal.dump($data_weapons, file)
  1087.     Marshal.dump($data_armors, file)
  1088.     Marshal.dump($data_classes, file)
  1089.    
  1090.    
  1091.    
  1092.    
  1093.    
  1094.    
  1095.   end
  1096. end

  1097. #==============================================================================
  1098. # ■ Window_LoadHelp
  1099. #------------------------------------------------------------------------------
  1100. #  存取档画面帮助信息的显示窗口。
  1101. #==============================================================================

  1102. class Window_LoadHelp < Window_Base
  1103. #--------------------------------------------------------------------------
  1104. #  初始化对象
  1105. #--------------------------------------------------------------------------
  1106. def initialize
  1107.   super(0, 0, 320, 64)
  1108.   self.contents = Bitmap.new(width - 32, height - 32)
  1109. end
  1110. #--------------------------------------------------------------------------
  1111. #  刷新文本
  1112. #--------------------------------------------------------------------------
  1113. def set_text(text, align = 1)
  1114.   if text != @text or align != @align
  1115.     self.contents.clear
  1116.     self.contents.font.color = normal_color
  1117.     self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
  1118.     @text = text
  1119.     @align = align
  1120.     @actor = nil
  1121.   end
  1122.   self.visible = true
  1123. end
  1124. end

  1125. #==============================================================================
  1126. #  Scene_Loadsave
  1127. #------------------------------------------------------------------------------
  1128. # 处理存取档画面的类。
  1129. #==============================================================================

  1130. class Scene_Loadsave
  1131. #--------------------------------------------------------------------------
  1132. # ● 初始化对像
  1133. #     $last_savefile_index : 记录光标位置
  1134. #--------------------------------------------------------------------------
  1135.   def initialize
  1136.     $last_savefile_index = 0 if $last_savefile_index == nil
  1137.     # 再生成临时对像
  1138.     $game_temp = Game_Temp.new
  1139.     # 选择存档时间最新的文件
  1140.     $game_temp.last_file_index = 0
  1141.     latest_time = Time.at(0)
  1142.     for i in 0..51
  1143.       filename = DIR+$username.to_s+"Save#{i}.rxdata"
  1144.       if FileTest.exist?(filename)
  1145.         file = File.open(filename, "r")
  1146.         if file.mtime > latest_time
  1147.           latest_time = file.mtime
  1148.           $game_temp.last_file_index = i
  1149.         end
  1150.         file.close
  1151.       end
  1152.     end
  1153.   end
  1154. #--------------------------------------------------------------------------
  1155. #  主处理
  1156. #--------------------------------------------------------------------------
  1157.   def main
  1158.     @savestate = 0
  1159.     # 生成窗口
  1160.     @help_window = Window_LoadHelp.new
  1161.     @help_window.set_text("小提示:在游戏中按下F5键自动存档.")
  1162.     @option_window = Window_LoadCommand.new
  1163.     @option_window.index = $last_savefile_index
  1164.    
  1165.     ########################################################
  1166.     @command_window = Window_Command.new(160,["自动存档","进度一","进度二",
  1167.       "进度三","进度四","进度五","进度六","进度七","进度八","进度九","进度十",
  1168.     ])
  1169.       @command_window.y = 64
  1170.       @command_window.height = 416
  1171.       @command_window.index = $game_temp.last_file_index
  1172.       @content_window = Window_File.new($game_temp.last_file_index)
  1173.       @command_window.active = false
  1174.         ###############覆盖存档
  1175.         @confirm_window = Window_Base.new(120, 188, 400, 64)
  1176.         @confirm_window.contents = Bitmap.new(368, 32)
  1177.         string = "确定要覆盖这个进度吗?"
  1178.         @confirm_window.contents.font.name = "黑体"
  1179.         @confirm_window.contents.font.size = 24
  1180.         @confirm_window.contents.draw_text(4, 0, 368, 32, string)
  1181.         @yes_no_window = Window_Command.new(100, ["覆盖", "取消"])
  1182.         @confirm_window.z = 1500
  1183.         @yes_no_window.index = 1
  1184.         @yes_no_window.x = 270
  1185.         @yes_no_window.y = 252
  1186.         @yes_no_window.z = 1500
  1187.         @confirm_window.visible = false
  1188.         @yes_no_window.visible = false
  1189.         @yes_no_window.active = false

  1190.     # 执行过渡
  1191.     Graphics.transition
  1192.     # 主循环
  1193.     loop do
  1194.       # 刷新游戏画面
  1195.       Graphics.update
  1196.       # 刷新输入信息
  1197.       Input.update
  1198.       # 刷新画面
  1199.       update
  1200.       # 如果画面被切换的话就中断循环
  1201.       if $scene != self
  1202.         break
  1203.       end
  1204.     end
  1205.     # 准备过渡
  1206.     Graphics.freeze
  1207.     # 释放窗口
  1208.     @command_window.dispose
  1209.     @content_window.dispose
  1210.     @confirm_window.dispose
  1211.     @yes_no_window.dispose
  1212.     @help_window.dispose
  1213.     @option_window.dispose

  1214.   end

  1215. #--------------------------------------------------------------------------
  1216. #  ● 刷新画面
  1217. #--------------------------------------------------------------------------
  1218.   def update
  1219.     # 刷新窗口
  1220.     @help_window.update
  1221.     @option_window.update
  1222. #   @content_window.update
  1223.     @command_window.update
  1224.     if @yes_no_window.active
  1225.         confirm_update
  1226.         return
  1227.     end
  1228.     @content_window.index = @command_window.index
  1229.     @content_window.refresh
  1230.     case @savestate
  1231.     when 0
  1232.         if Input.trigger?(Input::B)
  1233.         $game_system.se_play($data_system.cancel_se)
  1234.         # 淡入淡出 BGM
  1235.         Audio.bgm_fade(800)
  1236.         # 返回地图
  1237.         if $menu_call == false
  1238.         # 切换到地图画面
  1239.         $scene = Scene_Map.new
  1240.           return
  1241.         end
  1242.         # 切换到菜单画面
  1243.         $menu_call = false
  1244.         $scene = Scene_Menu.new(7)
  1245.      end
  1246.       if Input.trigger?(Input::C)
  1247.         case @option_window.index
  1248.         when 0
  1249.           @command_window.active = true
  1250.           @option_window.active = false
  1251.           $game_system.se_play($data_system.decision_se)
  1252.           @help_window.set_text("请选择一个文件进行读取.")
  1253.           @savestate  = 1
  1254.           return
  1255.         when 1
  1256.           @command_window.active = true
  1257.           @option_window.active = false
  1258.           $game_system.se_play($data_system.decision_se)
  1259.           @help_window.set_text("请选择一个文件进行存储.")
  1260.           @savestate = 2
  1261.          
  1262.           return
  1263.         return
  1264.         end
  1265.       end
  1266.     when 1,2
  1267.       if Input.trigger?(Input::C)
  1268.         if @savestate == 1
  1269.           $menu_call = false
  1270.           load_file
  1271.           return
  1272.         else
  1273.           # 禁止存档的情况下
  1274.           if $game_system.save_disabled
  1275.             @help_window.set_text("抱歉,这里禁止存储.")
  1276.             # 演奏冻结 SE
  1277.             $game_system.se_play($data_system.buzzer_se)
  1278.             return
  1279.           end
  1280.          $game_system.se_play($data_system.decision_se)
  1281.          $last_savefile_index = @option_window.index
  1282.   
  1283.          save_file
  1284.           return
  1285.         end
  1286.       end
  1287.       # 取消
  1288.       if Input.trigger?(Input::B)
  1289.         $game_system.se_play($data_system.cancel_se)
  1290.         @command_window.active = false
  1291.         @help_window.set_text("小提示:在游戏中按下F5键自动存档..")
  1292.         @savestate = 0
  1293.         @option_window.active = true
  1294.         return
  1295.       end
  1296.       
  1297.       if Input.trigger?(Input::B)
  1298.         $game_system.se_play($data_system.cancel_se)
  1299.         @savestate = 2
  1300.         @command_window.active = true

  1301.         return
  1302.       end
  1303.     end
  1304.   end
  1305. #--------------------------------------------------------------------------
  1306. # 建立记录文件索引
  1307. #--------------------------------------------------------------------------

  1308. #--------------------------------------------------------------------------
  1309. #  读取记录文件
  1310. #     filename  : 被读取文件
  1311. #--------------------------------------------------------------------------
  1312. def load_file
  1313.       # 文件不存在的情况下
  1314.       unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
  1315.         # 演奏冻结 SE
  1316.         $game_system.se_play($data_system.buzzer_se)
  1317.         return
  1318.       end
  1319.       # 演奏读档 SE
  1320.       $game_system.se_play($data_system.load_se)
  1321.       # 写入存档数据
  1322.       file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "rb")
  1323.       read_save_data(file)
  1324.       file.close
  1325.       # 还原 BGM、BGS
  1326.       $game_system.bgm_play($game_system.playing_bgm)
  1327.       $game_system.bgs_play($game_system.playing_bgs)
  1328.       # 刷新地图 (执行并行事件)
  1329.       $game_map.update
  1330.       # 切换到地图画面
  1331.       $scene = Scene_Map.new
  1332.     end
  1333.    
  1334.    
  1335.    
  1336.    
  1337.    
  1338.    
  1339.    
  1340.    
  1341.    
  1342.    
  1343.    
  1344.    
  1345.    
  1346.    
  1347.    
  1348. #--------------------------------------------------------------------------
  1349. # ● 读取存档数据
  1350. #     file : 读取用文件对像 (已经打开)
  1351. #--------------------------------------------------------------------------
  1352.   def read_save_data(file)
  1353.     # 读取描绘存档文件用的角色数据
  1354.     characters = Marshal.load(file)
  1355.     # 读取测量游戏时间用画面计数
  1356.     Graphics.frame_count = Marshal.load(file)
  1357.     # 读取各种游戏对像
  1358.     $game_system        = Marshal.load(file)
  1359.     $game_switches      = Marshal.load(file)
  1360.     $game_variables     = Marshal.load(file)
  1361.     $game_self_switches = Marshal.load(file)
  1362.     $game_screen        = Marshal.load(file)
  1363.     $game_actors        = Marshal.load(file)
  1364.     $game_party         = Marshal.load(file)
  1365.     $game_troop         = Marshal.load(file)
  1366.     $game_map           = Marshal.load(file)
  1367.     $game_player        = Marshal.load(file)
  1368.    
  1369.    
  1370.         $data_items         = Marshal.load(file)
  1371.     $newitem            = Marshal.load(file)
  1372.     $newitemx           = Marshal.load(file)
  1373.     $newitemy           = Marshal.load(file)
  1374.     $newitemm           = Marshal.load(file)
  1375.    
  1376.    
  1377.      $data_weapons       = Marshal.load(file)
  1378.     $data_armors        = Marshal.load(file)
  1379.     $data_classes       = Marshal.load(file)
  1380.    
  1381.    
  1382.    
  1383.   
  1384.    
  1385.     # 魔法编号与保存时有差异的情况下
  1386.     # (加入编辑器的编辑过的数据)
  1387.     if $game_system.magic_number != $data_system.magic_number
  1388.       # 重新装载地图
  1389.       $game_map.setup($game_map.map_id)
  1390.       $game_player.center($game_player.x, $game_player.y)
  1391.     end
  1392.     # 刷新同伴成员
  1393.     $game_party.refresh
  1394.   end
  1395.   #--------------------------------------------------------------------------
  1396.   # ● 写入存档文件
  1397.   #--------------------------------------------------------------------------
  1398.   def save_file
  1399.     if Input.trigger?(Input::C)
  1400.       unless FileTest.exist?(DIR+$username.to_s+"Save#{@command_window.index}.rxdata")
  1401.         # 演奏冻结 SE
  1402.         # 演奏存档 SE
  1403.           $game_system.se_play($data_system.save_se)
  1404.           # 写入存档数据
  1405.           file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "wb")
  1406.           write_save_data(file)
  1407.           if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
  1408.             File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
  1409.           end
  1410.           file.close
  1411.           $game_temp.last_file_index = @command_window.index
  1412.           # 如果被事件调用
  1413.           if $game_temp.save_calling
  1414.             # 清除存档调用标志
  1415.             $game_temp.save_calling = false
  1416.             @confirm_window.dispose
  1417.             # 切换到地图画面
  1418.             $scene = Scene_Map.new   
  1419.             return
  1420.           end
  1421.         # 切换到菜单画面
  1422.           $scene = Scene_Map.new  
  1423.       end
  1424.       @yes_no_window.active = true
  1425.       @command_window.active = false            
  1426.     end
  1427.     #———————————————————————#     
  1428.   end
  1429.   #-------------------------------------------------------------------
  1430.   def confirm_update
  1431.     @command_index = @command_window.index
  1432.     @confirm_window.visible = true
  1433.     @confirm_window.z = 1500
  1434.     @yes_no_window.visible = true
  1435.     @yes_no_window.active = true
  1436.     @yes_no_window.z = 1500
  1437.     @yes_no_window.update
  1438.     if Input.trigger?(Input::C)
  1439.       if @yes_no_window.index == 0
  1440.           #######################################################
  1441.           # 演奏存档 SE
  1442.           $game_system.se_play($data_system.save_se)
  1443.           # 写入存档数据
  1444.           file = File.open(DIR+$username.to_s+"Save#{@command_window.index}.rxdata", "wb")
  1445.           write_save_data(file)
  1446.           if FileTest.exist?(DIR+$username.to_s+"shot.jpg")
  1447.             File.rename(DIR+$username.to_s+"shot.jpg", DIR+$username.to_s+"Save#{@command_window.index}.jpg")
  1448.           end
  1449.           file.close
  1450.           $game_temp.last_file_index = @command_window.index
  1451.           # 如果被事件调用
  1452.           if $game_temp.save_calling
  1453.             # 清除存档调用标志
  1454.             $game_temp.save_calling = false
  1455.             @confirm_window.dispose
  1456.             @content_window.dispose
  1457.             # 切换到地图画面
  1458.             $scene = Scene_Map.new
  1459.    
  1460.             return
  1461.           end
  1462.         # 切换到菜单画面
  1463.           $scene = Scene_Map.new        
  1464.         else
  1465.         $game_system.se_play($data_system.cancel_se)
  1466.         @yes_no_window.active = false
  1467.         @command_window.active = true
  1468.         end
  1469.     end
  1470.     if Input.trigger?(Input::B)
  1471.       $game_system.se_play($data_system.cancel_se)
  1472.       @yes_no_window.active = false
  1473.       @command_window.active = true
  1474.     end
  1475.   end
  1476.   
  1477.   
  1478.   
  1479.   
  1480.   
  1481.   
  1482.   
  1483.   
  1484.   
  1485.   
  1486.   
  1487.   
  1488.   #--------------------------------------------------------------------------
  1489.   # ● 写入存档数据
  1490.   #     file : 写入用文件对像 (已经打开)
  1491.   #--------------------------------------------------------------------------
  1492.   def write_save_data(file)
  1493.     # 生成描绘存档文件用的角色图形
  1494.     characters = []
  1495.     for i in 0...$game_party.actors.size
  1496.       actor = $game_party.actors[i]
  1497.       characters.push([actor.character_name, actor.character_hue, actor])
  1498.     end
  1499.     # 写入描绘存档文件用的角色数据
  1500.     Marshal.dump(characters, file)
  1501.     # 写入测量游戏时间用画面计数
  1502.     Marshal.dump(Graphics.frame_count, file)
  1503.     # 增加 1 次存档次数
  1504.     $game_system.save_count += 1
  1505.     # 保存魔法编号
  1506.     # (将编辑器保存的值以随机值替换)
  1507.     $game_system.magic_number = $data_system.magic_number
  1508.     # 写入各种游戏对像
  1509.     Marshal.dump($game_system, file)
  1510.     Marshal.dump($game_switches, file)
  1511.     Marshal.dump($game_variables, file)
  1512.     Marshal.dump($game_self_switches, file)
  1513.     Marshal.dump($game_screen, file)
  1514.     Marshal.dump($game_actors, file)
  1515.     Marshal.dump($game_party, file)
  1516.     Marshal.dump($game_troop, file)
  1517.     Marshal.dump($game_map, file)
  1518.     Marshal.dump($game_player, file)
  1519.    
  1520.    
  1521.    
  1522.    
  1523.      
  1524.       Marshal.dump($data_items, file)
  1525.     Marshal.dump($newitem, file)
  1526.     Marshal.dump($newitemx, file)
  1527.     Marshal.dump($newitemy, file)
  1528.     Marshal.dump($newitemm, file)
  1529.    
  1530.    
  1531.     Marshal.dump($data_weapons, file)
  1532.     Marshal.dump($data_armors, file)
  1533.     Marshal.dump($data_classes, file)
  1534.    
  1535.    
  1536.   
  1537.    
  1538.    
  1539.    
  1540.   end
  1541. end
复制代码
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
帖子
1516
4
发表于 2015-5-29 17:32:23 | 只看该作者
看起来这些都不是。可能在其他的脚本里
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
207 小时
注册时间
2014-8-16
帖子
132
5
 楼主| 发表于 2015-5-30 21:38:25 | 只看该作者
汪汪 发表于 2015-5-29 17:32
看起来这些都不是。可能在其他的脚本里

问题自己已经解决!还是要谢谢大家的解答。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-23 03:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表