查看: 2863|回复: 1

[已经解决] (已解决)求教,YEA存档显示变量,变量怎么显示文本?

[复制链接]
梦石
20
星屑
13972
在线时间
1744 小时
注册时间
2017-1-12
回帖
1666

MZ评测员开拓者

发表于 2019-7-2 19:03:14 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 火锅深处 于 2019-7-2 21:00 编辑

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

  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - 存档系统 v1.03
  4. # -- 最后更新: 2012.07.22
  5. # -- 使用难度: 普通
  6. # -- 需要脚本: 无
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-SaveEngine"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.07.22 - Fixed: Location Drawing.
  15. # 2012.01.23 - Anti-crash method added for removed maps.
  16. # 2011.12.26 - Compatibility Update: New Game+
  17. # 2011.12.26 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ 介绍
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # 本脚本为玩家提供一个新式存档界面,可以直接在存档界面读档或删除存档。同时为玩家
  23. # 显示更多的存档信息,例如地点、所持金钱以及其他任何你想要显示的变量。
  24. #
  25. # 如果你第一次使用此脚本,查看旧存档文件可能会出现丢失部分存档数据的情况,这时候
  26. # 需要你重新读档并再次存档。
  27. #
  28. #==============================================================================
  29. # ▼ 安装方式
  30. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. # 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
  32. # 脚本页/槽中.记得保存你的工程以使脚本生效.
  33. #
  34. #==============================================================================
  35. # ▼ 兼容性
  36. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37. # 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
  38. #
  39. #==============================================================================

  40. module YEA
  41.   module SAVE
  42.    
  43.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  44.     # - 存档文件窗口设置 -
  45.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  46.     MAX_FILES = 32         # 最大存档数. 默认: 16
  47.     SLOT_NAME = "文件 %s"  # 存档文件文本.
  48.    
  49.     # These are the icons
  50.     SAVE_ICON  = 368       # 已存档的图标
  51.     EMPTY_ICON = 375       # 未存档的图标
  52.    
  53.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  54.     # - 指令窗口设置 -
  55.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  56.     ACTION_LOAD   = "载入"           # 载入的文本.
  57.     ACTION_SAVE   = "存档"           # 存档的文本.
  58.     ACTION_DELETE = "删除"           # 删除的文本.
  59.     DELETE_SOUND  = RPG::SE.new("Collapse3", 100, 100) # 删除的音效.
  60.    
  61.     # 在帮助窗口中显示的文本.
  62.     SELECT_HELP = "请选择一个存档文件."
  63.     LOAD_HELP   = "从已保存数据中载入."
  64.     SAVE_HELP   = "保存当前游戏数据."
  65.     DELETE_HELP = "删除全部已保存数据."
  66.    
  67.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  68.     # - 游戏状态窗口文本 -
  69.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  70.     EMPTY_TEXT = "无存档数据"      # 无存档数据的文本.
  71.     PLAYTIME   = "游戏时间"        # 显示游戏时间的文本.
  72.     TOTAL_SAVE = "存档次数: "      # 存档次数的文本.
  73.     TOTAL_GOLD = "总金钱数: "      # 总金钱数的文本.
  74. #   LOCATION   = "地点: "          # 地点的文本.
  75.    
  76.     # 在数组中填入你想要显示变量数值的变量ID,0为不显示
  77.     COLUMN1_VARIABLES = [1, 2, 3]
  78.     COLUMN2_VARIABLES = [4, 5, 6]
  79.    
  80.   end # SAVE
  81. end # YEA

  82. #==============================================================================
  83. # ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
  84. # 所以编辑了后果自负。
  85. #==============================================================================

  86. #==============================================================================
  87. # ■ Icon
  88. #==============================================================================

  89. module Icon
  90.   
  91.   #--------------------------------------------------------------------------
  92.   # self.save_icon
  93.   #--------------------------------------------------------------------------
  94.   def self.save_icon; return YEA::SAVE::SAVE_ICON; end
  95.   
  96.   #--------------------------------------------------------------------------
  97.   # self.empty_icon
  98.   #--------------------------------------------------------------------------
  99.   def self.empty_icon; return YEA::SAVE::EMPTY_ICON; end
  100.    
  101. end # Icon

  102. #==============================================================================
  103. # ■ Numeric
  104. #==============================================================================

  105. class Numeric
  106.   
  107.   #--------------------------------------------------------------------------
  108.   # new method: group_digits
  109.   #--------------------------------------------------------------------------
  110.   unless $imported["YEA-CoreEngine"]
  111.   def group; return self.to_s; end
  112.   end # $imported["YEA-CoreEngine"]
  113.    
  114. end # Numeric

  115. #==============================================================================
  116. # ■ DataManager
  117. #==============================================================================

  118. module DataManager
  119.   
  120.   #--------------------------------------------------------------------------
  121.   # overwrite method: savefile_max
  122.   #--------------------------------------------------------------------------
  123.   def self.savefile_max
  124.     return YEA::SAVE::MAX_FILES
  125.   end
  126.   
  127.   #--------------------------------------------------------------------------
  128.   # overwrite method: self.make_save_header
  129.   #--------------------------------------------------------------------------
  130.   def self.make_save_header
  131.     header = {}
  132.     header[:characters]    = $game_party.characters_for_savefile
  133.     header[:playtime_s]    = $game_system.playtime_s
  134.     header[:system]        = Marshal.load(Marshal.dump($game_system))
  135.     header[:timer]         = Marshal.load(Marshal.dump($game_timer))
  136.     header[:message]       = Marshal.load(Marshal.dump($game_message))
  137.     header[:switches]      = Marshal.load(Marshal.dump($game_switches))
  138.     header[:variables]     = Marshal.load(Marshal.dump($game_variables))
  139.     header[:self_switches] = Marshal.load(Marshal.dump($game_self_switches))
  140.     header[:actors]        = Marshal.load(Marshal.dump($game_actors))
  141.     header[:party]         = Marshal.load(Marshal.dump($game_party))
  142.     header[:troop]         = Marshal.load(Marshal.dump($game_troop))
  143.     header[:map]           = Marshal.load(Marshal.dump($game_map))
  144.     header[:player]        = Marshal.load(Marshal.dump($game_player))
  145.     header
  146.   end
  147.   
  148. end # DataManager

  149. #==============================================================================
  150. # ■ Window_MenuCommand
  151. #==============================================================================

  152. class Window_MenuCommand < Window_Command
  153.   
  154.   #--------------------------------------------------------------------------
  155.   # overwrite method: save_enabled
  156.   #--------------------------------------------------------------------------
  157.   def save_enabled; return true; end
  158.   
  159. end # Window_MenuCommand

  160. #==============================================================================
  161. # ■ Window_FileList
  162. #==============================================================================

  163. class Window_FileList < Window_Selectable
  164.   
  165.   #--------------------------------------------------------------------------
  166.   # initialize
  167.   #--------------------------------------------------------------------------
  168.   def initialize(dx, dy)
  169.     super(dx, dy, 128, Graphics.height - dy)
  170.     refresh
  171.     activate
  172.     select(SceneManager.scene.first_savefile_index)
  173.   end
  174.   
  175.   #--------------------------------------------------------------------------
  176.   # item_max
  177.   #--------------------------------------------------------------------------
  178.   def item_max; return DataManager.savefile_max; end
  179.   
  180.   #--------------------------------------------------------------------------
  181.   # current_item_enabled?
  182.   #--------------------------------------------------------------------------
  183.   def current_item_enabled?
  184.     header = DataManager.load_header(index)
  185.     return false if header.nil? && SceneManager.scene_is?(Scene_Load)
  186.     return true
  187.   end
  188.   
  189.   #--------------------------------------------------------------------------
  190.   # refresh
  191.   #--------------------------------------------------------------------------
  192.   def refresh
  193.     create_contents
  194.     draw_all_items
  195.   end
  196.   
  197.   #--------------------------------------------------------------------------
  198.   # draw_item
  199.   #--------------------------------------------------------------------------
  200.   def draw_item(index)
  201.     header = DataManager.load_header(index)
  202.     enabled = !header.nil?
  203.     rect = item_rect(index)
  204.     rect.width -= 4
  205.     draw_icon(save_icon?(header), rect.x, rect.y, enabled)
  206.     change_color(normal_color, enabled)
  207.     text = sprintf(YEA::SAVE::SLOT_NAME, (index + 1).group)
  208.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  209.   end
  210.   
  211.   #--------------------------------------------------------------------------
  212.   # save_icon?
  213.   #--------------------------------------------------------------------------
  214.   def save_icon?(header)
  215.     return Icon.empty_icon if header.nil?
  216.     return Icon.save_icon
  217.   end
  218.   
  219. end # Window_FileList

  220. #==============================================================================
  221. # ■ Window_FileStatus
  222. #==============================================================================

  223. class Window_FileStatus < Window_Base
  224.   
  225.   #--------------------------------------------------------------------------
  226.   # initialize
  227.   #--------------------------------------------------------------------------
  228.   def initialize(dx, dy, file_window)
  229.     super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  230.     @file_window = file_window
  231.     @current_index = @file_window.index
  232.     refresh
  233.   end
  234.   
  235.   #--------------------------------------------------------------------------
  236.   # update
  237.   #--------------------------------------------------------------------------
  238.   def update
  239.     super
  240.     return if @file_window.index < 0
  241.     return if @current_index == @file_window.index
  242.     @current_index = @file_window.index
  243.     refresh
  244.   end
  245.   
  246.   #--------------------------------------------------------------------------
  247.   # refresh
  248.   #--------------------------------------------------------------------------
  249.   def refresh
  250.     contents.clear
  251.     reset_font_settings
  252.     @header = DataManager.load_header(@file_window.index)
  253.     if @header.nil?
  254.       draw_empty
  255.     else
  256.       draw_save_contents
  257.     end
  258.   end
  259.   
  260.   #--------------------------------------------------------------------------
  261.   # draw_empty
  262.   #--------------------------------------------------------------------------
  263.   def draw_empty
  264.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  265.     rect = Rect.new(0, 0, contents.width, contents.height)
  266.     contents.fill_rect(rect, colour)
  267.     text = YEA::SAVE::EMPTY_TEXT
  268.     change_color(system_color)
  269.     draw_text(rect, text, 1)
  270.   end
  271.   
  272.   #--------------------------------------------------------------------------
  273.   # draw_save_slot
  274.   #--------------------------------------------------------------------------
  275.   def draw_save_slot(dx, dy, dw)
  276.     reset_font_settings
  277.     change_color(system_color)
  278.     text = sprintf(YEA::SAVE::SLOT_NAME, "")
  279.     draw_text(dx, dy, dw, line_height, text)
  280.     cx = text_size(text).width
  281.     change_color(normal_color)
  282.     draw_text(dx+cx, dy, dw-cx, line_height, (@file_window.index+1).group)
  283.   end
  284.   
  285.   #--------------------------------------------------------------------------
  286.   # draw_save_playtime
  287.   #--------------------------------------------------------------------------
  288.   def draw_save_playtime(dx, dy, dw)
  289.     return if @header[:playtime_s].nil?
  290.     reset_font_settings
  291.     change_color(system_color)
  292.     draw_text(dx, dy, dw, line_height, YEA::SAVE::PLAYTIME, 0)
  293.     change_color(normal_color)
  294.     draw_text(dx, dy, dw, line_height, @header[:playtime_s], 2)
  295.   end
  296.   
  297.   #--------------------------------------------------------------------------
  298.   # draw_save_total_saves
  299.   #--------------------------------------------------------------------------
  300.   def draw_save_total_saves(dx, dy, dw)
  301.     return if @header[:system].nil?
  302.     reset_font_settings
  303.     change_color(system_color)
  304.     text = YEA::SAVE::TOTAL_SAVE
  305.     draw_text(dx, dy, dw, line_height, text)
  306.     cx = text_size(text).width
  307.     change_color(normal_color)
  308.     draw_text(dx+cx, dy, dw-cx, line_height, @header[:system].save_count.group)
  309.   end
  310.   
  311.   #--------------------------------------------------------------------------
  312.   # draw_save_gold
  313.   #--------------------------------------------------------------------------
  314.   def draw_save_gold(dx, dy, dw)
  315.     return if @header[:party].nil?
  316.     reset_font_settings
  317.     change_color(system_color)
  318.     draw_text(dx, dy, dw, line_height, YEA::SAVE::TOTAL_GOLD)
  319.     text = Vocab::currency_unit
  320.     draw_text(dx, dy, dw, line_height, text, 2)
  321.     cx = text_size(text).width
  322.     change_color(normal_color)
  323.     text = @header[:party].gold.group
  324.     draw_text(dx, dy, dw-cx, line_height, text, 2)
  325.   end
  326.   
  327.   #--------------------------------------------------------------------------
  328.   # draw_save_location
  329.   #--------------------------------------------------------------------------
  330. #  def draw_save_location(dx, dy, dw)
  331. #   return if @header[:map].nil?
  332.   #  reset_font_settings
  333.    # change_color(system_color)
  334.     #draw_text(dx, dy, dw, line_height, YEA::SAVE::LOCATION)
  335.     #change_color(normal_color)
  336.     #cx = text_size(YEA::SAVE::LOCATION).width
  337.     #return if $data_mapinfos[@header[:map].map_id].nil?
  338.     #text = @header[:map].display_name
  339.     #text = $data_mapinfos[@header[:map].map_id].name if text == ""
  340.     #draw_text(dx+cx, dy, dw-cx, line_height, text)
  341.   #end
  342.   
  343.   #--------------------------------------------------------------------------
  344.   # draw_save_characters
  345.   #--------------------------------------------------------------------------
  346.   def draw_save_characters(dx, dy)
  347.     return if @header[:party].nil?
  348.     reset_font_settings
  349.     make_font_smaller
  350.     dw = (contents.width - dx) / @header[:party].max_battle_members
  351.     dx += dw/2
  352.     for member in @header[:party].battle_members
  353.       next if member.nil?
  354.       member = @header[:actors][member.id]
  355.       change_color(normal_color)
  356.       draw_actor_graphic(member, dx, dy)
  357.       text = member.name
  358.       draw_text(dx-dw/2, dy, dw, line_height, text, 1)
  359.       text = member.level.group
  360.       draw_text(dx-dw/2, dy-line_height, dw-4, line_height, text, 2)
  361.       cx = text_size(text).width
  362.       change_color(system_color)
  363.       text = Vocab::level_a
  364.       draw_text(dx-dw/2, dy-line_height, dw-cx-4, line_height, text, 2)
  365.       dx += dw
  366.     end
  367.   end
  368.   
  369.   #--------------------------------------------------------------------------
  370.   # draw_save_column1
  371.   #--------------------------------------------------------------------------
  372.   def draw_save_column1(dx, dy, dw)
  373.     data = YEA::SAVE::COLUMN1_VARIABLES
  374.     draw_column_data(data, dx, dy, dw)
  375.   end
  376.   
  377.   #--------------------------------------------------------------------------
  378.   # draw_save_column2
  379.   #--------------------------------------------------------------------------
  380.   def draw_save_column2(dx, dy, dw)
  381.     data = YEA::SAVE::COLUMN2_VARIABLES
  382.     draw_column_data(data, dx, dy, dw)
  383.   end
  384.   
  385.   #--------------------------------------------------------------------------
  386.   # draw_column_data
  387.   #--------------------------------------------------------------------------
  388.   def draw_column_data(data, dx, dy, dw)
  389.     return if @header[:variables].nil?
  390.     reset_font_settings
  391.     for variable_id in data
  392.       next if $data_system.variables[variable_id].nil?
  393.       change_color(system_color)
  394.       name = $data_system.variables[variable_id]
  395.       draw_text(dx, dy, dw, line_height, name, 0)
  396.       value = @header[:variables][variable_id].group
  397.       change_color(normal_color)
  398.       draw_text(dx, dy, dw, line_height, value, 2)
  399.       dy += line_height
  400.     end
  401.   end
  402.   
  403.   #--------------------------------------------------------------------------
  404.   # draw_save_contents
  405.   #--------------------------------------------------------------------------
  406.   def draw_save_contents
  407.     draw_save_slot(4, 0, contents.width/2-8)
  408.     draw_save_playtime(contents.width/2+4, 0, contents.width/2-8)
  409.     draw_save_total_saves(4, line_height, contents.width/2-8)
  410.     draw_save_gold(contents.width/2+4, line_height, contents.width/2-8)
  411. #    draw_save_location(4, line_height*2, contents.width-8)
  412.     draw_save_characters(0, line_height*5 + line_height/3)
  413.     draw_save_column1(16, line_height*7, contents.width/2-48)
  414.     draw_save_column2(contents.width/2+16, line_height*7, contents.width/2-48)
  415.   end
  416.   
  417. end # Window_FileStatus

  418. #==============================================================================
  419. # ■ Window_FileAction
  420. #==============================================================================

  421. class Window_FileAction < Window_HorzCommand
  422.   
  423.   #--------------------------------------------------------------------------
  424.   # initialize
  425.   #--------------------------------------------------------------------------
  426.   def initialize(dx, dy, file_window)
  427.     @file_window = file_window
  428.     super(dx, dy)
  429.     deactivate
  430.     unselect
  431.   end
  432.   
  433.   #--------------------------------------------------------------------------
  434.   # window_width
  435.   #--------------------------------------------------------------------------
  436.   def window_width; Graphics.width - 128; end
  437.   
  438.   #--------------------------------------------------------------------------
  439.   # col_max
  440.   #--------------------------------------------------------------------------
  441.   def col_max; return 3; end
  442.   
  443.   #--------------------------------------------------------------------------
  444.   # update
  445.   #--------------------------------------------------------------------------
  446.   def update
  447.     super
  448.     return if @file_window.index < 0
  449.     return if @current_index == @file_window.index
  450.     @current_index = @file_window.index
  451.     refresh
  452.   end
  453.   
  454.   #--------------------------------------------------------------------------
  455.   # make_command_list
  456.   #--------------------------------------------------------------------------
  457.   def make_command_list
  458.     @header = DataManager.load_header(@file_window.index)
  459.     add_load_command
  460.     add_save_command
  461.     add_delete_command
  462.   end
  463.   
  464.   #--------------------------------------------------------------------------
  465.   # add_load_command
  466.   #--------------------------------------------------------------------------
  467.   def add_load_command
  468.     add_command(YEA::SAVE::ACTION_LOAD, :load, load_enabled?)
  469.   end
  470.   
  471.   #--------------------------------------------------------------------------
  472.   # load_enabled?
  473.   #--------------------------------------------------------------------------
  474.   def load_enabled?
  475.     return false if @header.nil?
  476.     return true
  477.   end
  478.   
  479.   #--------------------------------------------------------------------------
  480.   # add_save_command
  481.   #--------------------------------------------------------------------------
  482.   def add_save_command
  483.     add_command(YEA::SAVE::ACTION_SAVE, :save, save_enabled?)
  484.   end
  485.   
  486.   #--------------------------------------------------------------------------
  487.   # save_enabled?
  488.   #--------------------------------------------------------------------------
  489.   def save_enabled?
  490.     return false if @header.nil? && SceneManager.scene_is?(Scene_Load)
  491.     return false if SceneManager.scene_is?(Scene_Load)
  492.     return false if $game_system.save_disabled
  493.     return true
  494.   end
  495.   
  496.   #--------------------------------------------------------------------------
  497.   # add_delete_command
  498.   #--------------------------------------------------------------------------
  499.   def add_delete_command
  500.     add_command(YEA::SAVE::ACTION_DELETE, :delete, delete_enabled?)
  501.   end
  502.   
  503.   #--------------------------------------------------------------------------
  504.   # delete_enabled?
  505.   #--------------------------------------------------------------------------
  506.   def delete_enabled?
  507.     return false if @header.nil?
  508.     return true
  509.   end
  510.   
  511.   #--------------------------------------------------------------------------
  512.   # update_help
  513.   #--------------------------------------------------------------------------
  514.   def update_help
  515.     case current_symbol
  516.     when :load; @help_window.set_text(YEA::SAVE::LOAD_HELP)
  517.     when :save; @help_window.set_text(YEA::SAVE::SAVE_HELP)
  518.     when :delete; @help_window.set_text(YEA::SAVE::DELETE_HELP)
  519.     end
  520.   end
  521.   
  522. end # Window_FileAction

  523. #==============================================================================
  524. # ■ Scene_File
  525. #==============================================================================

  526. class Scene_File < Scene_MenuBase
  527.   
  528.   #--------------------------------------------------------------------------
  529.   # overwrite method: start
  530.   #--------------------------------------------------------------------------
  531.   def start
  532.     super
  533.     create_all_windows
  534.   end
  535.   
  536.   #--------------------------------------------------------------------------
  537.   # overwrite method: terminate
  538.   #--------------------------------------------------------------------------
  539.   def terminate
  540.     super
  541.   end
  542.   
  543.   #--------------------------------------------------------------------------
  544.   # overwrite method: update
  545.   #--------------------------------------------------------------------------
  546.   def update
  547.     super
  548.   end
  549.   
  550.   #--------------------------------------------------------------------------
  551.   # new method: create_all_windows
  552.   #--------------------------------------------------------------------------
  553.   def create_all_windows
  554.     create_help_window
  555.     create_file_window
  556.     create_action_window
  557.     create_status_window
  558.   end
  559.   
  560.   #--------------------------------------------------------------------------
  561.   # overwrite method: create_help_window
  562.   #--------------------------------------------------------------------------
  563.   def create_help_window
  564.     @help_window = Window_Help.new
  565.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  566.   end
  567.   
  568.   #--------------------------------------------------------------------------
  569.   # new method: create_file_window
  570.   #--------------------------------------------------------------------------
  571.   def create_file_window
  572.     wy = @help_window.height
  573.     @file_window = Window_FileList.new(0, wy)
  574.     @file_window.set_handler(:ok, method(:on_file_ok))
  575.     @file_window.set_handler(:cancel, method(:return_scene))
  576.   end
  577.   
  578.   #--------------------------------------------------------------------------
  579.   # new method: create_action_window
  580.   #--------------------------------------------------------------------------
  581.   def create_action_window
  582.     wx = @file_window.width
  583.     wy = @help_window.height
  584.     @action_window = Window_FileAction.new(wx, wy, @file_window)
  585.     @action_window.help_window = @help_window
  586.     @action_window.set_handler(:cancel, method(:on_action_cancel))
  587.     @action_window.set_handler(:load, method(:on_action_load))
  588.     @action_window.set_handler(:save, method(:on_action_save))
  589.     @action_window.set_handler(:delete, method(:on_action_delete))
  590.   end
  591.   
  592.   #--------------------------------------------------------------------------
  593.   # new method: create_status_window
  594.   #--------------------------------------------------------------------------
  595.   def create_status_window
  596.     wx = @action_window.x
  597.     wy = @action_window.y + @action_window.height
  598.     @status_window = Window_FileStatus.new(wx, wy, @file_window)
  599.   end
  600.   
  601.   #--------------------------------------------------------------------------
  602.   # new method: on_file_ok
  603.   #--------------------------------------------------------------------------
  604.   def on_file_ok
  605.     @action_window.activate
  606.     index = SceneManager.scene_is?(Scene_Load) ? 0 : 1
  607.     @action_window.select(index)
  608.   end
  609.   
  610.   #--------------------------------------------------------------------------
  611.   # new method: on_action_cancel
  612.   #--------------------------------------------------------------------------
  613.   def on_action_cancel
  614.     @action_window.unselect
  615.     @file_window.activate
  616.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  617.   end
  618.   
  619.   #--------------------------------------------------------------------------
  620.   # new method: on_action_load
  621.   #--------------------------------------------------------------------------
  622.   def on_action_load
  623.     if DataManager.load_game(@file_window.index)
  624.       on_load_success
  625.     else
  626.       Sound.play_buzzer
  627.     end
  628.   end
  629.   
  630.   #--------------------------------------------------------------------------
  631.   # overwrite method: on_load_success
  632.   #--------------------------------------------------------------------------
  633.   def on_load_success
  634.     Sound.play_load
  635.     fadeout_all
  636.     $game_system.on_after_load
  637.     SceneManager.goto(Scene_Map)
  638.   end
  639.   
  640.   #--------------------------------------------------------------------------
  641.   # new method: on_action_save
  642.   #--------------------------------------------------------------------------
  643.   def on_action_save
  644.     @action_window.activate
  645.     if DataManager.save_game(@file_window.index)
  646.       on_save_success
  647.       refresh_windows
  648.     else
  649.       Sound.play_buzzer
  650.     end
  651.   end
  652.   
  653.   #--------------------------------------------------------------------------
  654.   # overwrite method: on_save_success
  655.   #--------------------------------------------------------------------------
  656.   def on_save_success; Sound.play_save; end
  657.   
  658.   #--------------------------------------------------------------------------
  659.   # new method: on_action_delete
  660.   #--------------------------------------------------------------------------
  661.   def on_action_delete
  662.     @action_window.activate
  663.     DataManager.delete_save_file(@file_window.index)
  664.     on_delete_success
  665.     refresh_windows
  666.   end
  667.   
  668.   #--------------------------------------------------------------------------
  669.   # new method: on_delete_success
  670.   #--------------------------------------------------------------------------
  671.   def on_delete_success
  672.     YEA::SAVE::DELETE_SOUND.play
  673.   end
  674.   
  675.   #--------------------------------------------------------------------------
  676.   # new method: refresh_windows
  677.   #--------------------------------------------------------------------------
  678.   def refresh_windows
  679.     @file_window.refresh
  680.     @action_window.refresh
  681.     @status_window.refresh
  682.   end
  683.   
  684. end # Scene_File

  685. #==============================================================================
  686. # ■ Scene_Save
  687. #==============================================================================

  688. class Scene_Save < Scene_File
  689.   
  690.   #--------------------------------------------------------------------------
  691.   # overwrite method: on_savefile_ok
  692.   #--------------------------------------------------------------------------
  693.   def on_savefile_ok; super; end
  694.   
  695.   #--------------------------------------------------------------------------
  696.   # overwrite method: on_save_success
  697.   #--------------------------------------------------------------------------
  698.   def on_save_success; super; end
  699.   
  700. end # help_window_text

  701. #==============================================================================
  702. # ■ Scene_Load
  703. #==============================================================================

  704. class Scene_Load < Scene_File
  705.   
  706.   #--------------------------------------------------------------------------
  707.   # overwrite method: on_savefile_ok
  708.   #--------------------------------------------------------------------------
  709.   def on_savefile_ok; super; end
  710.   
  711.   #--------------------------------------------------------------------------
  712.   # overwrite method: on_load_success
  713.   #--------------------------------------------------------------------------
  714.   def on_load_success; super; end
  715.   
  716. end # Scene_Load

  717. #==============================================================================
  718. #
  719. # ■ End of File
  720. #
  721. #==============================================================================
