RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Catalogue Base

0 Members and 2 Guests are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Catalogue Base
Version: 1.1
Author: modern algebra
Date: October 6, 2009

Version History


  • <Version 1.1> 10.06.2009 - updated for an easier way to vary the size of windows. This makes it possible to have a much more dynamic design
  • <Version 1.0> 08.16.2009 - Original Release

Description


This script acts as a base script for my catalogue scripts, and it is required for each of those scripts. It has a number of shared classes and methods that thereby reduce unnecessary coding for those scripts.

It is, however, strictly a support script. It has no useful purpose on its own.

Features

  • This is really just a helper script, so it doesn't have many features worth listing. The format can be seen in the Screenshots section
  • It allows for easy creation of other Catalogues. All that needs to be done is to make a subclass of Catalogue_Base, and make a new Card window with the info you want to show.
Screenshots

This is what the basic format of all my catalogue scripts will be:



Instructions

No real insructions. For any script that requires this, just paste it above Main and above the scripts that require it but below the default scripts. If you wish to use it to write your own scripts, than post and I will write some instructions. But if nobody wants to, I don't want to write them all out :)

Script


Code: [Select]
#==============================================================================
#    Catalogue Base
#    Version: 1.1
#    Author: modern algebra (rmrk.net)
#    Date: October 6, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#  
#    This script acts as a base script for my catalogue scripts, and it is
#   required for each of those scripts. It has a number of shared classes and
#   methods that thereby reduce unnecessary coding for those scripts.
#
#    It is, however, strictly a support script. It has no useful purpose on
#   its own.
#==============================================================================

#==============================================================================
# ** Data Catalogues
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class handles catalogues. It's a wrapper for the built-in class Array
#==============================================================================

class Data_Catalogues
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize
    @data = []
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Catalogue
  #     catalogue_id : ID of the catalogue
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def [](catalogue_id)
    if @data[catalogue_id] == nil
      return Catalogue_Base.new
    else
      return @data[catalogue_id]
    end
  end
end

#==============================================================================
# ** Catalogue_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  This is the base to all Catalogue Groups.
#==============================================================================

class Catalogue_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :name
  attr_reader   :objects
  attr_accessor :visible_objects
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (name = 'Catalogue', objects = [], show_all = false)
    # Set variables
    @name = name
    @objects = objects
    @visible_objects = []
    @show_all = show_all
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Card
  #``````````````````````````````````````````````````````````````````````````
  #  This method returns the Card Window for a Catalogue, and should be
  # overwritten by any subclasses
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def card
    return Window_CatalogueCard
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Include?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def include? (index)
    return true
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Enable?
  #    index : the index of object in objects array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def enable? (index)
    return true
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object (index)
    return @objects[index]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Icon
  #     index : The index of the object in objects array
  #``````````````````````````````````````````````````````````````````````````
  #  This returns an icon to show in Window_CatalogueCommand. By default, it
  # will return the output of the object method icon_index. It must be
  # overwritten if the object class has no icon_index method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object_icon (index)
    return index < @objects.size ? object (index).icon_index : 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Name
  #     index : The index of the object in objects array
  #``````````````````````````````````````````````````````````````````````````
  #  This returns a name to show in Window_CatalogueCommand. By default, it
  # will return the output of the object method name. It must be overwritten
  # if the object class has no name method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object_name (index)
    return index < @objects.size ? object (index).name : ''
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object_help_text (index)
    return ''
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * C Disabled?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def c_disabled
    return true
  end
end

#==============================================================================
# ** Window Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - cb_outline_rect
#==============================================================================

class Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Outline_Rect
  #    x, y, width, height : rect to outline around
  #    colour              : the colour object for this box
  #    t                   : thickness of the edges
  #    type                : 0 => rounded rectangle; 1 => rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def cb_outline_rect (x, y, width, height, colour = system_color, t = 2, type = 0)
    # If fill round, check if possible
    if type == 0
      if !contents.methods.include? ("fill_rounded_rect")
        type = 1
      else
        contents.fill_rounded_rect (Rect.new (x, y, width, height), colour)
        rect = Rect.new (x + t, y + t, width - (2*t), height - (2*t))
        contents.fill_rounded_rect (rect, Color.new (0,0,0,0))
      end
    end
    # Otherwise, draw rectangle
    if type == 1
      # Draw Horizontal
      contents.fill_rect (x, y, width, t, colour)
      contents.fill_rect (x, y + height - t, width, t, colour)
      # Draw Vertical
      contents.fill_rect (x, y + t, t, height - (2*t), colour)
      contents.fill_rect (x + width - t, y + t, t, height - (2*t), colour)
    end
  end
