ID:1424790
 
(See the best response by Ss4toby.)
Is there a way to force a flexible grid to always display two columns? I currently have my inventory grid in two columns, one for the item and the other for its suffix, but when the window is resized or an obj's name is too long, the grid doesn't auto-adjust.

Is there something like text-wrap available for grids?

Here's a picture of the grid functioning normally:



and one of it not functioning properly:

Best response
The only option I can think of is to change it from a flexible list of entries and add items into a strict grid. Just because it isn't flexible, it does not mean it's size is fixed.

mob/verb/inventoryExample()
var/row=0
for(var/obj/O in contents)
row++
src << output(O, "grid1:1,[row]")
src << output(O.suffix, "grid1:2,[row]")


And removing items from the list wouldn't be too hard either.

mob/proc/removeItem(var/obj/O)
if(!isobj(O))
return
var/n=contents.Find(O)
if(n)
src<<output(null,"grid1:1,[n]")
src<<output(null,"grid1:2,[n]")
contents-=O
for(var/v = n to gridItems.len)//This would move everything above the item down one row
var/obj/c=contents[v]
if(isobj(c))
src<<output(c,"grid1:1,[v]")
src<<output(c.suffix,"grid1:2,[v]")
winset(src,"default.grid1","cells=2,[contents.len]")//This would update your grid


If I were you, I'd utilize the Entered() and Exit() proc's for mobs. This way, when things are added and removed from contents it can be made automatic. However, be sure to use Move().

Example:
mob
Entered(obj/o)
if(isobj(o)&&client)
src<<output(o,"grid1:1,[contents.len]")
src<<output(o.suffix,"grid1:2,[contents.len]")
Exit(obj/o)
if(isobj(o)&&client)
removeItem(o)
return 1

obj/itemExample
verb/Get()
set src in range(1)
Move(usr)
verb/Drop()
set src in usr
Move(usr.loc)