Project1

标题: 物品分类脚本如何在为选择物品时物品不显示光标? [打印本页]

作者: 爆焰    时间: 2011-11-18 16:49
标题: 物品分类脚本如何在为选择物品时物品不显示光标?
本帖最后由 爆焰 于 2011-11-18 23:05 编辑

dsu_plus_rewardpost_czw
作者: rainfly    时间: 2011-11-18 20:52
  1. #==============================================================================

  2. # ■ Harts_Window_ItemCommand

  3. #==============================================================================



  4. class Harts_Window_ItemCommand < Window_Selectable

  5.   attr_accessor :commands

  6.   #--------------------------------------------------------------------------

  7.   # ● 初始化,生成commands窗口

  8.   #--------------------------------------------------------------------------

  9.   def initialize

  10.     super(0, 128, 160, 352)

  11.     self.contents = Bitmap.new(width - 32, height - 32)

  12.     @commands = []

  13.     #————————生成commands窗口

  14.     for i in 1...$data_items.size

  15.       if $game_party.item_number(i) > 0

  16.         push = true

  17.         for com in @commands

  18.           if com == $data_items[i].desc

  19.             push = false

  20.           end

  21.         end

  22.         if push == true

  23.           @commands.push($data_items[i].desc)

  24.         end

  25.       end

  26.     end

  27.     for i in 1...$data_weapons.size

  28.       if $game_party.weapon_number(i) > 0

  29.         push = true

  30.         for com in @commands

  31.           if com == $data_weapons[i].desc

  32.             push = false

  33.           end

  34.         end

  35.         if push == true

  36.           @commands.push($data_weapons[i].desc)

  37.         end

  38.       end

  39.     end

  40.     for i in 1...$data_armors.size

  41.       if $game_party.armor_number(i) > 0

  42.         push = true

  43.         for com in @commands

  44.           if com == $data_armors[i].desc

  45.             push = false

  46.           end

  47.         end

  48.         if push == true

  49.           @commands.push($data_armors[i].desc)

  50.         end

  51.       end

  52.     end

  53.     if @commands == []

  54.       @commands.push("无任何物品")

  55.     end      

  56.     @item_max = @commands.size

  57.     refresh

  58.     self.index = 0

  59.   end

  60.   #--------------------------------------------------------------------------

  61.   #--------------------------------------------------------------------------
  62.   def update_cursor_rect
  63.     self.cursor_rect.empty
  64.   end
  65.   def refresh

  66.     self.contents.clear

  67.     for i in 0...@item_max

  68.       draw_item(i, normal_color)

  69.     end

  70.   end

  71.   #--------------------------------------------------------------------------

  72.   #--------------------------------------------------------------------------

  73.   def draw_item(index, color)

  74.     self.contents.font.color = color

  75.     y = index * 32

  76.     self.contents.draw_text(4, y, 128, 32, @commands[index])

  77.   end

  78.   #--------------------------------------------------------------------------

  79.   # 只描绘原文字

  80.   #--------------------------------------------------------------------------

  81.   def update_help

  82.     @help_window.set_text(@commands[self.index])

  83.   end

  84. end



  85. #==============================================================================

  86. # ■ Window_Item

  87. #==============================================================================



  88. class Harts_Window_ItemList < Window_Selectable

  89.   #--------------------------------------------------------------------------

  90.   #--------------------------------------------------------------------------

  91.   def initialize

  92.     super(160, 64, 480, 416)

  93.     refresh

  94.     self.index = 0

  95.   end

  96.   #--------------------------------------------------------------------------

  97.   #--------------------------------------------------------------------------

  98.   def item

  99.     return @data[self.index]

  100.   end

  101.   #--------------------------------------------------------------------------

  102.   #--------------------------------------------------------------------------

  103.   def refresh

  104.     if self.contents != nil

  105.       self.contents.dispose

  106.       self.contents = nil

  107.     end

  108.     @data = []

  109.   end

  110.   #--------------------------------------------------------------------------

  111.   #--------------------------------------------------------------------------

  112.   def set_item(command)

  113.     refresh

  114.     for i in 1...$data_items.size

  115.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command

  116.         @data.push($data_items[i])

  117.       end

  118.     end

  119.     for i in 1...$data_weapons.size

  120.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command

  121.         @data.push($data_weapons[i])

  122.       end

  123.     end

  124.     for i in 1...$data_armors.size

  125.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command

  126.         @data.push($data_armors[i])

  127.       end

  128.     end

  129.     @item_max = @data.size

  130.     if @item_max > 0

  131.       self.contents = Bitmap.new(width - 32, row_max * 32)

  132.       self.contents.clear

  133.       for i in 0...@item_max

  134.         draw_item(i)

  135.       end

  136.     end

  137.   end

  138.   #--------------------------------------------------------------------------

  139.   #--------------------------------------------------------------------------

  140.   def item_number

  141.     return @item_max

  142.   end

  143.   #--------------------------------------------------------------------------

  144.   #--------------------------------------------------------------------------

  145.   def draw_item(index)

  146.     item = @data[index]

  147.     case item

  148.     when RPG::Item

  149.       number = $game_party.item_number(item.id)

  150.     when RPG::Weapon

  151.       number = $game_party.weapon_number(item.id)

  152.     when RPG::Armor

  153.       number = $game_party.armor_number(item.id)

  154.     end

  155.     if item.is_a?(RPG::Item) and

  156.       $game_party.item_can_use?(item.id)

  157.       self.contents.font.color = normal_color

  158.     else

  159.       self.contents.font.color = disabled_color

  160.     end

  161.     x = 4

  162.     y = index * 32

  163.     bitmap = RPG::Cache.icon(item.icon_name)

  164.     opacity = self.contents.font.color == normal_color ? 255 : 128

  165.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

  166.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)

  167.     self.contents.draw_text(x + 400, y, 16, 32, ":", 1)

  168.     self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)

  169.   end

  170.   #--------------------------------------------------------------------------

  171.   #--------------------------------------------------------------------------
  172. def update_cursor_rect
  173.     self.cursor_rect.empty
  174.   end
  175.   def update_help

  176.     @help_window.set_text(self.item == nil ? "" : self.item.description)

  177.   end

  178. end

复制代码
替换原来的
作者: 各种压力的猫君    时间: 2011-11-18 22:52
112行
  1. self.index = 0
复制代码
285行
  1. @itemlist_window.index = 0
复制代码

以上两处的0改成-1




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