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

Project1

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

[有事请教] 存檔欄位擴充腳本如何讓游標停在最後操作的檔案上

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1299
在线时间
305 小时
注册时间
2023-6-6
帖子
22
跳转到指定楼层
1
发表于 2023-9-2 16:52:49 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
10星屑
以下存檔擴充的腳本
如何讓游標停在最後操作的檔案上
比如存在第6個檔案
在讀取檔案時 游標就停在第6號檔案上
依此類推
像原内建一樣存哪裡游標就會在哪裡

RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4.  
  5.  
  6.  
  7. # --------------------------------------------------------------------
  8. # 本脚本来自[url]www.66rpg.com[/url],转载自[url]www.phylomortis.com[/url],转载请保留此信息
  9. # --------------------------------------------------------------------
  10. class Scene_File
  11.   #——最大存档数量,一般我认为最多50足够了,20比较合适
  12.   SAVEFILE_MAX = 30
  13.   # -------------------
  14.   def initialize(help_text)
  15.     @help_text = help_text
  16.   end
  17.   # -------------------
  18.   def main
  19.     @help_window = Window_Help.new
  20.     @help_window.set_text(@help_text)
  21.     @savefile_windows = []
  22.     @cursor_displace = 0
  23.     for i in 0..3
  24.       @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))
  25.     end
  26.     @file_index = 0
  27.     @savefile_windows[@file_index].selected = true
  28.     Graphics.transition
  29.     loop do
  30.       Graphics.update
  31.       Input.update
  32.       update
  33.       if $scene != self
  34.         break
  35.       end
  36.     end
  37.     Graphics.freeze
  38.     @help_window.dispose
  39.     for i in @savefile_windows
  40.       i.dispose
  41.     end
  42.   end
  43.   # -------------------
  44.   def update
  45.     @help_window.update
  46.     for i in @savefile_windows
  47.       i.update
  48.     end
  49.     if Input.trigger?(Input::C)
  50.       on_decision(make_filename(@file_index))
  51.       $game_temp.last_file_index = @file_index
  52.       return
  53.     end
  54.     if Input.trigger?(Input::B)
  55.       on_cancel
  56.       return
  57.     end
  58.     if Input.repeat?(Input::DOWN)
  59.       if Input.trigger?(Input::DOWN) or @file_index < SAVEFILE_MAX - 1
  60.         if @file_index == SAVEFILE_MAX - 1
  61.           $game_system.se_play($data_system.buzzer_se)
  62.           return
  63.         end
  64.         @cursor_displace += 1
  65.         if @cursor_displace == 4
  66.           @cursor_displace = 3
  67.           for i in @savefile_windows
  68.             i.dispose
  69.           end
  70.           @savefile_windows = []
  71.           for i in 0..3
  72.             f = i - 2 + @file_index
  73.             name = make_filename(f)
  74.             @savefile_windows.push(Window_SaveFile.new(f, name, i))
  75.             @savefile_windows[i].selected = false
  76.           end
  77.         end
  78.         $game_system.se_play($data_system.cursor_se)
  79.         @file_index = (@file_index + 1)
  80.         if @file_index == SAVEFILE_MAX
  81.           @file_index = SAVEFILE_MAX - 1
  82.         end
  83.         for i in 0..3
  84.           @savefile_windows[i].selected = false
  85.         end
  86.         @savefile_windows[@cursor_displace].selected = true
  87.         return
  88.       end
  89.     end
  90.     if Input.repeat?(Input::UP)
  91.       if Input.trigger?(Input::UP) or @file_index > 0
  92.         if @file_index == 0
  93.           $game_system.se_play($data_system.buzzer_se)
  94.           return
  95.         end
  96.         @cursor_displace -= 1
  97.         if @cursor_displace == -1
  98.           @cursor_displace = 0
  99.           for i in @savefile_windows
  100.             i.dispose
  101.           end
  102.           @savefile_windows = []
  103.           for i in 0..3
  104.             f = i - 1 + @file_index
  105.             name = make_filename(f)
  106.             @savefile_windows.push(Window_SaveFile.new(f, name, i))
  107.             @savefile_windows[i].selected = false
  108.           end
  109.         end
  110.         $game_system.se_play($data_system.cursor_se)
  111.         @file_index = (@file_index - 1)
  112.         if @file_index == -1
  113.           @file_index = 0
  114.         end
  115.         for i in 0..3
  116.           @savefile_windows[i].selected = false
  117.         end
  118.         @savefile_windows[@cursor_displace].selected = true
  119.         return
  120.       end
  121.     end
  122.   end
  123.   # -------------------
  124.   def make_filename(file_index)
  125.     return "Save#{file_index +1}.rxdata"
  126.   end
  127.   # -------------------
  128. end
  129.  
  130.  
  131.  
  132.  
  133. class Window_SaveFile < Window_Base
  134.   # -------------------
  135.   def initialize(file_index, filename, position)
  136.     y = 64 + position * 104
  137.     super(0, y, 640, 104)
  138.     self.contents = Bitmap.new(width - 32, height - 32)
  139.     @file_index = file_index
  140.     @filename = "Save#{@file_index +1}.rxdata"
  141.     @time_stamp = Time.at(0)
  142.     @file_exist = FileTest.exist?(@filename)
  143.     if @file_exist
  144.       file = File.open(@filename, "r")
  145.       @time_stamp = file.mtime
  146.       @characters = Marshal.load(file)
  147.       @frame_count = Marshal.load(file)
  148.       @game_system = Marshal.load(file)
  149.       @game_switches = Marshal.load(file)
  150.       @game_variables = Marshal.load(file)
  151.       @total_sec = @frame_count / Graphics.frame_rate
  152.       file.close
  153.     end
  154.     refresh
  155.     @selected = false
  156.   end
  157. end
  158.  
  159.  
  160. #==============================================================================
  161. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  162. #==============================================================================

