查看: 1600|回复: 5

[已经过期] 求个调用自定义物品种类的scene?

[复制链接]
梦石
0
星屑
163
在线时间
445 小时
注册时间
2013-7-18
回帖
90
发表于 2013-8-6 20:22:24 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 lottesong 于 2013-8-10 08:44 编辑

我想要建一个scene  可以用SceneManager.call调出自定义种类的道具窗口  
就是在注释里含有 \cim_category![present]  字样的道具,把它们放在一起显示
照葫芦画瓢还不是很懂  挫到家了  是用eval判断note么 为啥不好用呢……大概出了无数的纰漏 (艸)
不知道要在脚本的窗口和场景里改些什么
能不能麻烦好心人帮忙写个即用的  非常感谢  让我好好的研究一下



----------------------------------以下请无视----------------------------------------------
使用了modern algebra的 自定义道具种类脚本,简单好用~~~Yanfly大大的太深奥了看不懂
已经在道具物品栏增加了“礼物”那项  
然后……如何在和队友对话的时候,调出礼物的窗口呢
就像  SceneManager.call(Scene_Equip)这样直接调出武器这种……限定这个时候只能使用present下的物品 然后其余道具,比如回复药水不能赠送
还是要自己建个Scene什么的0。0 怎么建  (作为新人我很白,只能用现成的ruby脚本……原理不懂)
还是要建个开关……判断语句?  礼物的道具都是在注释写了 "\cim_category![present]"

