查看: 3049|回复: 5

[已经过期] 选择项光标移动出现问题

[复制链接]
梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2018-1-12 16:46:05 | 显示全部楼层 |阅读模式

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

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

×
我把物品菜单做成了2级分类,之后出现了一个问题
如果选择武器的查看,最后3个分类项无法显示在分类菜单,但是物品清单里是已经刷新出来了的

具体情况如图

1.jpg 2.jpg 3.jpg 4.jpg



脚本
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_ItemCategory
  4. #------------------------------------------------------------------------------
  5. #  物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。
  6. #==============================================================================

  7. class Window_ItemCategory < Window_HorzCommand
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :item_window
  12.   #--------------------------------------------------------------------------
  13.   # ● 初始化对象
  14.   #--------------------------------------------------------------------------
  15.   def initialize
  16.     super(0, 0)
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 获取窗口的宽度
  20.   #--------------------------------------------------------------------------
  21.   def window_width
  22.     Graphics.width
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 获取列数
  26.   #--------------------------------------------------------------------------
  27.   def col_max
  28.     return 4
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 更新画面
  32.   #--------------------------------------------------------------------------
  33.   def update
  34.     super
  35.     @item_window.category = current_symbol if @item_window
  36.     #current_symbol#:items
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 生成指令列表
  40.   #--------------------------------------------------------------------------
  41.   def make_command_list
  42.     $listid||=0
  43.     $typelist||=[]
  44.     #p typelist
  45.     #p $game_party.items#weapons#armors
  46.    
  47.     #@actor.added_skill_types.sort.each do |stype_id|
  48.     #  name = $data_system.skill_types[stype_id]
  49.     #  add_command(name, :skill, true, stype_id)
  50.     #end
  51.    
  52. #p $data_system.weapon_types
  53. #p $data_system.armor_types
  54.    
  55.     if $listid==0
  56.       add_command(Vocab::item,     :item)
  57.       add_command(Vocab::weapon,   :weapon)
  58.       add_command(Vocab::armor,    :armor)
  59.       add_command(Vocab::key_item, :key_item)
  60.     else
  61.       if $listid==1
  62.         $game_party.items.each{|item|item.types.each{|tid|$typelist.push(tid)}}
  63.         $typelist.uniq!.sort!
  64.         $typelist.each{|i|add_command(Item::TypeList[i], :item, true, i)}
  65.       elsif $listid==2
  66.         $game_party.equip_items.each{|item|item.types.each{|tid|
  67.           if tid.kind_of?(Numeric)
  68.             $typelist.push(tid)
  69.           else
  70.             $typelist+=tid
  71.           end
  72.           }
  73.         }
  74.         $typelist.uniq!.sort!.delete_if{|i|i>0}
  75.         $typelist.reverse!
  76.         $typelist.each{|i|add_command(Vocab::wtype(-i), :equip_items)}
  77.       elsif $listid==3
  78.         $game_party.equip_items.each{|item|item.types.each{|tid|
  79.           if tid.kind_of?(Numeric)
  80.             $typelist.push(tid)
  81.           else
  82.             $typelist+=tid
  83.           end
  84.           }
  85.         }
  86.         $typelist.uniq!.sort!.delete_if{|i|i<0}
  87.         $typelist.each{|i|add_command(Vocab::atype(i), :equip_items)}
  88.       end
  89.       #(4-$typelist.size%4).times.each{|i|add_command("", "", false)} if $typelist.size%4!=0
  90.     end
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 设置物品窗口
  94.   #--------------------------------------------------------------------------
  95.   def item_window=(item_window)
  96.     @item_window = item_window
  97.     update
  98.   end
  99. end