Lv3.寻梦者

梦石
0
星屑
1299
在线时间
305 小时
注册时间
2023-6-6
帖子
22
2
 楼主| 发表于 2023-9-2 18:53:45 | 显示全部楼层
soulsaga 发表于 2023-9-2 17:39
#--------------------------------------------------------------------------
  # ● 主处理
  #------- ...

你這個跟我貼的那個腳本不同吧
你這個還有新的窗口Window_SavePage.new
應該不太一樣
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1299
在线时间
305 小时
注册时间
2023-6-6
帖子
22
3
 楼主| 发表于 2023-9-4 20:22:16 | 显示全部楼层
Istrien 发表于 2023-9-4 01:12
看到你的脚本中每次存档时仍然记录了档案编号(第 51 行):

那么进入存读档界面时,将光标位置设为先前的 ...

照你的方式修改了
存檔介面是成功達到我想要的效果了
可是讀取檔案的介面只有存1~4欄位會正常
存到5~30之後 讀檔時  光標總是停在第2欄位

其實我只是想要和基本內建時只有4個檔案時的效果一樣
存在1時 打開存檔或讀取 光標都會在1
如果這時存在3  那再次開啟存檔或讀取時光標會在3
而這時如果又存新的檔案覆蓋1號  那下次打開存檔或讀取時  光標會ˋ自動停在1號  這個樣子

目前依你的方式修改  存檔是達到效果了  讀取卻沒有
還是很感謝你
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1299
在线时间
305 小时
注册时间
2023-6-6
帖子
22
4
 楼主| 发表于 2023-9-4 21:33:19 | 显示全部楼层
SailCat 发表于 2023-9-4 20:58
你的这个插件版本过老了
https://rpg.blue/thread-403346-1-1.html

其實之前有看到貓大的這份腳本
確實非常強大
可是總覺得有些玩家天生叛逆  存檔時不是從一號位開始存檔 而是先存在 第5位 第9位 之類的
所以一直在考慮

不過我現在思考思考……
或許不要執著才是對的QQ

決定了 就認可貓大的答案了
也很感謝@Istrien 的解答

謝謝你們
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-12 05:58

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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