[pre lang="ruby" line="1" file="gift"]
    #==============================================================================
    #    Customizable Item Menu
    #    Version: 1.0.1
    #    Author: modern algebra (rmrk.net)
    #    Date: August 10, 2012
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Description:
    #
    #    This script allows you to customize various features of the default item
    #   menu. It lets you:
    #
    #      - Increase the number of lines you can use in the description window.
    #      - Change the position of the description window.
    #      - Show an enlarged picture of the item in the description window.
    #      - Make new categories to make the item menu cleaner to navigate.
    #      - Represent categories by icons instead of plain text.
    #      - Give descriptions to the categories.
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Instructions:
    #
    #    Paste this script into its own slot in the Script Editor, above Main but
    #   below Materials and other custom scripts.
    #
    #    All of the configuration for this script is done within the Editable
    #   Region starting at line 71. It is heavily commented and explains what each
    #   option does, so I encourage you to read it. Here, however, I will explain
    #   the configuration you can do within the note field of each item.
    #``````````````````````````````````````````````````````````````````````````````
    #    If you set the image_in_description value at line 83 to true, then you can
    #   assign an image to any given item with the following code in a note field:
    #
    #      \image[filename]
    #    where filename is the name of an image file in the Pictures folder of
    #   Graphics.
    #``````````````````````````````````````````````````````````````````````````````
    #    If you set the description_lines value at line 79 to more than 2, then
    #   you can add new lines to the description of an item with the followinf
    #   code in a note field:
    #
    #      \desc+{new line of description}
    #   You can add as many lines as you like, and message codes like \c[n] are
    #   recognized.
    #``````````````````````````````````````````````````````````````````````````````
    #    If you are using custom categories, then you can assign an item to appear
    #   in the new category with the following code:
    #
    #      \cim_category[unique_1, unique_2, etc...]
    #    where unique_1, unique_2, etc... are the names of the custom categories to
    #    which you want to assign the item. Also, if you do not want the item to
    #    appear in its default category (a weapon in Weapons, an armour in Armours,
    #    etc...), then all you need to do is place an ! after category and the
    #    item will then only appear in the categories you specify, like so:
    #
    #      \cim_category![unique_1, unique_2, etc...]
    #
    #    EXAMPLE:
    #  Say the following is in the note field of item 1:
    #      \cim_category[potion]
    #        This item will now appear in the :all, :item, and :potion categories.
    #
    #  However, if the following is used:
    #      \cim_category![potion]
    #        then the item will only appear in the :all and :potion categories.
    #==============================================================================
     
    $imported ||= {}
    $imported[:"MA Customizable Item Menu 1.0.x"] = true
     
    MA_CUSTOM_ITEM_MENU = {
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    #    BEGIN Editable Region
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    # DESCRIPTION OPTIONS
    #``````````````````````````````````````````````````````````````````````````````
    #  description_at_top - If true, the description window will be at the top of
    # the screen. If false, it will be at the bottom.
    description_at_top: true,
    #  description_lines - The number of lines to show in the description.
    description_lines: 3,
    #  image_in_description - If false, there will be no image shown in the
    # description. If true, there will be. See line 29 for instructions on how to
    # assign an image to an item through its notefield.
    image_in_description: false,
    #  image_width - If showing an image in the description window, this value is
    # the number of pixels the description image requires horizontally.
      image_width: 0,
    #  use_enlarged_icons_as_default - If you are showing images in the description
    # window and this value is true, then for any item which has no assigned image,
    # an enlarged version of its icon will be shown instead. If false, then no
    # image will be shown unless one is specifically assigned.
      use_enlarged_icons_as_default: false,
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    # CATEGORY OPTIONS
    #``````````````````````````````````````````````````````````````````````````````
    #  use_icons_for_categories - If true, the categories will be represented by
    # icons. If false, the categories will just be shown as text, as is normal
    use_icons_for_categories: true,
    #  show_category_label - if using icons for categories, this determines whether
    # the name of the category is shown in a parallel window. If this value is true,
    # then the category name is shown. If false, then it will just be the icons.
      show_category_label: true,
    #  icon_category_width - if using icons for categories and are showing labels,
    # this determines the width of the icon category window.
        icon_category_width: 288,
    #  category_label_position - If using icons for categories and showing the
    # category label, this determines the position of the label window relative to
    # the icon window. If :left, will be to the left. If :right, will be to the
    # right.
        category_label_position: :left,
    #``````````````````````````````````````````````````````````````````````````````
    #  custom_categories - This option allows you to choose which categories are
    # shown in the Item Menu. There are five default categories: :item, :weapon,
    # :armor, :key_item, and :all. As you would expect, the :item shows non-key
    # items, :weapon shows all weapons, :armor shows all armors, :key_item shows
    # all key items, and :all shows all items held by the party. They will appear
    # in the order that you set below. You can also create your own categories -
    # all you need to do is first create a symbol for the category and add it to
    # the array below. This can be anything as long as it is unique and in the
    # format:
    #      :unique
    # Next, you will need to go to the category_vocab and category_icons hashes and
    # assign to it a Label (if showing labels) and an icon (if using category
    # icons). See the instructions above those hashes for details.
    #
    #    EXAMPLE:
    #  If we wanted to add a Potions category, we could call it :potion and the
    # array would look as follows:
    #
    #    custom_categories: [:item, :potion, :weapon, :armor, :key_item],
    #
    # To find out how to assign an item to one of the custom categories you create,
    # see line 44.
    custom_categories: [:item, :weapon, :armor, :key_item, :present],
    #  category_vocab - In this hash, you can set the name of each category. You
    # need to set a name for every category included in the custom_categories
    # array unless you are using icons and not showing any label at all. You set
    # each label as a "string" and that will be what shows up in-game. You can also
    # set it so that the name is retrieved by evaluating an expression. To do that,
    # just put a : in front of the quotation marks, like so:
    #
    #     :"expression"
    #
    #  Below, you will see examples of both - the :all category is set, by default,
    # to an ordinary string, while the others are all set to retrieve the name for
    # the category that is assigned in the Database.
    #
    #  Now, to set the name of a custom category that you create, all you need to
    # do is make a new line before the } line in the following format:
    #
    #    :unique => "",
    #
    #    EXAMPLE:
    #  To set the name of our new potions category, we could do the following:
    #
    #    :potion => "Potions",
    category_vocab: {
      :all =>      "All Items",
      :item =>     :"Vocab::item",
      :present =>   "礼物",
      :weapon =>   :"Vocab::weapon",
      :armor =>    :"Vocab::armor",
      :key_item => :"Vocab::key_item",
    }, # END VOCAB HASH
    #  category_icons - If using icons to represent categories, then this is where
    # you set which icons will show for each category. Just set it to whichever
    # icon index you want. Similar to the vocab hash, the format is:
    #
    #    :unique => 0,
    #
    #    EXAMPLE:
    #  Our potions category could be set as follows:
    #   
    #    :potion => 192,
    category_icons: {
      :all =>      672,
      :item =>     260,
      :present =>   122,
      :weapon =>   115,
      :armor =>    141,
      :key_item => 597,
    }, # END ICONS HASH
    #  category_descriptions - If you wish you can make it so that each category
    # has a description which will be shown in the help window whenever you are
    # selecting a category. Similar to the above hashes, the format is:
    #
    #    :unique => "",
    #
    #  To make a new line, simply put a \\n within the string.
    #
    #    EXAMPLE:
    #  Our potions category could have a new description as follows:
    #
    #    :potion => "Alchemical concoctions to \\c[3]remedy\\c[0] various\\nillnesses.",
    #
    #  If you are showing an image in the description of items, you can also set
    # an image to show for the category description by the following code:
    #
    #    :unique => ["description", "image filename"],
    #
    #  where description is the regular description and image filename is the
    # filename of an image in the Pictures folder of Graphics. You could also just
    # put an integer, in which case it would draw an enlarged version of the icon
    # with that index.
    #
    #    EXAMPLES:
    #  If you wanted your potions category to show an enlarged version of icon 192
    # and be described as "Alchemical concoctions", you would add the following
    # line:
    #
    #    :potion => ["Alchemical concoctions", 192],
    #
    #  If you instead wanted to use a graphic from Pictures called "Potion01", then
    # the line would be:
    #
    #    :potion => ["Alchemical concoctions", "Potion01"],
    category_descriptions: {
      :all =>      "",
      :item =>     "",
      :weapon =>   "",
      :armor =>    "",
      :key_item => "",
    }, # END DESCRIPTIONS HASH
    #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    #    END Editable Region
    #//////////////////////////////////////////////////////////////////////////////
    }
    MA_CUSTOM_ITEM_MENU[:category_vocab].default = ""
    MA_CUSTOM_ITEM_MENU[:category_descriptions].default = ""
    MA_CUSTOM_ITEM_MENU[:category_icons].default = 0
     
    #==============================================================================
    # *** MACIM_RPG_ItemWeaponArmor
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This method mixes in with RPG::Item, RPG::Weapon, and RPG::Armor, adding
    # the following:
    #    new method - macim_categories
    #==============================================================================
     
    module MACIM_RPG_ItemWeaponArmor
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Custom Categories
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def macim_categories
        if !@macim_categories
          @macim_categories = [macim_default_category]
          if self.note[/\\CIM[_ ]CATEGOR(Y|IES)(!?)\s*\[\s*(.+?)\s*\]/i]
            @macim_categories.delete(macim_default_category) unless $2.empty?
            cats = $3.scan(/[^:,;\s]+/)
            cats.each { |category| @macim_categories.push(category.to_sym) }
          end
        end
        @macim_categories
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Image
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def macim_desc_image
        if !@macim_desc_image
          @macim_desc_image = ""
          if self.note[/\\IMAGE\[(.+?)\]/i]
            @macim_desc_image = $1
          elsif MA_CUSTOM_ITEM_MENU[:use_enlarged_icons_as_default]
            @macim_desc_image = $imported[:MAIcon_Hue] ? [icon_index, icon_hue] : icon_index
          end
        end
        @macim_desc_image
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Description
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def description(*args, &block)
        result = super(*args, &block)
        if !@macim_description_plus
          @macim_description_plus = ""
          self.note.scan(/\\(DESC|DESCRIPTION)\+\{(.+?)\}/im) { |line|
            desc_plus = line[1].gsub(/\s*[\r\n]+\s*/, " ")
            desc_plus.gsub!(/\\[Nn]/, "\n")
            @macim_description_plus += "\n" + desc_plus
          }
        end
        result + @macim_description_plus
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Default Category
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def macim_default_category; :item; end
    end
     
    #==============================================================================
    # *** RPG
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This adds a few methods to the Item, Weapon, and Armor classes by mixing in
    # the MACIM_RPG_ItemWeaponArmor module.
    #==============================================================================
     
    module RPG
      class Item
        include MACIM_RPG_ItemWeaponArmor
        def macim_default_category; key_item? ? :key_item : :item; end
      end
      class Weapon
        include MACIM_RPG_ItemWeaponArmor
        def macim_default_category; :weapon; end
      end
      class Armor
        include MACIM_RPG_ItemWeaponArmor
        def macim_default_category; :armor; end
      end
    end
     
    unless $imported[:"MA_ParagraphFormat_1.0"]
    #==============================================================================
    # ** MA_Window_ParagraphFormat
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This module inserts into Window_Base and provides a method to format the
    # strings so as to go to the next line if it exceeds a set limit. This is
    # designed to work with draw_text_ex, and a string formatted by this method
    # should go through that, not draw_text.
    #==============================================================================
     
    module MA_Window_ParagraphFormat
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Calc Line Width
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
        return tw if line.nil?
        line = line.clone
        unless contents_dummy
          real_contents = contents # Preserve Real Contents
          # Create a dummy contents
          self.contents = Bitmap.new(contents_width, 24)
          reset_font_settings
        end
        pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
        while line[/^(.*?)\e(.*)/]
          tw += text_size($1).width
          line = $2
          # Remove all ancillaries to the code, like parameters
          code = obtain_escape_code(line)
          # If direct setting of x, reset tw.
          tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
            ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
          #  If I need to do something special on the basis that it is testing,
          # alias process_escape_character and differentiate using @atsf_testing
          process_escape_character(code, line, pos)
        end
        #  Add width of remaining text, as well as the value of pos[:x] under the
        # assumption that any additions to it are because the special code is
        # replaced by something which requires space (like icons)
        tw += text_size(line).width + pos[:x]
        unless contents_dummy
          contents.dispose # Dispose dummy contents
          self.contents = real_contents # Restore real contents
        end
        return tw
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Format Paragraph
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def mapf_format_paragraph(text, max_width = contents_width)
        text = text.clone
        #  Create a Dummy Contents - I wanted to boost compatibility by using the
        # default process method for escape codes. It may have the opposite effect,
        # for some :(
        real_contents = contents # Preserve Real Contents
        self.contents = Bitmap.new(contents_width, 24)
        reset_font_settings
        paragraph = ""
        while !text.empty?
          text.lstrip!
          oline, nline, tw = mapf_format_by_line(text.clone, max_width)
          # Replace old line with the new one
          text.sub!(/#{Regexp.escape(oline)}/m, nline)
          paragraph += text.slice!(/.*?(\n|$)/)
        end
        contents.dispose # Dispose dummy contents
        self.contents = real_contents # Restore real contents
        return paragraph
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Format By Line
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def mapf_format_by_line(text, max_width = contents_width)
        oline, nline, tw = "", "", 0
        loop do
          #  Format each word until reach the width limit
          oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
          return oline, nline, tw if done
        end
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Format By Word
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def mapf_format_by_word(text, line, tw, max_width)
        return line, line, tw, true if text.nil? || text.empty?
        # Extract next word
        if text.sub!(/(\s*)([^\s\n\f]*)([\n\f]?)/, "") != nil
          prespace, word, line_end = $1, $2, $3
          ntw = mapf_calc_line_width(word, tw, true)
          pw = contents.text_size(prespace).width
          if (pw + ntw >= max_width)
            # Insert
            if line.empty?
              # If one word takes entire line
              return prespace + word, word + "\n", ntw, true
            else
              return line + prespace + word, line + "\n" + word, tw, true
            end
          else
            line += prespace + word
            tw = pw + ntw
            # If the line is force ended, then end
            return line, line, tw, true if !line_end.empty?
          end
        else
          return line, line, tw, true
        end
        return line, line, tw, false
      end
    end
     
    class Window_Base
      include MA_Window_ParagraphFormat
    end
     
    $imported[:"MA_ParagraphFormat_1.0"] = true
    end
     
    unless $imported[:"MA_IconHorzCommand_1.0"]
    #==============================================================================
    # ** Window_MA_IconHorzCommand
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This window is a base window to show a horizontal command window populated
    # with icons.
    #==============================================================================
     
    class Window_MA_IconHorzCommand < Window_HorzCommand
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Public Instance Variable
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      attr_reader   :observing_procs
      attr_accessor :cursor_hide
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Object Initialization
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def initialize(*args, &block)
        @observing_procs = {}
        super(*args, &block)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Column Max
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def col_max; [(width - standard_padding) / (24 + spacing), item_max].min; end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Item
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def item
        @list[index] ? @list[index][:symbol] : nil
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Enabled? / Current Item Enabled?
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def enable?(index); self.index == index; end
      def current_item_enabled?; !current_data.nil?; end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Draw Item
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def draw_item(index)
        rect = item_rect(index)
        contents.clear_rect(rect)
        draw_icon(@list[index][:ext], rect.x + ((rect.width - 24) / 2), rect.y, enable?(index))
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Set Index
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def index=(index)
        old_index = self.index
        super(index)
        draw_item(old_index)
        draw_item(self.index)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Frame Update
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def update
        super
        @observing_procs.values.each { |block| block.call(item) }
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Add/Remove Observing Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def add_observing_proc(id, &block)
        @observing_procs[id] = block
        update
      end
      def remove_observing_proc(id)     ; @observing_procs.delete(id) ; end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Update Cursor
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def update_cursor
        super
        cursor_rect.empty if @cursor_hide
      end
    end
    $imported[:"MA_IconHorzCommand_1.0"] = true
    end
     
    #==============================================================================
    # ** Window_ItemCategory
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    overwritten method - make_command_list; update_help
    #==============================================================================
     
    class Window_ItemCategory
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Command List
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def make_command_list
        categories = MA_CUSTOM_ITEM_MENU[:custom_categories]
        vocab = MA_CUSTOM_ITEM_MENU[:category_vocab]
        categories.each {|category|
          text = vocab[category].is_a?(Symbol) ? eval(vocab[category].to_s) : vocab[category]
          add_command(text, category)
        }
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Update Help
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def update_help
        @help_window.set_text(MA_CUSTOM_ITEM_MENU[:category_descriptions][current_symbol])
      end
    end
     
    #==============================================================================
    # ** Window_ItemCategory
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    aliased method - include?
    #==============================================================================
     
    class Window_ItemList
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Include in Item List?
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias ma_cim_includecheck_2hj7 include?
      def include?(item, *args, &block)
        return true if @category == :all
        if item.is_a?(MACIM_RPG_ItemWeaponArmor)
          item.macim_categories.include?(@category)
        else
          ma_cim_includecheck_2hj7(item, *args, &block)
        end
      end
    end
     
    #==============================================================================
    # ** Window_MACIM_ItemIconCategory
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This window shows categories represented by icons
    #==============================================================================
     
    class Window_MACIM_ItemIconCategory < Window_MA_IconHorzCommand
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Object Initialization
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def initialize(x = 0, y = 0, categories = MA_CUSTOM_ITEM_MENU[:custom_categories])
        @cursor_hide = false
        @categories = categories
        super(x, y)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Window Width
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def window_width
        !MA_CUSTOM_ITEM_MENU[:show_category_label] ? Graphics.width :
          MA_CUSTOM_ITEM_MENU[:icon_category_width]
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Category=
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def category=(category)
        self.index = @categories.index(category) if @categories.include?(category)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Command List
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def make_command_list
        icons = MA_CUSTOM_ITEM_MENU[:category_icons]
        @categories.each {|category|
          add_command("", category, false, icons[category])
        }
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Set Item Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def item_window=(window, *args)
        add_observing_proc(:list) {|category| window.category = category }
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Update Help
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def update_help
        desc = MA_CUSTOM_ITEM_MENU[:category_descriptions][current_symbol]
        desc = [desc] if !desc.is_a?(Array)
        @help_window.set_text(*desc)
      end
    end
     
    #==============================================================================
    # ** Window Category Label
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This window simply shows a label for category currently selected
    #==============================================================================
     
    class Window_MACIM_CategoryLabel < Window_Base
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Object Initialization
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def initialize(x, y, label = "")
        super(x, y, window_width, window_height)
        refresh(label)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Window Attributes
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def window_width; Graphics.width - MA_CUSTOM_ITEM_MENU[:icon_category_width]; end
      def window_height; line_height + (standard_padding*2); end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Refresh
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def refresh(label = @label)
        @label = label.is_a?(String) ? convert_escape_characters(label) : ""
        contents.clear
        reset_font_settings
        tw = mapf_calc_line_width(@label)
        draw_text_ex((contents_width - tw) / 2, 0, @label)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Set Category
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def category=(category)
        return if @category == category
        @category = category
        vocab = MA_CUSTOM_ITEM_MENU[:category_vocab][@category]
        label = vocab.is_a?(Symbol) ? eval(vocab.to_s) : vocab
        refresh(label)
      end
    end
     
    #==============================================================================
    # ** Window_MACIM_Help
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This window is a help window with adjustable height and can show an image
    #==============================================================================
     
    class Window_MACIM_Help < Window_Help
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Set Text
      #    Adds argument to change the image associated with the description
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def set_text(text, filename = "")
        if filename != @image || text != @text
          @text = text
          @image = filename
          refresh
        end
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Set Item
      #     item : Skills and items etc.
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def set_item(item)
        item ? set_text(item.description, item.is_a?(MACIM_RPG_ItemWeaponArmor) ? item.macim_desc_image : "") : set_text("", "")
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Refresh
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def refresh
        contents.clear
        draw_image(0, 0, MA_CUSTOM_ITEM_MENU[:image_width], contents_height, @image) unless @image == ""
        # Adjust x position for text to give room for image
        x = 4
        x += MA_CUSTOM_ITEM_MENU[:image_width]
        draw_text_ex(x, 0, @text)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Draw Image
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def draw_image(x, y, w, h, filename)
        contents.clear_rect(x, y, w, h)
        bmp = make_image_bmp(filename, w, h)
        # Adjust position and src_rect
        src_rect = Rect.new(0, 0, w, h)
        if w >= bmp.rect.width # If width allowed greater than width of image
          x += ((w - bmp.rect.width) / 2) # Centre
          src_rect.width = bmp.rect.width
        else # If width allowed is less than width of image
          src_rect.x += ((bmp.rect.width - w) / 2) # Cut to centre
        end
        if h >= bmp.rect.height # If height allowed is greater than height of image
          y += ((h - bmp.rect.height) / 2) # Centre
          src_rect.height = bmp.rect.height
        else # If height allowed is less than height of image
          src_rect.y += ((bmp.rect.height - h) / 2) # Cut to centre
        end
        contents.blt(x, y, bmp, src_rect)
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Make the image bitmap
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def make_image_bmp(filename, w, h)
        case filename
        when String then Cache.picture(filename)                  # Filename
        when Integer then get_enlarged_icon([w, h].min, filename) # icon index
        when Array                                              # [icon index, hue]
          filename = filename.select {|num| num.is_a?(Integer) }
          filename.slice!(2, filename.size - 2) if filename.size > 2
          return if filename.empty?
          get_enlarged_icon([w, h].min, *filename)
        else                                                      # empty
          Cache.picture("")
        end
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Get Enlarged Icon
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def get_enlarged_icon(size, icon_index, icon_hue = 0)
        iconset = Cache.system("Iconset")
        src_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
        bmp = Bitmap.new(size, size)
        bmp.stretch_blt(bmp.rect, iconset, src_rect)
        # Compatibility with Icon Hues
        bmp.change_hue(icon_hue) if icon_hue != 0
        bmp
      end
    end
     
    #==============================================================================
    # ** Scene_Item
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    aliased method - start; create_category_window; create_help_window;
    #      create_item_window
    #    new method - create_category_label_window
    #==============================================================================
     
    class Scene_Item
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Start Processing
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias macim_start_2hz7 start
      def start(*args, &block)
        macim_start_2hz7(*args, &block) # Call Original Method
        create_category_label_window if MA_CUSTOM_ITEM_MENU[:use_icons_for_categories] &&
          MA_CUSTOM_ITEM_MENU[:show_category_label]
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Help Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias macim_createhelp_2sk4 create_help_window
      def create_help_window(*args, &block)
        if MA_CUSTOM_ITEM_MENU[:description_lines] == 2 &&
            !MA_CUSTOM_ITEM_MENU[:image_in_description]
          macim_createhelp_2sk4(*args, &block) # Call Original Method
        else
          # Create special help window if showing image - otherwise normal
          @help_window = MA_CUSTOM_ITEM_MENU[:image_in_description] ?
            Window_MACIM_Help.new(MA_CUSTOM_ITEM_MENU[:description_lines]) :
            Window_Help.new(MA_CUSTOM_ITEM_MENU[:description_lines])
          @help_window.viewport = @viewport
        end
        @help_window.y = Graphics.height - @help_window.height unless MA_CUSTOM_ITEM_MENU[:description_at_top]
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Category Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias macim_createcatwind_7jc4 create_category_window
      def create_category_window(*args, &block)
        if MA_CUSTOM_ITEM_MENU[:use_icons_for_categories] # If Icon Categories
          # Create Icon Categories window instead of regular
          x = (!MA_CUSTOM_ITEM_MENU[:show_category_label] ||
            MA_CUSTOM_ITEM_MENU[:category_label_position] == :right) ? 0 :
            Graphics.width - MA_CUSTOM_ITEM_MENU[:icon_category_width]
          y = MA_CUSTOM_ITEM_MENU[:description_at_top] ? @help_window.height : 0
          @category_window = Window_MACIM_ItemIconCategory.new(x, y)
          @category_window.viewport = @viewport
          @category_window.help_window = @help_window
          @category_window.set_handler(:ok,     method(:on_category_ok))
          @category_window.set_handler(:cancel, method(:return_scene))
        else # Create regular category window if not using icons
          macim_createcatwind_7jc4(*args, &block) # Call Original Method
        end
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Item Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias macim_cretitmwdow_4gz9 create_item_window
      def create_item_window(*args, &block)
        macim_cretitmwdow_4gz9(*args, &block) # Call Original Method
        unless MA_CUSTOM_ITEM_MENU[:description_at_top]
          @item_window.height -= @help_window.height
          @item_window.refresh
        end
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Category Label Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def create_category_label_window
        # Determine position
        x = MA_CUSTOM_ITEM_MENU[:category_label_position] == :right ?
          MA_CUSTOM_ITEM_MENU[:icon_category_width] : 0
        y = MA_CUSTOM_ITEM_MENU[:description_at_top] ? @help_window.height : 0
        # Create label window
        @macim_categorylabel_window = Window_MACIM_CategoryLabel.new(x, y)
        @macim_categorylabel_window.viewport = @viewport
        @category_window.add_observing_proc(:label) { |category|
          @macim_categorylabel_window.category = category }
      end
    end
     
    #==============================================================================
    # ** Scene_Battle
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    aliased method - create_help_window
    #==============================================================================
     
    class Scene_Battle
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Help Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias macim_crthelpwind_2kf6 create_help_window
      def create_help_window(*args, &block)
        if MA_CUSTOM_ITEM_MENU[:description_lines] == 2 &&
            !MA_CUSTOM_ITEM_MENU[:image_in_description]
          macim_crthelpwind_2kf6(*args, &block) # Call Original Method
        else
          # Create special help window if showing image - otherwise normal
          @help_window = MA_CUSTOM_ITEM_MENU[:image_in_description] ?
            Window_MACIM_Help.new(MA_CUSTOM_ITEM_MENU[:description_lines]) :
            Window_Help.new(MA_CUSTOM_ITEM_MENU[:description_lines])
          @help_window.visible = false
        end
      end
    end
     
    #==============================================================================
    # ** Scene_Equip
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    aliased method - create_help_window
    #==============================================================================
     
    class Scene_Equip
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Create Help Window
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias macim_catehelp_3nb7 create_help_window
      def create_help_window(*args, &block)
        if MA_CUSTOM_ITEM_MENU[:description_lines] == 2 &&
            !MA_CUSTOM_ITEM_MENU[:image_in_description]
          macim_catehelp_3nb7(*args, &block) # Call Original Method
        else
          # Create special help window if showing image - otherwise normal
          @help_window = MA_CUSTOM_ITEM_MENU[:image_in_description] ?
            Window_MACIM_Help.new(MA_CUSTOM_ITEM_MENU[:description_lines]) :
            Window_Help.new(MA_CUSTOM_ITEM_MENU[:description_lines])
          @help_window.viewport = @viewport
        end
      end
    end

[/pre]
梦石
0
星屑
50
在线时间
256 小时
注册时间
2013-5-27
回帖
187
发表于 2013-8-7 01:24:59 | 显示全部楼层
第一次看到这种注释比代码还长的脚本。
按你的要求,送礼物的功能,肯定是要重新写个Scene什么的,
回复

使用道具 举报

梦石
0
星屑
163
在线时间
445 小时
注册时间
2013-7-18
回帖
90
 楼主| 发表于 2013-8-7 01:48:01 | 显示全部楼层
scottyfan 发表于 2013-8-7 01:24
第一次看到这种注释比代码还长的脚本。
按你的要求,送礼物的功能,肯定是要重新写个Scene什么的, ...

谢谢你的回复
因为这样才是傻瓜手册, 我这样的初心者能用的脚本啊,一步步教人怎么改动就好。还可以学习一下思路。
yanfly大神的就感觉超级高深莫测的风格 "喏,拿去吧,小白问题别烦我……"
其实,俺真的完全不懂怎么用 QUQ  【安装书在哪儿啊,痛哭流涕】
哦 scene要重写啊  扶墙  

点评

虽然我比较讨厌yanfly这样的态度,但是代码的确是他写的好,好代码简洁干净易读。  发表于 2013-8-7 01:57
回复

使用道具 举报

梦石
0
星屑
163
在线时间
445 小时
注册时间
2013-7-18
回帖
90
 楼主| 发表于 2013-8-10 08:46:46 | 显示全部楼层
修改了一下标题,能不能拜托大神们,实在是遇到了瓶颈  QUQ
回复

使用道具 举报

梦石
0
星屑
50
在线时间
256 小时
注册时间
2013-5-27
回帖
187
发表于 2013-8-10 23:17:55 | 显示全部楼层
不嫌弃,就用我写的。
  1. #==============================================================================
  2. #  功能:[RMVA]增加物品栏类别
  3. #  作者:ScottyFan
  4. #  版本:v1.0 2013.8.8
  5. #  使用说明:
  6. #         在数据库-物品(包括装备)-备注 里写入 @itype[位置编号]
  7. #         新的物品分类编号是从 1 开始。比如 @itype[1]或者@itype[2]
  8. #==============================================================================
  9. module SFS
  10.   CATEGORY = [   #格式["显示名称", :标识],  标识随便写,不重复即可
  11.     ["",     :default], #注意,不要更改此行
  12.     ["药剂", :potion],  #此处为编号1
  13.     ["食物", :food],
  14.     ["光碟", :disc],
  15.     ["宝石", :gem],
  16.     ]
  17. end
  18.   
  19. class RPG::BaseItem
  20.   attr_reader   :category_id
  21.   def category_id
  22.     return if self.is_a?(RPG::Skill)
  23.     if @category_id.nil?
  24.       /@itype\[(.+?)\]/ =~ @note
  25.       @category_id = $1.to_i
  26.     end
  27.     @category_id
  28.   end
  29. end


  30. class Window_ItemCategory
  31.   #--------------------------------------------------------------------------
  32.   # ● 生成指令列表
  33.   #--------------------------------------------------------------------------
  34.   def make_command_list
  35.     SFS::CATEGORY.each do |itype|
  36.       next if itype[1] == :default
  37.       add_command(itype[0],  itype[1])
  38.     end
  39.     add_command("普通物品",     :item)
  40.     add_command(Vocab::weapon,   :weapon)
  41.     add_command(Vocab::armor,    :armor)
  42.     add_command(Vocab::key_item, :key_item)
  43.   end
  44. end


  45. class Window_ItemList
  46.   #--------------------------------------------------------------------------
  47.   # ● 查询列表中是否含有此物品
  48.   #--------------------------------------------------------------------------
  49.   def include?(item)
  50.     if item && item.category_id > 0 #如果是特殊类别
  51.       return @category == SFS::CATEGORY[item.category_id][1]
  52.     end
  53.     case @category   
  54.     when :item
  55.       item.is_a?(RPG::Item) && !item.key_item?
  56.     when :weapon
  57.       item.is_a?(RPG::Weapon)
  58.     when :armor
  59.       item.is_a?(RPG::Armor)
  60.     when :key_item
  61.       item.is_a?(RPG::Item) && item.key_item?
  62.     else
  63.       false
  64.     end
  65.   end
  66. end
复制代码

评分

参与人数 1梦石 +1 收起 理由
迷糊的安安 + 1 认可答案 附赠精美好人卡一张~~.

查看全部评分

回复

使用道具 举报

梦石
0
星屑
163
在线时间
445 小时
注册时间
2013-7-18
回帖
90
 楼主| 发表于 2013-8-11 04:55:40 | 显示全部楼层
scottyfan 发表于 2013-8-10 23:17
不嫌弃,就用我写的。

(⊙A⊙)!
谢谢  试了一下。怎么做到的用简洁的篇幅,实现的这个归类功能呢 真不错
而且还是新鲜出炉编写得来着       
小白问题永远都不嫌少
虽然还是似懂非懂,但是很快乐地剽去研究了  3Q~~
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部