I'm trying to do a menu myself (The layout) and so far it's not that "hard" but there's 2 things I need to do but don't know how to do it, so here I am asking your help you wise scripters.
What I need to know is:
1] How can I make the list show horizontal instead of vertical.
2] Fixed
That's it I think.
Thanks
[Edit]
Oh it's on rpg maker xp.
here is a basic example of how i would do it
#==============================================================================
# ** Window_Item_Command
#==============================================================================
class Window_Item_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(icons,x,y,)
super(x, y, 32+(icons.size*32), 64)
@column_max = icons.size
@icons = icons
self.opacity = 0
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# If item count is not 0, make a bit map and draw all items
@item_max = @icons.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index % @column_max * 32
y = index / @column_max * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(@icons[index])
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
msg = case @index
when 0
'Inventory'
when 1
'Skills'
when 2
'Equipment'
end
@help_window.set_text(msg) if msg != nil
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index*32,0,32,32)
end
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@menu_back = Sprite.new
@menu_back.bitmap = RPG::Cache.picture("Menu.png") rescue nil
icons = ['021-Potion01','050-Skill07','001-Weapon01']
@command_window = Window_Item_Command.new(icons,0,64)
@help_window = Window_Help.new
@help_window.opacity = 0
@command_window.help_window = @help_window
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
@menu_back.dispose
@command_window.dispose
@help_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@command_window.update
@help_window.update
end
end
Ok from your script I managed to show the picture and help window, thanks.
Now, your script gives a syntax error on this line:
def initialize(icons,x,y,)
So couldn't try it out.
I tried checking your script and experimenting on mine but can't manage to make horizontal commands to work :/
Here's the code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
#Invisible Background
@mapback = Spriteset_Map.new
#Image
@menu_back = Sprite.new
@menu_back.bitmap = RPG::Cache.picture("Menu.png") rescue nil
# Make command window
s1 = ""
s2 = ""
s3 = ""
@command_window = Window_Command_New.new(65, [s1, s2, s3])
@command_window.x = 300
@command_window.y = 0
@command_window.z = 9999
@command_window.opacity = 0
@command_window.index = @menu_index
@help_window = Window_Help.new
@help_window.y = 416
@help_window.opacity = 200
@command_window.help_window = @help_window
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@mapback.dispose
@command_window.dispose
@help_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@mapback.update
@command_window.update
@help_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to Status screen
$scene = Scene_Status.new
when 2 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
when 2
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_End.new(@end_window.index)
end
return
end
end
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
msg = case @index
when 0
'Inventory'
when 1
'Status'
when 2
'Exit'
end
@help_window.set_text(msg) if msg != nil
end
#===============================================================================
# ** Window_Command_New
#-------------------------------------------------------------------------------
# This code allows the command window in the menu to display icons.
#===============================================================================
class Window_Command_New < Window_Selectable
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_reader :continue
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize(index, continue)
commands = ['', '','']
super(0, 0, 65, commands.size * 32 + 32) #0, 0, 160
#@item_max = commands.size
@columm_max = commands.size
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#-----------------------------------------------------------------------------
# * Draw Item
#-----------------------------------------------------------------------------
def draw_item(i, color)
self.contents.fill_rect(0, i*32, 148, 32, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon("Menu#{i}")
opacity = (color == normal_color ? 255 : 128)
self.contents.blt(4, 4 + i*32, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.font.color = color
self.contents.draw_text(28, i*32, 148, 32, @commands[i])
end
#-----------------------------------------------------------------------------
# * Disable Item
#-----------------------------------------------------------------------------
def disable_item(i)
draw_item(i, disabled_color)
end
#-----------------------------------------------------------------------------
# * Refresh
#-----------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
end
This was something I am searching about but doubt I'll ever know how to do it but I'll ask here anyway..
Is it possible to have the menu slide into position when called and slides off screen when you exit menu or fade slowly in and fade out when you call or exit it? (Would prefer first choice but whatever)
Also currently the piece of coding for the icons is pretty much copied from another menu script but 1 thing I really wanted to do different was making the icons sort of different aligned like in the picture below:
(http://img403.imageshack.us/img403/9006/menubackground.png)
Would that be harder to do?
that wouldn't realy be hard unless you want it to turn like a ring menu as for the syntax error remove the leading comma
def initialize(icons,x,y)
Nah not turning like a ring menu but forget it I don't mind them how they are right now.
Anyway I just tried again your script but while it's horizontal after I enter the menu I can no longer exit it nor enter any of the choices lol it just gets stucked.
i didn't make any of the commands do anything as i said it was a basic example
edit: i wouldn't mind making it for you if you gave me a layout i just figured from your first post you were trying to make it yourself
Problem is I don't understand what to do in my version to get the menu horizontal like in your example.
I'm not a scripter, was trying to figure it out myself as I know people have stuff to do so I tried to do it myself.
I'll pm you the layout.
Thanks
Everything I had problems with is solved, thanks nathmatt.
This can be closed.