复制代码

  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Window_ItemList
  4. #------------------------------------------------------------------------------
  5. #  物品画面中,显示持有物品的窗口。
  6. #==============================================================================

  7. class Window_ItemList < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对象
  10.   #--------------------------------------------------------------------------
  11.   def initialize(x, y, width, height)
  12.     super
  13.     @category = :none
  14.     @data = []
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 设置分类
  18.   #--------------------------------------------------------------------------
  19.   def category=(category)
  20.     return if @category == category
  21.     @category = category
  22.     refresh
  23.     self.oy = 0
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 获取行间距的宽度
  27.   #--------------------------------------------------------------------------
  28.   def spacing
  29.     return 2
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 获取项目的宽度
  33.   #--------------------------------------------------------------------------
  34.   def item_width
  35.     24
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 获取列数
  39.   #--------------------------------------------------------------------------
  40.   def col_max
  41.     return 20
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 获取项目数
  45.   #--------------------------------------------------------------------------
  46.   def item_max
  47.     @data ? @data.size : 1
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 获取物品
  51.   #--------------------------------------------------------------------------
  52.   def item
  53.     @data && index >= 0 ? @data[index] : nil
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 获取选择项目的有效状态
  57.   #--------------------------------------------------------------------------
  58.   def current_item_enabled?
  59.     enable?(@data[index])
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 查询列表中是否含有此物品
  63.   #--------------------------------------------------------------------------
  64.   def include?(item)
  65.     #item.types
  66.     case @category
  67.     when :item
  68.       item.is_a?(RPG::Item) && !item.key_item?
  69.     when :weapon
  70.       item.is_a?(RPG::Weapon)
  71.     when :armor
  72.       item.is_a?(RPG::Armor)
  73.     when :key_item
  74.       item.is_a?(RPG::Item) && item.key_item?
  75.     else
  76.       false
  77.     end
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 查询此物品是否可用
  81.   #--------------------------------------------------------------------------
  82.   def enable?(item)
  83.     $game_party.usable?(item)
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 生成物品列表
  87.   #--------------------------------------------------------------------------
  88.   def make_item_list
  89.     $list2id||=0
  90.     @data = $game_party.all_items.select {|item| include?(item) }
  91.     @data.clear if $listid!=0
  92.     if $listid==1
  93.       $game_party.items.each{|item|
  94.         if item and $typelist.size>0
  95.           #p $typelist[$list2id]
  96.           @data.push(item) if item.types.include?($typelist[$list2id])
  97.         end
  98.       }
  99.     elsif $listid==2
  100.       $game_party.equip_items.each{|item|
  101.         if item
  102.           #p $typelist[$list2id]
  103.           @data.push(item) if item.types.include?($typelist[$list2id])
  104.         end
  105.       }
  106.     elsif $listid==3
  107.       $game_party.equip_items.each{|item|
  108.         if item
  109.           #p $typelist[$list2id]
  110.           @data.push(item) if item.types.include?($typelist[$list2id])
  111.         end
  112.       }
  113.     end
  114.       
  115.     @data.push(nil) if include?(nil)
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 返回上一个选择的位置
  119.   #--------------------------------------------------------------------------
  120.   def select_last
  121.     select(@data.index($game_party.last_item.object) || 0)
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 绘制项目
  125.   #--------------------------------------------------------------------------
  126.   def draw_item(index)
  127.     item = @data[index]
  128.     if item
  129.       rect = item_rect(index)
  130.       rect.width -= 4
  131.       draw_item_icon(item, rect.x, rect.y, enable?(item))
  132.       draw_item_number(rect, item)
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ● 绘制物品个数
  137.   #--------------------------------------------------------------------------
  138.   def draw_item_number(rect, item)
  139.     contents.font.size=14
  140.     contents.font.bold = true
  141.     change_color(text_color_id(item.namecolor))#待修改显示位置
  142.     i_n=$game_party.item_number(item)
  143.     if i_n>99
  144.       draw_text(rect.x,rect.y+6,rect.width+6,rect.height, sprintf("%2d", i_n), 2)
  145.     elsif i_n>1
  146.       draw_text(rect.x+6,rect.y+6,rect.width,rect.height, sprintf("%2d", i_n), 2)
  147.     end
  148.     reset_font_settings
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● 更新帮助内容
  152.   #--------------------------------------------------------------------------
  153.   def update_help
  154.     @help_window.set_item(item)
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 刷新
  158.   #--------------------------------------------------------------------------
  159.   def refresh
  160.     make_item_list
  161.     create_contents
  162.     draw_all_items
  163.   end
  164. end
