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.
Alternative Window Commands

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Alternative Window_Command Scripts
Version: 1.0
Author: modern algebra
Date: November 2, 2007

Version History


  • Version 1.0 - Original Script: Window_HorizontalCommand and Window_ScrollCommand


Description


These scripts add alternatives to the standard Window_Command. Window_HorizontalCommand allows you to easily set a command window which has options extending from left to right, rather then up and down. Window_ScrollCommand allows you to have a command window with a scroll bar if the options extend beyond the space in which you have them.

Features

  • Nice, different ways to display a command window.
  • Allows for the ability to place a command window somewhere with limited area available to you
  • Allows for an easy way to customize your menus

Screenshots




Instructions

Use these scripts pretty much the same way you would use a command window. You set up the horizontal command window the exact same way you would a regular command window. With Window_ScrollCommand, you should specify a height as well, so like this:

Code: [Select]
@command_window = Window_ScrollCommand.new (<width>, <commands array>, <height>)

Script


Window_HorizontalCommand:

Code: [Select]
#==============================================================================
# ** Window_HorizontalCommand
#------------------------------------------------------------------------------
#  This window deals with general command choices, displayed horizontally
#==============================================================================

class Window_HorizontalCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize (width, commands)
    @average = (width - 32) / commands.size
    super (width, commands)
    self.height = 64
    self.contents = Bitmap.new (width - 32, height - 32)
    @column_max = commands.size
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(index*@average, 0, @average - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rect
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(index*@average, 0, @average - 10, 32)
    end
  end
end

Window_ScrollCommand:

Code: [Select]
#----------------------------------------------------------------------------
# ** Window_ScrollCommand
#----------------------------------------------------------------------------
#  This is a subclass of Window_Command, and it will just display a scroll
#  bar on the right if it so happens that the commands extend beyond the
#  max height (which is an additional argument)
#----------------------------------------------------------------------------

class Window_ScrollCommand < Window_Command
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands : command text string array
  #--------------------------------------------------------------------------
  def initialize(width, commands, height = 480)
    # Compute window height from command quantity
    super(width, commands)
    self.height = height
    @scroll_bar = Bitmap.new (7, self.height - 32)
    # Draw the arrows
    for i in 0...4
      # Top Arrow
      @scroll_bar.fill_rect (i, 3 - i, 7 - 2*i, 1, normal_color)
      # Bottom Arrow
      @scroll_bar.fill_rect (3 - i, @scroll_bar.height - 1 - i, 1 + 2*i, 1, normal_color)
    end
    # Draw the sides
    @scroll_bar.fill_rect (0, 4, 1, @scroll_bar.height - 8, normal_color)
    @scroll_bar.fill_rect (6, 4, 1, @scroll_bar.height - 8, normal_color)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def update_cursor_rect
    super ()
    # If there are more commands then room, and the bitmap has moved
    if (self.height - 32) < @commands.size*32 && @last_top_row != self.top_row
      @last_top_row = self.top_row
      # Erase old scroll bar
      self.contents.fill_rect (self.contents.width - 7, 0, 7, self.contents.height, Color.new (0, 0, 0, 0))
      src_rect = Rect.new (0, 0, 7, @scroll_bar.height)
      # Draw the basic bar
      self.contents.blt (self.contents.width - 7, self.top_row*32, @scroll_bar, src_rect)
      # Scale the size of the bar appropriately
      scale_ratio = ((self.height - 40).to_f) / ((@commands.size*32).to_f)
      # Get the y for the scrolling bar
      y = 4 + (self.top_row*32) + ((self.top_row*32)*scale_ratio).to_i
      # Get the height of the bar
      height = ((self.height - 32)*scale_ratio).to_i
      # Draw the bar
      self.contents.fill_rect (self.contents.width - 6, y, 5, height, system_color)
    end
    self.cursor_rect.width -= 8
  end
end

Credit


  • modern algebra

Support


If there are any bugs, or if you have an idea for another variation on Window_Command, please just ask me within this topic. I will provide support at bothe RMRK and RMRevolution.

Author's Notes

Basically, I just needed a few variations of Window_Command for a couple scripts I was writing, and so these things came up. I figured they might be helpful to people and so I shared them. It's a boring story.