查看: 5649|回复: 1

[已经解决] 选项扩展脚本导致的无法存档是怎回事呢??

[复制链接]
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2021-3-4 22:41:48 | 显示全部楼层 |阅读模式
悬赏180星屑已解决
本帖最后由 alexncf125 于 2021-4-1 20:34 编辑

插入脚本后, 还是能存档的...
但一用"显示选项"事件指令, 就会变得不能存档了...
这BUG是怎么一回事呢  
  1. #===============================================================================
  2. # Zetu Engine V: Choices Extention
  3. #     by Zetu
  4. #     --- Created: 12/30/2014
  5. #     --- Updated: 01/06/2015 v1.02
  6. #-------------------------------------------------------------------------------
  7. # Instructions: Place special commands inside Display Choices.
  8. # [mode=?]
  9. #   Option: H
  10. #       Displays choices horizontally
  11. #   Option: C
  12. #       Centers choice display
  13. #   Option: X
  14. #       Shows no back window while displayed
  15. #   Option: F
  16. #       Fixes location of first selection
  17. #   Option: U, Adds F, H, C
  18. #       Centers options on item, rather than window
  19. #   Option: R, Ignores H, U
  20. #       Counts as X. Display choices in a circular fasion.
  21. # [img=?]
  22. #   Displays an image with the specified filename as an option. Option: I
  23. # [switch=?]
  24. #   Only shows if specified switch ID is ON.
  25. #-------------------------------------------------------------------------------
  26. # Changelog:
  27. #   v1.01
  28. #     * Fixed bug causing normal text to not adapt window size.
  29. #         < Reported by ArbitraryGuy >
  30. #   v1.02
  31. #     + Added [icon=?]
  32. #     + Added [switch=?]
  33. #     + Added F mode option.
  34. #     + Added U mode option.
  35. #     + Added Feature to combine Choice Box Dialogs.
  36. #===============================================================================

  37. class Window_Command < Window_Selectable
  38.   
  39.   #=============================================================================
  40.   # Create Objects
  41.   #-----------------------------------------------------------------------------
  42.   alias :zev_choice_add_command :add_command
  43.   def add_command(name, symbol, enabled = true, ext = nil)
  44.     command = name.dup
  45.     if command =~ /\[mode\=(.+?)\]/i
  46.       modes = $1.lstrip.rstrip.upcase
  47.       modes.split(//).each do |m|
  48.         @modes |= [m]
  49.         case m
  50.         when "U"
  51.           @modes |= ["H", "C", "F"]
  52.         end
  53.       end
  54.       command.gsub!(/\[mode\=.+?\]/i, "")
  55.     end
  56.     if name =~ /\[img\=(.+?)\]/i
  57.       @modes |= ["I"]
  58.       filename = $1.lstrip.rstrip
  59.       filename = $game_variables[$1.to_f.to_i].lstrip.rstrip if $1.to_f.to_i > 0
  60.       width    = Cache.picture(filename).width
  61.       height   = Cache.picture(filename).height
  62.       @list.push({:name=>command, :symbol=>symbol, :enabled=>enabled, :ext=>ext,
  63.       :zev_ext=>:image, :filename=>filename, :width=>width, :height=>height})
  64.     else
  65.       zev_choice_add_command(command, symbol, enabled, ext)
  66.     end
  67.   end
  68.   
  69.   #=============================================================================
  70.   # Clear
  71.   #-----------------------------------------------------------------------------
  72.   alias :zev_stabs_clear_command_list :clear_command_list
  73.   def clear_command_list
  74.     @modes = []
  75.     zev_stabs_clear_command_list
  76.   end
  77.   
  78.   #=============================================================================
  79.   # Conditions
  80.   #-----------------------------------------------------------------------------
  81.   def mode_include?(s)
  82.     return false unless @modes
  83.     return true if @modes.include?(s)
  84.     return false
  85.   end
  86.   
  87. end

  88. class Window_ChoiceList < Window_Command
  89.   
  90.   alias :zev_sbp_start :start
  91.   def start
  92.     zev_sbp_start
  93.     update_placement
  94.     select(0)
  95.   end
  96.   
  97.   #=============================================================================
  98.   # Update
  99.   #-----------------------------------------------------------------------------
  100.   def update
  101.     super
  102.     update_xy(self.index)
  103.   end
  104.   
  105.   def update_placement
  106.     update_size
  107.     update_xy
  108.     self.opacity = mode_include?("X") ? 0 : 255
  109.   end
  110.   
  111.   def update_size
  112.     self.width  = contents_width + padding * 2
  113.     self.height = contents_height + padding * 2
  114.   end
  115.   
  116.   def update_xy(index = 0)
  117.     self.x = Graphics.width - width
  118.     if @message_window.y >= Graphics.height / 2
  119.       self.y = @message_window.y - height
  120.     else
  121.       if mode_include?("C")
  122.         self.y = Graphics.height + @message_window.y + @message_window.height - self.height
  123.       else
  124.         self.y = @message_window.y + @message_window.height
  125.       end
  126.     end
  127.     if mode_include?("C")
  128.       self.x /= 2
  129.       self.y /= 2
  130.     end
  131.     if mode_include?("U")
  132.       self.x = (Graphics.width - item_rect(index).width) / 2
  133.     end
  134.     if mode_include?("F")
  135.       if mode_include?("H")
  136.         self.x -= get_special_x(index)
  137.       else
  138.         self.y -= get_special_y(index)
  139.       end
  140.     end
  141.   end
  142.   
  143.   def update_padding_bottom
  144.     if mode_include?("I")
  145.       self.padding_bottom = 0
  146.     else
  147.       super
  148.     end
  149.   end
  150.   
  151.   def ensure_cursor_visible
  152.     unless mode_include?("R")
  153.       super
  154.     end
  155.   end
  156.   
  157.   #=============================================================================
  158.   # Object Calls
  159.   #-----------------------------------------------------------------------------
  160.   def call_cancel_handler
  161.     $game_message.choice_cancel_proc.call($game_message.choice_cancel_type - 1)
  162.     close
  163.   end
  164.   
  165.   #=============================================================================
  166.   # Conditions
  167.   #-----------------------------------------------------------------------------
  168.   def cancel_enabled?
  169.     $game_message.choice_cancel_data != nil
  170.   end
  171.   
  172.   #=============================================================================
  173.   # Reference Objects
  174.   #-----------------------------------------------------------------------------
  175.   def contents_width
  176.     if mode_include?("H")
  177.       return sp_global_width
  178.     elsif mode_include?("R")
  179.       return 3 * sp_item_width(24)
  180.     else
  181.       return sp_item_width
  182.     end
  183.   end
  184.   
  185.   def contents_height
  186.     if mode_include?("H")
  187.       return sp_item_height
  188.     elsif mode_include?("R")
  189.       return 3 * sp_item_height(24)
  190.     else
  191.       return sp_global_height
  192.     end
  193.   end
  194.   
  195.   def sp_text_size(string)
  196.     return Rect.new(0,0,0,0) if string.nil?
  197.     bitmap = Bitmap.new(1,1)
  198.     w = 8
  199.     string = string.gsub(/\\i\[\d+?\]/i) do |s|
  200.       w += 24
  201.       ""
  202.     end
  203.     string = string.gsub(/\[mode\=.+?\]/i, "")
  204.     rect = bitmap.text_size(string)
  205.     rect.width += w
  206.     bitmap.dispose
  207.     rect
  208.   end
  209.   
  210.   def sp_item_width(min = 96)
  211.     @list.each.with_index.inject(0) { |sum, (hash,i)|
  212.       [sum, (hash[:width] || [min, sp_text_size($game_message.choices[i]).width].max)].max
  213.     }
  214.   end
  215.   
  216.   def sp_item_height(min = line_height)
  217.     @list.inject(0) { |sum, hash|
  218.       [sum, (hash[:height] || [min,line_height].max)].max
  219.     } || 0
  220.   end
  221.   
  222.   def sp_global_width(min = 96)
  223.     @list.each.with_index.inject(0) { |sum, (hash,i)|
  224.       sum+(hash[:width]|| [min, sp_text_size($game_message.choices[i]).width].max)
  225.     }
  226.   end
  227.   
  228.   def sp_global_height(min = line_height)
  229.     @list.inject(0) { |sum, hash|
  230.       sum + (hash[:height] || [min,line_height].max)
  231.     } || 0
  232.   end
  233.   
  234.   def item_rect(index)
  235.     data = @list[index]||{}
  236.     rect = Rect.new
  237.     if mode_include?("R")
  238.       rect.width = sp_item_width(24)
  239.       rect.height = sp_item_height(24)
  240.       r = index.to_f / item_max
  241.       r *= 2 * Math.acos(-1)
  242.       rect.x = Math.cos(r) * sp_item_width(24) + self.contents.width / 2
  243.       rect.x -= sp_item_width(24) / 2
  244.       #rect.y = Math.sin(r) * line_height + sp_item_height(24)
  245.       rect.y = Math.sin(r) * sp_item_height(24) + self.contents.height / 2
  246.       rect.y -= sp_item_height(24) / 2
  247.     elsif mode_include?("H")
  248.       rect.width = data[:width] || 96
  249.       rect.height = contents_height
  250.       rect.x = get_special_x(index)
  251.       rect.y = 0
  252.     else
  253.       rect.width = contents_width
  254.       rect.height = data[:height] || item_height
  255.       rect.x = 0
  256.       rect.y = get_special_y(index)
  257.     end
  258.     rect
  259.   end
  260.   
  261.   def get_special_x(index)
  262.     @list[0...index].inject(0) do |sum, hash|
  263.       sum + (hash[:width] || 96)
  264.     end || 0
  265.   end
  266.   
  267.   def get_special_y(index)
  268.     @list[0...index].inject(0) do |sum, hash|
  269.       sum + (hash[:height] || line_height)
  270.     end || 0
  271.   end
  272.   
  273.   def col_max
  274.     return @list.size if mode_include?("H")
  275.     return super
  276.   end
  277.   
  278.   def row_max
  279.     return 1 if mode_include?("H")
  280.     return super
  281.   end
  282.   
  283.   def alignment
  284.     return 1 if mode_include?("R")
  285.     return 0
  286.   end
  287.   
  288.   #=============================================================================
  289.   # Drawing
  290.   #-----------------------------------------------------------------------------
  291.   
  292.   alias :zev_choice_draw_item :draw_item
  293.   def draw_item(index)
  294.     data = @list[index]
  295.     case data[:zev_ext]
  296.     when nil
  297.       zev_choice_draw_item(index)
  298.     when :image
  299.       bitmap = Cache.picture(data[:filename])
  300.       irect = item_rect(index)
  301.       brect = Rect.new(0,0,data[:width],data[:height])
  302.       contents.blt(irect.x, irect.y, bitmap, brect)
  303.     end
  304.   end
  305.   
  306. end

  307. class Game_Message
  308.   attr_accessor :choice_data
  309.   attr_accessor :choice_cancel_data
  310.   attr_accessor :choice_cancel_proc
  311. end

  312. class Game_Interpreter
  313.   
  314.   alias :zev_choice_clear :clear
  315.   def clear
  316.     zev_choice_clear
  317.     @choice_skip = {}
  318.   end
  319.   
  320.   def add_zev_special_choice_data(ti)
  321.     choice_data = {}
  322.     @list[ti].parameters[0].each_with_index do |c, i|
  323.       name = c.dup
  324.       if name =~ /\[switch\=(\d+?)\]/i
  325.         next unless $game_switches[$1.to_i]
  326.         name.gsub!(/\[switch\=\d+?\]/i, "")
  327.       end
  328.       choice_data[i] = name
  329.     end
  330.     s_index = $game_message.choices.size
  331.     skip    = $game_message.choice_data.size
  332.     choice_data.values.each {|s| $game_message.choices.push(s) }
  333.     $game_message.choice_data << {
  334.       :si   => s_index,
  335.       :skip => skip,
  336.       :choice_data => choice_data.keys
  337.     }
  338.     if @list[ti].parameters[1] != 0
  339.       $game_message.choice_cancel_data = {
  340.         :skip => skip,
  341.         :n    => @list[ti].parameters[1] - 1
  342.       }
  343.     end
  344.   end
  345.   
  346.   alias :zev_choice_setup_choices :setup_choices
  347.   def setup_choices(params)
  348.     $game_message.choice_data = []
  349.     $game_message.choice_cancel_data = nil
  350.     add_zev_special_choice_data(@index)
  351.     ti = @index
  352.     while @list[ti] and @list[ti].code == 102
  353.       ti += 1
  354.       ti += 1 while @list[ti].indent > @indent or [402,403,404].include? @list[ti].code
  355.       break if @list[ti].code != 102
  356.       add_zev_special_choice_data(ti)
  357.     end
  358.     $game_message.choice_proc = Proc.new {|n|
  359.       data = $game_message.choice_data.select do |h|
  360.         h[:si] <= n
  361.       end.max_by do |h|
  362.         h[:si]
  363.       end
  364.       @choice_skip[@indent] = data[:skip]
  365.       @branch[@indent] = data[:choice_data][n - data[:si]]
  366.     }
  367.     $game_message.choice_cancel_proc = Proc.new{|n|
  368.       data = $game_message.choice_cancel_data
  369.       @choice_skip[@indent] = data[:skip]
  370.       @branch[@indent] = data[:n]
  371.     }
  372.   end
  373.   
  374.   alias :zev_choice_command_102 :command_102
  375.   def command_102
  376.     return if @list[@index - 1].code == 404 if @list[@index - 1]
  377.     zev_choice_command_102
  378.   end
  379.   
  380.   def command_402
  381.     command_skip if @branch[@indent] != @params[0] or @choice_skip[@indent] != 0
  382.   end
  383.   
  384.   def command_403
  385.     command_skip if @branch[@indent] != 4 or @choice_skip[@indent] != 0
  386.   end
  387.   
  388.   def command_404
  389.     @choice_skip[@indent] -= 1 if @choice_skip[@indent]
  390.   end
  391.   
  392. end
复制代码

最佳答案

查看完整内容

因为它新增了一个proc对象,但是没有像默认RGSS里面那样在使用后清除,导致存档在存储Proc对象时失败 像默认一样加个清除就好了

老鹰

梦石
40
星屑
38044
在线时间
7127 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2021-3-4 22:41:49 | 显示全部楼层
因为它新增了一个proc对象,但是没有像默认RGSS里面那样在使用后清除,导致存档在存储Proc对象时失败

像默认一样加个清除就好了
  1. class Game_Message
  2.   alias :zev_message_choice_clear :clear
  3.   def clear
  4.     zev_message_choice_clear
  5.     @choice_cancel_proc = nil
  6.   end
  7. end
复制代码

评分

参与人数 1赞 +1 收起 理由
alexncf125 + 1 谢谢大大的帮忙!~

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部