查看: 3552|回复: 0

[已经过期] 装备说明颜色报错啦

[复制链接]
梦石
0
星屑
704
在线时间
91 小时
注册时间
2018-9-30
回帖
43
发表于 2019-4-19 12:04:27 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 vixv 于 2019-4-19 12:11 编辑

[/pre]如下图,出现了这个英文,我百度也不知道怎么解决。
本来好好的,我再装备下面照图添加品质就报错了,
请问下是什么原因啊。是不是这个装备说明和物品颜色描绘冲突了啊
出问题是710行    color = Color.new(c[0],c[1],c[2],c[3])

  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ 装备说明增强 By wyongcan
  4. #==============================================================================
  5. module Equipplus
  6.   CODE ={
  7.     11 => "属性抗性",
  8.     12 => "弱化抗性",
  9.     13 => "状态抗性",
  10.     14 => "状态免疫",
  11.     21 => "普通能力",
  12.     22 => "添加能力",
  13.     23 => "特殊能力",
  14.     31 => "攻击附带属性",
  15.     32 => "攻击附带状态",
  16.     33 => "修正攻击速度",
  17.     34 => "添加攻击次数",
  18.     41 => "添加技能类型",
  19.     42 => "禁用技能类型",
  20.     43 => "添加技能",
  21.     44 => "禁用技能",
  22.     51 => "可装备武器类型",
  23.     52 => "可装备护甲类型",
  24.     53 => "固定装备",
  25.     54 => "禁用装备",
  26.     55 => "装备风格",
  27.     61 => "添加行动次数",
  28.     62 => "特殊标志",
  29.     63 => "消失效果",
  30.     64 => "队伍能力"}
  31.   #特殊标志
  32.   FLAG ={
  33.                 0 => "自动战斗",
  34.                 1 => "擅长防御",
  35.                 2 => "保护弱者",
  36.                 3 => "技能专注"}
  37.   #普通能力
  38.         PARAM ={
  39. #~                 0 => "最大HP",
  40. #~                 1 => "最大MP",
  41. #~                 2 => "物理攻击",
  42. #~                 3 => "物理防御",
  43. #~                 4 => "法术攻击",
  44. #~                 5 => "法术防御",
  45. #~                 6 => "敏 捷 值",
  46. #~                 7 => "幸 运 值"}
  47.                 0 => "最大兵力",
  48.                 1 => "最大谋点",
  49.                 2 => "武  力",
  50.                 3 => "防  御",
  51.                 4 => "智  力",
  52.                 5 => "策  防",
  53.                 6 => "速  度",
  54.                 7 => "统  帅"}
  55.   #添加能力
  56.         XPARAM ={
  57.                 0 => "物理命中几率:",
  58.                 1 => "物理闪避几率:",
  59.                 2 => "必杀几率:",
  60.                 3 => "必杀闪避几率:",
  61.                 4 => "法术闪避几率:",
  62.                 5 => "法术反射几率:",
  63.                 6 => "物理反击几率:",
  64.                 7 => "体力值再生速度:",
  65.                 8 => "魔力值再生速度:",
  66.                 9 => "技能值再生速度:"}
  67.   #特殊能力
  68.         SPARAM ={
  69.                 0 => "受到攻击的几率",
  70.                 1 => "防御效果比率",
  71.                 2 => "恢复效果比率",
  72.                 3 => "药理知识",
  73.                 4 => "MP消费率",
  74.                 5 => "TP消耗率",
  75.                 6 => "物理伤害加成",
  76.                 7 => "法术伤害加成",
  77.                 8 => "地形伤害加成",
  78.                 9 => "经验获得加成"}
  79.         @队伍能力 ={
  80.                 0 => "遇敌几率减半",
  81.                 1 => "随机遇敌无效",
  82.                 2 => "敌人偷袭无效",
  83.                 3 => "先制攻击几率上升",
  84.                 4 => "获得金钱数量双倍",
  85.                 5 => "物品掉落几率双倍"}
  86.   def self.equiphelpready
  87.     @状态 = {}
  88.     @武器类型 = {}
  89.     @防具类型 = {}
  90.     @属性 = {}
  91.     $data_states.each{|x| @状态[x.id] = x.name if x != nil}
  92.     elements = $data_system.elements
  93.     weapon_types = $data_system.weapon_types
  94.     armor_types = $data_system.armor_types
  95.     elements.each_with_index{|x,y| @属性[y] = x if x != ""}
  96.     weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}
  97.     armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}
  98.   end
  99.   
  100.   def self.getequiphelp(equip,actor=nil)#$game_party.leader)
  101.     need_help = ""
  102.     param = []
  103.     hzhj = " "
  104.     if equip.level_limit > 0
  105.       hzhj = "\001[255,255,255]装备要求:\001[-1,-1,-1]"      
  106.       need_help += hzhj# + "\n"
  107.       color = actor ? (actor.level < equip.level_limit ? "\001[255,0,0]" : "\001[0,255,0]") : "\001[255,255,255]"
  108.       need_help += sprintf(color+" %s %d %s\n",  Vocab.level, equip.level_limit, "\001[-1,-1,-1]")
  109.     end
  110.     for i in 0..7
  111.       if equip.params_limit(i) > 0
  112.         hzhj = "" if hzhj == "\001[255,255,255]装备要求:\001[-1,-1,-1]"
  113.         hzhj = "\001[255,255,255]装备要求\001[-1,-1,-1]" if hzhj == " "
  114.         need_help += hzhj# + "\n"
  115.         color = actor ? (actor.param(i) < equip.params_limit(i) ? "\001[255,0,0]" : "\001[0,255,0]") : "\001[255,255,255]"
  116.         need_help += sprintf(color+" %s %d %s\n", Vocab.param(i), equip.params_limit(i), "\001[-1,-1,-1]")
  117.       end
  118.     end
  119.     # 基本属性
  120.     params_help = ""
  121.     equip.params.each_with_index do |x,y|
  122.       text = ""
  123.       if y >= 2 && equip.level[y-2] > 0
  124.         text = ESTS::ESTSSetting[equip.level[y-2]][5]+"("+ESTS::ESTSSetting[equip.level[y-2]][0]+")"
  125.       end
  126.       param.push(["\001[255,255,255]" + PARAM[y],x,text])
  127.       
  128.     end
  129.     param = param.select{|x| x[1] != 0}
  130.     param.each_with_index do |x,i|
  131. #~       params_help += x[0] + "+" + x[1].to_int.to_s + x[2] +"\001[-1,-1,-1]\n"
  132.       params_help += x[0] + "   " + x[1].to_int.to_s + x[2] +"\001[-1,-1,-1]\n" if  x[1] < 0   
  133.       params_help += x[0] + "   +" + x[1].to_int.to_s + x[2] +"\001[-1,-1,-1]\n" if   x[1] > 0        
  134.     end
  135.     # 特性
  136.     features_help = ""
  137.     features = equip.features
  138.     features.select{|x| x.code == 55}.each{|x| features_help += CODE[x.code] + " 二刀流\001[-1,-1,-1]\n"}
  139.     features.select{|x| x.code == 11}.each{|x| features_help += CODE[x.code] + " " + @属性[x.data_id] + "*" + x.value.to_s  + "\001[-1,-1,-1]\n"}
  140.     features.select{|x| x.code == 12}.each{|x| features_help += CODE[x.code] + " " + PARAM[x.data_id] + "*" + x.value.to_s  + "\001[-1,-1,-1]\n"}
  141.     features.select{|x| x.code == 13}.each{|x| features_help += CODE[x.code] + " " + @状态[x.data_id] + "*" + x.value.to_s  + "\001[-1,-1,-1]\n"}
  142.     features.select{|x| x.code == 14}.each{|x| features_help += CODE[x.code] + " " + @状态[x.data_id]  + "\001[-1,-1,-1]\n"}
  143.     features.select{|x| x.code == 31}.each{|x| features_help += CODE[x.code] + " " + @属性[x.data_id]  + "\001[-1,-1,-1]\n"}
  144.     features.select{|x| x.code == 32}.each{|x| features_help += CODE[x.code] + " " + @状态[x.data_id] + "+" + x.value.to_s  + "\001[-1,-1,-1]\n"}
  145.     features.select{|x| x.code == 33}.each{|x| features_help += CODE[x.code] + " " + x.value.to_s  + "\001[-1,-1,-1]\n"}
  146.     features.select{|x| x.code == 34}.each{|x| features_help += CODE[x.code] + " " + x.value.to_s  + "\001[-1,-1,-1]\n"}
  147.     features.select{|x| x.code == 41}.each{|x| features_help += CODE[x.code] + " " + (x.data_id == 1 ? "体术" : "忍术")   + "\001[-1,-1,-1]\n"}
  148.     features.select{|x| x.code == 42}.each{|x| features_help += CODE[x.code] + " " + (x.data_id == 1 ? "体术" : "忍术")   + "\001[-1,-1,-1]\n"}
  149.     features.select{|x| x.code == 43}.each{|x| features_help += CODE[x.code] + " " + $data_skills[x.data_id].name   + "\001[-1,-1,-1]\n"}
  150.     features.select{|x| x.code == 44}.each{|x| features_help += CODE[x.code] + " " + $data_skills[x.data_id].name   + "\001[-1,-1,-1]\n"}
  151.     features.select{|x| x.code == 51}.each{|x| features_help += CODE[x.code] + " " + @武器类型[x.data_id]   + "\001[-1,-1,-1]\n"}
  152.     features.select{|x| x.code == 52}.each{|x| features_help += CODE[x.code] + " " + @防具类型[x.data_id]   + "\001[-1,-1,-1]\n"}
  153.     features.select{|x| x.code == 61}.each{|x| features_help += CODE[x.code] + " " + x.value.to_s   + "\001[-1,-1,-1]\n"}
  154.     features.select{|x| x.code == 62}.each{|x| features_help += CODE[x.code] + " " + FLAG[x.data_id]   + "\001[-1,-1,-1]\n"}
  155.     features.select{|x| x.code == 64}.each{|x| features_help += CODE[x.code] + " " + @队伍能力[x.data_id]   + "\001[-1,-1,-1]\n"}
  156.     featuresparam = []
  157.     featuresparam.push features.select{|x| x.code == 21}
  158.     featuresparam.push features.select{|x| x.code == 22}
  159.     featuresparam.push features.select{|x| x.code == 23}
  160.     featuresparam[0].each{|x| features_help += "\001[128,255,128]"+PARAM[x.data_id] + "* " + x.value.to_s  + "\001[-1,-1,-1]\n"}
  161.     featuresparam[1].each{|x| features_help += "\001[255,0,255]"+XPARAM[x.data_id] + "+ " +x.value.to_s  + "\001[-1,-1,-1]\n"}
  162.     featuresparam[2].each{|x| features_help += "\001[128,128,255]"+SPARAM[x.data_id] + "* " +x.value.to_s  + "\001[-1,-1,-1]\n"}
  163.     strongto_help = ""
  164.     if equip.strongto > 0
  165.       strong = nil
  166.       if equip.is_a?(RPG::Weapon)
  167.         strong = $data_weapons[equip.strongto]
  168.       elsif equip.is_a?(RPG::Armor)
  169.         strong = $data_armors[equip.strongto]
  170.       end
  171.       c = ItemLevelDrawer::ColorSet[[strong.quality-1,0].max]
  172.       strongto_help += "\001[255,128,255]可升阶到 \001["+c[0].to_s+","+c[1].to_s+","+c[2].to_s+"]" + strong.name + "\001[-1,-1,-1]"
  173.     else
  174.       strongto_help += "\001[255,128,255]无法升阶"
  175.     end
  176.     set_help = "\001[255,0,0]镶嵌:\n"
  177.     set_text = ""
  178.     equip.set.each do |s|
  179.       if s
  180.         c = ItemLevelDrawer::ColorSet[[s.quality-1,0].max]
  181.         set_text += "\001["+c[0].to_s+","+c[1].to_s+","+c[2].to_s+"]" + s.name + "\001[-1,-1,-1]\n"
  182.       end
  183.     end
  184.     set_text = "\001[228,228,228]无\n" if set_text == ""
  185.     set_help += set_text
  186.     help = [need_help,params_help,features_help,strongto_help,set_help]
  187.     return help
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 获取升阶后装备
  191.   #--------------------------------------------------------------------------
  192.   def self.after_levelup_equip(equip)
  193.     if equip.is_a?(RPG::Weapon)
  194.       if equip.level == [0]*6 && equip.set.compact == []
  195.         new_equip = $data_weapons[equip.strongto]
  196.       else
  197.         new_equip = $data_weapons[equip.strongto].dup
  198.         new_equip.id = $data_weapons.size
  199.         new_equip.params = $data_weapons[equip.strongto].params.dup
  200.         new_equip.level = $data_weapons[equip.strongto].level.dup
  201.         new_equip.set = $data_weapons[equip.strongto].set.dup
  202.         equip.level.each_with_index {|p,id| p.times {new_equip.level_up(id)}}
  203.         equip.set.each_with_index {|s,i| new_equip.set_item(i,s) if s}
  204.       end
  205.     else
  206.       if equip.level == [0]*6 && equip.set.compact == []
  207.         new_equip = $data_armors[equip.strongto]
  208.       else
  209.         new_equip = $data_armors[equip.strongto].dup
  210.         new_equip.id = $data_armors.size
  211.         new_equip.params = $data_armors[equip.strongto].params.dup
  212.         new_equip.level = $data_armors[equip.strongto].level.dup
  213.         new_equip.set = $data_armors[equip.strongto].set.dup
  214.         equip.level.each_with_index {|p,id| p.times {new_equip.level_up(id)}}
  215.         equip.set.each_with_index {|s,i| new_equip.set_item(i,s) if s}
  216.       end
  217.     end
  218.     new_equip
  219.   end
  220.    
  221.   def self.getline(text,maxtext)
  222.     xtext = []
  223.     line = 0
  224.     text.each_line{|x| xtext.push x.sub(/\n/){}}
  225.     xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}
  226.     line
  227.   end
  228. end
  229. #==============================================================================
  230. # ■ Window_Help
  231. #------------------------------------------------------------------------------
  232. #  显示技能和物品等的说明、以及角色状态的窗口
  233. #==============================================================================

  234. class Window_Help2 < Window_Base
  235.   #--------------------------------------------------------------------------
  236.   # ● 初始化对象
  237.   #--------------------------------------------------------------------------
  238.   def initialize(line_number = 0)
  239.     super(0, 0, 210, 0) #0,0,210,0
  240.     self.z = 150
  241.     contents.font.size = 14
  242.     hide
  243.   end
  244.   #--------------------------------------------------------------------------
  245.   # ● 设置内容
  246.   #--------------------------------------------------------------------------
  247.   def set_text(text)
  248.       @text = text
  249.       refresh
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● 清除
  253.   #--------------------------------------------------------------------------
  254.   def clear
  255.     set_text("")
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 更新帮助位置
  259.   #--------------------------------------------------------------------------
  260.   def uppos(index,rect,window)
  261.     self.height = fitting_height2(Equipplus.getline(@xtext,13))
  262.     create_contents
  263.     contents.font.size = 14
  264.     rect.x -= window.ox
  265.     rect.y -= window.oy
  266.     ax = rect.x + rect.width + 10
  267.     ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
  268.     ax += window.x
  269.     ax = 0 if ax < 0
  270.     ay = rect.y + rect.height
  271.     ay = rect.y - self.height if ay + self.height > window.height
  272.     ay += window.y
  273.     ay = 0 if ay < 0
  274.     self.x = ax
  275.     self.y = ay
  276.     set_text(@xtext)
  277.     show
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 设置物品
  281.   #     item : 技能、物品等
  282.   #--------------------------------------------------------------------------
  283.   def set_item(item)
  284.     if item == nil
  285.       set_text("")
  286.       return
  287.     end
  288.     @xtext = ""
  289.     @xtext = "\\c[1]名称\\c[0]:" + item.name + "\n"
  290.     @xtext += "\\c[1]介绍\\c[0]:" + item.description + "\n"
  291.     @xtext += "\\c[1]价格\\c[0]:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  292.     help,set = Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
  293.     @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ● 刷新
  297.   #--------------------------------------------------------------------------
  298.   def refresh
  299.     contents.clear
  300.     hide if @text == ""
  301.     draw_text_ex(4, 0, @text,width,40,false)
  302.   end
  303. end
  304. class Window_Base < Window
  305.   #--------------------------------------------------------------------------
  306.   # ● 计算窗口显示指定行数时的应用高度2*************************
  307.   #--------------------------------------------------------------------------
  308.   def fitting_height2(line_number)
  309.     line_number * contents.font.size + standard_padding * 2
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ● 文字的处理
  313.   #     c    : 文字
  314.   #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  315.   #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  316.   #--------------------------------------------------------------------------
  317.   def process_character(c, text, pos)
  318.     case c
  319.     when "\r"   # 回车
  320.       return
  321.     when "\n"   # 换行
  322.       process_new_line(text, pos)
  323.     when "\f"   # 翻页
  324.       process_new_page(text, pos)
  325.     when "\e"   # 控制符
  326.       process_escape_character(obtain_escape_code(text), text, pos)
  327.     else        # 普通文字
  328.       pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
  329.       if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
  330.         process_new_line(text, pos)
  331.       end
  332.       process_normal_character(c, pos)
  333.     end
  334.   end
  335. end

  336. class Window_ItemList < Window_Selectable
  337.   #--------------------------------------------------------------------------
  338.   # ● 显示窗口
  339.   #--------------------------------------------------------------------------
  340.   def show
  341.     @help_window.visible = true
  342.     super
  343.   end
  344.   #--------------------------------------------------------------------------
  345.   # ● 隐藏窗口
  346.   #--------------------------------------------------------------------------
  347.   def hide
  348.     @help_window.visible = false if(@help_window)
  349.     super
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # ● 更新帮助内容
  353.   #--------------------------------------------------------------------------
  354.   def update_help
  355.     @help_window.set_item(item)
  356.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil
  357.   end
  358. end
  359. class Window_EquipItem < Window_ItemList
  360.   #--------------------------------------------------------------------------
  361.   # ● 显示窗口
  362.   #--------------------------------------------------------------------------
  363.   def show
  364.     @help_window.visible=true
  365.     super
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 隐藏窗口
  369.   #--------------------------------------------------------------------------
  370.   def hide
  371.     @help_window.visible=false
  372.     super
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● 更新帮助内容
  376.   #--------------------------------------------------------------------------
  377.   def update_help
  378.     @help_window.set_item(item,@actor) if @help_window
  379.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil
  380.     if @actor && @status_window
  381.       temp_actor = Marshal.load(Marshal.dump(@actor))
  382.       temp_actor.force_change_equip(@slot_id, item)
  383.       @status_window.set_temp_actor(temp_actor)
  384.     end
  385.   end
  386. end

  387. class Window_SkillList < Window_Selectable
  388.   #--------------------------------------------------------------------------
  389.   # ● 显示窗口
  390.   #--------------------------------------------------------------------------
  391.   def show
  392.     @help_window.visible=true
  393.     super
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 隐藏窗口
  397.   #--------------------------------------------------------------------------
  398.   def hide
  399.     @help_window.visible=false
  400.     super
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ● 更新帮助内容
  404.   #--------------------------------------------------------------------------
  405.   def update_help
  406.     @help_window.set_item(item)
  407.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil
  408.   end
  409. end

  410. class Window_ShopBuy < Window_Selectable
  411.   #--------------------------------------------------------------------------
  412.   # ● 显示窗口
  413.   #--------------------------------------------------------------------------
  414.   def show
  415.     @help_window.visible=true
  416.     super
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 隐藏窗口
  420.   #--------------------------------------------------------------------------
  421.   def hide
  422.     @help_window.visible=false
  423.     super
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ● 更新帮助内容
  427.   #--------------------------------------------------------------------------
  428.   def update_help
  429.     @help_window.set_item(item) if @help_window
  430.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil && @help_window
  431.     @status_window.item = item if @status_window
  432.   end
  433. end

  434. class Window_EquipSlot < Window_Selectable
  435.     #--------------------------------------------------------------------------
  436.   # ● 显示窗口
  437.   #--------------------------------------------------------------------------
  438.   def show
  439.     @help_window.visible=true
  440.     super
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ● 隐藏窗口
  444.   #--------------------------------------------------------------------------
  445.   def hide
  446.     @help_window.visible=false
  447.     super
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● 更新帮助内容
  451.   #--------------------------------------------------------------------------
  452.   def update_help
  453.     super
  454.     @help_window.set_item(item,@actor) if @help_window
  455.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil && @help_window
  456.     @status_window.set_temp_actor(nil) if @status_window
  457.   end
  458. end

  459. class Scene_Shop < Scene_MenuBase
  460.         alias on_sell_ok_old on_sell_ok
  461.         def on_sell_ok
  462.                 on_sell_ok_old
  463.                 @help_window.hide
  464.         end
  465.         alias on_buy_ok_old on_buy_ok
  466.         def on_buy_ok
  467.                 on_buy_ok_old
  468.                 @help_window.hide
  469.         end
  470.         alias on_number_ok_old on_number_ok
  471.         def on_number_ok
  472.                 on_number_ok_old
  473.     @help_window.refresh
  474.                 @help_window.show
  475.         end
  476.         alias on_number_cancel_old on_number_cancel
  477.         def on_number_cancel
  478.                 on_number_cancel_old
  479.     @help_window.refresh
  480.                 @help_window.show
  481.         end
  482. end

  483. class Scene_Title < Scene_Base
  484.   alias start_old start
  485.   def start
  486.     start_old
  487.     Equipplus.equiphelpready
  488.   end
  489. end

  490. class Scene_ItemBase < Scene_MenuBase
  491.         alias old_on_actor_cancel on_actor_cancel
  492.   def on_actor_cancel
  493.     old_on_actor_cancel
  494.     @help_window.refresh
  495.   end
  496.         alias old_on_actor_ok on_actor_ok
  497.   def on_actor_ok
  498.     old_on_actor_ok
  499.     @help_window.refresh
  500.   end
  501. end

  502. class Window_Base < Window
  503.         alias old_process_new_line process_new_line
  504.         def process_new_line(text, pos)
  505.     old_process_new_line(text, pos)
  506.                 pos[:height] = contents.font.size if pos[:width] != nil
  507.         end
  508. end

  509. class Scene_MenuBase < Scene_Base
  510.   def create_help_window
  511.     @help_window = NIS_Item_Help.new(nil,0,0,156)
  512.   end
  513. end
  514. class Scene_Battle < Scene_Base
  515.   def create_help_window
  516.     @help_window = NIS_Item_Help.new(nil,0,0,156)
  517.   end
  518. end

  519. #==============================================================================
  520. # ■ NIS_Item_Help
  521. #------------------------------------------------------------------------------
  522. #  显示技能和物品等的说明、以及角色状态的界面
  523. #==============================================================================

  524. class NIS_Item_Help < NIS_InfoContents
  525.   #--------------------------------------------------------------------------
  526.   # ● 初始化对象
  527.   #--------------------------------------------------------------------------  
  528.   def initialize(item,x,y,width,text_size=18,auto_height = true,auto_scroll = false,scroll_pix=1,scroll_space=1)
  529.     width_help = width #加了这个作为帮助窗口的宽度 PannyDD
  530.     width = 300        #加了这个作为帮助窗口的宽度 PannyDD
  531.     super(0,0,Bitmap.new(width,1),auto_scroll,scroll_pix,scroll_space)   
  532.     @visible = false
  533.     @status = :open
  534.     @viewport = Viewport.new(Rect.new(x,y,width,1))
  535.     @viewport.z = 1000

  536.     @window.viewport = @viewport
  537.     @window.bitmap.font.size = text_size
  538.     @auto_height = auto_height
  539.     @item = item
  540.     width = width_help #加了这个作为帮助窗口的宽度 PannyDD
  541.     refresh
  542.   end
  543.   #--------------------------------------------------------------------------
  544.   # ● 出现
  545.   #--------------------------------------------------------------------------
  546.   def width
  547.     @window.width
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ● 隐藏
  551.   #--------------------------------------------------------------------------
  552.   def height
  553.     @window.height
  554.   end
  555.   #--------------------------------------------------------------------------
  556.   # ● 出现
  557.   #--------------------------------------------------------------------------
  558.   def show
  559.     self.visible2=true
  560.   end
  561.   #--------------------------------------------------------------------------
  562.   # ● 隐藏
  563.   #--------------------------------------------------------------------------
  564.   def hide
  565.     self.visible2=true
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # ● 获取边距尺寸
  569.   #--------------------------------------------------------------------------
  570.   def padding
  571.     return 4
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # ● 更改可视属性(渐变操作)
  575.   #--------------------------------------------------------------------------
  576.   def visible2=(value)
  577.     case value
  578.     when true
  579.       @viewport.visible = true
  580.       @visible = true
  581.       @opacity = 0
  582.       @active = true
  583.       @status = :show
  584.     when false
  585.       @opacity = 255
  586.       @status = :hide
  587.     end
  588.   end
  589.   #--------------------------------------------------------------------------
  590.   # ● 更新
  591.   #--------------------------------------------------------------------------
  592.   def update
  593.     super
  594.     update_visible
  595.   end
  596.   #--------------------------------------------------------------------------
  597.   # ● 更新渐变效果
  598.   #--------------------------------------------------------------------------
  599.   def update_visible
  600.     @count += 1
  601.     case @status
  602.     when :show
  603.       @window.opacity += 10
  604.       @contents.opacity += 10
  605.       @status = :open if @window.opacity >= 255
  606.     when :hide
  607.       @window.opacity -= 10
  608.       @contents.opacity -= 10
  609.       @count = 0
  610.       @visible = false if @window.opacity <= 0
  611.     end
  612.   end
  613.   #--------------------------------------------------------------------------
  614.   # ● 清除
  615.   #--------------------------------------------------------------------------
  616.   def clear
  617.     set_item(nil)
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 设置物品
  621.   #     item : 技能、物品等
  622.   #--------------------------------------------------------------------------
  623.   def set_item(item,actor = nil)
  624.     @item = item  if @item != item
  625.     @actor = actor if @actor != actor
  626.     refresh
  627.   end
  628.   #--------------------------------------------------------------------------
  629.   # ● 更新帮助位置
  630.   #--------------------------------------------------------------------------
  631.   def uppos(rect,window)
  632.     rect.x -= window.ox
  633.     rect.y -= window.oy
  634.     ax = rect.x + rect.width + 10
  635.     ax = rect.x - @window.width + 10 if ax + @window.width > window.width + 10
  636.     ax += window.x
  637.     ax = 0 if ax < 0
  638.     ay = rect.y + rect.height
  639.     ay = rect.y - @window.height if ay + @window.height > window.height
  640.     ay += window.y
  641.     ay = 0 if ay < 0
  642.     @viewport.rect.x = ax
  643.     @viewport.rect.y = ay
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● 获取帮助
  647.   #--------------------------------------------------------------------------
  648.   def get_help
  649.     help = []
  650.     help.push(@item.name)
  651.     help.push(@item.description)
  652.     help += Equipplus.getequiphelp(@item,@actor) if @item.is_a?(RPG::EquipItem)
  653.     help.push("\001[128,128,255]价格:\001[-1,-1,-1]" + @item.price.to_s) if !@item.is_a?(RPG::Skill)
  654.     help.delete("")
  655.     help
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 获取帮助高度
  659.   #--------------------------------------------------------------------------
  660.   def get_help_height(help)
  661.     help_height = [0]*help.size
  662.     help.size.times do |i|
  663.       @window.bitmap.font.size -= 2 if i == 1
  664.       help_height[i] = @window.bitmap.font.size+2 if i == 0
  665.       help_height[i] = get_height(help[i],@window.bitmap.width-padding,@window.bitmap) if i > 0
  666.       @window.bitmap.font.size += 2 if i == 1
  667.     end
  668.     help_height
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # ● 获取帮助高度
  672.   #--------------------------------------------------------------------------
  673.   def get_help_height_sum(help_height)
  674.     sum = 0
  675.     help_height.each{|h| sum += h + 5}
  676.     return sum - 5
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # ● 改变高度
  680.   #--------------------------------------------------------------------------
  681.   def change_height(height)
  682.     if @auto_height
  683.       @window.bitmap = Bitmap.new(@window.bitmap.width,height+2*padding)
  684.       @window.viewport.rect.height = height+2*padding
  685.     else
  686.       src_height = @window.height
  687.       @window.bitmap = Bitmap.new(@window.bitmap.width,height+2*padding)
  688.       @window.src_rect = Rect.new(0,0,@window.bitmap.width-padding,src_height)
  689.     end
  690.    
  691.   end
  692.   #--------------------------------------------------------------------------
  693.   # ● 绘制背景
  694.   #--------------------------------------------------------------------------
  695.   def draw_background(height)
  696.     c = ItemLevelDrawer::ColorSet[[@item.quality-1,0].max]
  697.     color = Color.new(c[0],c[1],c[2],c[3])
  698.     font_size = @window.bitmap.font.size
  699.    
  700.     change_height(height)
  701.    
  702.     @window.bitmap.fill_rect(0,0,@window.bitmap.width,@window.bitmap.height,Color.new(25,25,25,182))
  703.     @window.bitmap.font.color = color
  704.     @window.bitmap.font.size = font_size
  705.   end
  706.   #--------------------------------------------------------------------------
  707.   # ● 绘制内容
  708.   #--------------------------------------------------------------------------
  709.   def draw_contents(help,help_height)
  710.     color = @window.bitmap.font.color.clone
  711.     sum_height = padding
  712.     help.each_with_index do |h,i|
  713.       @window.bitmap.font.size -= 2 if i == 1
  714.       draw_colorful_text(@window.bitmap,padding,sum_height,@window.bitmap.width-padding,help_height[0],h,color.clone,false,1,1) if i == 0
  715.       draw_colorful_text(@window.bitmap,padding,sum_height,@window.bitmap.width-padding,@window.bitmap.font.size,h,color.clone) if i > 0
  716.       @window.bitmap.font.size += 2 if i == 1
  717.       sum_height += help_height[i]
  718.       draw_split_line(sum_height+2,color) if i < help.size - 1
  719.       sum_height += 5
  720.     end
  721.   end
  722.   #--------------------------------------------------------------------------
  723.   # ● 绘制分割线
  724.   #--------------------------------------------------------------------------
  725.   def draw_split_line(y,color=Color.new(254,215,0))
  726.     @window.bitmap.draw_line(padding,y,@window.bitmap.width-padding,y,color)
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● 刷新
  730.   #--------------------------------------------------------------------------
  731.   def refresh
  732.     @window.bitmap.clear
  733.     return unless @item
  734.     help = get_help
  735.     help_height = get_help_height(help)   
  736.     draw_background(get_help_height_sum(help_height))
  737.     draw_contents(help,help_height)
  738.    
  739.     show
  740.   end
  741. end


复制代码
12345.png
想做一款 吞食天地2重制版 游戏
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部