TAChuck

Member
Hello guys! I think I might need your advice.

I have a list of string attached to a player that I use for a custom titles system :

"Thief"
"Peasant"
"Rogue"
etc..

Now, I'm trying to make a menu where the player can choose which Title he wants to show on his paperdoll.

I know from the WhoGump that something like this is possible, and with a couple of try and error, by using the WhoGump, I would get to something that works. But I think that would be time consuming and at the end, I don't think I would understand how the script really works.

So, here's a simple question, with, maybe not a simple answer : How can I generate a gump from a list?
 
When working with a collection of any form with a gump, the first thing you have to think about is the length/count. There is only so much room. It's easy to get pages working with the Linq system. To actually make it work, in the gump's constructor after you have the page and background stuff set up you can do a for loop from the list and add button/lable to the gump.

Code:
var list = new List<string>(); //the list.
public listGump() : base(0,0)
{
	...//Page 0 ... background
	var perPage = 15;
	for(var i = 0; i< list.Count; i++)
	{
		if(i % perPage == 0)
		{
			//add new page
			//add paging button
		}
		AddButton(...); // here you use i to calculate the position
						// if you want the list vertical spacing at 20 px for the y it'd be, 20 * (i % perPage) + 20.
					// Also use i for the button index.
		AddLable(10, (i % perPage), 32, list[i]);
	}
}
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back