Project1

标题: (已解决)求教,YEA存档显示变量,变量怎么显示文本? [打印本页]

作者: 火锅深处    时间: 2019-7-2 19:03
标题: (已解决)求教,YEA存档显示变量,变量怎么显示文本?
本帖最后由 火锅深处 于 2019-7-2 21:00 编辑

一般来说变量在脚本那个空里用英文双引号中间写文本就可以把变量显示变成文本了,但是Yanfly大佬这个脚本好像变量只能显示数字,否则就会报错。
我去原网那边看,这个脚本11年发出来以后15年还是有人提了变量不能显示文本的问题,所以估计现在也一样......
所以各位有什么解决方法吗?

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - 存档系统 v1.03
  4. # -- 最后更新: 2012.07.22
  5. # -- 使用难度: 普通
  6. # -- 需要脚本: 无
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SaveEngine"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.07.22 - Fixed: Location Drawing.
  17. # 2012.01.23 - Anti-crash method added for removed maps.
  18. # 2011.12.26 - Compatibility Update: New Game+
  19. # 2011.12.26 - Started Script and Finished.
  20. #
  21. #==============================================================================
  22. # ▼ 介绍
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # 本脚本为玩家提供一个新式存档界面,可以直接在存档界面读档或删除存档。同时为玩家
  25. # 显示更多的存档信息,例如地点、所持金钱以及其他任何你想要显示的变量。
  26. #
  27. # 如果你第一次使用此脚本,查看旧存档文件可能会出现丢失部分存档数据的情况,这时候
  28. # 需要你重新读档并再次存档。
  29. #
  30. #==============================================================================
  31. # ▼ 安装方式
  32. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. # 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
  34. # 脚本页/槽中.记得保存你的工程以使脚本生效.
  35. #
  36. #==============================================================================
  37. # ▼ 兼容性
  38. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39. # 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
  40. #
  41. #==============================================================================
  42.  
  43. module YEA
  44.   module SAVE
  45.  
  46.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  47.     # - 存档文件窗口设置 -
  48.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  49.  
  50.     MAX_FILES = 32         # 最大存档数. 默认: 16
  51.     SLOT_NAME = "文件 %s"  # 存档文件文本.
  52.  
  53.     # These are the icons
  54.     SAVE_ICON  = 368       # 已存档的图标
  55.     EMPTY_ICON = 375       # 未存档的图标
  56.  
  57.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58.     # - 指令窗口设置 -
  59.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  60.  
  61.     ACTION_LOAD   = "载入"           # 载入的文本.
  62.     ACTION_SAVE   = "存档"           # 存档的文本.
  63.     ACTION_DELETE = "删除"           # 删除的文本.
  64.     DELETE_SOUND  = RPG::SE.new("Collapse3", 100, 100) # 删除的音效.
  65.  
  66.     # 在帮助窗口中显示的文本.
  67.     SELECT_HELP = "请选择一个存档文件."
  68.     LOAD_HELP   = "从已保存数据中载入."
  69.     SAVE_HELP   = "保存当前游戏数据."
  70.     DELETE_HELP = "删除全部已保存数据."
  71.  
  72.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  73.     # - 游戏状态窗口文本 -
  74.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  75.  
  76.     EMPTY_TEXT = "无存档数据"      # 无存档数据的文本.
  77.     PLAYTIME   = "游戏时间"        # 显示游戏时间的文本.
  78.     TOTAL_SAVE = "存档次数: "      # 存档次数的文本.
  79.     TOTAL_GOLD = "总金钱数: "      # 总金钱数的文本.
  80. #   LOCATION   = "地点: "          # 地点的文本.
  81.  
  82.     # 在数组中填入你想要显示变量数值的变量ID,0为不显示
  83.     COLUMN1_VARIABLES = [1, 2, 3]
  84.     COLUMN2_VARIABLES = [4, 5, 6]
  85.  
  86.   end # SAVE
  87. end # YEA
  88.  
  89. #==============================================================================
  90. # ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
  91. # 所以编辑了后果自负。
  92. #==============================================================================
  93.  
  94. #==============================================================================
  95. # ■ Icon
  96. #==============================================================================
  97.  
  98. module Icon
  99.  
  100.   #--------------------------------------------------------------------------
  101.   # self.save_icon
  102.   #--------------------------------------------------------------------------
  103.   def self.save_icon; return YEA::SAVE::SAVE_ICON; end
  104.  
  105.   #--------------------------------------------------------------------------
  106.   # self.empty_icon
  107.   #--------------------------------------------------------------------------
  108.   def self.empty_icon; return YEA::SAVE::EMPTY_ICON; end
  109.  
  110. end # Icon
  111.  
  112. #==============================================================================
  113. # ■ Numeric
  114. #==============================================================================
  115.  
  116. class Numeric
  117.  
  118.   #--------------------------------------------------------------------------
  119.   # new method: group_digits
  120.   #--------------------------------------------------------------------------
  121.   unless $imported["YEA-CoreEngine"]
  122.   def group; return self.to_s; end
  123.   end # $imported["YEA-CoreEngine"]
  124.  
  125. end # Numeric
  126.  
  127. #==============================================================================
  128. # ■ DataManager
  129. #==============================================================================
  130.  
  131. module DataManager
  132.  
  133.   #--------------------------------------------------------------------------
  134.   # overwrite method: savefile_max
  135.   #--------------------------------------------------------------------------
  136.   def self.savefile_max
  137.     return YEA::SAVE::MAX_FILES
  138.   end
  139.  
  140.   #--------------------------------------------------------------------------
  141.   # overwrite method: self.make_save_header
  142.   #--------------------------------------------------------------------------
  143.   def self.make_save_header
  144.     header = {}
  145.     header[:characters]    = $game_party.characters_for_savefile
  146.     header[:playtime_s]    = $game_system.playtime_s
  147.     header[:system]        = Marshal.load(Marshal.dump($game_system))
  148.     header[:timer]         = Marshal.load(Marshal.dump($game_timer))
  149.     header[:message]       = Marshal.load(Marshal.dump($game_message))
  150.     header[:switches]      = Marshal.load(Marshal.dump($game_switches))
  151.     header[:variables]     = Marshal.load(Marshal.dump($game_variables))
  152.     header[:self_switches] = Marshal.load(Marshal.dump($game_self_switches))
  153.     header[:actors]        = Marshal.load(Marshal.dump($game_actors))
  154.     header[:party]         = Marshal.load(Marshal.dump($game_party))
  155.     header[:troop]         = Marshal.load(Marshal.dump($game_troop))
  156.     header[:map]           = Marshal.load(Marshal.dump($game_map))
  157.     header[:player]        = Marshal.load(Marshal.dump($game_player))
  158.     header
  159.   end
  160.  
  161. end # DataManager
  162.  
  163. #==============================================================================
  164. # ■ Window_MenuCommand
  165. #==============================================================================
  166.  
  167. class Window_MenuCommand < Window_Command
  168.  
  169.   #--------------------------------------------------------------------------
  170.   # overwrite method: save_enabled
  171.   #--------------------------------------------------------------------------
  172.   def save_enabled; return true; end
  173.  
  174. end # Window_MenuCommand
  175.  
  176. #==============================================================================
  177. # ■ Window_FileList
  178. #==============================================================================
  179.  
  180. class Window_FileList < Window_Selectable
  181.  
  182.   #--------------------------------------------------------------------------
  183.   # initialize
  184.   #--------------------------------------------------------------------------
  185.   def initialize(dx, dy)
  186.     super(dx, dy, 128, Graphics.height - dy)
  187.     refresh
  188.     activate
  189.     select(SceneManager.scene.first_savefile_index)
  190.   end
  191.  
  192.   #--------------------------------------------------------------------------
  193.   # item_max
  194.   #--------------------------------------------------------------------------
  195.   def item_max; return DataManager.savefile_max; end
  196.  
  197.   #--------------------------------------------------------------------------
  198.   # current_item_enabled?
  199.   #--------------------------------------------------------------------------
  200.   def current_item_enabled?
  201.     header = DataManager.load_header(index)
  202.     return false if header.nil? && SceneManager.scene_is?(Scene_Load)
  203.     return true
  204.   end
  205.  
  206.   #--------------------------------------------------------------------------
  207.   # refresh
  208.   #--------------------------------------------------------------------------
  209.   def refresh
  210.     create_contents
  211.     draw_all_items
  212.   end
  213.  
  214.   #--------------------------------------------------------------------------
  215.   # draw_item
  216.   #--------------------------------------------------------------------------
  217.   def draw_item(index)
  218.     header = DataManager.load_header(index)
  219.     enabled = !header.nil?
  220.     rect = item_rect(index)
  221.     rect.width -= 4
  222.     draw_icon(save_icon?(header), rect.x, rect.y, enabled)
  223.     change_color(normal_color, enabled)
  224.     text = sprintf(YEA::SAVE::SLOT_NAME, (index + 1).group)
  225.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  226.   end
  227.  
  228.   #--------------------------------------------------------------------------
  229.   # save_icon?
  230.   #--------------------------------------------------------------------------
  231.   def save_icon?(header)
  232.     return Icon.empty_icon if header.nil?
  233.     return Icon.save_icon
  234.   end
  235.  
  236. end # Window_FileList
  237.  
  238. #==============================================================================
  239. # ■ Window_FileStatus
  240. #==============================================================================
  241.  
  242. class Window_FileStatus < Window_Base
  243.  
  244.   #--------------------------------------------------------------------------
  245.   # initialize
  246.   #--------------------------------------------------------------------------
  247.   def initialize(dx, dy, file_window)
  248.     super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  249.     @file_window = file_window
  250.     @current_index = @file_window.index
  251.     refresh
  252.   end
  253.  
  254.   #--------------------------------------------------------------------------
  255.   # update
  256.   #--------------------------------------------------------------------------
  257.   def update
  258.     super
  259.     return if @file_window.index < 0
  260.     return if @current_index == @file_window.index
  261.     @current_index = @file_window.index
  262.     refresh
  263.   end
  264.  
  265.   #--------------------------------------------------------------------------
  266.   # refresh
  267.   #--------------------------------------------------------------------------
  268.   def refresh
  269.     contents.clear
  270.     reset_font_settings
  271.     @header = DataManager.load_header(@file_window.index)
  272.     if @header.nil?
  273.       draw_empty
  274.     else
  275.       draw_save_contents
  276.     end
  277.   end
  278.  
  279.   #--------------------------------------------------------------------------
  280.   # draw_empty
  281.   #--------------------------------------------------------------------------
  282.   def draw_empty
  283.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  284.     rect = Rect.new(0, 0, contents.width, contents.height)
  285.     contents.fill_rect(rect, colour)
  286.     text = YEA::SAVE::EMPTY_TEXT
  287.     change_color(system_color)
  288.     draw_text(rect, text, 1)
  289.   end
  290.  
  291.   #--------------------------------------------------------------------------
  292.   # draw_save_slot
  293.   #--------------------------------------------------------------------------
  294.   def draw_save_slot(dx, dy, dw)
  295.     reset_font_settings
  296.     change_color(system_color)
  297.     text = sprintf(YEA::SAVE::SLOT_NAME, "")
  298.     draw_text(dx, dy, dw, line_height, text)
  299.     cx = text_size(text).width
  300.     change_color(normal_color)
  301.     draw_text(dx+cx, dy, dw-cx, line_height, (@file_window.index+1).group)
  302.   end
  303.  
  304.   #--------------------------------------------------------------------------
  305.   # draw_save_playtime
  306.   #--------------------------------------------------------------------------
  307.   def draw_save_playtime(dx, dy, dw)
  308.     return if @header[:playtime_s].nil?
  309.     reset_font_settings
  310.     change_color(system_color)
  311.     draw_text(dx, dy, dw, line_height, YEA::SAVE::PLAYTIME, 0)
  312.     change_color(normal_color)
  313.     draw_text(dx, dy, dw, line_height, @header[:playtime_s], 2)
  314.   end
  315.  
  316.   #--------------------------------------------------------------------------
  317.   # draw_save_total_saves
  318.   #--------------------------------------------------------------------------
  319.   def draw_save_total_saves(dx, dy, dw)
  320.     return if @header[:system].nil?
  321.     reset_font_settings
  322.     change_color(system_color)
  323.     text = YEA::SAVE::TOTAL_SAVE
  324.     draw_text(dx, dy, dw, line_height, text)
  325.     cx = text_size(text).width
  326.     change_color(normal_color)
  327.     draw_text(dx+cx, dy, dw-cx, line_height, @header[:system].save_count.group)
  328.   end
  329.  
  330.   #--------------------------------------------------------------------------
  331.   # draw_save_gold
  332.   #--------------------------------------------------------------------------
  333.   def draw_save_gold(dx, dy, dw)
  334.     return if @header[:party].nil?
  335.     reset_font_settings
  336.     change_color(system_color)
  337.     draw_text(dx, dy, dw, line_height, YEA::SAVE::TOTAL_GOLD)
  338.     text = Vocab::currency_unit
  339.     draw_text(dx, dy, dw, line_height, text, 2)
  340.     cx = text_size(text).width
  341.     change_color(normal_color)
  342.     text = @header[:party].gold.group
  343.     draw_text(dx, dy, dw-cx, line_height, text, 2)
  344.   end
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # draw_save_location
  348.   #--------------------------------------------------------------------------
  349. #  def draw_save_location(dx, dy, dw)
  350. #   return if @header[:map].nil?
  351.   #  reset_font_settings
  352.    # change_color(system_color)
  353.     #draw_text(dx, dy, dw, line_height, YEA::SAVE::LOCATION)
  354.     #change_color(normal_color)
  355.     #cx = text_size(YEA::SAVE::LOCATION).width
  356.     #return if $data_mapinfos[@header[:map].map_id].nil?
  357.     #text = @header[:map].display_name
  358.     #text = $data_mapinfos[@header[:map].map_id].name if text == ""
  359.     #draw_text(dx+cx, dy, dw-cx, line_height, text)
  360.   #end
  361.  
  362.   #--------------------------------------------------------------------------
  363.   # draw_save_characters
  364.   #--------------------------------------------------------------------------
  365.   def draw_save_characters(dx, dy)
  366.     return if @header[:party].nil?
  367.     reset_font_settings
  368.     make_font_smaller
  369.     dw = (contents.width - dx) / @header[:party].max_battle_members
  370.     dx += dw/2
  371.     for member in @header[:party].battle_members
  372.       next if member.nil?
  373.       member = @header[:actors][member.id]
  374.       change_color(normal_color)
  375.       draw_actor_graphic(member, dx, dy)
  376.       text = member.name
  377.       draw_text(dx-dw/2, dy, dw, line_height, text, 1)
  378.       text = member.level.group
  379.       draw_text(dx-dw/2, dy-line_height, dw-4, line_height, text, 2)
  380.       cx = text_size(text).width
  381.       change_color(system_color)
  382.       text = Vocab::level_a
  383.       draw_text(dx-dw/2, dy-line_height, dw-cx-4, line_height, text, 2)
  384.       dx += dw
  385.     end
  386.   end
  387.  
  388.   #--------------------------------------------------------------------------
  389.   # draw_save_column1
  390.   #--------------------------------------------------------------------------
  391.   def draw_save_column1(dx, dy, dw)
  392.     data = YEA::SAVE::COLUMN1_VARIABLES
  393.     draw_column_data(data, dx, dy, dw)
  394.   end
  395.  
  396.   #--------------------------------------------------------------------------
  397.   # draw_save_column2
  398.   #--------------------------------------------------------------------------
  399.   def draw_save_column2(dx, dy, dw)
  400.     data = YEA::SAVE::COLUMN2_VARIABLES
  401.     draw_column_data(data, dx, dy, dw)
  402.   end
  403.  
  404.   #--------------------------------------------------------------------------
  405.   # draw_column_data
  406.   #--------------------------------------------------------------------------
  407.   def draw_column_data(data, dx, dy, dw)
  408.     return if @header[:variables].nil?
  409.     reset_font_settings
  410.     for variable_id in data
  411.       next if $data_system.variables[variable_id].nil?
  412.       change_color(system_color)
  413.       name = $data_system.variables[variable_id]
  414.       draw_text(dx, dy, dw, line_height, name, 0)
  415.       value = @header[:variables][variable_id].group
  416.       change_color(normal_color)
  417.       draw_text(dx, dy, dw, line_height, value, 2)
  418.       dy += line_height
  419.     end
  420.   end
  421.  
  422.   #--------------------------------------------------------------------------
  423.   # draw_save_contents
  424.   #--------------------------------------------------------------------------
  425.   def draw_save_contents
  426.     draw_save_slot(4, 0, contents.width/2-8)
  427.     draw_save_playtime(contents.width/2+4, 0, contents.width/2-8)
  428.     draw_save_total_saves(4, line_height, contents.width/2-8)
  429.     draw_save_gold(contents.width/2+4, line_height, contents.width/2-8)
  430. #    draw_save_location(4, line_height*2, contents.width-8)
  431.     draw_save_characters(0, line_height*5 + line_height/3)
  432.     draw_save_column1(16, line_height*7, contents.width/2-48)
  433.     draw_save_column2(contents.width/2+16, line_height*7, contents.width/2-48)
  434.   end
  435.  
  436. end # Window_FileStatus
  437.  
  438. #==============================================================================
  439. # ■ Window_FileAction
  440. #==============================================================================
  441.  
  442. class Window_FileAction < Window_HorzCommand
  443.  
  444.   #--------------------------------------------------------------------------
  445.   # initialize
  446.   #--------------------------------------------------------------------------
  447.   def initialize(dx, dy, file_window)
  448.     @file_window = file_window
  449.     super(dx, dy)
  450.     deactivate
  451.     unselect
  452.   end
  453.  
  454.   #--------------------------------------------------------------------------
  455.   # window_width
  456.   #--------------------------------------------------------------------------
  457.   def window_width; Graphics.width - 128; end
  458.  
  459.   #--------------------------------------------------------------------------
  460.   # col_max
  461.   #--------------------------------------------------------------------------
  462.   def col_max; return 3; end
  463.  
  464.   #--------------------------------------------------------------------------
  465.   # update
  466.   #--------------------------------------------------------------------------
  467.   def update
  468.     super
  469.     return if @file_window.index < 0
  470.     return if @current_index == @file_window.index
  471.     @current_index = @file_window.index
  472.     refresh
  473.   end
  474.  
  475.   #--------------------------------------------------------------------------
  476.   # make_command_list
  477.   #--------------------------------------------------------------------------
  478.   def make_command_list
  479.     @header = DataManager.load_header(@file_window.index)
  480.     add_load_command
  481.     add_save_command
  482.     add_delete_command
  483.   end
  484.  
  485.   #--------------------------------------------------------------------------
  486.   # add_load_command
  487.   #--------------------------------------------------------------------------
  488.   def add_load_command
  489.     add_command(YEA::SAVE::ACTION_LOAD, :load, load_enabled?)
  490.   end
  491.  
  492.   #--------------------------------------------------------------------------
  493.   # load_enabled?
  494.   #--------------------------------------------------------------------------
  495.   def load_enabled?
  496.     return false if @header.nil?
  497.     return true
  498.   end
  499.  
  500.   #--------------------------------------------------------------------------
  501.   # add_save_command
  502.   #--------------------------------------------------------------------------
  503.   def add_save_command
  504.     add_command(YEA::SAVE::ACTION_SAVE, :save, save_enabled?)
  505.   end
  506.  
  507.   #--------------------------------------------------------------------------
  508.   # save_enabled?
  509.   #--------------------------------------------------------------------------
  510.   def save_enabled?
  511.     return false if @header.nil? && SceneManager.scene_is?(Scene_Load)
  512.     return false if SceneManager.scene_is?(Scene_Load)
  513.     return false if $game_system.save_disabled
  514.     return true
  515.   end
  516.  
  517.   #--------------------------------------------------------------------------
  518.   # add_delete_command
  519.   #--------------------------------------------------------------------------
  520.   def add_delete_command
  521.     add_command(YEA::SAVE::ACTION_DELETE, :delete, delete_enabled?)
  522.   end
  523.  
  524.   #--------------------------------------------------------------------------
  525.   # delete_enabled?
  526.   #--------------------------------------------------------------------------
  527.   def delete_enabled?
  528.     return false if @header.nil?
  529.     return true
  530.   end
  531.  
  532.   #--------------------------------------------------------------------------
  533.   # update_help
  534.   #--------------------------------------------------------------------------
  535.   def update_help
  536.     case current_symbol
  537.     when :load; @help_window.set_text(YEA::SAVE::LOAD_HELP)
  538.     when :save; @help_window.set_text(YEA::SAVE::SAVE_HELP)
  539.     when :delete; @help_window.set_text(YEA::SAVE::DELETE_HELP)
  540.     end
  541.   end
  542.  
  543. end # Window_FileAction
  544.  
  545. #==============================================================================
  546. # ■ Scene_File
  547. #==============================================================================
  548.  
  549. class Scene_File < Scene_MenuBase
  550.  
  551.   #--------------------------------------------------------------------------
  552.   # overwrite method: start
  553.   #--------------------------------------------------------------------------
  554.   def start
  555.     super
  556.     create_all_windows
  557.   end
  558.  
  559.   #--------------------------------------------------------------------------
  560.   # overwrite method: terminate
  561.   #--------------------------------------------------------------------------
  562.   def terminate
  563.     super
  564.   end
  565.  
  566.   #--------------------------------------------------------------------------
  567.   # overwrite method: update
  568.   #--------------------------------------------------------------------------
  569.   def update
  570.     super
  571.   end
  572.  
  573.   #--------------------------------------------------------------------------
  574.   # new method: create_all_windows
  575.   #--------------------------------------------------------------------------
  576.   def create_all_windows
  577.     create_help_window
  578.     create_file_window
  579.     create_action_window
  580.     create_status_window
  581.   end
  582.  
  583.   #--------------------------------------------------------------------------
  584.   # overwrite method: create_help_window
  585.   #--------------------------------------------------------------------------
  586.   def create_help_window
  587.     @help_window = Window_Help.new
  588.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  589.   end
  590.  
  591.   #--------------------------------------------------------------------------
  592.   # new method: create_file_window
  593.   #--------------------------------------------------------------------------
  594.   def create_file_window
  595.     wy = @help_window.height
  596.     @file_window = Window_FileList.new(0, wy)
  597.     @file_window.set_handler(:ok, method(:on_file_ok))
  598.     @file_window.set_handler(:cancel, method(:return_scene))
  599.   end
  600.  
  601.   #--------------------------------------------------------------------------
  602.   # new method: create_action_window
  603.   #--------------------------------------------------------------------------
  604.   def create_action_window
  605.     wx = @file_window.width
  606.     wy = @help_window.height
  607.     @action_window = Window_FileAction.new(wx, wy, @file_window)
  608.     @action_window.help_window = @help_window
  609.     @action_window.set_handler(:cancel, method(:on_action_cancel))
  610.     @action_window.set_handler(:load, method(:on_action_load))
  611.     @action_window.set_handler(:save, method(:on_action_save))
  612.     @action_window.set_handler(:delete, method(:on_action_delete))
  613.   end
  614.  
  615.   #--------------------------------------------------------------------------
  616.   # new method: create_status_window
  617.   #--------------------------------------------------------------------------
  618.   def create_status_window
  619.     wx = @action_window.x
  620.     wy = @action_window.y + @action_window.height
  621.     @status_window = Window_FileStatus.new(wx, wy, @file_window)
  622.   end
  623.  
  624.   #--------------------------------------------------------------------------
  625.   # new method: on_file_ok
  626.   #--------------------------------------------------------------------------
  627.   def on_file_ok
  628.     @action_window.activate
  629.     index = SceneManager.scene_is?(Scene_Load) ? 0 : 1
  630.     @action_window.select(index)
  631.   end
  632.  
  633.   #--------------------------------------------------------------------------
  634.   # new method: on_action_cancel
  635.   #--------------------------------------------------------------------------
  636.   def on_action_cancel
  637.     @action_window.unselect
  638.     @file_window.activate
  639.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  640.   end
  641.  
  642.   #--------------------------------------------------------------------------
  643.   # new method: on_action_load
  644.   #--------------------------------------------------------------------------
  645.   def on_action_load
  646.     if DataManager.load_game(@file_window.index)
  647.       on_load_success
  648.     else
  649.       Sound.play_buzzer
  650.     end
  651.   end
  652.  
  653.   #--------------------------------------------------------------------------
  654.   # overwrite method: on_load_success
  655.   #--------------------------------------------------------------------------
  656.   def on_load_success
  657.     Sound.play_load
  658.     fadeout_all
  659.     $game_system.on_after_load
  660.     SceneManager.goto(Scene_Map)
  661.   end
  662.  
  663.   #--------------------------------------------------------------------------
  664.   # new method: on_action_save
  665.   #--------------------------------------------------------------------------
  666.   def on_action_save
  667.     @action_window.activate
  668.     if DataManager.save_game(@file_window.index)
  669.       on_save_success
  670.       refresh_windows
  671.     else
  672.       Sound.play_buzzer
  673.     end
  674.   end
  675.  
  676.   #--------------------------------------------------------------------------
  677.   # overwrite method: on_save_success
  678.   #--------------------------------------------------------------------------
  679.   def on_save_success; Sound.play_save; end
  680.  
  681.   #--------------------------------------------------------------------------
  682.   # new method: on_action_delete
  683.   #--------------------------------------------------------------------------
  684.   def on_action_delete
  685.     @action_window.activate
  686.     DataManager.delete_save_file(@file_window.index)
  687.     on_delete_success
  688.     refresh_windows
  689.   end
  690.  
  691.   #--------------------------------------------------------------------------
  692.   # new method: on_delete_success
  693.   #--------------------------------------------------------------------------
  694.   def on_delete_success
  695.     YEA::SAVE::DELETE_SOUND.play
  696.   end
  697.  
  698.   #--------------------------------------------------------------------------
  699.   # new method: refresh_windows
  700.   #--------------------------------------------------------------------------
  701.   def refresh_windows
  702.     @file_window.refresh
  703.     @action_window.refresh
  704.     @status_window.refresh
  705.   end
  706.  
  707. end # Scene_File
  708.  
  709. #==============================================================================
  710. # ■ Scene_Save
  711. #==============================================================================
  712.  
  713. class Scene_Save < Scene_File
  714.  
  715.   #--------------------------------------------------------------------------
  716.   # overwrite method: on_savefile_ok
  717.   #--------------------------------------------------------------------------
  718.   def on_savefile_ok; super; end
  719.  
  720.   #--------------------------------------------------------------------------
  721.   # overwrite method: on_save_success
  722.   #--------------------------------------------------------------------------
  723.   def on_save_success; super; end
  724.  
  725. end # help_window_text
  726.  
  727. #==============================================================================
  728. # ■ Scene_Load
  729. #==============================================================================
  730.  
  731. class Scene_Load < Scene_File
  732.  
  733.   #--------------------------------------------------------------------------
  734.   # overwrite method: on_savefile_ok
  735.   #--------------------------------------------------------------------------
  736.   def on_savefile_ok; super; end
  737.  
  738.   #--------------------------------------------------------------------------
  739.   # overwrite method: on_load_success
  740.   #--------------------------------------------------------------------------
  741.   def on_load_success; super; end
  742.  
  743. end # Scene_Load
  744.  
  745. #==============================================================================
  746. #
  747. # ■ End of File
  748. #
  749. #==============================================================================

