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.
Vertical or Horizontal Menu 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
Here's the script. (Replace Window_Command with this)

This script was made to be SDK compliant, however it will also work if you don't have the SDK. For those of you have no idea what I'm talking about, simply enjoy the peace of ignorance *it's a joke, no offense intended*

Code: [Select]
#=========================================================
#  * VH_Window_Command
#---------------------------------------------------------
# Make Horizontal or Vertical Menus with or without icons
#---------------------------------------------------------
# Version 2
# 12.12.05
#---------------------------------------------------------
# Tsunokiette
# * Give Credit *
#=========================================================

#*********************************
# * SDK Log Script
#*********************************

SDK.log('Tsunokiette', 'VH_Window_Command', 2, '12.12.05') unless defined?(SDK) == 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?
for i in 0...icons.size
@icons[i] = RPG::Cache.icons("#{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, normal_color)
else
draw_v_icon(index, normal_color)
end
when 'horizontal'
if @icons.nil?
draw_h(index, normal_color)
else
draw_h_icon(index, normal_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
#*********************************



Use like this-

For Vertical Menu With Icons
Code: [Select]
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
i1 = 'icon name'
i2 = 'icon name'
i3 = 'icon name'
@Command_Menu = VH_Window_Command.new('vertical', [c1,c2,c3], [i1,i2,i3])



For Vertical Menu Without Icons
Code: [Select]
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
@Command_Menu = VH_Window_Command.new('vertical', [c1,c2,c3])



For Horizontal Menu With Icons
Code: [Select]
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
i1 = 'icon name'
i2 = 'icon name'
i3 = 'icon name'
@Command_Menu = VH_Window_Command.new('horizontal', [c1,c2,c3], [i1,i2,i3])



For Horizontal Menu Without Icons
Code: [Select]
c1 = 'Option'
c2 = 'Option'
c3 = 'Option'
@Command_Menu = VH_Window_Command.new('horizontal', [c1,c2,c3])
"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."

***
Rep:
Level 90
Nooooooooooooooooooooooooooooooooooooooooooooooo!!!!!!!
I was making that!
You are fast than me! :evil:

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Quote from: Season In The Abyss
Nooooooooooooooooooooooooooooooooooooooooooooooo!!!!!!!
I was making that!
You are fast than me! :evil:


I'm re-writing it right now, since it didn't work before (at least for me)
"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."

*
Rep:
Level 97
Definitely better than Hitler.
2014 Best IRC Chatterbox2014 Best Musician2013 King of RMRK2013 Best Musician2013 Best Use of Avatar and Signature Space2013 Funniest MemberFor the great victory in the Breakfast War.2012 Best Username2012 Best MusicianFor frequent good quality Wiki writing [citation needed]2011 Funniest Member2011 Best MusicianMost entertaining member on the IRC2010 Most Missed Member
I tried it and it didn't work, although maybe I wasn't using it correctly.
:tinysmile:

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Quote from: HaloOfTheSun
I tried it and it didn't work, although maybe I wasn't using it correctly.


It should have worked, but it doesn't, so that's why I'm re-writing it.
"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."

***
Rep: +0/-0Level 90
X_X

you should test your scripts better before posting them......



Unless I say so, I'm using RPG Maker XP.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Quote from: The Moogle
X_X

you should test your scripts better before posting them......


Ya, but I have  to burn them to disk, take them to my messed up computer without an internet connection which is loaded with viruses,etc. and test it on the illegal version which is bound to effect the way the script runs.

So, I actualy do test my scripts, but before I do that I re-read the scripts constantly  looking for mistakes. If an un-foreseen error arises it's not my fault. It's usualy something that shouldn't be happening.

EDIT:

do you see anything wrong with this?

Code: [Select]
     unless icons.nil?
         for i in 0...icons.size
            @icons[i] = RPG::Cache.icon("#{icons[i]}")
         end
      end


because that's where the error keeps arising. oh, and if the script is used properly, then the above is the same as this-

Code: [Select]
     unless icons.nil?
         for i in 0...icons.size
            @icons[i] = RPG::Cache.icon(icons[i])
         end
      end


I'm working on a verion that doesn't use that method, hopefuly getting rid of the problem.

EDIT2: now that I think about it, RPG::Cache.icon(icons) actualy loads a file, so the error  I was recieving may have been because @icons wasn't a sprite. But that still doesn't explain why it was telling me I couldn't use []
"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."