复制代码


  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ Scene_Item
  4. #------------------------------------------------------------------------------
  5. #  物品画面
  6. #==============================================================================

  7. class Scene_Item < Scene_ItemBase
  8.   #--------------------------------------------------------------------------
  9.   # ● 开始处理
  10.   #--------------------------------------------------------------------------
  11.   def start
  12.     super
  13.     create_help_window
  14.     create_category_window
  15.     create_item_window
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 生成分类窗口
  19.   #--------------------------------------------------------------------------
  20.   def create_category_window
  21.     @category_window = Window_ItemCategory.new
  22.     @category_window.viewport = @viewport
  23.     @category_window.help_window = @help_window
  24.     @category_window.y = @help_window.height
  25.     @category_window.set_handler(:ok,     method(:on_category_ok))
  26.     @category_window.set_handler(:cancel, method(:on_category_cancel))
  27.     #@category_window.set_handler(:cancel, method(:return_scene))
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● 生成物品窗口
  31.   #--------------------------------------------------------------------------
  32.   def create_item_window
  33.     wy = @category_window.y + @category_window.height
  34.     wh = Graphics.height - wy
  35.     @item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
  36.     @item_window.viewport = @viewport
  37.     @item_window.help_window = @help_window
  38.     @item_window.set_handler(:ok,     method(:on_item_ok))
  39.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  40.     @category_window.item_window = @item_window
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 分类“确定”
  44.   #--------------------------------------------------------------------------
  45.   def on_category_ok
  46.     if $listid==0
  47.       $listid=@category_window.index+1
  48.       @category_window.index=0
  49.       if $listid==1
  50. #      $game_party.items.each{|item|item.types.each{|tid|$typelist.push(tid)}}
  51. #      $typelist.uniq!.sort!
  52.       end
  53.       @item_window.refresh
  54.       @category_window.refresh
  55.       @category_window.activate
  56.     else
  57.       @item_window.activate
  58.       @item_window.select_last
  59.     end   
  60.   end
  61.   
  62.   
  63.   #--------------------------------------------------------------------------
  64.   # ● 更新画面追加定义:当列表内分类切换时刷新分类id
  65.   #--------------------------------------------------------------------------
  66.   def update
  67.     super
  68.     $list2id||=-1
  69.     $list2id=@category_window.index if $listid!=0
  70.     $list2id=-1 if $listid==0
  71.     $typelist=[] if $listid==0
  72.    
  73.     @category_window.refresh
  74.     @item_window.refresh
  75.   end
  76.   
  77.   #物品分类列表,光标移动时的处理
  78.   def refreshlist
  79.     msgbox(123)
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # ● 分类“取消”
  83.   #--------------------------------------------------------------------------
  84.   def on_category_cancel
  85.     if $listid==0
  86.       return_scene
  87.     else
  88.       #$list2id=-1
  89.      # $typelist=[]
  90.       @category_window.unselect
  91.       @item_window.refresh
  92.       @category_window.refresh
  93.       @category_window.index=$listid-1
  94.       $listid=0
  95.       @category_window.activate
  96.       update
  97.     end
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 物品“确定”
  101.   #--------------------------------------------------------------------------
  102.   def on_item_ok
  103.     $game_party.last_item.object = item
  104.     determine_item
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 物品“取消”
  108.   #--------------------------------------------------------------------------
  109.   def on_item_cancel
  110.     @item_window.unselect
  111.     @category_window.activate
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 播放使用物品声效
  115.   #--------------------------------------------------------------------------
  116.   def play_se_for_item
  117.     Sound.play_use_item
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 使用物品
  121.   #--------------------------------------------------------------------------
  122.   def use_item
  123.     super
  124.     @item_window.redraw_current_item
  125.   end
  126. end
复制代码


[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

 楼主| 发表于 2018-1-13 01:27:16 | 显示全部楼层
本帖最后由 chd114 于 2018-1-13 01:32 编辑
WantMy蕙 发表于 2018-1-12 18:27
为什么你斧子能显示后面三个不能,是按过去光标就不动吗...
VA的脚本不是很懂,但是我觉得吧这个问题应该是 ...


用默认脚本试了下···
默认的也有bug···只要是横向移动的选择项,超过显示项2个以上的一定显示有问题···

比如(以下为显示项最大值和实际项目数量):
col_max对应的能正常显示的项的上限
4-7
5-9
6-11

因为默认防具类型只有6种,刚好低于ItemList的col_max为4时能正常显示的项的上限,所以防具的情况即使横向移动查看也不会有bug···
但是武器有10种,从第七种之后右移动和第一种之前左移动的情况就会出bug
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

 楼主| 发表于 2018-1-14 15:20:57 | 显示全部楼层
  1. #==============================================================================
  2. # ■ Window_HorzCommand
  3. #------------------------------------------------------------------------------
  4. #  横向选择的指令窗口
  5. #==============================================================================

  6. class Window_HorzCommand < Window_Command
  7.   #--------------------------------------------------------------------------
  8.   # ● 设置首列位置
  9.   #--------------------------------------------------------------------------
  10.   def top_col=(col)
  11.     col = 0 if col < 0
  12. #    col =  col_max - 1 if col>col_max-1
  13.     col = index - col_max + 1 if col > col_max - 1
  14.     self.ox = col * (item_width + spacing)
  15.   end
  16. end
复制代码

BUG找出了···(注释掉的为之前的脚本)
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

梦石
0
星屑
2724
在线时间
227 小时
注册时间
2016-3-27
回帖
557
发表于 2018-1-12 18:27:23 | 显示全部楼层
为什么你斧子能显示后面三个不能,是按过去光标就不动吗...
VA的脚本不是很懂,但是我觉得吧这个问题应该是光标或者哪里的脚本只识别了五个,所以移动的时候没移过去...
你把这几个有关的脚本还有光标的脚本检查一遍,看看有没有类似的语句...
现在还能改名吗qwq
回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

 楼主| 发表于 2018-1-12 19:06:03 | 显示全部楼层
WantMy蕙 发表于 2018-1-12 18:27
为什么你斧子能显示后面三个不能,是按过去光标就不动吗...
VA的脚本不是很懂,但是我觉得吧这个问题应该是 ...

光标是过去了的,但是窗口上显示的没变
下方具体的物品是显示的正确的分类里的,但是上方选项条没动
从1往左和7往右都是显示的图1、2的情况(显示的选择项没变动)
refresh和update了都不行感觉有点迷

点评

应该有办法改的吧...解除上线限制???或者自己重新写一个光标??...  发表于 2018-1-13 12:03
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部