Alright, I have a feeling I got it all down. Let's first talk about Window_ItemList#ace_item_include?(item).
The first issue, as you pointed out, was that when viewing :all, it would always draw all armors regardless of the category. Thus @types_window.method was not returning :items or :weapons. By using a print method, I was able to see that @types_window.method was actually returning
the exact same symbol as @category was. @types_window contains the items 'Usable, Field, Battle, etc.', but you wanted the window that has the items 'Items, Weapons, Armors'. I'm guessing you wanted to use Window_ItemCommand.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Window_ItemList
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_ItemList < Window_Item
include ACE::CORE
def initialize(y, height)
super(0, y, 640, height)
deactivate
@category = :none
@ext = :none
@name = ""
end
def category=(category)
if @types_window.nil?
return if @category == category
@category = category
refresh
self.oy = 0
else
return unless update_types?(category)
@category = category
if @types_window.active
@name = @types_window.commands
@ext = @types_window.method
end
refresh
self.oy = 0
end
end
def update_types?(category)
return true if @category != category
return false unless @types_window.active
return @name != @types_window.commands if category == :category
return @ext != @types_window.method
end
def types_window=(window)
@types_window = window
end
# Kk20 : New method. Called in Scene_Item#create_item_window
def category_window=(window)
@category_window = window
end
def include?(item)
return false if item.nil?
@types_window.nil? ? old_item_include?(item) : ace_item_include?(item)
end
def old_item_include?(item)
case @category
when :items then item.is_a?(RPG::Item)
when :weapons then item.is_a?(RPG::Weapon)
when :armor then item.is_a?(RPG::Armor)
else false
end
end
#KK20
# Editted with category_window instead of types_window
def ace_item_include?(item)
# @category is equal to @types_window.method
case @category
when :usable then item.is_a?(RPG::Item) && item.usable_ok?
when :field
return false unless item.is_a?(RPG::Item)
return false if item.battle_ok?
return item.menu_ok?
when :battle
return false unless item.is_a?(RPG::Item)
return false if item.menu_ok?
return item.battle_ok?
when :key_item then item.is_a?(RPG::Item) && item.key_item?
#---
when :shield then item.is_a?(RPG::Armor) && item.shield?
when :helmet then item.is_a?(RPG::Armor) && item.helmet?
when :body_armor then item.is_a?(RPG::Armor) && item.body_armor?
when :accessory then item.is_a?(RPG::Armor) && item.acessory?
#---
when :all
#KK20
# :item => :items
# :weapon => :weapons
case @category_window.method
# No idea why 'if $game_temp.in_battle' is there...
when :items then return item.is_a?(RPG::Item) #if $game_temp.in_battle
when :weapons then return item.is_a?(RPG::Weapon)
else return item.is_a?(RPG::Armor)
end
#---
#KK20
# When viewing 'Food', for example, @category was returning :food (not :category)
# Thus, this is the new 'else' condition
#when :category
else
case @category_window.method
when :items then return false unless item.is_a?(RPG::Item)
when :weapons then return false unless item.is_a?(RPG::Weapon)
else return false unless item.is_a?(RPG::Armor)
end
# If the item has a category and it matches the category you want to view
if !item.category.nil? && item.category.include?(@category.to_s)#.upcase)
return true
else # The original 'else' condition you had before
return old_item_include?(item)
end
#---
#else
# return old_item_include?(item)
end
end
def select_last
select(@data.size - 1) if item.id == $game_party.last_item_id
select([self.index, 0].max)
end
def make_item_list
$game_party.items.each {|item| next unless include?(item); @data << item}
end
def draw_item(index)
rect = item_rect(index)
contents.clear_rect(rect)
item = @data[index]
return if item.nil?
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
contents.draw_text(rect, sprintf(':%2d', $game_party.item_number(item)), 2)
end
end
I've commented areas with 'KK20' to mark changes and additions I made.
I also noticed that, after selecting "Weapons", you would not be shown the right subcategories. I made this change to Window_ItemType
def reveal(type)
@type = type
# KK20==================
array = make_command_list
@data = array[1]
commands = array[0]
@item_max, @commands = commands.size, commands
# KK20==================
refresh
activate
select(0)
end
As for the RPG::Item issue, I did this:
def name
return @name.gsub(/\\category\[(\w+)\]/) {""}
end
def category
@category = []
@name.downcase.gsub!(/\\category\[(\w+)\]/) do
return @category = $1.to_s
end
end
I'm not super experienced with Regexp yet, but this looked good to me.
So what is this now...? Like the 10th time I've helped you with your scripts? =P