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.
Command window, vertical, horizontal, with or without icons

0 Members and 1 Guest are viewing this topic.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Okay, I was overcomplicating it before, and I realized why.

Put this with the other Window scripts.

Code: [Select]
#========================================================
# ? VH_Window_Command
#--------------------------------------------------------
# Make Horizontal or Vertical Menus with or without icons
#--------------------------------------------------------
# Version 1
# 12.18.05
#--------------------------------------------------------
# Tsunokiette (Give credit lads and lassies)
#========================================================


#*********************************
# 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)
#set intance variables to equal their parameter counterparts
@type = type
@commands = commands
@icons = icons
#if type equals 'vertical'
if @type == 'vertical'
#super-class initialization
super(0,0,182,32 *  @commands.size + 32)
#if type equals 'horizontal'
elsif @type == 'horizontal'
#super-class initialization
super(0,0,640,64)
#if the other circumstances are false
else
#run method named give_error
give_error
end
#create a new bitmap
self.contents = Bitmap.new(height - 32,width - 32)
#run method named font_properties
font_properties
#item_max equals the ammount of commands
@item_max = commands.size
#columns equals item_max unless type is not horizontal
@columns = @item_max unless @type != 'horizontal'
#run method named refresh
refresh
#set index to 0
self.index = 0
end

#--------------------
# Give Error and Exit
#--------------------

def give_error
#create lines for the error message
line1 = "ERROR: '#{@type}' is an invalid Window Type! /n "
line2 = " /n "
line3 = "Solution #1 -  /n "
line4 = "       Specify as either 'vertical' or 'horizontal'. /n "
line5 = "Solution #2 - /n "
line6 = "       Define specified Window Type Manualy."
#show the error message on-screen
p "#{line1}#{line2}#{line3}#{line4}#{line5}#{line6}"
#exit from the game
exit
end

#------------------------
# Set the Font Properties
#------------------------

def font_properties
#set font name to 'Times New Roman'
self.contents.font.name = 'Times New Roman'
#set font size to 22
self.contents.font.size = 22
end
   
#------------------------------
# Refresh the Window's Contents
#------------------------------

def refresh
#clear the window's contents
self.contents.clear
#case statement using type
case @type
#when type is 'vertical'
when 'vertical'
#if icons are nil (nothing)
if  @icons.nil?
#run a loop (i in 0 to item_max)
for i in 0...@item_max
#run method named draw_v
draw_v(i,normal_color)
end
#if the other circumstance is false
else
#run a loop (i in 0 to item_max)
for i in 0...@item_max
#run method named draw_v_icon
draw_v_icon(i,normal_color)
end
end
#when type is 'horizontal'
when 'horizontal'
#if icons are nil (nothing)
if @icons.nil?
#run a loop (i in 0 to item_max)
for i in 0...@item_max
#run method named draw_h
draw_h(i,normal_color)
end
#if the other circumstance is false
else
#run a loop (i in 0 to item_max)
for i in 0...@item_max
#run method named draw_h_icon
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)
#calculate x y width and height for the commands
x = 24
y = 32 * index
w = self.content.width - 24
h = 32
#calculate x and y for the icons
ix = 0
iy = 32 * index + 4
#set font color to equal the parameter color
self.contents.font.color = color
#create a new Rect object
rect = Rect.new(x,y,w,h)
#make rect invisible
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
#draw text commands
self.contents.draw_text(rect, @commands[index], 1)
#run method named draw_icon
draw_icon(@icons[index],ix,iy)
end

#---------------------------------------
# Draw Contents Vertically Without Icons
#_______________________________________
# Index = Command Location
# Color = Text Color
#---------------------------------------
   
def draw_v(index, color)
#calculate x y width and height for the commands
x = 0
y = 32 * index
w = self.content.width
h = 32
#set font color to equal the parameter color
self.contents.font.color = color
#create a new Rect object
rect = Rect.new(x,y,w,h)
#make rect invisible
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
#draw text commands
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)
#calculate x y width and height for the commands
x = self.contents.width / @commands.size * index + 24
y = o
w = self.contents.width / @commands.size - 24
h = 32
#calculate x and y for the icons
ix = self.contents.width / @commands.size *index
iy = 4
#set font color to equal the parameter color
self.contents.font.color = color
#create a new Rect object
rect = Rect.new(x,y,w,h)
#make rect invisible
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
#draw text commands
self.contents.draw_text(rect, @commands[index], 1)
#run method named draw_icon
draw_icon(@icons[index],ix,iy)
end