end

#==============================================================================
# ** Window_CatalogueCard
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  This window display information on objects in the catalogue
#==============================================================================

class Window_CatalogueCard < Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize
  #    catalogue : the catalogue information this card shows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (catalogue)
    super (224, 0, Graphics.width - 224, Graphics.height - 32 - WLH)
    @catalogue = catalogue
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh (index)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh (index = nil)
    contents.clear
    return false if index == nil
    @object = @catalogue.object (index)
  end
end

#==============================================================================
# ** Window Catalogue Label
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This window displays the name of the Catalogue
#==============================================================================

class Window_CatalogueLabel < Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (x, y, width, height, name)
    super (x, y, width, height)
    contents.font.color = system_color
    contents.draw_text (0, 0, contents.width, contents.height, name, 1)
  end
end

#==============================================================================
# ** Window Catalogue Command
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This window lists all available objects from the catalogue
#==============================================================================

class Window_CatalogueCommand < Window_Command
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (width, catalogue, *args)
    @catalogue = catalogue
    super (width, Array.new (@catalogue.visible_objects.size), 1)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def draw_item (window_index)
    # Get real object Index
    cat_index = @catalogue.visible_objects[window_index]
    enabled = @catalogue.enable? (cat_index)
    rect = item_rect(window_index)
    self.contents.clear_rect(rect)
    # Draw Icon
    draw_icon (@catalogue.object_icon (cat_index), rect.x, rect.y, enabled)
    rect.x += 28
    rect.width -= 28
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @catalogue.object_name (cat_index))
  end
end

#==============================================================================
# ** Scene Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - load_database; load_bt_database
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdnabalg_ctlge_base_lddata_5hv9 load_database
  def load_database (*args)
    mdnabalg_ctlge_base_lddata_5hv9 (*args) # Run Original Method
    $data_catalogues = Data_Catalogues.new
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Battle Test Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias algebramodern_catalogues_btdatabselod_3hb7 load_bt_database
  def load_bt_database (*args)
    algebramodern_catalogues_btdatabselod_3hb7 (*args) # Run Original Method
    $data_catalogues = Data_Catalogues.new
  end
end

#==============================================================================
# ** Scene Catalogue
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This scene handles processing for a catalogue scene
#==============================================================================

