Advanced Command Window
Version: 2.11
Introduction
This is both a scripting tool and a script. It's a scripting because it
will allow scripters to manage his command windows easily, and is a script
because will allow non-scripters to easily manage his menus.
Features
# 1. Shows icons in command windows
# 2. Changes text alignment in command windows
# 3. Allows multiples columns in command windows
# 4. Allows to use arrows in selectable windows or removing the cursor rect
# 5. Allows adding items to default menu system or changing order
Screenshots
Featuring my CMS, Trickster's RTAB, a multi-layer title screen with Naramura battlers and Inquisitor tileset (at background).
http://img66.imageshack.us/img66/1913/cmdwin01vo0.th.png[/IMG] http://img401.imageshack.us/img401/2842/cmdwin02eg3.th.png[/IMG] http://img338.imageshack.us/img338/6582/cmdwin03eh4.th.png[/IMG] http://img398.imageshack.us/img398/184/cmdwin04uq0.th.png[/IMG]
Script
Instructions
(these instructions are bad, I'll rewrite them later)
When initializing a command window, follow the syntax
Where width is the window width,
commands is an array of strings, bitmaps or Data_Command objects,
column_max (optional) is the window number of columns (default 1).
When you add strings to the commands array, nothing different happens, but when you add a bitmap it will draw the bitmap and not the text. You can use Data_Command objects to store items text, icons and actions. You initialize a Data_Command object with the syntax
Where name is the item text,
icon_name (optional) is the icon filename,
call_proc is a Proc to be called when the item is selected (pressing Input::C),
enabled_proc (optional) is a Proc that returns if the item is enabled,
help (optional) is the text to show in help windows when the item is selected.
Compatibility / Requirements
Requires the SDK 2.2 Part I, and SephirothSpawn Window_Selectable (below)
Credits and Thanks
I don't need credits.
Easy Plug-in
You can add the following script to add icons to your game menu and battle, and get a better look to your title screen. It requires SDK part IV
Version: 2.11
Introduction
This is both a scripting tool and a script. It's a scripting because it
will allow scripters to manage his command windows easily, and is a script
because will allow non-scripters to easily manage his menus.
Features
# 1. Shows icons in command windows
# 2. Changes text alignment in command windows
# 3. Allows multiples columns in command windows
# 4. Allows to use arrows in selectable windows or removing the cursor rect
# 5. Allows adding items to default menu system or changing order
Screenshots
Featuring my CMS, Trickster's RTAB, a multi-layer title screen with Naramura battlers and Inquisitor tileset (at background).
http://img66.imageshack.us/img66/1913/cmdwin01vo0.th.png[/IMG] http://img401.imageshack.us/img401/2842/cmdwin02eg3.th.png[/IMG] http://img338.imageshack.us/img338/6582/cmdwin03eh4.th.png[/IMG] http://img398.imageshack.us/img398/184/cmdwin04uq0.th.png[/IMG]
Script
script
Spoiler
#============================================================================
# ** Advanced Command Window
#----------------------------------------------------------------------------
# Tibuda
# 2.11
# 04.11.2007
#----------------------------------------------------------------------------
# * Version History :
# 01.17.2007 - Version 1.00 - Plug'n'Play Menu
# 04.05.2007 - Version 2.00 - Advanced Command Window
# - Added: Icons, text alignment, cursor arrow, custom fonts
# 04.07.2007 - Version 2.10
# - Remove: Window sprites dependancy
# - Added: Custom icon alignment
# 04.11.2007 - Version 2.11
# - Bugfix: Stupid bug I've forgotten when removing window sprites dependancy
# - Changed: Increased compatibility with SDK part IV
#============================================================================
# This is both a scripting tool and a script. It's a scripting because it
# will allow scripters to manage his command windows easily, and is a script
# because will allow non-scripters to easily manage his menus.
#----------------------------------------------------------------------------
# * Features
# 1. Shows icons in command windows
# 2. Changes text alignment in command windows
# 3. Allows multiples columns in command windows
# 4. Allows to use arrows in selectable windows or removing the cursor rect
# 5. Allows adding items to default menu system or changing order
#============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Adv Command Window', 'tibuda', 2.10, '04.07.2007')
#--------------------------------------------------------------------------
# SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2, [1])
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Adv Command Window')
#==========================================================================
class Data_Command
#--------------------------------------------------------------------------
attr_accessor :call_proc
attr_accessor :enabled_proc
attr_accessor :help
attr_accessor :icon_name
attr_accessor :name
#--------------------------------------------------------------------------
def initialize(name, icon_name = '', call_proc = nil, enabled_proc = nil, help = '')
@call_proc = call_proc
@enabled_proc = enabled_proc
@help = help
@icon_name = icon_name
@name = name
end
#--------------------------------------------------------------------------
def enabled?
return true if @enabled_proc.nil?
case @enabled_proc
when Proc
return @enabled_proc.call
when String
return eval(@enabled_proc)
end
return @enabled_proc
end
#--------------------------------------------------------------------------
def check_enabled
unless enabled?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return false
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
return true
end
#--------------------------------------------------------------------------
def call(*args)
return unless check_enabled
return if @call_proc.nil?
case @call_proc
when Proc
return @call_proc.call(*args)
when String
return eval(@call_proc)
end
return nil
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Base
#--------------------------------------------------------------------------
attr_accessor :normal_font, :disabled_font, :selected_font
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_base_init, :initialize
def initialize(*args)
tibuda_cmdwin_win_base_init(*args)
@normal_font = Font.new
@normal_font.color = normal_color
@disabled_font = Font.new
@disabled_font.color = disabled_color
@selected_font = Font.new
@selected_font.color = normal_color
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Selectable
#--------------------------------------------------------------------------
attr_reader :column_max
attr_accessor :show_arrow
attr_accessor :show_cursor_rect
attr_accessor :arrow_align
attr_reader :text_align
attr_reader :icon_align
attr_reader :icon_opacity
#--------------------------------------------------------------------------
def text_align=(value)
@text_align = value
refresh
end
#--------------------------------------------------------------------------
def icon_align=(value)
@icon_align = value
refresh
end
#--------------------------------------------------------------------------
def icon_opacity=(value)
@icon_opacity = value
refresh
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_init, :initialize
def initialize(*args)
tibuda_cmdwin_win_sel_init(*args)
@show_arrow = false
@show_cursor_rect = true
@arrow_align = 1
@arrow = Arrow_Base.new(self.viewport)
@arrow.visible = @show_arrow
@icon_opacity = 255
@icon_align = 0
@text_align = self.is_a?(Window_HorizCommand) ? 1 : 0
@disabled_commands = []
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_update_cursor_rect, :update_cursor_rect
def update_cursor_rect
tibuda_cmdwin_win_sel_update_cursor_rect
@arrow.y = @arrow_align == 1 ? self.cursor_rect.y : 0
@arrow.y += self.y + 96 + 16
case @arrow_align
when 0
@arrow.x = self.cursor_rect.x
when 1
@arrow.x = self.cursor_rect.x + self.cursor_rect.width / 2
when 2
@arrow.x = self.cursor_rect.x + self.cursor_rect.width
end
@arrow.x += self.x - self.ox + 16
@arrow.visible = @show_arrow && self.active
self.cursor_rect.empty unless @show_cursor_rect
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_update, :update
def update
tibuda_cmdwin_win_sel_update
@arrow.update if @arrow.visible
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_dispose, :dispose
def dispose
tibuda_cmdwin_win_sel_dispose
@arrow.dispose
end
#--------------------------------------------------------------------------
def contents_opacity=(value)
super(value)
@arrow.opacity = value
end
#--------------------------------------------------------------------------
end
#==========================================================================
module TibudaWinCommand
#--------------------------------------------------------------------------
def draw_command_item(index, enabled = nil)
enabled = true if enabled == nil
if self.is_a?(Window_Command)
rect = Rect.new(index % @column_max * (self.width / @column_max),
index / @column_max * oh,
self.width / @column_max - 32,
oh)
elsif self.is_a?(Window_HorizCommand)
rect = Rect.new(index * @c_spacing, 0, @c_spacing, self.height - 32)
end
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
item = @commands[index]
case item
when String
text = item
icon = ''
align = 0
when Bitmap
return
when Data_Command
text = item.name
icon = item.icon_name
enabled = item.enabled?
end
opacity = (enabled && @icon_align == 0) ? @icon_opacity : @icon_opacity/2
x = 4
unless icon == ''
icon = RPG::Cache.icon(icon)
unless icon.nil?
case @icon_align
when 0
icon_x = rect.x + 4
when 1
icon_x = rect.x + (rect.width - 32) / 2
when 2
icon_x = rect.x + rect.width - 32
end
self.contents.blt(icon_x, rect.y + 4, icon, Rect.new(0, 0, 24, 24), opacity)
if @icon_align == 0 && opacity == 255
rect.x += 28
rect.width -= 28
end
end
end
unless @text == ''
rect.x += 4
rect.width -= 8
if !enabled
self.contents.font = @disabled_font
elsif self.index == index
self.contents.font = @selected_font
else
self.contents.font = @normal_font
end
self.contents.draw_text(rect, text, @text_align)
end
end
#--------------------------------------------------------------------------
def call(*args)
if @commands[@index].is_a?(Data_Command)
@commands[@index].call(*args)
end
end
#--------------------------------------------------------------------------
def update_help
return unless @help_window.is_a?(Window_Help)
if @commands[@index].is_a?(Data_Command)
@help_window.set_text(@commands[@index].help)
elsif @commands[@index].is_a?(String)
@help_window.set_text(@commands[@index])
else
@help_window.set_text('')
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Command
#--------------------------------------------------------------------------
include TibudaWinCommand
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :initialize)
def initialize(width, commands, column_max = 1)
super(0, 0, width, 32 * commands.size / column_max + 32)
@item_max = commands.size
@commands = commands
@column_max = column_max
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :refresh)
def refresh
if self.contents.height != @commands.size * oh / column_max
self.contents.dispose
@item_max = @commands.size
self.contents = Bitmap.new(self.width - 32, @item_max * oh / column_max)
else
self.contents.clear
end
for i in 0...@item_max
draw_item(i, nil)
end
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :update_cursor_rect)
def update_cursor_rect
super
draw_item(self.index > 0 ? self.index-1 : @item_max-1)
draw_item(self.index < @item_max-1 ? self.index+1 : 0)
draw_item(self.index)
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :draw_item)
def draw_item(index, color = nil)
draw_command_item(index)
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :disable_item)
def disable_item(index)
draw_command_item(index, false)
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_HorizCommand
#--------------------------------------------------------------------------
include TibudaWinCommand
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_HorizCommand, :refresh)
def refresh
if self.contents.width != @commands.size * @c_spacing
self.contents.dispose
@item_max = @commands.size
self.contents = Bitmap.new(@item_max * @c_spacing, height - 32)
else
self.contents.clear
end
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_horiz_update_cursor_rect, :update_cursor_rect
def update_cursor_rect
tibuda_cmdwin_win_horiz_update_cursor_rect
draw_item(self.index > 0 ? self.index-1 : @item_max-1)
draw_item(self.index < @item_max-1 ? self.index+1 : 0)
draw_item(self.index)
@arrow.y = @arrow_align == 1 ? self.cursor_rect.y : 0
@arrow.y += self.y + 96 + 16
case @arrow_align
when 0
@arrow.x = self.cursor_rect.x
when 1
@arrow.x = self.cursor_rect.x + self.cursor_rect.width / 2
when 2
@arrow.x = self.cursor_rect.x + self.cursor_rect.width
end
@arrow.x += self.x - self.ox + 16
@arrow.visible = @show_arrow && self.active
self.cursor_rect.empty unless @show_cursor_rect
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_HorizCommand, :draw_item)
def draw_item(index, color = nil)
draw_command_item(index)
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_HorizCommand, :disable_item)
def disable_item(index)
draw_command_item(index, false)
end
#--------------------------------------------------------------------------
end
#==========================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------
# ** Advanced Command Window
#----------------------------------------------------------------------------
# Tibuda
# 2.11
# 04.11.2007
#----------------------------------------------------------------------------
# * Version History :
# 01.17.2007 - Version 1.00 - Plug'n'Play Menu
# 04.05.2007 - Version 2.00 - Advanced Command Window
# - Added: Icons, text alignment, cursor arrow, custom fonts
# 04.07.2007 - Version 2.10
# - Remove: Window sprites dependancy
# - Added: Custom icon alignment
# 04.11.2007 - Version 2.11
# - Bugfix: Stupid bug I've forgotten when removing window sprites dependancy
# - Changed: Increased compatibility with SDK part IV
#============================================================================
# This is both a scripting tool and a script. It's a scripting because it
# will allow scripters to manage his command windows easily, and is a script
# because will allow non-scripters to easily manage his menus.
#----------------------------------------------------------------------------
# * Features
# 1. Shows icons in command windows
# 2. Changes text alignment in command windows
# 3. Allows multiples columns in command windows
# 4. Allows to use arrows in selectable windows or removing the cursor rect
# 5. Allows adding items to default menu system or changing order
#============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Adv Command Window', 'tibuda', 2.10, '04.07.2007')
#--------------------------------------------------------------------------
# SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2, [1])
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Adv Command Window')
#==========================================================================
class Data_Command
#--------------------------------------------------------------------------
attr_accessor :call_proc
attr_accessor :enabled_proc
attr_accessor :help
attr_accessor :icon_name
attr_accessor :name
#--------------------------------------------------------------------------
def initialize(name, icon_name = '', call_proc = nil, enabled_proc = nil, help = '')
@call_proc = call_proc
@enabled_proc = enabled_proc
@help = help
@icon_name = icon_name
@name = name
end
#--------------------------------------------------------------------------
def enabled?
return true if @enabled_proc.nil?
case @enabled_proc
when Proc
return @enabled_proc.call
when String
return eval(@enabled_proc)
end
return @enabled_proc
end
#--------------------------------------------------------------------------
def check_enabled
unless enabled?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return false
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
return true
end
#--------------------------------------------------------------------------
def call(*args)
return unless check_enabled
return if @call_proc.nil?
case @call_proc
when Proc
return @call_proc.call(*args)
when String
return eval(@call_proc)
end
return nil
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Base
#--------------------------------------------------------------------------
attr_accessor :normal_font, :disabled_font, :selected_font
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_base_init, :initialize
def initialize(*args)
tibuda_cmdwin_win_base_init(*args)
@normal_font = Font.new
@normal_font.color = normal_color
@disabled_font = Font.new
@disabled_font.color = disabled_color
@selected_font = Font.new
@selected_font.color = normal_color
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Selectable
#--------------------------------------------------------------------------
attr_reader :column_max
attr_accessor :show_arrow
attr_accessor :show_cursor_rect
attr_accessor :arrow_align
attr_reader :text_align
attr_reader :icon_align
attr_reader :icon_opacity
#--------------------------------------------------------------------------
def text_align=(value)
@text_align = value
refresh
end
#--------------------------------------------------------------------------
def icon_align=(value)
@icon_align = value
refresh
end
#--------------------------------------------------------------------------
def icon_opacity=(value)
@icon_opacity = value
refresh
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_init, :initialize
def initialize(*args)
tibuda_cmdwin_win_sel_init(*args)
@show_arrow = false
@show_cursor_rect = true
@arrow_align = 1
@arrow = Arrow_Base.new(self.viewport)
@arrow.visible = @show_arrow
@icon_opacity = 255
@icon_align = 0
@text_align = self.is_a?(Window_HorizCommand) ? 1 : 0
@disabled_commands = []
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_update_cursor_rect, :update_cursor_rect
def update_cursor_rect
tibuda_cmdwin_win_sel_update_cursor_rect
@arrow.y = @arrow_align == 1 ? self.cursor_rect.y : 0
@arrow.y += self.y + 96 + 16
case @arrow_align
when 0
@arrow.x = self.cursor_rect.x
when 1
@arrow.x = self.cursor_rect.x + self.cursor_rect.width / 2
when 2
@arrow.x = self.cursor_rect.x + self.cursor_rect.width
end
@arrow.x += self.x - self.ox + 16
@arrow.visible = @show_arrow && self.active
self.cursor_rect.empty unless @show_cursor_rect
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_update, :update
def update
tibuda_cmdwin_win_sel_update
@arrow.update if @arrow.visible
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_sel_dispose, :dispose
def dispose
tibuda_cmdwin_win_sel_dispose
@arrow.dispose
end
#--------------------------------------------------------------------------
def contents_opacity=(value)
super(value)
@arrow.opacity = value
end
#--------------------------------------------------------------------------
end
#==========================================================================
module TibudaWinCommand
#--------------------------------------------------------------------------
def draw_command_item(index, enabled = nil)
enabled = true if enabled == nil
if self.is_a?(Window_Command)
rect = Rect.new(index % @column_max * (self.width / @column_max),
index / @column_max * oh,
self.width / @column_max - 32,
oh)
elsif self.is_a?(Window_HorizCommand)
rect = Rect.new(index * @c_spacing, 0, @c_spacing, self.height - 32)
end
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
item = @commands[index]
case item
when String
text = item
icon = ''
align = 0
when Bitmap
return
when Data_Command
text = item.name
icon = item.icon_name
enabled = item.enabled?
end
opacity = (enabled && @icon_align == 0) ? @icon_opacity : @icon_opacity/2
x = 4
unless icon == ''
icon = RPG::Cache.icon(icon)
unless icon.nil?
case @icon_align
when 0
icon_x = rect.x + 4
when 1
icon_x = rect.x + (rect.width - 32) / 2
when 2
icon_x = rect.x + rect.width - 32
end
self.contents.blt(icon_x, rect.y + 4, icon, Rect.new(0, 0, 24, 24), opacity)
if @icon_align == 0 && opacity == 255
rect.x += 28
rect.width -= 28
end
end
end
unless @text == ''
rect.x += 4
rect.width -= 8
if !enabled
self.contents.font = @disabled_font
elsif self.index == index
self.contents.font = @selected_font
else
self.contents.font = @normal_font
end
self.contents.draw_text(rect, text, @text_align)
end
end
#--------------------------------------------------------------------------
def call(*args)
if @commands[@index].is_a?(Data_Command)
@commands[@index].call(*args)
end
end
#--------------------------------------------------------------------------
def update_help
return unless @help_window.is_a?(Window_Help)
if @commands[@index].is_a?(Data_Command)
@help_window.set_text(@commands[@index].help)
elsif @commands[@index].is_a?(String)
@help_window.set_text(@commands[@index])
else
@help_window.set_text('')
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Command
#--------------------------------------------------------------------------
include TibudaWinCommand
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :initialize)
def initialize(width, commands, column_max = 1)
super(0, 0, width, 32 * commands.size / column_max + 32)
@item_max = commands.size
@commands = commands
@column_max = column_max
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :refresh)
def refresh
if self.contents.height != @commands.size * oh / column_max
self.contents.dispose
@item_max = @commands.size
self.contents = Bitmap.new(self.width - 32, @item_max * oh / column_max)
else
self.contents.clear
end
for i in 0...@item_max
draw_item(i, nil)
end
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :update_cursor_rect)
def update_cursor_rect
super
draw_item(self.index > 0 ? self.index-1 : @item_max-1)
draw_item(self.index < @item_max-1 ? self.index+1 : 0)
draw_item(self.index)
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :draw_item)
def draw_item(index, color = nil)
draw_command_item(index)
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_Command, :disable_item)
def disable_item(index)
draw_command_item(index, false)
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_HorizCommand
#--------------------------------------------------------------------------
include TibudaWinCommand
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_HorizCommand, :refresh)
def refresh
if self.contents.width != @commands.size * @c_spacing
self.contents.dispose
@item_max = @commands.size
self.contents = Bitmap.new(@item_max * @c_spacing, height - 32)
else
self.contents.clear
end
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_win_horiz_update_cursor_rect, :update_cursor_rect
def update_cursor_rect
tibuda_cmdwin_win_horiz_update_cursor_rect
draw_item(self.index > 0 ? self.index-1 : @item_max-1)
draw_item(self.index < @item_max-1 ? self.index+1 : 0)
draw_item(self.index)
@arrow.y = @arrow_align == 1 ? self.cursor_rect.y : 0
@arrow.y += self.y + 96 + 16
case @arrow_align
when 0
@arrow.x = self.cursor_rect.x
when 1
@arrow.x = self.cursor_rect.x + self.cursor_rect.width / 2
when 2
@arrow.x = self.cursor_rect.x + self.cursor_rect.width
end
@arrow.x += self.x - self.ox + 16
@arrow.visible = @show_arrow && self.active
self.cursor_rect.empty unless @show_cursor_rect
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_HorizCommand, :draw_item)
def draw_item(index, color = nil)
draw_command_item(index)
end
#--------------------------------------------------------------------------
SDK.log_overwrite(:Window_HorizCommand, :disable_item)
def disable_item(index)
draw_command_item(index, false)
end
#--------------------------------------------------------------------------
end
#==========================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------
Expand to see the code.
Instructions
(these instructions are bad, I'll rewrite them later)
When initializing a command window, follow the syntax
window = Window_Command.new(width, commands[, column_max])
Expand to see the code.
Where width is the window width,
commands is an array of strings, bitmaps or Data_Command objects,
column_max (optional) is the window number of columns (default 1).
When you add strings to the commands array, nothing different happens, but when you add a bitmap it will draw the bitmap and not the text. You can use Data_Command objects to store items text, icons and actions. You initialize a Data_Command object with the syntax
Data_Command.new(name[, icon_name, call_proc, enabled_proc, help])
Expand to see the code.
Where name is the item text,
icon_name (optional) is the icon filename,
call_proc is a Proc to be called when the item is selected (pressing Input::C),
enabled_proc (optional) is a Proc that returns if the item is enabled,
help (optional) is the text to show in help windows when the item is selected.
Compatibility / Requirements
Requires the SDK 2.2 Part I, and SephirothSpawn Window_Selectable (below)
Window_Selectable
Spoiler
#==============================================================================
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#-------------------------------------------------------------------------
# Name: oh
# Info: Used to determine row height. This is used to overwrite
# the top_row, top_row=, page_row_max & update_cursor_rect
# methods replacing the constant 32 with a variable amout.
# Author: SephirothSpawn
# Call Info: No Arguments
# Returns: Returns Command Offset Height
#-------------------------------------------------------------------------
def oh
return 32
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
return self.oy / self.oh
end
#--------------------------------------------------------------------------
# * Set Top Row
#--------------------------------------------------------------------------
def top_row=(row)
self.oy = [[row, 0].max, row_max - 1].min * self.oh
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
return (self.height - 32) / self.oh
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 32
# Calculate cursor coordinates
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * self.oh - self.oy
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, self.oh)
end
end
# ** Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#-------------------------------------------------------------------------
# Name: oh
# Info: Used to determine row height. This is used to overwrite
# the top_row, top_row=, page_row_max & update_cursor_rect
# methods replacing the constant 32 with a variable amout.
# Author: SephirothSpawn
# Call Info: No Arguments
# Returns: Returns Command Offset Height
#-------------------------------------------------------------------------
def oh
return 32
end
#--------------------------------------------------------------------------
# * Get Top Row
#--------------------------------------------------------------------------
def top_row
return self.oy / self.oh
end
#--------------------------------------------------------------------------
# * Set Top Row
#--------------------------------------------------------------------------
def top_row=(row)
self.oy = [[row, 0].max, row_max - 1].min * self.oh
end
#--------------------------------------------------------------------------
# * Get Number of Rows Displayable on 1 Page
#--------------------------------------------------------------------------
def page_row_max
return (self.height - 32) / self.oh
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 32
# Calculate cursor coordinates
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * self.oh - self.oy
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, self.oh)
end
end
Expand to see the code.
Credits and Thanks
I don't need credits.
Easy Plug-in
You can add the following script to add icons to your game menu and battle, and get a better look to your title screen. It requires SDK part IV
Content Hidden
Spoiler
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Adv Command Window') && SDK::Parts.include?(4)
module SDK::Scene_Commands
module Scene_Title
New_Game = 'New Game'
Continue = 'Continue'
Shutdown = 'Shutdown'
Commands = [New_Game, Continue, Shutdown]
end
module Scene_Menu
Item = Data_Command.new(DataSystem.words.item, '032-Item01')
Skill = Data_Command.new(DataSystem.words.skill, '044-Skill01')
Equip = Data_Command.new(DataSystem.words.equip, '010-Head01')
Status = Data_Command.new('Status', '050-Skill07')
Save = Data_Command.new('Save', '037-Item06')
End_Game = Data_Command.new('End Game', '020-Accessory05')
Commands = [Item, Skill, Equip, Status]
if SDK.enabled?('Exseiken\'s Party Switcher')
Switch = Data_Command.new('Switch', '016-Accessory01',
proc {$scene = Scene_Switch.new})
Commands << Switch
end
if SDK.enabled?('Trickster\'s Bestiary')
Bestiary = Data_Command.new('Bestiary', '046-Skill03',
proc {$scene = Scene_Bestiary.new})
Commands << Bestiary
end
Commands += [Save, End_Game]
end
module Scene_Battle
Escape = Data_Command.new('Escape', '020-Accessory05')
Attack = Data_Command.new(DataSystem.words.attack, '001-Weapon01')
Skill = Data_Command.new(DataSystem.words.skill, '044-Skill01')
Guard = Data_Command.new(DataSystem.words.guard, '009-Shield01')
Item = Data_Command.new(DataSystem.words.item, '032-Item01')
end
end
#==========================================================================
class Scene_Menu
#--------------------------------------------------------------------------
SDK.log_overwrite(:Scene_Menu, :main_command_window)
def main_command_window
# Make command window
commands = SDK::Scene_Commands::Scene_Menu::Commands.dup
@command_window = Window_Command.new(160, commands)
@command_window.index = $menu_index.is_a?(Numeric) ? $menu_index : 0
@command_window.height = 7 * 32
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_scnmenu_disabled_main_command?, :disabled_main_command?
def disabled_main_command?
# Gets Current Command
command = @command_window.command
# Unless command has enabled proc
unless command.is_a?(Data_Command) && !command.enabled?.nil?
# Calls the aliased method
tibuda_cmdwin_scnmenu_disabled_main_command?
end
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_scnmenu_main_cmd_input, :main_command_input
def main_command_input
# Gets Current Command
command = @command_window.command
# Stores last item index
$menu_index = @command_window.index
# Unless command has call proc
unless command.is_a?(Data_Command) && !command.call.nil?
# Calls the aliased method
tibuda_cmdwin_scnmenu_main_cmd_input
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Scene_Title
#--------------------------------------------------------------------------
attr_reader :continue_enabled
#--------------------------------------------------------------------------
SDK.log_overwrite(:Scene_Title, :main_window)
def main_window
super
commands = SDK::Scene_Commands::Scene_Title::Commands.dup
@command_window = Window_HorizCommand.new([180 * commands.size, 640].min, commands)
@command_window.show_cursor_rect = false
@command_window.show_arrow = true
@command_window.opacity = 0
@command_window.arrow_align = 1
@command_window.text_align = 1
@command_window.selected_font.bold = true
@command_window.selected_font.size = 28
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 416 - @command_window.height
@command_window.refresh
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
@command_window.index = 1 if @continue_enabled
end
#--------------------------------------------------------------------------
end
#==========================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.enabled?('Adv Command Window') && SDK::Parts.include?(4)
module SDK::Scene_Commands
module Scene_Title
New_Game = 'New Game'
Continue = 'Continue'
Shutdown = 'Shutdown'
Commands = [New_Game, Continue, Shutdown]
end
module Scene_Menu
Item = Data_Command.new(DataSystem.words.item, '032-Item01')
Skill = Data_Command.new(DataSystem.words.skill, '044-Skill01')
Equip = Data_Command.new(DataSystem.words.equip, '010-Head01')
Status = Data_Command.new('Status', '050-Skill07')
Save = Data_Command.new('Save', '037-Item06')
End_Game = Data_Command.new('End Game', '020-Accessory05')
Commands = [Item, Skill, Equip, Status]
if SDK.enabled?('Exseiken\'s Party Switcher')
Switch = Data_Command.new('Switch', '016-Accessory01',
proc {$scene = Scene_Switch.new})
Commands << Switch
end
if SDK.enabled?('Trickster\'s Bestiary')
Bestiary = Data_Command.new('Bestiary', '046-Skill03',
proc {$scene = Scene_Bestiary.new})
Commands << Bestiary
end
Commands += [Save, End_Game]
end
module Scene_Battle
Escape = Data_Command.new('Escape', '020-Accessory05')
Attack = Data_Command.new(DataSystem.words.attack, '001-Weapon01')
Skill = Data_Command.new(DataSystem.words.skill, '044-Skill01')
Guard = Data_Command.new(DataSystem.words.guard, '009-Shield01')
Item = Data_Command.new(DataSystem.words.item, '032-Item01')
end
end
#==========================================================================
class Scene_Menu
#--------------------------------------------------------------------------
SDK.log_overwrite(:Scene_Menu, :main_command_window)
def main_command_window
# Make command window
commands = SDK::Scene_Commands::Scene_Menu::Commands.dup
@command_window = Window_Command.new(160, commands)
@command_window.index = $menu_index.is_a?(Numeric) ? $menu_index : 0
@command_window.height = 7 * 32
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_scnmenu_disabled_main_command?, :disabled_main_command?
def disabled_main_command?
# Gets Current Command
command = @command_window.command
# Unless command has enabled proc
unless command.is_a?(Data_Command) && !command.enabled?.nil?
# Calls the aliased method
tibuda_cmdwin_scnmenu_disabled_main_command?
end
end
#--------------------------------------------------------------------------
alias_method :tibuda_cmdwin_scnmenu_main_cmd_input, :main_command_input
def main_command_input
# Gets Current Command
command = @command_window.command
# Stores last item index
$menu_index = @command_window.index
# Unless command has call proc
unless command.is_a?(Data_Command) && !command.call.nil?
# Calls the aliased method
tibuda_cmdwin_scnmenu_main_cmd_input
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Scene_Title
#--------------------------------------------------------------------------
attr_reader :continue_enabled
#--------------------------------------------------------------------------
SDK.log_overwrite(:Scene_Title, :main_window)
def main_window
super
commands = SDK::Scene_Commands::Scene_Title::Commands.dup
@command_window = Window_HorizCommand.new([180 * commands.size, 640].min, commands)
@command_window.show_cursor_rect = false
@command_window.show_arrow = true
@command_window.opacity = 0
@command_window.arrow_align = 1
@command_window.text_align = 1
@command_window.selected_font.bold = true
@command_window.selected_font.size = 28
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 416 - @command_window.height
@command_window.refresh
# If continue is enabled, move cursor to "Continue"
# If disabled, display "Continue" text in gray
@command_window.index = 1 if @continue_enabled
end
#--------------------------------------------------------------------------
end
#==========================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------
Expand to see the code.