复制代码
梦石
0
星屑
39336
在线时间
11161 小时
注册时间
2009-3-15
回帖
4768
发表于 2019-7-2 20:39:07 | 显示全部楼层
本帖最后由 soulsaga 于 2019-7-2 20:44 编辑
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - 存档系统 v1.03
  4. # -- 最后更新: 2012.07.22
  5. # -- 使用难度: 普通
  6. # -- 需要脚本: 无
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YEA-SaveEngine"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.07.22 - Fixed: Location Drawing.
  15. # 2012.01.23 - Anti-crash method added for removed maps.
  16. # 2011.12.26 - Compatibility Update: New Game+
  17. # 2011.12.26 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ 介绍
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # 本脚本为玩家提供一个新式存档界面,可以直接在存档界面读档或删除存档。同时为玩家
  23. # 显示更多的存档信息,例如地点、所持金钱以及其他任何你想要显示的变量。
  24. #
  25. # 如果你第一次使用此脚本,查看旧存档文件可能会出现丢失部分存档数据的情况,这时候
  26. # 需要你重新读档并再次存档。
  27. #
  28. #==============================================================================
  29. # ▼ 安装方式
  30. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. # 打开脚本编辑器,将本脚本拷贝/复制到一个在▼ 插件脚本之下▼ Main之上的新
  32. # 脚本页/槽中.记得保存你的工程以使脚本生效.
  33. #
  34. #==============================================================================
  35. # ▼ 兼容性
  36. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37. # 本脚本仅为RPG Maker VX Ace编写.极不可能在无任何修改的情况下运行于RPG Maker VX.
  38. #
  39. #==============================================================================

  40. module YEA
  41.   module SAVE

  42.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  43.     # - 存档文件窗口设置 -
  44.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  45.     MAX_FILES = 32         # 最大存档数. 默认: 16
  46.     SLOT_NAME = "文件 %s"  # 存档文件文本.

  47.     # These are the icons
  48.     SAVE_ICON  = 368       # 已存档的图标
  49.     EMPTY_ICON = 375       # 未存档的图标

  50.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  51.     # - 指令窗口设置 -
  52.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  53.     ACTION_LOAD   = "载入"           # 载入的文本.
  54.     ACTION_SAVE   = "存档"           # 存档的文本.
  55.     ACTION_DELETE = "删除"           # 删除的文本.
  56.     DELETE_SOUND  = RPG::SE.new("Collapse3", 100, 100) # 删除的音效.

  57.     # 在帮助窗口中显示的文本.
  58.     SELECT_HELP = "请选择一个存档文件."
  59.     LOAD_HELP   = "从已保存数据中载入."
  60.     SAVE_HELP   = "保存当前游戏数据."
  61.     DELETE_HELP = "删除全部已保存数据."

  62.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  63.     # - 游戏状态窗口文本 -
  64.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  65.     EMPTY_TEXT = "无存档数据"      # 无存档数据的文本.
  66.     PLAYTIME   = "游戏时间"        # 显示游戏时间的文本.
  67.     TOTAL_SAVE = "存档次数: "      # 存档次数的文本.
  68.     TOTAL_GOLD = "总金钱数: "      # 总金钱数的文本.
  69. #   LOCATION   = "地点: "          # 地点的文本.

  70.     # 在数组中填入你想要显示变量数值的变量ID,0为不显示
  71.     COLUMN1_VARIABLES = [1, 2, 3]
  72.     COLUMN2_VARIABLES = [4, 5, 6]

  73.   end # SAVE
  74. end # YEA

  75. #==============================================================================
  76. # ▼ 编辑以下内容可能会出现电脑损坏、死机,电脑主人脑袋爆炸、昏迷、死亡或口臭
  77. # 所以编辑了后果自负。
  78. #==============================================================================

  79. #==============================================================================
  80. # ■ Icon
  81. #==============================================================================

  82. module Icon

  83.   #--------------------------------------------------------------------------
  84.   # self.save_icon
  85.   #--------------------------------------------------------------------------
  86.   def self.save_icon; return YEA::SAVE::SAVE_ICON; end

  87.   #--------------------------------------------------------------------------
  88.   # self.empty_icon
  89.   #--------------------------------------------------------------------------
  90.   def self.empty_icon; return YEA::SAVE::EMPTY_ICON; end

  91. end # Icon

  92. #==============================================================================
  93. # ■ Numeric
  94. #==============================================================================

  95. class Numeric

  96.   #--------------------------------------------------------------------------
  97.   # new method: group_digits
  98.   #--------------------------------------------------------------------------
  99.   unless $imported["YEA-CoreEngine"]
  100.   def group; return self.to_s; end
  101.   end # $imported["YEA-CoreEngine"]

  102. end # Numeric

  103. #==============================================================================
  104. # ■ DataManager
  105. #==============================================================================

  106. module DataManager

  107.   #--------------------------------------------------------------------------
  108.   # overwrite method: savefile_max
  109.   #--------------------------------------------------------------------------
  110.   def self.savefile_max
  111.     return YEA::SAVE::MAX_FILES
  112.   end

  113.   #--------------------------------------------------------------------------
  114.   # overwrite method: self.make_save_header
  115.   #--------------------------------------------------------------------------
  116.   def self.make_save_header
  117.     header = {}
  118.     header[:characters]    = $game_party.characters_for_savefile
  119.     header[:playtime_s]    = $game_system.playtime_s
  120.     header[:system]        = Marshal.load(Marshal.dump($game_system))
  121.     header[:timer]         = Marshal.load(Marshal.dump($game_timer))
  122.     header[:message]       = Marshal.load(Marshal.dump($game_message))
  123.     header[:switches]      = Marshal.load(Marshal.dump($game_switches))
  124.     header[:variables]     = Marshal.load(Marshal.dump($game_variables))
  125.     header[:self_switches] = Marshal.load(Marshal.dump($game_self_switches))
  126.     header[:actors]        = Marshal.load(Marshal.dump($game_actors))
  127.     header[:party]         = Marshal.load(Marshal.dump($game_party))
  128.     header[:troop]         = Marshal.load(Marshal.dump($game_troop))
  129.     header[:map]           = Marshal.load(Marshal.dump($game_map))
  130.     header[:player]        = Marshal.load(Marshal.dump($game_player))
  131.     header
  132.   end

  133. end # DataManager

  134. #==============================================================================
  135. # ■ Window_MenuCommand
  136. #==============================================================================

  137. class Window_MenuCommand < Window_Command

  138.   #--------------------------------------------------------------------------
  139.   # overwrite method: save_enabled
  140.   #--------------------------------------------------------------------------
  141.   def save_enabled; return true; end

  142. end # Window_MenuCommand

  143. #==============================================================================
  144. # ■ Window_FileList
  145. #==============================================================================

  146. class Window_FileList < Window_Selectable

  147.   #--------------------------------------------------------------------------
  148.   # initialize
  149.   #--------------------------------------------------------------------------
  150.   def initialize(dx, dy)
  151.     super(dx, dy, 128, Graphics.height - dy)
  152.     refresh
  153.     activate
  154.     select(SceneManager.scene.first_savefile_index)
  155.   end

  156.   #--------------------------------------------------------------------------
  157.   # item_max
  158.   #--------------------------------------------------------------------------
  159.   def item_max; return DataManager.savefile_max; end

  160.   #--------------------------------------------------------------------------
  161.   # current_item_enabled?
  162.   #--------------------------------------------------------------------------
  163.   def current_item_enabled?
  164.     header = DataManager.load_header(index)
  165.     return false if header.nil? && SceneManager.scene_is?(Scene_Load)
  166.     return true
  167.   end

  168.   #--------------------------------------------------------------------------
  169.   # refresh
  170.   #--------------------------------------------------------------------------
  171.   def refresh
  172.     create_contents
  173.     draw_all_items
  174.   end

  175.   #--------------------------------------------------------------------------
  176.   # draw_item
  177.   #--------------------------------------------------------------------------
  178.   def draw_item(index)
  179.     header = DataManager.load_header(index)
  180.     enabled = !header.nil?
  181.     rect = item_rect(index)
  182.     rect.width -= 4
  183.     draw_icon(save_icon?(header), rect.x, rect.y, enabled)
  184.     change_color(normal_color, enabled)
  185.     text = sprintf(YEA::SAVE::SLOT_NAME, (index + 1).group)
  186.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  187.   end

  188.   #--------------------------------------------------------------------------
  189.   # save_icon?
  190.   #--------------------------------------------------------------------------
  191.   def save_icon?(header)
  192.     return Icon.empty_icon if header.nil?
  193.     return Icon.save_icon
  194.   end

  195. end # Window_FileList

  196. #==============================================================================
  197. # ■ Window_FileStatus
  198. #==============================================================================

  199. class Window_FileStatus < Window_Base

  200.   #--------------------------------------------------------------------------
  201.   # initialize
  202.   #--------------------------------------------------------------------------
  203.   def initialize(dx, dy, file_window)
  204.     super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  205.     @file_window = file_window
  206.     @current_index = @file_window.index
  207.     refresh
  208.   end

  209.   #--------------------------------------------------------------------------
  210.   # update
  211.   #--------------------------------------------------------------------------
  212.   def update
  213.     super
  214.     return if @file_window.index < 0
  215.     return if @current_index == @file_window.index
  216.     @current_index = @file_window.index
  217.     refresh
  218.   end

  219.   #--------------------------------------------------------------------------
  220.   # refresh
  221.   #--------------------------------------------------------------------------
  222.   def refresh
  223.     contents.clear
  224.     reset_font_settings
  225.     @header = DataManager.load_header(@file_window.index)
  226.     if @header.nil?
  227.       draw_empty
  228.     else
  229.       draw_save_contents
  230.     end
  231.   end

  232.   #--------------------------------------------------------------------------
  233.   # draw_empty
  234.   #--------------------------------------------------------------------------
  235.   def draw_empty
  236.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  237.     rect = Rect.new(0, 0, contents.width, contents.height)
  238.     contents.fill_rect(rect, colour)
  239.     text = YEA::SAVE::EMPTY_TEXT
  240.     change_color(system_color)
  241.     draw_text(rect, text, 1)
  242.   end

  243.   #--------------------------------------------------------------------------
  244.   # draw_save_slot
  245.   #--------------------------------------------------------------------------
  246.   def draw_save_slot(dx, dy, dw)
  247.     reset_font_settings
  248.     change_color(system_color)
  249.     text = sprintf(YEA::SAVE::SLOT_NAME, "")
  250.     draw_text(dx, dy, dw, line_height, text)
  251.     cx = text_size(text).width
  252.     change_color(normal_color)
  253.     draw_text(dx+cx, dy, dw-cx, line_height, (@file_window.index+1).group)
  254.   end

  255.   #--------------------------------------------------------------------------
  256.   # draw_save_playtime
  257.   #--------------------------------------------------------------------------
  258.   def draw_save_playtime(dx, dy, dw)
  259.     return if @header[:playtime_s].nil?
  260.     reset_font_settings
  261.     change_color(system_color)
  262.     draw_text(dx, dy, dw, line_height, YEA::SAVE::PLAYTIME, 0)
  263.     change_color(normal_color)
  264.     draw_text(dx, dy, dw, line_height, @header[:playtime_s], 2)
  265.   end

  266.   #--------------------------------------------------------------------------
  267.   # draw_save_total_saves
  268.   #--------------------------------------------------------------------------
  269.   def draw_save_total_saves(dx, dy, dw)
  270.     return if @header[:system].nil?
  271.     reset_font_settings
  272.     change_color(system_color)
  273.     text = YEA::SAVE::TOTAL_SAVE
  274.     draw_text(dx, dy, dw, line_height, text)
  275.     cx = text_size(text).width
  276.     change_color(normal_color)
  277.     draw_text(dx+cx, dy, dw-cx, line_height, @header[:system].save_count.group)
  278.   end

  279.   #--------------------------------------------------------------------------
  280.   # draw_save_gold
  281.   #--------------------------------------------------------------------------
  282.   def draw_save_gold(dx, dy, dw)
  283.     return if @header[:party].nil?
  284.     reset_font_settings
  285.     change_color(system_color)
  286.     draw_text(dx, dy, dw, line_height, YEA::SAVE::TOTAL_GOLD)
  287.     text = Vocab::currency_unit
  288.     draw_text(dx, dy, dw, line_height, text, 2)
  289.     cx = text_size(text).width
  290.     change_color(normal_color)
  291.     text = @header[:party].gold.group
  292.     draw_text(dx, dy, dw-cx, line_height, text, 2)
  293.   end

  294.   #--------------------------------------------------------------------------
  295.   # draw_save_location
  296.   #--------------------------------------------------------------------------
  297. #  def draw_save_location(dx, dy, dw)
  298. #   return if @header[:map].nil?
  299.   #  reset_font_settings
  300.    # change_color(system_color)
  301.     #draw_text(dx, dy, dw, line_height, YEA::SAVE::LOCATION)
  302.     #change_color(normal_color)
  303.     #cx = text_size(YEA::SAVE::LOCATION).width
  304.     #return if $data_mapinfos[@header[:map].map_id].nil?
  305.     #text = @header[:map].display_name
  306.     #text = $data_mapinfos[@header[:map].map_id].name if text == ""
  307.     #draw_text(dx+cx, dy, dw-cx, line_height, text)
  308.   #end

  309.   #--------------------------------------------------------------------------
  310.   # draw_save_characters
  311.   #--------------------------------------------------------------------------
  312.   def draw_save_characters(dx, dy)
  313.     return if @header[:party].nil?
  314.     reset_font_settings
  315.     make_font_smaller
  316.     dw = (contents.width - dx) / @header[:party].max_battle_members
  317.     dx += dw/2
  318.     for member in @header[:party].battle_members
  319.       next if member.nil?
  320.       member = @header[:actors][member.id]
  321.       change_color(normal_color)
  322.       draw_actor_graphic(member, dx, dy)
  323.       text = member.name
  324.       draw_text(dx-dw/2, dy, dw, line_height, text, 1)
  325.       text = member.level.group
  326.       draw_text(dx-dw/2, dy-line_height, dw-4, line_height, text, 2)
  327.       cx = text_size(text).width
  328.       change_color(system_color)
  329.       text = Vocab::level_a
  330.       draw_text(dx-dw/2, dy-line_height, dw-cx-4, line_height, text, 2)
  331.       dx += dw
  332.     end
  333.   end

  334.   #--------------------------------------------------------------------------
  335.   # draw_save_column1
  336.   #--------------------------------------------------------------------------
  337.   def draw_save_column1(dx, dy, dw)
  338.     data = YEA::SAVE::COLUMN1_VARIABLES
  339.     draw_column_data(data, dx, dy, dw)
  340.   end

  341.   #--------------------------------------------------------------------------
  342.   # draw_save_column2
  343.   #--------------------------------------------------------------------------
  344.   def draw_save_column2(dx, dy, dw)
  345.     data = YEA::SAVE::COLUMN2_VARIABLES
  346.     draw_column_data(data, dx, dy, dw)
  347.   end

  348.   #--------------------------------------------------------------------------
  349.   # draw_column_data
  350.   #--------------------------------------------------------------------------
  351.   def draw_column_data(data, dx, dy, dw)
  352.     return if @header[:variables].nil?
  353.     reset_font_settings
  354.     for variable_id in data
  355.       next if $data_system.variables[variable_id].nil?
  356.       change_color(system_color)
  357.       name = $data_system.variables[variable_id]
  358.       draw_text(dx, dy, dw, line_height, name, 0)
  359.       value = @header[:variables][variable_id].to_s#by:SOULSAGA改造
  360.       change_color(normal_color)
  361.       draw_text(dx, dy, dw, line_height, value, 2)
  362.       dy += line_height
  363.     end
  364.   end

  365.   #--------------------------------------------------------------------------
  366.   # draw_save_contents
  367.   #--------------------------------------------------------------------------
  368.   def draw_save_contents
  369.     draw_save_slot(4, 0, contents.width/2-8)
  370.     draw_save_playtime(contents.width/2+4, 0, contents.width/2-8)
  371.     draw_save_total_saves(4, line_height, contents.width/2-8)
  372.     draw_save_gold(contents.width/2+4, line_height, contents.width/2-8)
  373. #    draw_save_location(4, line_height*2, contents.width-8)
  374.     draw_save_characters(0, line_height*5 + line_height/3)
  375.     draw_save_column1(16, line_height*7, contents.width/2-48)
  376.     draw_save_column2(contents.width/2+16, line_height*7, contents.width/2-48)
  377.   end

  378. end # Window_FileStatus

  379. #==============================================================================
  380. # ■ Window_FileAction
  381. #==============================================================================

  382. class Window_FileAction < Window_HorzCommand

  383.   #--------------------------------------------------------------------------
  384.   # initialize
  385.   #--------------------------------------------------------------------------
  386.   def initialize(dx, dy, file_window)
  387.     @file_window = file_window
  388.     super(dx, dy)
  389.     deactivate
  390.     unselect
  391.   end

  392.   #--------------------------------------------------------------------------
  393.   # window_width
  394.   #--------------------------------------------------------------------------
  395.   def window_width; Graphics.width - 128; end

  396.   #--------------------------------------------------------------------------
  397.   # col_max
  398.   #--------------------------------------------------------------------------
  399.   def col_max; return 3; end

  400.   #--------------------------------------------------------------------------
  401.   # update
  402.   #--------------------------------------------------------------------------
  403.   def update
  404.     super
  405.     return if @file_window.index < 0
  406.     return if @current_index == @file_window.index
  407.     @current_index = @file_window.index
  408.     refresh
  409.   end

  410.   #--------------------------------------------------------------------------
  411.   # make_command_list
  412.   #--------------------------------------------------------------------------
  413.   def make_command_list
  414.     @header = DataManager.load_header(@file_window.index)
  415.     add_load_command
  416.     add_save_command
  417.     add_delete_command
  418.   end

  419.   #--------------------------------------------------------------------------
  420.   # add_load_command
  421.   #--------------------------------------------------------------------------
  422.   def add_load_command
  423.     add_command(YEA::SAVE::ACTION_LOAD, :load, load_enabled?)
  424.   end

  425.   #--------------------------------------------------------------------------
  426.   # load_enabled?
  427.   #--------------------------------------------------------------------------
  428.   def load_enabled?
  429.     return false if @header.nil?
  430.     return true
  431.   end

  432.   #--------------------------------------------------------------------------
  433.   # add_save_command
  434.   #--------------------------------------------------------------------------
  435.   def add_save_command
  436.     add_command(YEA::SAVE::ACTION_SAVE, :save, save_enabled?)
  437.   end

  438.   #--------------------------------------------------------------------------
  439.   # save_enabled?
  440.   #--------------------------------------------------------------------------
  441.   def save_enabled?
  442.     return false if @header.nil? && SceneManager.scene_is?(Scene_Load)
  443.     return false if SceneManager.scene_is?(Scene_Load)
  444.     return false if $game_system.save_disabled
  445.     return true
  446.   end

  447.   #--------------------------------------------------------------------------
  448.   # add_delete_command
  449.   #--------------------------------------------------------------------------
  450.   def add_delete_command
  451.     add_command(YEA::SAVE::ACTION_DELETE, :delete, delete_enabled?)
  452.   end

  453.   #--------------------------------------------------------------------------
  454.   # delete_enabled?
  455.   #--------------------------------------------------------------------------
  456.   def delete_enabled?
  457.     return false if @header.nil?
  458.     return true
  459.   end

  460.   #--------------------------------------------------------------------------
  461.   # update_help
  462.   #--------------------------------------------------------------------------
  463.   def update_help
  464.     case current_symbol
  465.     when :load; @help_window.set_text(YEA::SAVE::LOAD_HELP)
  466.     when :save; @help_window.set_text(YEA::SAVE::SAVE_HELP)
  467.     when :delete; @help_window.set_text(YEA::SAVE::DELETE_HELP)
  468.     end
  469.   end

  470. end # Window_FileAction

  471. #==============================================================================
  472. # ■ Scene_File
  473. #==============================================================================

  474. class Scene_File < Scene_MenuBase

  475.   #--------------------------------------------------------------------------
  476.   # overwrite method: start
  477.   #--------------------------------------------------------------------------
  478.   def start
  479.     super
  480.     create_all_windows
  481.   end

  482.   #--------------------------------------------------------------------------
  483.   # overwrite method: terminate
  484.   #--------------------------------------------------------------------------
  485.   def terminate
  486.     super
  487.   end

  488.   #--------------------------------------------------------------------------
  489.   # overwrite method: update
  490.   #--------------------------------------------------------------------------
  491.   def update
  492.     super
  493.   end

  494.   #--------------------------------------------------------------------------
  495.   # new method: create_all_windows
  496.   #--------------------------------------------------------------------------
  497.   def create_all_windows
  498.     create_help_window
  499.     create_file_window
  500.     create_action_window
  501.     create_status_window
  502.   end

  503.   #--------------------------------------------------------------------------
  504.   # overwrite method: create_help_window
  505.   #--------------------------------------------------------------------------
  506.   def create_help_window
  507.     @help_window = Window_Help.new
  508.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  509.   end

  510.   #--------------------------------------------------------------------------
  511.   # new method: create_file_window
  512.   #--------------------------------------------------------------------------
  513.   def create_file_window
  514.     wy = @help_window.height
  515.     @file_window = Window_FileList.new(0, wy)
  516.     @file_window.set_handler(:ok, method(:on_file_ok))
  517.     @file_window.set_handler(:cancel, method(:return_scene))
  518.   end

  519.   #--------------------------------------------------------------------------
  520.   # new method: create_action_window
  521.   #--------------------------------------------------------------------------
  522.   def create_action_window
  523.     wx = @file_window.width
  524.     wy = @help_window.height
  525.     @action_window = Window_FileAction.new(wx, wy, @file_window)
  526.     @action_window.help_window = @help_window
  527.     @action_window.set_handler(:cancel, method(:on_action_cancel))
  528.     @action_window.set_handler(:load, method(:on_action_load))
  529.     @action_window.set_handler(:save, method(:on_action_save))
  530.     @action_window.set_handler(:delete, method(:on_action_delete))
  531.   end

  532.   #--------------------------------------------------------------------------
  533.   # new method: create_status_window
  534.   #--------------------------------------------------------------------------
  535.   def create_status_window
  536.     wx = @action_window.x
  537.     wy = @action_window.y + @action_window.height
  538.     @status_window = Window_FileStatus.new(wx, wy, @file_window)
  539.   end

  540.   #--------------------------------------------------------------------------
  541.   # new method: on_file_ok
  542.   #--------------------------------------------------------------------------
  543.   def on_file_ok
  544.     @action_window.activate
  545.     index = SceneManager.scene_is?(Scene_Load) ? 0 : 1
  546.     @action_window.select(index)
  547.   end

  548.   #--------------------------------------------------------------------------
  549.   # new method: on_action_cancel
  550.   #--------------------------------------------------------------------------
  551.   def on_action_cancel
  552.     @action_window.unselect
  553.     @file_window.activate
  554.     @help_window.set_text(YEA::SAVE::SELECT_HELP)
  555.   end

  556.   #--------------------------------------------------------------------------
  557.   # new method: on_action_load
  558.   #--------------------------------------------------------------------------
  559.   def on_action_load
  560.     if DataManager.load_game(@file_window.index)
  561.       on_load_success
  562.     else
  563.       Sound.play_buzzer
  564.     end
  565.   end

  566.   #--------------------------------------------------------------------------
  567.   # overwrite method: on_load_success
  568.   #--------------------------------------------------------------------------
  569.   def on_load_success
  570.     Sound.play_load
  571.     fadeout_all
  572.     $game_system.on_after_load
  573.     SceneManager.goto(Scene_Map)
  574.   end

  575.   #--------------------------------------------------------------------------
  576.   # new method: on_action_save
  577.   #--------------------------------------------------------------------------
  578.   def on_action_save
  579.     @action_window.activate
  580.     if DataManager.save_game(@file_window.index)
  581.       on_save_success
  582.       refresh_windows
  583.     else
  584.       Sound.play_buzzer
  585.     end
  586.   end

  587.   #--------------------------------------------------------------------------
  588.   # overwrite method: on_save_success
  589.   #--------------------------------------------------------------------------
  590.   def on_save_success; Sound.play_save; end

  591.   #--------------------------------------------------------------------------
  592.   # new method: on_action_delete
  593.   #--------------------------------------------------------------------------
  594.   def on_action_delete
  595.     @action_window.activate
  596.     DataManager.delete_save_file(@file_window.index)
  597.     on_delete_success
  598.     refresh_windows
  599.   end

  600.   #--------------------------------------------------------------------------
  601.   # new method: on_delete_success
  602.   #--------------------------------------------------------------------------
  603.   def on_delete_success
  604.     YEA::SAVE::DELETE_SOUND.play
  605.   end

  606.   #--------------------------------------------------------------------------
  607.   # new method: refresh_windows
  608.   #--------------------------------------------------------------------------
  609.   def refresh_windows
  610.     @file_window.refresh
  611.     @action_window.refresh
  612.     @status_window.refresh
  613.   end

  614. end # Scene_File

  615. #==============================================================================
  616. # ■ Scene_Save
  617. #==============================================================================

  618. class Scene_Save < Scene_File

  619.   #--------------------------------------------------------------------------
  620.   # overwrite method: on_savefile_ok
  621.   #--------------------------------------------------------------------------
  622.   def on_savefile_ok; super; end

  623.   #--------------------------------------------------------------------------
  624.   # overwrite method: on_save_success
  625.   #--------------------------------------------------------------------------
  626.   def on_save_success; super; end

  627. end # help_window_text

  628. #==============================================================================
  629. # ■ Scene_Load
  630. #==============================================================================

  631. class Scene_Load < Scene_File

  632.   #--------------------------------------------------------------------------
  633.   # overwrite method: on_savefile_ok
  634.   #--------------------------------------------------------------------------
  635.   def on_savefile_ok; super; end

  636.   #--------------------------------------------------------------------------
  637.   # overwrite method: on_load_success
  638.   #--------------------------------------------------------------------------
  639.   def on_load_success; super; end

  640. end # Scene_Load

  641. #==============================================================================
  642. #
  643. # ■ End of File
  644. #
  645. #==============================================================================
复制代码

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

评分

参与人数 2星屑 +50 赞 +1 收起 理由
VIPArcher + 50 认可答案
火锅深处 + 1 解决了,谢谢大佬

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部