Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Quasi Scene_Item
- #==============================================================================
- # Scene with custom categories.
- #==============================================================================
- module Quasi
- module Scene_Item
- #--------------------------------------------------------------------------
- # TYPE hash is used to create the categories and notetag
- # :tag => vocab
- # tag(without colon) is used for the notetag in the item surrounded by <>'s
- # vocab is used as the name to display in the menu
- #
- # In the setup below :mats becomes a notetag of <mats> and displays
- # Materials in the menu.
- #--------------------------------------------------------------------------
- TYPE = {
- :mats => "Materials",
- :shards => "Shards",
- :runes => "Runes",
- }
- #--------------------------------------------------------------------------
- # The width of the category window (X values of other windows are
- # automatically adjusted)
- #--------------------------------------------------------------------------
- WIN_CAT_WIDTH = 125
- end
- end
- #==============================================================================#
- # By Quasi (http://quasixi.com/)
- # - 12/21/14
- #==============================================================================#
- #==============================================================================
- # ** Scene_Item
- #------------------------------------------------------------------------------
- # This class performs the item screen processing.
- #==============================================================================
- class Scene_Item < Scene_ItemBase
- #--------------------------------------------------------------------------
- # * Fix so it works with YanFly
- #--------------------------------------------------------------------------
- def relocate_windows
- return
- end
- #--------------------------------------------------------------------------
- # * Create Category Window
- #--------------------------------------------------------------------------
- def create_category_window
- @category_window = Window_QItemCategory.new
- @category_window.viewport = @viewport
- @category_window.help_window = @help_window
- @category_window.y = @help_window.height
- @category_window.height = Graphics.height - @help_window.height
- @category_window.set_handler(:ok, method(:on_category_ok))
- @category_window.set_handler(:cancel, method(:return_scene))
- end
- #--------------------------------------------------------------------------
- # * Create Item Window
- #--------------------------------------------------------------------------
- def create_item_window
- wy = @help_window.height
- wx = @category_window.width
- ww = Graphics.width - wx
- wh = Graphics.height - wy
- @item_window = Window_ItemList.new(wx, wy, ww, wh)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.set_handler(:ok, method(:on_item_ok))
- @item_window.set_handler(:cancel, method(:on_item_cancel))
- @category_window.item_window = @item_window
- end
- end
- #==============================================================================
- # ** Window_QItemCategory
- #------------------------------------------------------------------------------
- # This window is for selecting a category of normal items and equipment
- # on the item screen or shop screen.
- #==============================================================================
- class Window_QItemCategory < Window_Command
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :item_window
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- Quasi::Scene_Item::WIN_CAT_WIDTH
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- @item_window.category = current_symbol if @item_window
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(Vocab::item, :item)
- #add_command(Vocab::weapon, :weapon)
- add_command(Vocab::armor, :armor)
- Quasi::Scene_Item::TYPE.each do |key, value|
- add_command(value, key)
- end
- add_command(Vocab::key_item, :key_item)
- end
- #--------------------------------------------------------------------------
- # * Set Item Window
- #--------------------------------------------------------------------------
- def item_window=(item_window)
- @item_window = item_window
- update
- end
- end
- #==============================================================================
- # ** Window_ItemList
- #------------------------------------------------------------------------------
- # This window displays a list of party items on the item screen.
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- # * Include in Item List?
- #--------------------------------------------------------------------------
- def include?(item)
- case @category
- when :item
- item.is_a?(RPG::Item) && !item.key_item? && !item.qtype
- #when :weapon
- #item.is_a?(RPG::Weapon) && !item.qtype
- when :armor
- item.is_a?(RPG::Armor) && !item.qtype
- when :key_item
- item.is_a?(RPG::Item) && item.key_item? && !item.qtype
- else
- return false unless item
- if Quasi::Scene_Item::TYPE.keys.include?(@category)
- return item.qtype == @category
- end
- false
- end
- end
- end
- #==============================================================================
- # ** RPG::Item
- #==============================================================================
- class RPG::BaseItem
- def qtype
- if @qtype.nil?
- @qtype = false
- Quasi::Scene_Item::TYPE.each_key do |key|
- regex = /<(?i:#{key.to_s})>/
- @qtype = key if @note =~ regex
- end
- end
- return @qtype
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement