Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ 「SIMPLE STUPID」 Item Filter ver.0.61
- # by HBK61
- # Requires: N/A
- # Rewrites method:
- # Window_ItemList#make_item_list
- # Aliases method:
- # Window_ItemList#initialize
- # Scene_Item#start
- # Scene_Item#create_category_window
- # Scene_Item#create_item_window
- #
- #==============================================================================
- # CHANGELOG
- # - ver0.60 2013.07.01 Started the script & finished
- # - ver0.61 2013.07.01 Add sorting function
- #==============================================================================
- # INTRODUCTION
- # - Simply stupidly add filtering & sorting function in Scene Item.
- #==============================================================================
- # INSTRUCTION
- # - Simply write "<category(space)=(space)my_category>" (without quotes)
- # in item's/weapon's/armor's note.
- # example:
- # <category = loot_items>
- #==============================================================================
- module HBK
- module ITEM_TAB
- #enable/disable
- ENABLED = true
- # use "_" for space & no upcase!
- FILTER =[
- :alchemy,
- :tradeable,
- :loots,
- :crap,
- ]
- CAT_HELP_TEXT = "←→:Category select\nA: Organize B:Back C:Decision"
- end #ITEM_TAB
- end #HBK
- if HBK::ITEM_TAB::ENABLED
- #==============================================================================
- # ■ Window_ItemCategory
- #==============================================================================
- class Window_ItemCategory < Window_HorzCommand
- def process_handling
- super
- return process_extend if handle?(:extend) && Input.trigger?(:A) && active
- end
- def process_extend
- Sound.play_ok
- Input.update
- call_handler(:extend)
- end
- def update_help
- @help_window.set_text(HBK::ITEM_TAB::CAT_HELP_TEXT)
- end
- end #Window_ItemCategory
- #==============================================================================
- # ■ Window_ItemList
- #==============================================================================
- class Window_ItemList < Window_Selectable
- alias hbk_ssit_initialize initialize
- def initialize(x, y, width, height)
- hbk_ssit_initialize(x, y, width, height)
- @filter = :none
- @sort = :none
- end
- def process_handling
- super
- return process_extend if handle?(:extend) && Input.trigger?(:A) && active
- end
- def process_extend
- Sound.play_ok
- Input.update
- call_handler(:extend)
- end
- def filter=(filter)
- return if @filter == filter
- @filter = filter
- refresh
- self.oy = 0
- end
- def filter?(item)
- return false if item.nil?
- if HBK::ITEM_TAB::FILTER.include?(@filter)
- item.note.include?("<category = " + @filter.to_s + ">")
- elsif @filter == :no_filter
- true
- else
- false
- end
- end
- def sorting=(value)
- return if @sorting == value
- @sorting = value
- refresh
- self.oy = 0
- end
- #--------------------------------------------------------------------------
- # ● rewrite
- #--------------------------------------------------------------------------
- def make_item_list
- @data = $game_party.all_items.select {|item|
- ( include?(item) && filter?(item) )
- }
- @data.push(nil) if include?(nil)
- #~~
- if @sorting == :default
- return
- elsif @sorting == :alphabet_a
- @data.sort!{|a,b| a.name <=> b.name}
- elsif @sorting == :alphabet_d
- @data.sort!{|a,b| b.name <=> a.name}
- elsif @sorting == :quantity_a
- @data.sort!{|a,b|
- $game_party.item_number(a) - $game_party.item_number(b) }
- elsif @sorting == :quantity_d
- @data.sort!{|a,b|
- $game_party.item_number(b) - $game_party.item_number(a) }
- elsif @sorting == :price_a
- @data.sort!{|a,b| a.price - b.price}
- elsif @sorting == :price_d
- @data.sort!{|a,b| b.price - a.price}
- end
- #~~
- end
- end #Window_ItemList
- #==============================================================================
- # ■ Window_ItemOrganizer
- #==============================================================================
- class Window_ItemOrganizer < Window_Command
- def initialize(x,y)
- super(x,y)
- @previous = nil
- end
- def window_width
- return 180
- end
- def make_command_list
- add_command("Filter", :filter)
- add_command("Sort", :sort)
- end
- attr_accessor :previous
- end #Window_ItemOrganizer
- #==============================================================================
- # ■ Window_ItemSort
- #==============================================================================
- class Window_ItemSort < Window_Command
- def initialize(x,y)
- super(x,y)
- end
- def window_width
- return 180
- end
- def make_command_list
- add_command("Default", :default)
- add_command("Alphabet ↑", :alphabet_a)
- add_command("Alphabet ↓", :alphabet_d)
- add_command("Quantity ↑", :quantity_a)
- add_command("Quantity ↓", :quantity_d)
- add_command("Price ↑", :price_a)
- add_command("Price ↓", :price_d)
- end
- end #Window_ItemSort
- #==============================================================================
- # ■ Window_ItemFilter
- #==============================================================================
- class Window_ItemFilter < Window_Command
- def window_width
- return 180
- end
- def make_command_list
- add_command("Clear Filter", :no_filter)
- HBK::ITEM_TAB::FILTER.size.times{|i|
- sym = HBK::ITEM_TAB::FILTER[i]
- next if sym.nil?
- txt = sym.to_s.capitalize
- txt.gsub!(/_/) {" "}
- txt.gsub!(/(\s\w)/) {$&.upcase}
- add_command(txt, sym)
- }
- end
- end #Window_ItemSort
- #==============================================================================
- # ■ Scene_Item
- #==============================================================================
- class Scene_Item
- alias hbk_ssit_start start
- def start
- hbk_ssit_start
- create_item_organizer_window
- create_item_filter_window
- create_item_sort_window
- end
- alias hbk_ssit_create_category_window create_category_window
- def create_category_window
- hbk_ssit_create_category_window
- @category_window.set_handler(:extend, method(:category_window_pre_organize))
- end
- alias hbk_ssit_create_item_window create_item_window
- def create_item_window
- hbk_ssit_create_item_window
- @item_window.set_handler(:extend, method(:item_window_pre_organize))
- @item_window.filter = :no_filter
- @item_window.sorting = :default
- end
- def create_item_organizer_window
- @organizer_window = Window_ItemOrganizer.new(0,0)
- @organizer_window.hide
- @organizer_window.close
- @organizer_window.x = Graphics.width - @organizer_window.width
- @organizer_window.y = @help_window.height
- @organizer_window.z = @viewport.z + 1
- @organizer_window.set_handler(:filter, method(:open_next_window))
- @organizer_window.set_handler(:sort, method(:open_next_window))
- @organizer_window.set_handler(:cancel, method(:return_prev_window))
- end
- def create_item_filter_window
- @filter_window = Window_ItemFilter.new(0,0)
- @filter_window.hide
- @filter_window.close
- @filter_window.x = @organizer_window.x
- @filter_window.y = @organizer_window.y
- @filter_window.z = @organizer_window.z + 1
- @filter_window.set_handler(:ok, method(:on_filter_ok))
- @filter_window.set_handler(:cancel, method(:return_organizer))
- end
- def create_item_sort_window
- @sort_window = Window_ItemSort.new(0,0)
- @sort_window.hide
- @sort_window.close
- @sort_window.x = @organizer_window.x
- @sort_window.y = @organizer_window.y
- @sort_window.z = @organizer_window.z + 1
- @sort_window.set_handler(:ok, method(:on_sort_ok))
- @sort_window.set_handler(:cancel, method(:return_organizer))
- end
- def item_window_pre_organize
- @item_window.deactivate
- @organizer_window.previous = @item_window
- start_organizer
- end
- def category_window_pre_organize
- @category_window.deactivate
- @organizer_window.previous = @category_window
- start_organizer
- end
- def start_organizer
- @organizer_window.show
- @organizer_window.open
- @organizer_window.activate
- end
- def open_next_window
- @organizer_window.close
- @organizer_window.deactivate
- if @organizer_window.current_symbol == :filter
- @filter_window.show
- @filter_window.open
- @filter_window.activate
- elsif @organizer_window.current_symbol == :sort
- @sort_window.show
- @sort_window.open
- @sort_window.activate
- end
- end
- def return_prev_window
- @organizer_window.close
- @organizer_window.deactivate
- @organizer_window.previous.activate
- @organizer_window.previous = nil
- end
- def on_filter_ok
- @item_window.filter = @filter_window.current_symbol
- return_organizer
- end
- def on_sort_ok
- @item_window.sorting = @sort_window.current_symbol
- return_organizer
- end
- def return_organizer
- @filter_window.close
- @filter_window.deactivate
- @sort_window.close
- @sort_window.deactivate
- @organizer_window.open
- @organizer_window.activate
- end
- end #Scene_Item
- end #if HBK::ITEM_TAB::ENABLED
Advertisement
Add Comment
Please, Sign In to add comment