Project1

标题: 游戏中删除存档_v1.1 [打印本页]

作者: 一箭烂YiJL    时间: 2011-3-27 20:10
标题: 游戏中删除存档_v1.1
本帖最后由 一箭烂YiJL 于 2011-4-1 18:00 编辑

0.前言
不知道前人是否有做过类似这样的东西呢?
但是不可不承认的是这是一件很渣的东西,
嗯~由于是一时的无聊想法,所以它用了很短的时间制造,同时也很废。

1.版本功能说明
1.0                         : 按下delete按钮,就会删除存挡,如无存档,则发出错误一声。

1.1                         : 按下delete就会弹出选择窗, 然后选择删除。
1.1(载图存档版)     : 跟1.1功能一样,只是专用于载图存档
1.1(新式菜单版)     : 跟1.1功能一样,只是专用于新式菜单
1.1的载图存档版和新式菜单版没有范例,只在5.脚本里提供。


2. 1.1版效果载图

正常:

载图存档版:

新式菜单版:



3.范例
最简洁的:
删除存档_v1.0.zip (282.52 KB, 下载次数: 1907)
有窗口选择的:
删除存档_v1.1.zip (283.19 KB, 下载次数: 4242)


4.版本讯息
    - *1.1.0* (2011-04-01) By 一箭烂(YiJL)
      *会弹出选择窗选择是否删除

    - *1.0.0* (2011-04-27) By 一箭烂(YiJL)
      *初版


5.脚本

1.1载图存档版:


  1. #==============================================================================
  2. # ■ 删除存档v1.1(载图存档版)    by 一箭烂
  3. #------------------------------------------------------------------------------
  4. #  按下delete就会弹出选择窗, 然后选择删除。
  5. #
  6. #    - *1.1.0* (2011-04-01) By 一箭烂(YiJL)
  7. #      *会弹出选择窗选择是否删除
  8. #
  9. #    - *1.0.0* (2011-04-27) By 一箭烂(YiJL)
  10. #      *初版
  11. #==============================================================================
  12. class Scene_File
  13.   Key = Win32API.new("user32","GetAsyncKeyState","i","i")
  14.   #--------------------------------------------------------------------------
  15.   # ● 开始
  16.   #--------------------------------------------------------------------------
  17.   alias del_start start
  18.   def start
  19.     del_start
  20.     @del_window = Window_DelFile.new
  21.     @del_window.z = 500
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 更新幀
  25.   #--------------------------------------------------------------------------
  26.   alias del_update update
  27.   def update
  28.     del_update
  29.     @del_window.update
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 更新选择
  33.   #--------------------------------------------------------------------------
  34.   def update_savefile_selection
  35.     if Input.trigger?(Input::C)
  36.       if @del_window.visible
  37.         case @del_window.index
  38.         when 0
  39.           do_delete
  40.           @del_window.visible = false
  41.         when 1
  42.           @del_window.visible = false
  43.         end
  44.       else
  45.         determine_savefile
  46.       end
  47.     elsif Input.trigger?(Input::B)
  48.       if @del_window.visible
  49.         @del_window.visible = false
  50.       else
  51.         Sound.play_cancel
  52.         return_scene
  53.       end
  54.     elsif Key.call(0x2E) & 1 != 0
  55.       @del_window.visible = true
  56.     end
  57.     if @refresh_index != @command_window.index and @del_window.visible == false
  58.       @refresh_index = @command_window.index
  59.       @savefile_window.dispose
  60.       create_savefile_window
  61.     end
  62.     @command_window.active = !@del_window.visible
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 删除存档
  66.   #--------------------------------------------------------------------------
  67.   def do_delete
  68.     if FileTest.exist?(SAVE_DIR + make_filename(@command_window.index))
  69.       File.delete(SAVE_DIR + make_filename(@command_window.index))
  70.       @refresh_index = @command_window.index
  71.       @savefile_window.dispose
  72.       create_savefile_window
  73.     else
  74.       Sound.play_buzzer
  75.     end
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 退出场景
  79.   #--------------------------------------------------------------------------
  80.   alias del_terminate terminate
  81.   def terminate
  82.     del_terminate
  83.     @del_window.dispose
  84.   end
  85. end
  86. #==============================================================================
  87. # ■ Window_DelFile
  88. #==============================================================================
  89. class Window_DelFile < Window_Selectable
  90.   #--------------------------------------------------------------------------
  91.   # ● 对象初始化
  92.   #--------------------------------------------------------------------------
  93.   def initialize
  94.     super((544-250)/2, (416-100)/2, 250, 90)
  95.     self.contents.draw_text(0, 0, 250-32, 24, "是否删除存档?", 1)
  96.     self.contents.draw_text(0, 32, 93, 24, "是", 1)
  97.     self.contents.draw_text(125, 32, 93, 24, "否", 1)
  98.     @item_max = 2
  99.     @column_max = 2
  100.     @index = 1
  101.     self.visible = false
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 帧更新
  105.   #--------------------------------------------------------------------------
  106.   def update
  107.     super
  108.     if self.visible
  109.       if cursor_movable?
  110.         last_index = @index
  111.         if Input.repeat?(Input::DOWN)
  112.           cursor_down(Input.trigger?(Input::DOWN))
  113.         end
  114.         if Input.repeat?(Input::UP)
  115.           cursor_up(Input.trigger?(Input::UP))
  116.         end
  117.         if @index != last_index
  118.           Sound.play_cursor
  119.         end
  120.       end
  121.       update_cursor
  122.       call_update_help
  123.     end
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 选择矩形
  127.   #--------------------------------------------------------------------------
  128.   def item_rect(index)
  129.     rect = Rect.new(0, 0, 0, 0)
  130.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  131.     rect.height = WLH
  132.     rect.x = index % @column_max * (rect.width + @spacing)
  133.     rect.y = index / @column_max * WLH + 32
  134.     return rect
  135.   end
  136. end
