#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= # ▼ Item Checker # Author: Trihan # Version 1 # Release date: 01/02/17 #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:= #------------------------------------------------------------------------------ # ▼ UPDATES #------------------------------------------------------------------------------ # 01/02/17 - First release #------------------------------------------------------------------------------ # ▼ TERMS OF USAGE #------------------------------------------------------------------------------ # This script may be used for any purpose with or without credit, though a # little mention would be nice. #------------------------------------------------------------------------------ # ▼ INTRODUCTION #------------------------------------------------------------------------------ # This script adds a new custom scene to your game for debugging purposes; it # will display a list of all items with the chosen occasion/price in their # settings so you can see at a glance whether you've made any mistakes while # choosing what situations an item can be used in. #------------------------------------------------------------------------------ # ▼ INSTRUCTIONS #------------------------------------------------------------------------------ # Just put "SceneManager.call(Scene_ItemChecker)" in a script call. #------------------------------------------------------------------------------ # ▼ COMPATIBILITY #------------------------------------------------------------------------------ # There shouldn't be any compatibility issues as this is a completely new # scene. $imported = {} if $imported.nil? $imported['tricheck'] = true #============================================================================== # ** Scene_ItemChecker #------------------------------------------------------------------------------ # Scene for showing the category choices and item list. #============================================================================== class Scene_ItemChecker < Scene_MenuBase #-------------------------------------------------------------------------- # * Constructor #-------------------------------------------------------------------------- def start super create_category_window create_item_window end #-------------------------------------------------------------------------- # * Create window with item setting categories #-------------------------------------------------------------------------- def create_category_window @category_window = Window_ItemCheckerCategory.new @category_window.viewport = @viewport @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # * Create window that lists items #-------------------------------------------------------------------------- def create_item_window wx = @category_window.x + @category_window.width ww = Graphics.width - wx @item_window = Window_ItemCheckerList.new(wx, 0, ww, Graphics.height) @item_window.viewport = @viewport @item_window.set_handler(:cancel, method(:on_item_cancel)) @category_window.item_window = @item_window end #-------------------------------------------------------------------------- # * Handler method for pressing 'ok' while a category is selected #-------------------------------------------------------------------------- def on_category_ok @item_window.activate @item_window.select_last end #-------------------------------------------------------------------------- # * Handler method for pressing 'cancel' while an item is selected #-------------------------------------------------------------------------- def on_item_cancel @item_window.unselect @category_window.activate end end #============================================================================== # ** Window_ItemCheckerCategory #------------------------------------------------------------------------------ # Window for displaying item categories #============================================================================== class Window_ItemCheckerCategory < Window_Command #-------------------------------------------------------------------------- # * Constructor #-------------------------------------------------------------------------- def initialize super(0, 0) end #-------------------------------------------------------------------------- # * We don't want the window to take up the whole width of the screen. #-------------------------------------------------------------------------- def window_width 240 end #-------------------------------------------------------------------------- # * Single-column category list #-------------------------------------------------------------------------- def col_max 1 end #-------------------------------------------------------------------------- # * Frame update method #-------------------------------------------------------------------------- def update super @item_window.category = current_symbol if @item_window end #-------------------------------------------------------------------------- # * Creates the list of categories and their associated symbols #-------------------------------------------------------------------------- def make_command_list add_command("Occasion: Always", :always) add_command("Occasion: Battle", :battle) add_command("Occasion: Menu", :menu) add_command("Occasion: Never", :never) add_command("Price: 0", :pricezero) end #-------------------------------------------------------------------------- # * Sets the window's associated item window to link up displays #-------------------------------------------------------------------------- def item_window=(item_window) @item_window = item_window update end end #============================================================================== # ** Window_ItemCheckerCategory #------------------------------------------------------------------------------ # Window for displaying list of items #============================================================================== class Window_ItemCheckerList < Window_ItemList #-------------------------------------------------------------------------- # * Constructor #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) end #-------------------------------------------------------------------------- # * Method to determine whether an item should currently be listed #-------------------------------------------------------------------------- def include?(item) if item case @category when :always item.occasion == 0 when :battle item.occasion == 1 when :menu item.occasion == 2 when :never item.occasion == 3 when :pricezero item.price == 0 else false end end end #-------------------------------------------------------------------------- # * Disable all items by default. Selecting them does nothing anyway. #-------------------------------------------------------------------------- def enable?(item) false end #-------------------------------------------------------------------------- # * Creates the list of items (all items in the database, basically) #-------------------------------------------------------------------------- def make_item_list @data = $data_items.select {|item| include?(item) if item } end #-------------------------------------------------------------------------- # * Need to overwrite the super method as we don't need item quantities #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] if item rect = item_rect(index) rect.width -= 4 draw_item_name(item, rect.x, rect.y) end end end