12-11-2005, 01:00 PM
(This post was last modified: 07-22-2017, 04:58 AM by DerVVulfman.)
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.
No support is given. If you are the owner of the thread, please contact administration.
Replace Window_Command with this script-
* Window_Command
Code:
#=========================================================
# * VH_Window_Command
#---------------------------------------------------------
# Make Horizontal or Vertical Menus with or without icons
#---------------------------------------------------------
# Version 3
# 12.15.05
#---------------------------------------------------------
# Tsunokiette
# * Give Credit *
#=========================================================
#*********************************
# * SDK Log Script
#*********************************
SDK.log('Tsunokiette', 'VH_Window_Command', 2, '12.12.05') unless SDK.defined? == false
#*********************************
# Window_Command Begins
#_________________________________
# Sub-Class of (Window_Selectable)
#*********************************
class VH_Window_Command < Window_Selectable
#------------------------------------------------------------------------
# Initialization
#________________________________________________________________________
# type = what kind of menu you want (set to 'vertical' or 'horizontal')
# commands = text commands
# icons = icons to go with commands (leave empty if you don't want icons)
#------------------------------------------------------------------------
def initialize(type = 'vertical', commands = [], icons = nil)
case type
when 'vertical'
super(0, 0, 182, commands.size * 32 + 32)
when 'horizontal'
super(0, 0, 640, 64)
end
unless icons.nil?
@icons = []
for i in 0...icons.size
@icons[i] = RPG::Cache.icon(icons[i])
end
end
@item_max = commands.size
@column_max = commands.size unless type != 'horizontal'
@commands = commands
@type = type
self.contents = Bitmap.new(width - 32, height - 32)
font_properties
refresh
self.index = 0
end
#------------------------
# Set the Font Properties
#------------------------
def font_properties
self.contents.font.name = 'Times New Roman'
self.contents.font.size = 22
end
#------------------------------
# Refresh the Window's Contents
#------------------------------
def refresh
self.contents.clear
case @type
when 'vertical'
if @icons.nil?
for i in 0...@item_max
draw_v(i, normal_color)
end
else
for i in 0...@item_max
draw_v_icon(i, normal_color)
end
end
when 'horizontal'
if @icons.nil?
for i in 0...@item_max
draw_h(i, normal_color)
end
else
for i in 0...@item_max
draw_h_icon(i, normal_color)
end
end
end
end
#------------------------------------
# Draw Contents Vertically With Icons
#____________________________________
# Index = Command Location
# Color = Text Color
#------------------------------------
def draw_v_icon(index, color)
self.contents.font.color = color
x = 24
y = 32 * index
w = self.contents.width - 24
h = 32
ix = 0
iy = ((32 * index) + 4)
rect = Rect.new(x, y, w, h)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
@icon_sprite[index] = Sprite.new
@icon_sprite[index].bitmap = @icons[index]
@icon_sprite[index].x = ix
@icon_sprite[index].y = iy
end
#---------------------------------------
# Draw Contents Vertically Without Icons
#_______________________________________
# Index = Command Location
# Color = Text Color
#---------------------------------------
def draw_v(index, color)
self.contents.font.color = color
x = 0
y = 32 * index
w = self.contents.width
h = 32
rect = Rect.new(x,y,w,h)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------
# Draw Contents Horizontally With Icons
#______________________________________
# Index = Command Location
# Color = Text Color
#--------------------------------------
def draw_h_icon(index, color)
self.contents.font.color = color
x = (((640 / @commands.size) * @index) + 24)
y = 0
w = ((640 / @commands.size) - 24)
h = 32
ix = ((640 / @commands.size) * @index)
iy = 4
rect = Rect.new(x,y,w,h)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
@icon_sprite[index] = Sprite.new
@icon_sprite[index].bitmap = @icons[index]
@icon_sprite[index].x = ix
@icon_sprite[index].y = iy
end
#-----------------------------------------
# Draw contents Horizontally Without Icons
#_________________________________________
# Index = Command Location
# Color = Text Color
#-----------------------------------------
def draw_h(index, color)
self.contents.font.color = color
x = ((640 / @commands.size) * @index)
y = 0
w = 640 / @commands.size
h = 32
rect = Rect.new(x,y,w,h)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#-------------------------
# Disable Command
#_________________________
# Index = Command Location
#-------------------------
def disable_item(index)
case @type
when 'vertical'
if @icons.nil?
draw_v(index, disabled_color)
else
draw_v_icon(index, disabled_color)
end
when 'horizontal'
if @icons.nil?
draw_h(index, disabled_color)
else
draw_h_icon(index, disabled_color)
end
end
end
#--------------
# Update Cursor
#--------------
def update_cursor_rect
unless @index >= 0
self.cursor_rect.empty unless @index >= 0
return
end
case @type
when 'vertical'
x = 0
y = @index * 32
w = self.contents.width
h = 32
self.cursor_rect.set(x, y, w, h)
when 'horizontal'
x = ((640 / @commands.size) * @index)
y = 0
w = 640 / @commands.size
h = 32
self.cursor_rect.set(x,y,w,h)
end
end
#--------------
# Alias Dispose
#--------------
alias :tsuno_UpdatedWindowCommand_VHWindowCommand_dispose :dispose
def dispose
unless @icons.nil?
for i in 0...@icons.size
@icon_sprite[i].dispose
end
end
tsuno_UpdatedWindowCommand_VHWindowCommand_dispose
end
end
#*********************************
# Window_Command Ends
#*********************************
Vertical Menu With Icons
Code:
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
i1 = 'icon name'
i2 = 'icon name'
i3 = 'icon name'
@Menu = VH_Window_Command.new('vertical', [c1,c2,c3], [i1,i2,i3])
Vertical Menu Without Icons
Code:
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
@Menu = VH_Window_Command.new('vertical', [c1,c2,c3])
Horizontal Menu With Icons
Code:
[code]c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
i1 = 'icon name'
i2 = 'icon name'
i3 = 'icon name'
@Menu = VH_Window_Command.new('horizontal', [c1,c2,c3], [i1,i2,i3])
Horizontal Menu Without Icons
Code:
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
@Menu = VH_Window_Command.new('horizontal', [c1,c2,c3])