作者: soulsaga    时间: 2019-7-2 20:39
本帖最后由 soulsaga 于 2019-7-2 20:44 编辑

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - 存档系统 v1.03
  4. # -- 最后更新: 2012.07.22
  5. # -- 使用难度: 普通
  6. # -- 需要脚本: 无
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SaveEngine"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.07.22 - Fixed: Location Drawing.
  17. # 2012.01.23 - Anti-crash method added for removed maps.
  18. # 2011.12.26 - Compatibility Update: New Game+
  19. # 2011.12.26 - Started Script and Finished.
  20. #
  21. #==============================================================================
  22. # ▼ 介绍
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # 本脚本为玩家提供一个新式存档界面,可以直接在存档界面读档或删除存档。同时为玩家
  25. # 显示更多的存档信息,例如地点、所持金钱以及其他任何你想要显示的变量。
  26. #
  27. # 如果你第一次使用此脚本,查看旧存档文件可能会出现丢失部分存档数据的情况,这时候
  28. # 需要你重新读档并再次存档。
  29. #
  30. #==============================================================================
  31. # ▼ 安装方式
  32. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. # 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
  34. # 脚本页/槽中.记得保存你的工程以使脚本生效.
  35. #
  36. #==============================================================================
  37. # ▼ 兼容性
  38. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39. # 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
  40. #
  41. #==============================================================================
  42.  
  43. module YEA
  44.   module SAVE
  45.  
  46.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  47.     # - 存档文件窗口设置 -
  48.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  49.  
  50.     MAX_FILES = 32         # 最大存档数. 默认: 16
  51.     SLOT_NAME = "文件 %s"  # 存档文件文本.
  52.  
  53.     # These are the icons
  54.     SAVE_ICON  = 368       # 已存档的图标
  55.     EMPTY_ICON = 375       # 未存档的图标
  56.  
  57.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  58.     # - 指令窗口设置 -
  59.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  60.  
  61.     ACTION_LOAD   = "载入"           # 载入的文本.
  62.     ACTION_SAVE   = "存档"           # 存档的文本.
  63.     ACTION_DELETE = "删除"           # 删除的文本.
  64.     DELETE_SOUND  = RPG::SE.new("Collapse3", 100, 100) # 删除的音效.
  65.  
  66.     # 在帮助窗口中显示的文本.
  67.     SELECT_HELP = "请选择一个存档文件."
  68.     LOAD_HELP   = "从已保存数据中载入."
  69.     SAVE_HELP   = "保存当前游戏数据."
  70.     DELETE_HELP = "删除全部已保存数据."
  71.  
  72.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  73.     # - 游戏状态窗口文本 -
  74.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  75.  
  76.     EMPTY_TEXT = "无存档数据"      # 无存档数据的文本.
  77.     PLAYTIME   = "游戏时间"        # 显示游戏时间的文本.
  78.     TOTAL_SAVE = "存档次数: "      # 存档次数的文本.
  79.     TOTAL_GOLD = "总金钱数: "      # 总金钱数的文本.
  80. #   LOCATION   = "地点: "          # 地点的文本.
  81.  
  82.     # 在数组中填入你想要显示变量数值的变量ID,0为不显示
  83.     COLUMN1_VARIABLES = [1, 2, 3]
  84.     COLUMN2_VARIABLES = [4, 5, 6]
  85.  
  86.   end # SAVE
  87. end # YEA
  88.  
  89. #==============================================================================
  90. # ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
  91. # 所以编辑了后果自负。
  92. #==============================================================================
  93.  
  94. #==============================================================================
  95. # ■ Icon
  96. #==============================================================================
  97.  
  98. module Icon
  99.  
  100.   #--------------------------------------------------------------------------
  101.   # self.save_icon
  102.   #--------------------------------------------------------------------------
  103.   def self.save_icon; return YEA::SAVE::SAVE_ICON; end
  104.  
  105.   #--------------------------------------------------------------------------
  106.   # self.empty_icon
  107.   #--------------------------------------------------------------------------
  108.   def self.empty_icon; return YEA::SAVE::EMPTY_ICON; end
  109.  
  110. end # Icon
  111.  
  112. #==============================================================================
  113. # ■ Numeric
  114. #==============================================================================
  115.  
  116. class Numeric
  117.  
  118.   #--------------------------------------------------------------------------
  119.   # new method: group_digits
  120.   #--------------------------------------------------------------------------
  121.   unless $imported["YEA-CoreEngine"]
  122.   def group; return self.to_s; end
  123.   end # $imported["YEA-CoreEngine"]
  124.  
  125. end # Numeric
  126.  
  127. #==============================================================================
  128. # ■ DataManager
  129. #==============================================================================
  130.  
  131. module DataManager
  132.  
  133.   #--------------------------------------------------------------------------
  134.   # overwrite method: savefile_max
  135.   #--------------------------------------------------------------------------
  136.   def self.savefile_max
  137.     return YEA::SAVE::MAX_FILES
  138.   end
  139.  
  140.   #--------------------------------------------------------------------------
  141.   # overwrite method: self.make_save_header
  142.   #--------------------------------------------------------------------------
  143.   def self.make_save_header
  144.     header = {}
  145.     header[:characters]    = $game_party.characters_for_savefile
  146.     header[:playtime_s]    = $game_system.playtime_s
  147.     header[:system]        = Marshal.load(Marshal.dump($game_system))
  148.     header[:timer]         = Marshal.load(Marshal.dump($game_timer))
  149.     header[:message]       = Marshal.load(Marshal.dump($game_message))
  150.     header[:switches]      = Marshal.load(Marshal.dump($game_switches))
  151.     header[:variables]     = Marshal.load(Marshal.dump($game_variables))
  152.     header[:self_switches] = Marshal.load(Marshal.dump($game_self_switches))
  153.     header[:actors]        = Marshal.load(Marshal.dump($game_actors))
  154.     header[:party]         = Marshal.load(Marshal.dump($game_party))
  155.     header[:troop]         = Marshal.load(Marshal.dump($game_troop))
  156.     header[:map]           = Marshal.load(Marshal.dump($game_map))
  157.     header[:player]        = Marshal.load(Marshal.dump($game_player))
  158.     header
  159.   end
  160.  
  161. end # DataManager
  162.  
  163. #==============================================================================
  164. # ■ Window_MenuCommand
  165. #==============================================================================
  166.  
  167. class Window_MenuCommand < Window_Command
  168.  
  169.   #--------------------------------------------------------------------------
  170.   # overwrite method: save_enabled
  171.   #--------------------------------------------------------------------------
  172.   def save_enabled; return true; end
  173.  
  174. end # Window_MenuCommand
  175.  
  176. #==============================================================================
  177. # ■ Window_FileList
  178. #==============================================================================
  179.  
  180. class Window_FileList < Window_Selectable
  181.  
  182.   #--------------------------------------------------------------------------
  183.   # initialize
  184.   #--------------------------------------------------------------------------
  185.   def initialize(dx, dy)
  186.     super(dx, dy, 128, Graphics.height - dy)
  187.     refresh
  188.     activate
  189.     select(SceneManager.scene.first_savefile_index)
  190.   end
  191.  
  192.   #--------------------------------------------------------------------------
  193.   # item_max
  194.   #--------------------------------------------------------------------------
  195.   def item_max; return DataManager.savefile_max; end
  196.  
  197.   #--------------------------------------------------------------------------
  198.   # current_item_enabled?
  199.   #--------------------------------------------------------------------------
  200.   def current_item_enabled?
  201.     header = DataManager.load_header(index)
  202.     return false if header.nil? && SceneManager.scene_is?(Scene_Load)
  203.     return true
  204.   end
  205.  
  206.   #--------------------------------------------------------------------------
  207.   # refresh
  208.   #--------------------------------------------------------------------------
  209.   def refresh
  210.     create_contents
  211.     draw_all_items
  212.   end
  213.  
  214.   #--------------------------------------------------------------------------
  215.   # draw_item
  216.   #--------------------------------------------------------------------------
  217.   def draw_item(index)
  218.     header = DataManager.load_header(index)
  219.     enabled = !header.nil?
  220.     rect = item_rect(index)
  221.     rect.width -= 4
  222.     draw_icon(save_icon?(header), rect.x, rect.y, enabled)
  223.     change_color(normal_color, enabled)
  224.     text = sprintf(YEA::SAVE::SLOT_NAME, (index + 1).group)
  225.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  226.   end
  227.  
  228.   #--------------------------------------------------------------------------
  229.   # save_icon?
  230.   #--------------------------------------------------------------------------
  231.   def save_icon?(header)
  232.     return Icon.empty_icon if header.nil?
  233.     return Icon.save_icon
  234.   end
  235.  
  236. end # Window_FileList
  237.  
  238. #==============================================================================
  239. # ■ Window_FileStatus
  240. #==============================================================================
  241.  
  242. class Window_FileStatus < Window_Base
  243.  
  244.   #--------------------------------------------------------------------------
  245.   # initialize
  246.   #--------------------------------------------------------------------------
  247.   def initialize(dx, dy, file_window)
  248.     super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  249.     @file_window = file_window
  250.     @current_index = @file_window.index
  251.     refresh
  252.   end
  253.  
  254.   #--------------------------------------------------------------------------
  255.   # update
  256.   #--------------------------------------------------------------------------
  257.   def update
  258.     super
  259.     return if @file_window.index < 0
  260.     return if @current_index == @file_window.index
  261.     @current_index = @file_window.index
  262.     refresh
  263.   end
  264.  
  265.   #--------------------------------------------------------------------------
  266.   # refresh
  267.   #--------------------------------------------------------------------------
  268.   def refresh
  269.     contents.clear
  270.     reset_font_settings
  271.     @header = DataManager.load_header(@file_window.index)
  272.     if @header.nil?
  273.       draw_empty
  274.     else
  275.       draw_save_contents
  276.     end
  277.   end
  278.  
  279.   #--------------------------------------------------------------------------
  280.   # draw_empty
  281.   #--------------------------------------------------------------------------
  282.   def draw_empty
  283.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  284.     rect = Rect.new(0, 0, contents.width, contents.height)
  285.     contents.fill_rect(rect, colour)
  286.     text = YEA::SAVE::EMPTY_TEXT
  287.     change_color(system_color)
  288.     draw_text(rect, text, 1)
  289.   end
  290.  
  291.   #--------------------------------------------------------------------------
  292.   # draw_save_slot
  293.   #--------------------------------------------------------------------------
  294.   def draw_save_slot(dx, dy, dw)
  295.     reset_font_settings
  296.     change_color(system_color)
  297.     text = sprintf(YEA::SAVE::SLOT_NAME, "")
  298.     draw_text(dx, dy, dw, line_height, text)
  299.     cx = text_size(text).width
  300.     change_color(normal_color)
  301.     draw_text(dx+cx, dy, dw-cx, line_height, (@file_window.index+1).group)
  302.   end
  303.  
  304.   #--------------------------------------------------------------------------
  305.   # draw_save_playtime
  306.   #--------------------------------------------------------------------------
  307.   def draw_save_playtime(dx, dy, dw)
  308.     return if @header[:playtime_s].nil?
  309.     reset_font_settings
  310.     change_color(system_color)
  311.     draw_text(dx, dy, dw, line_height, YEA::SAVE::PLAYTIME, 0)
  312.     change_color(normal_color)
  313.     draw_text(dx, dy, dw, line_height, @header[:playtime_s], 2)
  314.   end
  315.  
  316.   #--------------------------------------------------------------------------
  317.   # draw_save_total_saves
  318.   #--------------------------------------------------------------------------
  319.   def draw_save_total_saves(dx, dy, dw)
  320.     return if @header[:system].nil?
  321.     reset_font_settings
  322.     change_color(system_color)
  323.     text = YEA::SAVE::TOTAL_SAVE
  324.     draw_text(dx, dy, dw, line_height, text)
  325.     cx = text_size(text).width
  326.     change_color(normal_color)
  327.     draw_text(dx+cx, dy, dw-cx, line_height, @header[:system].save_count.group)
  328.   end
  329.  
  330.   #--------------------------------------------------------------------------
  331.   # draw_save_gold
  332.   #--------------------------------------------------------------------------
  333.   def draw_save_gold(dx, dy, dw)
  334.     return if @header[:party].nil?
  335.     reset_font_settings
  336.     change_color(system_color)
  337.     draw_text(dx, dy, dw, line_height, YEA::SAVE::TOTAL_GOLD)
  338.     text = Vocab::currency_unit
  339.     draw_text(dx, dy, dw, line_height, text, 2)
  340.     cx = text_size(text).width
  341.     change_color(normal_color)
  342.     text = @header[:party].gold.group
  343.     draw_text(dx, dy, dw-cx, line_height, text, 2)
  344.   end
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # draw_save_location
  348.   #--------------------------------------------------------------------------
  349. #  def draw_save_location(dx, dy, dw)
  350. #   return if @header[:map].nil?
  351.   #  reset_font_settings
  352.    # change_color(system_color)
  353.     #draw_text(dx, dy, dw, line_height, YEA::SAVE::LOCATION)
  354.     #change_color(normal_color)
  355.     #cx = text_size(YEA::SAVE::LOCATION).width
  356.     #return if $data_mapinfos[@header[:map].map_id].nil?
  357.     #text = @header[:map].display_name
  358.     #text = $data_mapinfos[@header[:map].map_id].name if text == ""
  359.     #draw_text(dx+cx, dy, dw-cx, line_height, text)
  360.   #end
  361.  
  362.   #--------------------------------------------------------------------------
  363.   # draw_save_characters
  364.   #--------------------------------------------------------------------------
  365.   def draw_save_characters(dx, dy)
  366.     return if @header[:party].nil?
  367.     reset_font_settings
  368.     make_font_smaller
  369.     dw = (contents.width - dx) / @header[:party].max_battle_members
  370.     dx += dw/2
  371.     for member in @header[:party].battle_members
  372.       next if member.nil?
  373.       member = @header[:actors][member.id]
  374.       change_color(normal_color)
  375.       draw_actor_graphic(member, dx, dy)
  376.       text = member.name
  377.       draw_text(dx-dw/2, dy, dw, line_height, text, 1)
  378.       text = member.level.group
  379.       draw_text(dx-dw/2, dy-line_height, dw-4, line_height, text, 2)
  380.       cx = text_size(text).width
  381.       change_color(system_color)
  382.       text = Vocab::level_a
  383.       draw_text(dx-dw/2, dy-line_height, dw-cx-4, line_height, text, 2)
  384.       dx += dw
  385.     end
  386.   end
  387.  
  388.   #--------------------------------------------------------------------------
  389.   # draw_save_column1
  390.   #--------------------------------------------------------------------------
  391.   def draw_save_column1(dx, dy, dw)
  392.     data = YEA::SAVE::COLUMN1_VARIABLES
  393.     draw_column_data(data, dx, dy, dw)
  394.   end
  395.  
  396.   #--------------------------------------------------------------------------
  397.   # draw_save_column2
  398.   #--------------------------------------------------------------------------
  399.   def draw_save_column2(dx, dy, dw)
  400.     data = YEA::SAVE::COLUMN2_VARIABLES
  401.     draw_column_data(data, dx, dy, dw)
  402.   end
  403.  
  404.   #--------------------------------------------------------------------------
  405.   # draw_column_data
  406.   #--------------------------------------------------------------------------
  407.   def draw_column_data(data, dx, dy, dw)
  408.     return if @header[:variables].nil?
  409.     reset_font_settings
  410.     for variable_id in data
  411.       next if $data_system.variables[variable_id].nil?
  412.       change_color(system_color)
  413.       name = $data_system.variables[variable_id]
  414.       draw_text(dx, dy, dw, line_height, name, 0)
  415.       value = @header[:variables][variable_id].to_s#by:SOULSAGA改造
  416.       change_color(normal_color)
  417.       draw_text(dx, dy, dw, line_height, value, 2)
  418.       dy += line_height
  419.     end
  420.   end
  421.  
  422.   #--------------------------------------------------------------------------
  423.   # draw_save_contents
  424.   #--------------------------------------------------------------------------
  425.   def draw_save_contents
  426.     draw_save_slot(4, 0, contents.width/2-8)
  427.     draw_save_playtime(contents.width/2+4, 0, contents.width/2-8)
  428.     draw_save_total_saves(4, line_height, contents.width/2-8)
  429.     draw_save_gold(contents.width/2+4, line_height, contents.width/2-8)
  430. #    draw_save_location(4, line_height*2, contents.width-8)
  431.     draw_save_characters(0, line_height*5 + line_height/3)
  432.     draw_save_column1(16, line_height*7, contents.width/2-48)
  433.     draw_save_column2(contents.width/2+16, line_height*7, contents.width/2-48)
  434.   end
  435.  
  436. end # Window_FileStatus
  437.  
  438. #==============================================================================
  439. # ■ Window_FileAction
  440. #==============================================================================
  441.  
  442. class Window_FileAction < Window_HorzCommand
  443.  
  444.   #--------------------------------------------------------------------------
  445.   # initialize
  446.   #--------------------------------------------------------------------------
  447.   def initialize(dx, dy, file_window)
  448.     @file_window = file_window
  449.     super(dx, dy)
  450.     deactivate
  451.     unselect
  452.   end
  453.  
  454.   #--------------------------------------------------------------------------
  455.   # window_width
  456.   #--------------------------------------------------------------------------
  457.   def window_width; Graphics.width - 128; end
  458.  
  459.   #--------------------------------------------------------------------------
  460.   # col_max
  461.   #--------------------------------------------------------------------------
  462.   def col_max; return 3; end
  463.  
  464.   #--------------------------------------------------------------------------
  465.   # update
  466.   #--------------------------------------------------------------------------
  467.   def update
  468.     super
  469.     return if @file_window.index < 0
  470.     return if @current_index == @file_window.index
  471.     @current_index = @file_window.index
  472.     refresh
  473.   end
  474.  
  475.   #--------------------------------------------------------------------------
  476.   # make_command_list
  477.   #--------------------------------------------------------------------------
  478.   def make_command_list
  479.     @header = DataManager.load_header(@file_window.index)
  480.     add_load_command
  481.     add_save_command
  482.     add_delete_command
  483.   end
  484.  
  485.   #--------------------------------------------------------------------------
  486.   # add_load_command
  487.   #--------------------------------------------------------------------------
  488.   def add_load_command
  489.     add_command(YEA::SAVE::ACTION_LOAD, :load, load_enabled?)
  490.   end
  491.  
  492.   #--------------------------------------------------------------------------
  493.   # load_enabled?
  494.   #--------------------------------------------------------------------------
  495.   def load_enabled?
  496.     return false if @header.nil?
  497.     return true
  498.   end
  499.  
  500.   #--------------------------------------------------------------------------
  501.   # add_save_command
  502.   #--------------------------------------------------------------------------
  503.   def add_save_command
  504.     add_command(YEA::SAVE::ACTION_SAVE, :save, save_enabled?)
  505.   end
  506.  
  507.   #--------------------------------------------------------------------------
  508.   # save_enabled?
  509.   #--------------------------------------------------------------------------
  510.   def save_enabled?
  511.     return false if @header.nil? && SceneManager.scene_is?(Scene_Load)
  512.     return false if SceneManager.scene_is?(Scene_Load)
  513.     return false if $game_system.save_disabled
  514.     return true
  515.   end
  516.  
  517.   #--------------------------------------------------------------------------
  518.   # add_delete_command
  519.   #--------------------------------------------------------------------------
  520.   def add_delete_command
  521.     add_command(YEA::SAVE::ACTION_DELETE, :delete, delete_enabled?)
  522.   end
  523.  
  524.   #--------------------------------------------------------------------------
  525.   # delete_enabled?
  526.   #--------------------------------------------------------------------------
  527.   def delete_enabled?
  528.     return false if @header.nil?
  529.     return true
  530.   end
  531.  
  532.   #--------------------------------------------------------------------------
  533.   # update_help
  534.   #--------------------------------------------------------------------------
  535.   def update_help
  536.     case current_symbol
  537.     when :load; @help_window.set_text(YEA::SAVE::LOAD_HELP)
  538.     when :save; @help_window.set_text(YEA::SAVE::SAVE_HELP)
  539.     when :delete; @help_window.set_text(YEA::SAVE::DELETE_HELP)
  540.     end
  541.   end
  542.  
  543. end # Window_FileAction
  544.  
  545. #==============================================================================
  546. # ■ Scene_File
  547. #==============================================================================
  548.  
  549. class Scene_File < Scene_MenuBase
  550.  
  551.   #--------------------------------------------------------------------------
  552.   # overwrite method: start
  553.   #--------------------------------------------------------------------------
  554.   def start
  555.     super
  556.     create_all_windows
  557.   end
  558.  
  559.   #--------------------------------------------------------------------------
  560.   # overwrite method: terminate
  561.   #--------------------------------------------------------------------------
  562.   def terminate
  563.     super
  564.   end
  565.  
  566.   #--------------------------------------------------------------------------
  567.   # overwrite method: update
  568.   #--------------------------------------------------------------------------
  569.   def update
  570.     super
  571.   end
  572.  
  573.   #--------------------------------------------------------------------------
  574.   # new method: create_all_windows
  575.   #--------------------------------------------------------------------------
  576.   def create_all_windows
  577.     create_help_window
  578.     create_file_window
  579.     create_action_window
  580.     create_status_window
  581.   end
  582.  
  583.   #--------------------------------------------------------------------------
  584.   # overwrite method: create_help_window
  585.   #--------------------------------------------------------------------------
  586.   def create_help_window
  587.     @help_window = Window_Help.new
  588.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  589.   end
  590.  
  591.   #--------------------------------------------------------------------------
  592.   # new method: create_file_window
  593.   #--------------------------------------------------------------------------
  594.   def create_file_window
  595.     wy = @help_window.height
  596.     @file_window = Window_FileList.new(0, wy)
  597.     @file_window.set_handler(:ok, method(:on_file_ok))
  598.     @file_window.set_handler(:cancel, method(:return_scene))
  599.   end
  600.  
  601.   #--------------------------------------------------------------------------
  602.   # new method: create_action_window
  603.   #--------------------------------------------------------------------------
  604.   def create_action_window
  605.     wx = @file_window.width
  606.     wy = @help_window.height
  607.     @action_window = Window_FileAction.new(wx, wy, @file_window)
  608.     @action_window.help_window = @help_window
  609.     @action_window.set_handler(:cancel, method(:on_action_cancel))
  610.     @action_window.set_handler(:load, method(:on_action_load))
  611.     @action_window.set_handler(:save, method(:on_action_save))
  612.     @action_window.set_handler(:delete, method(:on_action_delete))
  613.   end
  614.  
  615.   #--------------------------------------------------------------------------
  616.   # new method: create_status_window
  617.   #--------------------------------------------------------------------------
  618.   def create_status_window
  619.     wx = @action_window.x
  620.     wy = @action_window.y + @action_window.height
  621.     @status_window = Window_FileStatus.new(wx, wy, @file_window)
  622.   end
  623.  
  624.   #--------------------------------------------------------------------------
  625.   # new method: on_file_ok
  626.   #--------------------------------------------------------------------------
  627.   def on_file_ok
  628.     @action_window.activate
  629.     index = SceneManager.scene_is?(Scene_Load) ? 0 : 1
  630.     @action_window.select(index)
  631.   end
  632.  
  633.   #--------------------------------------------------------------------------
  634.   # new method: on_action_cancel
  635.   #--------------------------------------------------------------------------
  636.   def on_action_cancel
  637.     @action_window.unselect
  638.     @file_window.activate
  639.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  640.   end
  641.  
  642.   #--------------------------------------------------------------------------
  643.   # new method: on_action_load
  644.   #--------------------------------------------------------------------------
  645.   def on_action_load
  646.     if DataManager.load_game(@file_window.index)
  647.       on_load_success
  648.     else
  649.       Sound.play_buzzer
  650.     end
  651.   end
  652.  
  653.   #--------------------------------------------------------------------------
  654.   # overwrite method: on_load_success
  655.   #--------------------------------------------------------------------------
  656.   def on_load_success
  657.     Sound.play_load
  658.     fadeout_all
  659.     $game_system.on_after_load
  660.     SceneManager.goto(Scene_Map)
  661.   end
  662.  
  663.   #--------------------------------------------------------------------------
  664.   # new method: on_action_save
  665.   #--------------------------------------------------------------------------
  666.   def on_action_save
  667.     @action_window.activate
  668.     if DataManager.save_game(@file_window.index)
  669.       on_save_success
  670.       refresh_windows
  671.     else
  672.       Sound.play_buzzer
  673.     end
  674.   end
  675.  
  676.   #--------------------------------------------------------------------------
  677.   # overwrite method: on_save_success
  678.   #--------------------------------------------------------------------------
  679.   def on_save_success; Sound.play_save; end
  680.  
  681.   #--------------------------------------------------------------------------
  682.   # new method: on_action_delete
  683.   #--------------------------------------------------------------------------
  684.   def on_action_delete
  685.     @action_window.activate
  686.     DataManager.delete_save_file(@file_window.index)
  687.     on_delete_success
  688.     refresh_windows
  689.   end
  690.  
  691.   #--------------------------------------------------------------------------
  692.   # new method: on_delete_success
  693.   #--------------------------------------------------------------------------
  694.   def on_delete_success
  695.     YEA::SAVE::DELETE_SOUND.play
  696.   end
  697.  
  698.   #--------------------------------------------------------------------------
  699.   # new method: refresh_windows
  700.   #--------------------------------------------------------------------------
  701.   def refresh_windows
  702.     @file_window.refresh
  703.     @action_window.refresh
  704.     @status_window.refresh
  705.   end
  706.  
  707. end # Scene_File
  708.  
  709. #==============================================================================
  710. # ■ Scene_Save
  711. #==============================================================================
  712.  
  713. class Scene_Save < Scene_File
  714.  
  715.   #--------------------------------------------------------------------------
  716.   # overwrite method: on_savefile_ok
  717.   #--------------------------------------------------------------------------
  718.   def on_savefile_ok; super; end
  719.  
  720.   #--------------------------------------------------------------------------
  721.   # overwrite method: on_save_success
  722.   #--------------------------------------------------------------------------
  723.   def on_save_success; super; end
  724.  
  725. end # help_window_text
  726.  
  727. #==============================================================================
  728. # ■ Scene_Load
  729. #==============================================================================
  730.  
  731. class Scene_Load < Scene_File
  732.  
  733.   #--------------------------------------------------------------------------
  734.   # overwrite method: on_savefile_ok
  735.   #--------------------------------------------------------------------------
  736.   def on_savefile_ok; super; end
  737.  
  738.   #--------------------------------------------------------------------------
  739.   # overwrite method: on_load_success
  740.   #--------------------------------------------------------------------------
  741.   def on_load_success; super; end
  742.  
  743. end # Scene_Load
  744.  
  745. #==============================================================================
  746. #
  747. # ■ End of File
  748. #
  749. #==============================================================================

改好了..只能说是悲剧..




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