Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RMXP: Custom Item Menu Command Columns Issue

Hello! In my custom RMXP item menu, I want to display four items in each row rather than 2 as is the case in the default item menu.

I got it so the command box (that you move around to select your item before confirming) will move over and select four areas of the item box before moving to the next row down, but the text names of the items only render 2 of each per line...which is weird since in the Help box at the top, it displays the descriptions of the items correctly.

Like when I move right to the fourth item on the first row, the command rectangle is sitting over a blank area, and the NAME of that item is the second item on the second row.

So the names do not display correctly (2 names per line when there should be 4), but the selection rectangle does move and display the correct "selections" in the item box and in the Help box. Is there some simple fix for getting the names to display 4 to a row that I'm missing?
 
Indeed there is - check your script for a method that says draw_items. That actually doesn't refer to items as in potions or whatever, but 'items in the command window', so that could just as well be skills, enemies or checklist items. But yeah, not too important for your case here.
That draw_item call should be somewhere in a for i in 0..$game_party.items block or something... either directly in there, or in the draw_item method, you'll find a 2 (the number) that refers to the x value of your items, aka handles the display of two items in the same row. Change it to 4, and if you need, adjust the base x value to your width if you haven't already.

Sorry for the vague description here, but I haven't been using RMXP for a while, and since I'm at work, I can't even check my VX scripts ^^"
 
Not really... the versions are different in terms of easiness and efficiency (RGSS2 is superior in both really), but the base functionality stayed almost the same. Then again, it might as well be vastly different, and it'd really be me remembering it well, but that's most likely because I was into custom menu things back then as well pretty much.
 
I cannot figure this out. I can cut off the text, re-align it, move it around left to right and up and down, but I can't make 4 display to one line. I changed every x value I encountered, all with weird results. Here is the script in case it helps:

#==============================================================================
# ** Window_Options
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
#==============================================================================

class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(96, 192, 448, 192)
@column_max = 2
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add item
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items)
end
end
# Also add weapons and items if outside of battle
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
end
# If item count is not 0, make a bit map and draw all items
@item_max = @data.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)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (228 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 255, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

self.contents.draw_text(x, y, 212, 32, item.name, 0)
end

#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#===========================
 
That's why I said change a few 2's (the numbers) as well :p Like the line that says x = 4 + index % 2 * (228 + 32) can be securely and far more functionally be changed to this:
Code:
x = 4 + index % @column_max * (114 + 32)
You gotta figure around with it, which is fairly easy if you want to spend some minutes looking at how the code works. It's a bit stupidly coded though, but hey... you could've chosen VX ^^
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top