#-----------------------------------------
# Draw contents Horizontally Without Icons
#_________________________________________
# Index = Command Location
# Color = Text Color
#-----------------------------------------

def draw_h(index, color)
#calculate x y width and height for the commands
x = self.contents.width / @commands.size * index + 24
y = o
w = self.contents.width / @commands.size - 24
h = 32
#set font color to equal the parameter color
self.contents.font.color = color
#create a new Rect object
rect = Rect.new(x,y,w,h)
#make rect invisible
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
#draw text commands
self.contents.draw_text(rect, @commands[index], 1)
end

#-------------------------
# Draw Icon
#_________________________
# Icon = Icon name
# x = icon x
# y = icon y
#-------------------------

def draw_icon(icon = '',x = 0,y = 0)
#create a new rect object
rect = Rect.new(x,y,24,24)
#bitmap equals a new icon
bitmap = RPG::Cache.icon(icon)
#draw bitmap
self.contents.blt(0,0,bitmap)
end

#-------------------------
# Disable Command
#_________________________
# Index = Command Location
#-------------------------

def disable_item(index)
#case statement using type
case @type
#when type is 'vertical'
when 'vertical'
#if icons are nil (nothing)
if  @icons.nil?
#run method named draw_v
draw_v(index,disabled_color)
#if the other circumstance is false
else
#run method named draw_v_icon
draw_v_icon(index,disabled_color)
end
#when type is 'horizontal'
when 'horizontal'
#if icons are nil (nothing)
if @icons.nil?
#run method named draw_h
draw_h(index,disabled_color)
#if the other circumstance is false
else
#run method named draw_h_icon
draw_h_icon(index,disabled_color)
end
end
end

#--------------
# Update Cursor
#--------------

def update_cursor_rect
#unless the index is greater than or equal to 0
unless @index >= 0
#make cursor invisible
self.cursor_rect.empty
#end method processing
return
end
#case statement using type
case @type
#when type is 'vertical'
when 'vertical'
#calculate x y width and height for the cursor
x = 0
y = 32 * @index
w = self.contents.width
h = 32
#when type is 'horizontal'
when 'horizontal'
#calculate x y width and height for the cursor
x = self.contents.width / @commands.size * @index
y = 0
w = self.contents.width / @commands.size
h = 32
end
#place the cursor
self.cursor_rect.set(x,y,w,h)
end

end

#********************
# Window_Command Ends
#********************


Instructions are the same for this as last time. -

For a vertical menu with icons
Code: [Select]
c1 = 'Command Text'
c2 = 'Command Text'
c3 = 'Command Text'
i1 = 'icon name'
i2 = 'icon name'
i3 = 'icon name'
@menu = VH_Window_Command.new('vertical',[c1,c2,c3],[i1,i2,i3])


For a vertical menu without icons
Code: [Select]
c1 = 'Command Text'
c2 = 'Command Text'
c3 = 'Command Text'
@menu = VH_Window_Command.new('vertical',[c1,c2,c3])


For a horizontal menu with icons
Code: [Select]
c1 = 'Command Text'
c2 = 'Command Text'
c3 = 'Command Text'
i1 = 'icon name'
i2 = 'icon name'
i3 = 'icon name'
@menu = VH_Window_Command.new('horizontal',[c1,c2,c3],[i1,i2,i3])


For a horizontal menu without icons
Code: [Select]
c1 = 'Command Text'
c2 = 'Command Text'
c3 = 'Command Text'
@menu = VH_Window_Command.new('horizontal',[c1,c2,c3])


If you experience any errors, tell me imediately, I'd like to get this thing error free for once lol.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
*bump*

Sorry lol was in a rush last night and forget that I didn't need to alias dispose because the icon wasn't a sprite.

I deleted the aliased method and should work now, if you got an error saying (no method 'dispose' for nil:nilclass '@sprite[index]')

or something similar, that was why.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*******
I am epic, you are not.
Rep:
Level 93
Defender of Justice
can you post soem screenshots of what this script does?

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Quote from: Lord Dante
can you post soem screenshots of what this script does?


asap (in 4-5 days)
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*******
I am epic, you are not.
Rep:
Level 93
Defender of Justice
Quote from: Tsunokiette
Quote from: Lord Dante
can you post soem screenshots of what this script does?


asap (in 4-5 days)


lol