复制代码
1.1新式菜单版:

  1. #==============================================================================
  2. # ■ 删除存档v1.1(新式菜单版)    by 一箭烂
  3. #------------------------------------------------------------------------------
  4. #  按下delete就会弹出选择窗, 然后选择删除。
  5. #
  6. #    - *1.1.0* (2011-04-01) By 一箭烂(YiJL)
  7. #      *会弹出选择窗选择是否删除
  8. #
  9. #    - *1.0.0* (2011-04-27) By 一箭烂(YiJL)
  10. #      *初版
  11. #==============================================================================
  12. class Scene_File < Scene_Menu_Base
  13.   Key = Win32API.new("user32","GetAsyncKeyState","i","i")
  14.   #--------------------------------------------------------------------------
  15.   # ● 开始
  16.   #--------------------------------------------------------------------------
  17.   alias del_start start
  18.   def start
  19.     del_start
  20.     @del_window = Window_DelFile.new
  21.     @del_window.z = 500
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 更新幀
  25.   #--------------------------------------------------------------------------
  26.   alias del_update update
  27.   def update
  28.     del_update
  29.     @del_window.update
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 更新选择
  33.   #--------------------------------------------------------------------------
  34.   def update_savefile_selection
  35.     if Input.trigger?(Input::C)
  36.       if @del_window.visible
  37.         case @del_window.index
  38.         when 0
  39.           do_delete
  40.           @del_window.visible = false
  41.         when 1
  42.           @del_window.visible = false
  43.         end
  44.       else
  45.         determine_savefile
  46.       end
  47.     elsif Input.trigger?(Input::B)
  48.       if @del_window.visible
  49.         @del_window.visible = false
  50.       else
  51.         Sound.play_cancel
  52.         return_scene
  53.       end
  54.     elsif Key.call(0x2E) & 1 != 0
  55.       @del_window.visible = true
  56.     end
  57.     if @refresh_index != @file_command_window.index and @del_window.visible == false
  58.       @refresh_index = @file_command_window.index
  59.       @savefile_window.dispose
  60.       create_savefile_window
  61.     end
  62.     @file_command_window.active = !@del_window.visible
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 删除存档
  66.   #--------------------------------------------------------------------------
  67.   def do_delete
  68.     if FileTest.exist?(SAVE_DIR + make_filename(@file_command_window.index))
  69.       File.delete(SAVE_DIR + make_filename(@file_command_window.index))
  70.       @refresh_index = @file_command_window.index
  71.       @savefile_window.dispose
  72.       create_savefile_window
  73.     else
  74.       Sound.play_buzzer
  75.     end
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 退出场景
  79.   #--------------------------------------------------------------------------
  80.   alias del_terminate terminate
  81.   def terminate
  82.     del_terminate
  83.     @del_window.dispose
  84.   end
  85. end
  86. #==============================================================================
  87. # ■ Window_DelFile
  88. #==============================================================================
  89. class Window_DelFile < Window_Selectable
  90.   #--------------------------------------------------------------------------
  91.   # ● 对象初始化
  92.   #--------------------------------------------------------------------------
  93.   def initialize
  94.     super((544-250)/2, (416-100)/2, 250, 90)
  95.     self.contents.draw_text(0, 0, 250-32, 24, "是否删除存档?", 1)
  96.     self.contents.draw_text(0, 32, 93, 24, "是", 1)
  97.     self.contents.draw_text(125, 32, 93, 24, "否", 1)
  98.     @item_max = 2
  99.     @column_max = 2
  100.     @index = 1
  101.     self.visible = false
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 帧更新
  105.   #--------------------------------------------------------------------------
  106.   def update
  107.     super
  108.     if self.visible
  109.       if cursor_movable?
  110.         last_index = @index
  111.         if Input.repeat?(Input::DOWN)
  112.           cursor_down(Input.trigger?(Input::DOWN))
  113.         end
  114.         if Input.repeat?(Input::UP)
  115.           cursor_up(Input.trigger?(Input::UP))
  116.         end
  117.         if @index != last_index
  118.           Sound.play_cursor
  119.         end
  120.       end
  121.       update_cursor
  122.       call_update_help
  123.     end
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 选择矩形
  127.   #--------------------------------------------------------------------------
  128.   def item_rect(index)
  129.     rect = Rect.new(0, 0, 0, 0)
  130.     rect.width = (contents.width + @spacing) / @column_max - @spacing
  131.     rect.height = WLH
  132.     rect.x = index % @column_max * (rect.width + @spacing)
  133.     rect.y = index / @column_max * WLH + 32
  134.     return rect
  135.   end
  136. end
