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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
704
在线时间
91 小时
注册时间
2018-9-30
帖子
56
跳转到指定楼层
1
发表于 2019-4-19 12:04:27 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

RUBY 代码复制
  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.  
  235. class Window_Help2 < Window_Base
  236.   #--------------------------------------------------------------------------
  237.   # ● 初始化对象
  238.   #--------------------------------------------------------------------------
  239.   def initialize(line_number = 0)
  240.     super(0, 0, 210, 0) #0,0,210,0
  241.     self.z = 150
  242.     contents.font.size = 14
  243.     hide
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 设置内容
  247.   #--------------------------------------------------------------------------
  248.   def set_text(text)
  249.       @text = text
  250.       refresh
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ● 清除
  254.   #--------------------------------------------------------------------------
  255.   def clear
  256.     set_text("")
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 更新帮助位置
  260.   #--------------------------------------------------------------------------
  261.   def uppos(index,rect,window)
  262.     self.height = fitting_height2(Equipplus.getline(@xtext,13))
  263.     create_contents
  264.     contents.font.size = 14
  265.     rect.x -= window.ox
  266.     rect.y -= window.oy
  267.     ax = rect.x + rect.width + 10
  268.     ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
  269.     ax += window.x
  270.     ax = 0 if ax < 0
  271.     ay = rect.y + rect.height
  272.     ay = rect.y - self.height if ay + self.height > window.height
  273.     ay += window.y
  274.     ay = 0 if ay < 0
  275.     self.x = ax
  276.     self.y = ay
  277.     set_text(@xtext)
  278.     show
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 设置物品
  282.   #     item : 技能、物品等
  283.   #--------------------------------------------------------------------------
  284.   def set_item(item)
  285.     if item == nil
  286.       set_text("")
  287.       return
  288.     end
  289.     @xtext = ""
  290.     @xtext = "\\c[1]名称\\c[0]:" + item.name + "\n"
  291.     @xtext += "\\c[1]介绍\\c[0]:" + item.description + "\n"
  292.     @xtext += "\\c[1]价格\\c[0]:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
  293.     help,set = Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
  294.     @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● 刷新
  298.   #--------------------------------------------------------------------------
  299.   def refresh
  300.     contents.clear
  301.     hide if @text == ""
  302.     draw_text_ex(4, 0, @text,width,40,false)
  303.   end
  304. end
  305. class Window_Base < Window
  306.   #--------------------------------------------------------------------------
  307.   # ● 计算窗口显示指定行数时的应用高度2*************************
  308.   #--------------------------------------------------------------------------
  309.   def fitting_height2(line_number)
  310.     line_number * contents.font.size + standard_padding * 2
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 文字的处理
  314.   #     c    : 文字
  315.   #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  316.   #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  317.   #--------------------------------------------------------------------------
  318.   def process_character(c, text, pos)
  319.     case c
  320.     when "\r"   # 回车
  321.       return
  322.     when "\n"   # 换行
  323.       process_new_line(text, pos)
  324.     when "\f"   # 翻页
  325.       process_new_page(text, pos)
  326.     when "\e"   # 控制符
  327.       process_escape_character(obtain_escape_code(text), text, pos)
  328.     else        # 普通文字
  329.       pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
  330.       if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
  331.         process_new_line(text, pos)
  332.       end
  333.       process_normal_character(c, pos)
  334.     end
  335.   end
  336. end
  337.  
  338. class Window_ItemList < Window_Selectable
  339.   #--------------------------------------------------------------------------
  340.   # ● 显示窗口
  341.   #--------------------------------------------------------------------------
  342.   def show
  343.     @help_window.visible = true
  344.     super
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 隐藏窗口
  348.   #--------------------------------------------------------------------------
  349.   def hide
  350.     @help_window.visible = false if(@help_window)
  351.     super
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 更新帮助内容
  355.   #--------------------------------------------------------------------------
  356.   def update_help
  357.     @help_window.set_item(item)
  358.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil
  359.   end
  360. end
  361. class Window_EquipItem < Window_ItemList
  362.   #--------------------------------------------------------------------------
  363.   # ● 显示窗口
  364.   #--------------------------------------------------------------------------
  365.   def show
  366.     @help_window.visible=true
  367.     super
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 隐藏窗口
  371.   #--------------------------------------------------------------------------
  372.   def hide
  373.     @help_window.visible=false
  374.     super
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 更新帮助内容
  378.   #--------------------------------------------------------------------------
  379.   def update_help
  380.     @help_window.set_item(item,@actor) if @help_window
  381.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil
  382.     if @actor && @status_window
  383.       temp_actor = Marshal.load(Marshal.dump(@actor))
  384.       temp_actor.force_change_equip(@slot_id, item)
  385.       @status_window.set_temp_actor(temp_actor)
  386.     end
  387.   end
  388. end
  389.  
  390. class Window_SkillList < Window_Selectable
  391.   #--------------------------------------------------------------------------
  392.   # ● 显示窗口
  393.   #--------------------------------------------------------------------------
  394.   def show
  395.     @help_window.visible=true
  396.     super
  397.   end
  398.   #--------------------------------------------------------------------------
  399.   # ● 隐藏窗口
  400.   #--------------------------------------------------------------------------
  401.   def hide
  402.     @help_window.visible=false
  403.     super
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ● 更新帮助内容
  407.   #--------------------------------------------------------------------------
  408.   def update_help
  409.     @help_window.set_item(item)
  410.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil
  411.   end
  412. end
  413.  
  414. class Window_ShopBuy < Window_Selectable
  415.   #--------------------------------------------------------------------------
  416.   # ● 显示窗口
  417.   #--------------------------------------------------------------------------
  418.   def show
  419.     @help_window.visible=true
  420.     super
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # ● 隐藏窗口
  424.   #--------------------------------------------------------------------------
  425.   def hide
  426.     @help_window.visible=false
  427.     super
  428.   end
  429.   #--------------------------------------------------------------------------
  430.   # ● 更新帮助内容
  431.   #--------------------------------------------------------------------------
  432.   def update_help
  433.     @help_window.set_item(item) if @help_window
  434.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil && @help_window
  435.     @status_window.item = item if @status_window
  436.   end
  437. end
  438.  
  439. class Window_EquipSlot < Window_Selectable
  440.     #--------------------------------------------------------------------------
  441.   # ● 显示窗口
  442.   #--------------------------------------------------------------------------
  443.   def show
  444.     @help_window.visible=true
  445.     super
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 隐藏窗口
  449.   #--------------------------------------------------------------------------
  450.   def hide
  451.     @help_window.visible=false
  452.     super
  453.   end
  454.   #--------------------------------------------------------------------------
  455.   # ● 更新帮助内容
  456.   #--------------------------------------------------------------------------
  457.   def update_help
  458.     super
  459.     @help_window.set_item(item,@actor) if @help_window
  460.     @help_window.uppos(item_rect(index),self) if index != -1 && item != nil && @help_window
  461.     @status_window.set_temp_actor(nil) if @status_window
  462.   end
  463. end
  464.  
  465. class Scene_Shop < Scene_MenuBase
  466.         alias on_sell_ok_old on_sell_ok
  467.         def on_sell_ok
  468.                 on_sell_ok_old
  469.                 @help_window.hide
  470.         end
  471.         alias on_buy_ok_old on_buy_ok
  472.         def on_buy_ok
  473.                 on_buy_ok_old
  474.                 @help_window.hide
  475.         end
  476.         alias on_number_ok_old on_number_ok
  477.         def on_number_ok
  478.                 on_number_ok_old
  479.     @help_window.refresh
  480.                 @help_window.show
  481.         end
  482.         alias on_number_cancel_old on_number_cancel
  483.         def on_number_cancel
  484.                 on_number_cancel_old
  485.     @help_window.refresh
  486.                 @help_window.show
  487.         end
  488. end
  489.  
  490. class Scene_Title < Scene_Base
  491.   alias start_old start
  492.   def start
  493.     start_old
  494.     Equipplus.equiphelpready
  495.   end
  496. end
  497.  
  498. class Scene_ItemBase < Scene_MenuBase
  499.         alias old_on_actor_cancel on_actor_cancel
  500.   def on_actor_cancel
  501.     old_on_actor_cancel
  502.     @help_window.refresh
  503.   end
  504.         alias old_on_actor_ok on_actor_ok
  505.   def on_actor_ok
  506.     old_on_actor_ok
  507.     @help_window.refresh
  508.   end
  509. end
  510.  
  511. class Window_Base < Window
  512.         alias old_process_new_line process_new_line
  513.         def process_new_line(text, pos)
  514.     old_process_new_line(text, pos)
  515.                 pos[:height] = contents.font.size if pos[:width] != nil
  516.         end
  517. end
  518.  
  519. class Scene_MenuBase < Scene_Base
  520.   def create_help_window
  521.     @help_window = NIS_Item_Help.new(nil,0,0,156)
  522.   end
  523. end
  524. class Scene_Battle < Scene_Base
  525.   def create_help_window
  526.     @help_window = NIS_Item_Help.new(nil,0,0,156)
  527.   end
  528. end
  529.  
  530. #==============================================================================
  531. # ■ NIS_Item_Help
  532. #------------------------------------------------------------------------------
  533. #  显示技能和物品等的说明、以及角色状态的界面
  534. #==============================================================================
  535.  
  536. class NIS_Item_Help < NIS_InfoContents
  537.   #--------------------------------------------------------------------------
  538.   # ● 初始化对象
  539.   #--------------------------------------------------------------------------  
  540.   def initialize(item,x,y,width,text_size=18,auto_height = true,auto_scroll = false,scroll_pix=1,scroll_space=1)
  541.     width_help = width #加了这个作为帮助窗口的宽度 PannyDD
  542.     width = 300        #加了这个作为帮助窗口的宽度 PannyDD
  543.     super(0,0,Bitmap.new(width,1),auto_scroll,scroll_pix,scroll_space)   
  544.     @visible = false
  545.     @status = :open
  546.     @viewport = Viewport.new(Rect.new(x,y,width,1))
  547.     @viewport.z = 1000
  548.  
  549.     @window.viewport = @viewport
  550.     @window.bitmap.font.size = text_size
  551.     @auto_height = auto_height
  552.     @item = item
  553.     width = width_help #加了这个作为帮助窗口的宽度 PannyDD
  554.     refresh
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # ● 出现
  558.   #--------------------------------------------------------------------------
  559.   def width
  560.     @window.width
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 隐藏
  564.   #--------------------------------------------------------------------------
  565.   def height
  566.     @window.height
  567.   end
  568.   #--------------------------------------------------------------------------
  569.   # ● 出现
  570.   #--------------------------------------------------------------------------
  571.   def show
  572.     self.visible2=true
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 隐藏
  576.   #--------------------------------------------------------------------------
  577.   def hide
  578.     self.visible2=true
  579.   end
  580.   #--------------------------------------------------------------------------
  581.   # ● 获取边距尺寸
  582.   #--------------------------------------------------------------------------
  583.   def padding
  584.     return 4
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● 更改可视属性(渐变操作)
  588.   #--------------------------------------------------------------------------
  589.   def visible2=(value)
  590.     case value
  591.     when true
  592.       @viewport.visible = true
  593.       @visible = true
  594.       @opacity = 0
  595.       @active = true
  596.       @status = :show
  597.     when false
  598.       @opacity = 255
  599.       @status = :hide
  600.     end
  601.   end
  602.   #--------------------------------------------------------------------------
  603.   # ● 更新
  604.   #--------------------------------------------------------------------------
  605.   def update
  606.     super
  607.     update_visible
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● 更新渐变效果
  611.   #--------------------------------------------------------------------------
  612.   def update_visible
  613.     @count += 1
  614.     case @status
  615.     when :show
  616.       @window.opacity += 10
  617.       @contents.opacity += 10
  618.       @status = :open if @window.opacity >= 255
  619.     when :hide
  620.       @window.opacity -= 10
  621.       @contents.opacity -= 10
  622.       @count = 0
  623.       @visible = false if @window.opacity <= 0
  624.     end
  625.   end
  626.   #--------------------------------------------------------------------------
  627.   # ● 清除
  628.   #--------------------------------------------------------------------------
  629.   def clear
  630.     set_item(nil)
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # ● 设置物品
  634.   #     item : 技能、物品等
  635.   #--------------------------------------------------------------------------
  636.   def set_item(item,actor = nil)
  637.     @item = item  if @item != item
  638.     @actor = actor if @actor != actor
  639.     refresh
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # ● 更新帮助位置
  643.   #--------------------------------------------------------------------------
  644.   def uppos(rect,window)
  645.     rect.x -= window.ox
  646.     rect.y -= window.oy
  647.     ax = rect.x + rect.width + 10
  648.     ax = rect.x - @window.width + 10 if ax + @window.width > window.width + 10
  649.     ax += window.x
  650.     ax = 0 if ax < 0
  651.     ay = rect.y + rect.height
  652.     ay = rect.y - @window.height if ay + @window.height > window.height
  653.     ay += window.y
  654.     ay = 0 if ay < 0
  655.     @viewport.rect.x = ax
  656.     @viewport.rect.y = ay
  657.   end
  658.   #--------------------------------------------------------------------------
  659.   # ● 获取帮助
  660.   #--------------------------------------------------------------------------
  661.   def get_help
  662.     help = []
  663.     help.push(@item.name)
  664.     help.push(@item.description)
  665.     help += Equipplus.getequiphelp(@item,@actor) if @item.is_a?(RPG::EquipItem)
  666.     help.push("\001[128,128,255]价格:\001[-1,-1,-1]" + @item.price.to_s) if !@item.is_a?(RPG::Skill)
  667.     help.delete("")
  668.     help
  669.   end
  670.   #--------------------------------------------------------------------------
  671.   # ● 获取帮助高度
  672.   #--------------------------------------------------------------------------
  673.   def get_help_height(help)
  674.     help_height = [0]*help.size
  675.     help.size.times do |i|
  676.       @window.bitmap.font.size -= 2 if i == 1
  677.       help_height[i] = @window.bitmap.font.size+2 if i == 0
  678.       help_height[i] = get_height(help[i],@window.bitmap.width-padding,@window.bitmap) if i > 0
  679.       @window.bitmap.font.size += 2 if i == 1
  680.     end
  681.     help_height
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # ● 获取帮助高度
  685.   #--------------------------------------------------------------------------
  686.   def get_help_height_sum(help_height)
  687.     sum = 0
  688.     help_height.each{|h| sum += h + 5}
  689.     return sum - 5
  690.   end
  691.   #--------------------------------------------------------------------------
  692.   # ● 改变高度
  693.   #--------------------------------------------------------------------------
  694.   def change_height(height)
  695.     if @auto_height
  696.       @window.bitmap = Bitmap.new(@window.bitmap.width,height+2*padding)
  697.       @window.viewport.rect.height = height+2*padding
  698.     else
  699.       src_height = @window.height
  700.       @window.bitmap = Bitmap.new(@window.bitmap.width,height+2*padding)
  701.       @window.src_rect = Rect.new(0,0,@window.bitmap.width-padding,src_height)
  702.     end
  703.  
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # ● 绘制背景
  707.   #--------------------------------------------------------------------------
  708.   def draw_background(height)
  709.     c = ItemLevelDrawer::ColorSet[[@item.quality-1,0].max]
  710.     color = Color.new(c[0],c[1],c[2],c[3])
  711.     font_size = @window.bitmap.font.size
  712.  
  713.     change_height(height)
  714.  
  715.     @window.bitmap.fill_rect(0,0,@window.bitmap.width,@window.bitmap.height,Color.new(25,25,25,182))
  716.     @window.bitmap.font.color = color
  717.     @window.bitmap.font.size = font_size
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # ● 绘制内容
  721.   #--------------------------------------------------------------------------
  722.   def draw_contents(help,help_height)
  723.     color = @window.bitmap.font.color.clone
  724.     sum_height = padding
  725.     help.each_with_index do |h,i|
  726.       @window.bitmap.font.size -= 2 if i == 1
  727.       draw_colorful_text(@window.bitmap,padding,sum_height,@window.bitmap.width-padding,help_height[0],h,color.clone,false,1,1) if i == 0
  728.       draw_colorful_text(@window.bitmap,padding,sum_height,@window.bitmap.width-padding,@window.bitmap.font.size,h,color.clone) if i > 0
  729.       @window.bitmap.font.size += 2 if i == 1
  730.       sum_height += help_height[i]
  731.       draw_split_line(sum_height+2,color) if i < help.size - 1
  732.       sum_height += 5
  733.     end
  734.   end
  735.   #--------------------------------------------------------------------------
  736.   # ● 绘制分割线
  737.   #--------------------------------------------------------------------------
  738.   def draw_split_line(y,color=Color.new(254,215,0))
  739.     @window.bitmap.draw_line(padding,y,@window.bitmap.width-padding,y,color)
  740.   end
  741.   #--------------------------------------------------------------------------
  742.   # ● 刷新
  743.   #--------------------------------------------------------------------------
  744.   def refresh
  745.     @window.bitmap.clear
  746.     return unless @item
  747.     help = get_help
  748.     help_height = get_help_height(help)   
  749.     draw_background(get_help_height_sum(help_height))
  750.     draw_contents(help,help_height)
  751.  
  752.     show
  753.   end
  754. end

12345.png (5.85 KB, 下载次数: 19)

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

本版积分规则

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

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

GMT+8, 2024-4-27 10:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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