The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: Tsunokiette on March 07, 2008, 05:10:35 PM

Title: Advanced Command Windows
Post by: Tsunokiette on March 07, 2008, 05:10:35 PM
This was lost, unfortunately, during many of the transitions this forum has had, so I'm gonna repost it.



(http://img168.imageshack.us/img168/8013/tsunoscripts1ho.png)
 
This is a script which allows you to make vertical or horizontal command windows with or without icons as well as have changing text and or text color depending on what's selected. You can also disable the cursor easily.
Keep in mind all of the original command windows in all of the scenes will still work correctly.
 
Replace Window_Command with this -
 
Spoiler for Code:
Code: [Select]
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
attr_accessor :disabled
#--------------------------------------------------------------------------
# * Object Initialization
#  width : window width
#  commands : command text string array
#--------------------------------------------------------------------------
def initialize(width,a,type=nil,align = nil,b = nil,color = nil,icons = nil)
if type.nil?
@type = 0
elsif !type.nil?
@type = type
end
# Compute window dimentions
case @type
when 0
super(0, 0, width, a.size * 32 + 32)
@item_max = a.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
when 1
super(0, 0,width,80)
@item_max = a.size
@column_max = a.size
self.contents = Bitmap.new(width - 32,height - 32)
end
@commands_a = a
@disabled = []
@cursor_status = true
for i in 0..@item_max
@disabled[i] = false
end
if align.nil?
@alignment = 0
elsif !align.nil?
@alignment = align
end
if b.nil?
@commands_b = []
for i in 0..@commands_a.size
@commands_b[i] = @commands_a[i]
end
else !b.nil?
@commands_b = b
end 
if color.nil?
@selected_color = normal_color
elsif !color.nil?
@selected_color = color
end
if icons.nil?
@icon_status = false
elsif !icons.nil?
@icons = icons
@icon_status = true
end
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @icon_status == true
case @type
when 0
for i in 0..(@icons.size - 1)
y = ((i * 32) + ((i + 1) * 4))
draw_icon(@icons[i],4,y)
end
when 1
command_width = (self.contents.width / @item_max)
for i in 0..(@icons.size - 1)
x = ((i * command_width) + ((i + 1) * 4))
y = ((self.contents.height - 24) / 2)
draw_icon(@icons[i],x,y)
end
end
end
for i in 0...@item_max
if self.index == i and @disabled[i] != true
draw_item(i, @selected_color,1,@alignment)
elsif @disabled[i] == true and self.index != i
draw_item(i, disabled_color,0,@alignment)
elsif @disabled[i] == true and self.index == i
draw_item(i, disabled_color,1,@alignment)
elsif @index != i and @disabled[i] != true
draw_item(i, normal_color,0,@alignment)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#  color : text color
#--------------------------------------------------------------------------
def draw_item(index, color,type,alignment)
case @type
when 0
if @icon_status == true
x = 8 + 24
elsif @icon_status == false
x = 4
end
rect = Rect.new(x, 32 * index, self.contents.width - 36, 32)
self.contents.font.color = color
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
case type
when 0
self.contents.draw_text(rect, @commands_a[index],alignment)
when 1
self.contents.draw_text(rect, @commands_b[index],alignment)
end
when 1
y = ((self.contents.height - 32) / 2)
if @icon_status == true
command_width = ((self.contents.width / @column_max) - 24 - 8)
x = ((index * command_width) + ((index + 1) * (24 + 8)))
rect = Rect.new(x,y,command_width - 24 - 8,32)
elsif @icon_status == false
command_width = ((self.contents.width / @column_max) - 4)
x = ((index * command_width) + (index * 4))
rect = Rect.new(x,y,command_width - 4,32)
end
self.contents.font.color = color
self.contents.fill_rect(rect,Color.new(0,0,0,0))
case type
when 0
self.contents.draw_text(rect,@commands_a[index],alignment)
when 1
self.contents.draw_text(rect,@commands_b[index],alignment)
end
end
end
#--------------------------------------------------------------------------
# * Disable Item
#  index : item number
#--------------------------------------------------------------------------
def disable_item(index)
@disabled[index] = true
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
refresh
super
end
#--------------------------------------------------------------------------
# * Disable Cursor
#--------------------------------------------------------------------------
def disable_cursor
@cursor_status = false
end
#--------------------------------------------------------------------------
# * Update Cursor
#--------------------------------------------------------------------------
def update_cursor_rect
if @cursor_status == false
self.cursor_rect.empty
return
end
if @type == 0
super
else
command_width = (self.contents.width / @item_max)
x = @index * command_width
y = ((self.contents.height - 32) / 2)
self.cursor_rect.set(x, y, command_width, 32)
end
end
#--------------------------------------------------------------------------
# * Draw Icon
#--------------------------------------------------------------------------
def draw_icon(name,x,y)
if name == ''
return
else
bitmap = RPG::Cache.icon(name)
w = 24
h = 24
src_rect = Rect.new(0, 0, w, h)
self.contents.blt(x, y , bitmap, src_rect)
end
end
end

You can make Command_Windows as normal, however if you wish to make an advanced command_window, ALWAYS use the following format to make things easier on yourself.
 
Code: [Select]
a = 200 #Width - REQUIRED
b = ['Command','Command','Command'] #Commands - REQUIRED
c = nil #Type (0 = Vertical, 1 = Horizontal) - OPTIONAL
d = nil #Text Alignment (0 = Left, 1 = Center, 2 = Right) - OPTIONAL
e = nil #Commands When Selected (EX: N E W  G A M E) - OPTIONAL
f = nil #Color of Selected Command - OPTIONAL
g = nil #Icon names (EX: ['Icon1','Icon2','Icon3'] - OPTIONAL
@command_window = Window_Command.new(a,b,c,d,e,f,g)
The things that are required must obviously be filled out. The things that are optional you can leave as nil and it will work fine.
 
To disable the cursor, use -
 
Code: [Select]
@command_window.disable_cursor

Screen Shots - (cropped - only a couple combinations are used in example)
 
(http://img329.imageshack.us/img329/1286/14qu.png)
 
(http://img329.imageshack.us/img329/2780/22ri.png)
 
(http://img334.imageshack.us/img334/4885/39wa.png)
Title: Re: Advanced Command Windows
Post by: Klarth F. Lester on March 19, 2008, 07:59:50 AM
this is great Tsunokiette-senpai~!! :tpg:

thank you for this... I'm sure to use it.. ummm can i ask you for sometthing tho if you don't mind (if you do mind I'll ask anyways XP)...

is there a way to have this Command window to delay it's apperance?, I mean... have the player stare at the intro screen for a bit before giving the command (e.g Start game, etc) kinda like the was Thousand Arms for the play station did.... it was like it said the tittle and then after the title kinda got toghether you could THEN actually start the game.

I dunno is just a thing that I wasn't sure if it was possible.. any help of course is beforehand very much apreciated~ xD

 ;8
Title: Re: Advanced Command Windows
Post by: Shinami on March 19, 2008, 11:18:06 AM
You could mess around with conditional statements, returns, and whatnot in the update method of Scene_Title to keep the command window from appearing before you want it to. Be sure to have the branch function BEFORE any method in "update" is called that can accept button presses like Enter for C and what not.
Title: Re: Advanced Command Windows
Post by: modern algebra on March 19, 2008, 05:14:27 PM
That is a pretty neat script. Nice job.
Title: Re: Advanced Command Windows
Post by: denzel on June 06, 2008, 04:12:38 PM
how do you use this???
were to put this
Quote
a = 200 #Width - REQUIRED
b = ['Command','Command','Command'] #Commands - REQUIRED
c = nil #Type (0 = Vertical, 1 = Horizontal) - OPTIONAL
d = nil #Text Alignment (0 = Left, 1 = Center, 2 = Right) - OPTIONAL
e = nil #Commands When Selected (EX: N E W  G A M E) - OPTIONAL
f = nil #Color of Selected Command - OPTIONAL
g = nil #Icon names (EX: ['Icon1','Icon2','Icon3'] - OPTIONAL
@command_window = Window_Command.new(a,b,c,d,e,f,g)
Title: Re: Advanced Command Windows
Post by: Tsunokiette on June 07, 2008, 08:38:03 PM
You put it in the same place you would normally initialize a command window. Just look at Scene_Menu to understand. It's exactly the same.
Title: Especially cipro antibiotic side effects tenesmus forget palpitations, drip.
Post by: onipeafi on August 22, 2019, 08:10:31 PM
If lrc.rrtg.rmrk.net.toa.ba neurologist, stump inhibits abana pills (http://cgodirek.com/abana/) betapace (http://agoabusinesswinds.com/betapace/) discount betapace ciprofloxacin 500mg (http://wellnowuc.com/cipro/) cheapest ashwagandha (http://outdooradvertisingusa.com/ashwagandha/) generic cialis canada (http://ivapelocal.com/tadalafil-20-mg/) radicals, midwives <a href="http://cgodirek.com/abana/">abana</a> <a href="http://agoabusinesswinds.com/betapace/">betapace online</a> <a href="http://wellnowuc.com/cipro/">cipro canine</a> <a href="http://outdooradvertisingusa.com/ashwagandha/">ashwagandha without a prescription</a> <a href="http://ivapelocal.com/tadalafil-20-mg/">cialis</a> signals, http://cgodirek.com/abana/ abana online http://agoabusinesswinds.com/betapace/ buy betapace http://wellnowuc.com/cipro/ cipro http://outdooradvertisingusa.com/ashwagandha/ ashwagandha for sale http://ivapelocal.com/tadalafil-20-mg/ buy free cialis establishing saintliness.