复制代码


作者: 54酱    时间: 2011-3-27 20:15
貌似以前也有过一只这样的东西.......

忘了在哪里见过了...

脚本好像有100多行...

可能是XP的...

年纪大了...

脑子坏了...

什么都记不住了...

于是...

下载尝鲜...
作者: san9    时间: 2011-3-28 15:35
提示: 作者被禁止或删除 内容自动屏蔽
作者: 一箭烂YiJL    时间: 2011-4-1 18:01
更新了,顺便顶一下。这是版本跟新讯息:
    - *1.1.0* (2011-04-01) By 一箭烂(YiJL)
      *会弹出选择窗选择是否删除

    - *1.0.0* (2011-04-27) By 一箭烂(YiJL)
      *初版
作者: 冰舞蝶恋    时间: 2011-4-1 19:06
呼呼,还好地板还在~~剑兰前辈我爱你!~~~~
作者: 仲秋启明    时间: 2011-4-3 12:40
不错嘛,谢谢剑兰
作者: 2825136    时间: 2011-5-24 21:19
太美妙了~我傻傻的在测试游戏中将游戏存档了!幸亏我找到了这个~
作者: wen    时间: 2013-3-3 16:07
话说新式菜单不是存档很多吗?用这个好像没啥用。
(除非游戏太庞大,剧情太多,太难)
作者: 张咚咚    时间: 2013-7-28 13:50
好复杂...
↓直接删除Save文件夹下的指定存档↓

$i = 存档ID

for i in 1..4
File.delete("Save/Save#{$i}.rvdata") if
FileTest.exist?("Save/Save#{$i}.rvdata")
end




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1