class Scene_Catalogue < Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #    catalogue_id : the ID of the catalogue to be opened
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize(catalogue_id)
    @catalogue = $data_catalogues[catalogue_id]
    # Get all included and visible objects
    for i in 0...@catalogue.objects.size
      if @catalogue.include? (i)
        @catalogue.visible_objects.push (i)
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start
    super
    wlh = Window_Base::WLH
    # Create Label Window
    height = (Graphics.height - 96 - 2*wlh) % wlh
    height += 32 + wlh
    create_label_window (0, 0, 224, height)
    # Create Command Window
    height = Graphics.height - @label_window.height - 32 - wlh
    create_command_window (0, @label_window.height, 224, height)
    create_card_window
    create_help_window (0, Graphics.height - 32 - wlh, Graphics.width, 32 + wlh)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Terminate Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def terminate
    super
    @catalogue.visible_objects.clear
    # Dispose all windows
    @label_window.dispose unless @label_window.nil? || @label_window.disposed?
    @command_window.dispose unless @command_window.nil? || @command_window.disposed?
    @card_window.dispose unless @card_window.nil? || @card_window.disposed?
    @help_window.dispose unless @help_window.nil? || @help_window.disposed?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    super
    if @command_window.active
      update_command
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Label Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_label_window (x, y, width, height)
    @label_window = Window_CatalogueLabel.new (x, y, width, height, @catalogue.name)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Command Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_command_window (x, y, width, height)
    @command_window = Window_CatalogueCommand.new (width, @catalogue)
    @command_window.x, @command_window.y = x, y
    @command_window.height = height
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Card Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_card_window
    # X, Y, Width, Height set in the window itself, which has to be altered.
    @card_window = @catalogue.card.new (@catalogue)
    @card_window.refresh (@catalogue.visible_objects[0])
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Help Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def create_help_window (x, y, width, height)
    @help_window = Window_Help.new
    @help_window.width, @help_window.height = width, height
    @help_window.create_contents
    @help_window.x, @help_window.y = x, y
    @help_window.set_text (@catalogue.object_help_text (@catalogue.visible_objects[0]))
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Command Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_command
    old_index = @command_window.index
    @command_window.update
    # Get catalogue index for selected object
    cat_index = @catalogue.visible_objects[@command_window.index]
    # If cursor has moved
    if old_index != @command_window.index
      # Update Card Window
      @card_window.refresh (cat_index)
      @help_window.set_text (@catalogue.object_help_text (cat_index))
    end
    if Input.trigger? (Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger? (Input::C)
      if @catalogue.c_disabled || !@catalogue.enable? (cat_index)
        Sound.play_buzzer
      else
        process_button_c
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Processing if Button C is pressed and valid
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def process_button_c
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def return_scene
    $scene = Scene_Map.new
  end
end
    Credit


    • modern algebra

    Addons

    Any addons in this section will work for any type of catalogue I create.


    Support


    For support, please post directly in this topic at RMRK.net. Don't PM me.

    Known Compatibility Issues

    No known compatibility problems.

    Author's Notes


    I made this script to serve as a base for my own catalogue scripts (planned to make an Items & Skills Catalogue, as well as a Monster Catalogue script and possibly a Character Catalogue Script), but it's free to use if anybody else would like to make their own catalogues. :)
    [/list]


    Creative Commons License
    This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
    « Last Edit: February 11, 2010, 09:45:31 PM by Modern Algebra »

    *
    Rep:
    Level 97
    2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
    New Addon that will work for any and all catalogues that use this script as a base:

    Show Encounter Ratio

    This addon will show a small encounters window next to the description window, showing how many of the catalogue's objects are visible with relation to the total number of objects in the catalogue. It has three ways of showing this; either:

        Ratio : Shows "x / y", where x is encountered number and y is total  
        Percentile: Shows "x%", where x is encountered number / total
        Raw: Shows "x", where x is encountered number

    Screenshot (taken from Item & Skills Catalogue):

    Code: [Select]
    #==============================================================================
    #    Show Encountered Ratio
    #      Addon for Catalogue Base
    #    Version: 1.1
    #    Author: modern algebra
    #    Date: October 6, 2009
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Description:
    #
    #    This is an addon for the Catalogue Base script, and it will show a small
    #   encounters window next to the description window, showing how many of the
    #   catalogue's objects are visible with relation to the total number of
    #   objects in the catalogue. It has three ways of showing this; either:
    #
    #      Ratio : Shows "x / y", where x is encountered number and y is total
    #      Percentile: Shows "x%", where x is encountered number / total
    #      Raw: Shows "x", where x is encountered number
    #
    #   You can set which of these you want on line 39. You can also set which
    #  types of catalogues you want to show encounter ratio for on line 42
    #==============================================================================

    #==============================================================================
    # ** Catalogue_Base
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    new method - show_ratio?
    #==============================================================================

    class Catalogue_Base
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * CONSTANTS
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # Draw Ratio Type discerns the form which the encounter ration takes.
      #  0 => Ratio. Shows "x / y", where x is encountered number and y is total
      #  1 => Percentile. Shows "x%", where x is encountered number / total
      #  2 => Raw. Shows "x", where x is encountered number
      DRAW_RATIO_TYPE = 1
      # In this array, put the types of catalogues that will show the ratio. If
      # Catalogue_Base is included, it will show up for all catalogues.
      RATIOSHOW_CATALOGUE_TYPES = [Catalogue_Base]
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Show Ratio Check
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def show_ratio?
        RATIOSHOW_CATALOGUE_TYPES.each { |c| return true if self.is_a? (c) }
        return false
      end
    end

    #==============================================================================
    # ** Window Encountered Ratio
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  This window shows how many monsters in this catalogue have been encountered
    #==============================================================================

    class Window_EncounterRatio < Window_Base
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Object Initialization
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      def initialize (catalogue)
        super (Graphics.width - 128, Graphics.height - WLH - 32, 128, 32 + WLH)
        encountered, total = catalogue.visible_objects.size, catalogue.objects.size
        draw_type = Catalogue_Base::DRAW_RATIO_TYPE
        if draw_type == 0 # Draw Ratio
          tw = contents.text_size ("#{encountered}/#{total}").width
          if tw < contents.width # If room, draw both encountered and total
            contents.font.color = encountered == total ? system_color : normal_color
            x = (contents.width - tw) / 2
            contents.draw_text (x, 0, tw, WLH, encountered.to_s)
            contents.font.color = system_color
            contents.draw_text (x, 0, tw, WLH, "/" + total.to_s, 2)
          else # Only draw encountered
            draw_type = 2
          end
        end
        if draw_type == 1
          percent = total > 0 ? (encountered*100) / total : 100
          contents.font.color = encountered == total ? system_color : normal_color
          contents.draw_text (0, 0, contents.width, WLH, percent.to_s + "%", 1)
        end
        if draw_type == 2 # Only Draw Encountered
          contents.font.color = encountered == total ? system_color : normal_color
          contents.draw_text (0, 0, contents.width, WLH, encountered.to_s, 1)
        end
      end
    end

    #==============================================================================
    # ** Scene Catalogue
    #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    #  Summary of Changes:
    #    new window - Window_EncounterRatio
    #    aliased methods - create_help_window, terminate
    #==============================================================================

    class Scene_Catalogue
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Start
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias mdrnalbra_catencountrto_adon_crthlp_5hz2 create_help_window
      def create_help_window (x, y, width, *args)
        width -= 128 if @catalogue.show_ratio?
        mdrnalbra_catencountrto_adon_crthlp_5hz2 (x, y, width, *args) # Run Original Method
        @encounter_window = Window_EncounterRatio.new (@catalogue) if @catalogue.show_ratio?
      end
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # * Termination Processing
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      alias modalgba_encntrratio_trmnate_1kv3 terminate
      def terminate (*args)
        modalgba_encntrratio_trmnate_1kv3 (*args) # Run Original Method
        @encounter_window.dispose unless @encounter_window.nil? || @encounter_window.disposed?
      end
    end
    « Last Edit: October 06, 2009, 01:51:32 PM by modern algebra »

    *
    Rep:
    Level 97
    2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
    I updated the script for an easier way to modify the size of windows in the scene, making for the possibility of a much more dynamic design for the purpose of addons and special scripts.

    It still works with all currently existing catalogue scripts.

    **
    Rep:
    Level 82
     Cool Script!! :?:terra::?

    **
    Rep: +0/-0Level 76
    RMRK Junior
    Whenever i copy the script from the thing into rpg maker vx it always shows up on one line instead of like 127 lines is there a way to fix this or will i have to just sort it out on my own.

    *****
    Rep:
    Level 84
    This text is way too personal.
    Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
    SMF 2.0 codeboxes are not compatible with Internet Explorer.

    **
    Rep: +0/-0Level 68
    RMRK Junior
    Excusme ,i got a stack in line 256 ,System Stack Error ,how can i fix that ?

    ***
    Rep:
    Level 69
    RMRK Junior
    Can you tell me how to make it look like this?



    The window should be called by talking to an NPC, the names on the left should be selectable,
    and the biography should be formatted nicely.  I saw a biography script like this but it only worked for actors.  Ideally I would like it to be user friendly where I can plug in information, and the names should only be displayed after a certain variable is reached such as

    if $game.variable[16] = 32 then display these names:
    Ralph
    King Greyhem
    Hiro

    if $game.variable[16] = 33 then display these names:
    Ralph
    King Greyhem
    Hiro
    Kefka

    if $game.variable[16] = 32 then display these names:
    Ralph
    King Greyhem
    Hiro
    Ulrika
    Kefka

    and so on.. I would appreciate if you could help so much, Id even pay ya. I really want this. Thanks for reading.

    ***
    Rep:
    Level 69
    RMRK Junior
    If you can do this I would appreciate it, I can pay you if you'd like. :D