This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Introduction
It allows for highlighted options to scroll to the left, and icons next to selections.
Features
doesn't overwrite other menu command scripts
easily implemented
Demo
Not needed because it's so simple.
Script
Indenting Icon Commands
Code:
#==============================================================================
# ** Indenting Icon Commands
#----------------------------------------------------------------------------------------------------
# squall (squall@rmxp.ch)-original script (Edited by MasterMind5823)
# Version: 1
# Date: 24.06.2006
# Description:
# This command window is a merge of two scripts, the icon command script
# (author unknown), and squall's Window_Command script. It allows for
# highlighted options to scroll to the left, and icons next to selections.
#==============================================================================
class Window_Command2 < Window_Selectable
#--------------------------------------------------------------------------
# * Initialization
# width : the width in pixels
# commands : array with the commands
# icons : array with the icons of each command
#--------------------------------------------------------------------------
def initialize(width, commands, icons = [])
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
@icons = icons
@sprites = []
for i in 0...@item_max
@sprites[i] = Sprite.new
@sprites[i].x = self.x + 16
@sprites[i].y = self.y + 16 + 32 * i
@sprites[i].z = 100
@sprites[i].bitmap = Bitmap.new(self.width - 32, 32)
@sprites[i].bitmap.draw_text(32, 0, self.width - 32, 32, @commands[i])
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
for i in 0...@sprites.size
sprite = @sprites[i]
x = i == @index ? self.x + 16 + 32 : self.x + 16
if sprite.x < x
n = (x - sprite.x) / 3
n = 1 if n == 0
sprite.x += n
elsif sprite.x > x
n = (sprite.x - x) / 3
n = 1 if n == 0
sprite.x -= n
end
end
end
#--------------------------------------------------------------------------
# * X =(X)
#--------------------------------------------------------------------------
def x=(x)
super
return if @sprites == nil
for sprite in @sprites
sprite.x = self.x + 16
end
end
#--------------------------------------------------------------------------
# * Y =(Y)
#--------------------------------------------------------------------------
def y=(y)
super
return if @sprites == nil
for i in 0...@sprites.size
@sprites[i].y = self.y + 16 + 32 * i
end
end
#--------------------------------------------------------------------------
# * Visible = (Visible)
#--------------------------------------------------------------------------
def visible=(visible)
super
return if @sprites == nil
for sprite in @sprites
sprite.visible = visible
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
super
return if @sprites == nil
for sprite in @sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# * Draw text and icon
# index : number of the command
# color : color of the text
#--------------------------------------------------------------------------
def draw_item(index, color)
clean = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(clean, Color.new(0, 0, 0, 0))
rect = Rect.new(32, 32 * index, self.contents.width - 8 , 32)
opacity = color == normal_color ? 192 : 128
bitmap = RPG::Cache.icon(@icons[index])
self.contents.blt(4, (32 * index)+4, bitmap ,Rect.new(0, 0, 24, 24),opacity)
sprite = @sprites[index]
sprite.bitmap.clear
sprite.bitmap.font.color = color
sprite.bitmap.draw_text(32, 0, self.width - 32, 32, @commands[index])
end
#--------------------------------------------------------------------------
# * Make command disabled
# index : number of the command
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
Instructions
Place above Main. Then, when you create your command windows, use the code: