1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Generate a gump from a List<T>

Discussion in 'Script Support' started by TAChuck, Mar 20, 2017.

  1. TAChuck
    Offline

    TAChuck New Member

    Joined:
    Jul 1, 2015
    Messages:
    27
    Likes Received:
    2
    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 :

    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?
     
  2. Talow
    Offline

    Talow Member

    Joined:
    Aug 30, 2014
    Messages:
    271
    Likes Received:
    20
    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 (C#):
    1.  
    2. var list = new List<string>(); //the list.
    3. public listGump() : base(0,0)
    4. {
    5.     ...//Page 0 ... background
    6.     var perPage = 15;
    7.     for(var i = 0; i< list.Count; i++)
    8.     {
    9.         if(i % perPage == 0)
    10.         {
    11.             //add new page
    12.             //add paging button
    13.         }
    14.         AddButton(...); // here you use i to calculate the position
    15.                         // if you want the list vertical spacing at 20 px for the y it'd be, 20 * (i % perPage) + 20.
    16.                     // Also use i for the button index.
    17.         AddLable(10, (i % perPage), 32, list[i]);
    18.     }
    19. }
    20.  
     
    • Agree Agree x 1
    • Helpful Helpful x 1
  3. TAChuck
    Offline

    TAChuck New Member

    Joined:
    Jul 1, 2015
    Messages:
    27
    Likes Received:
    2
    Thank you! That is the information that I needed.

    I'll let you know If I can make it work!
     
Similar Threads: Generate gump
Forum Title Date
Archived Bug Reports Create World Gump - saying something is not generated when it is Feb 7, 2017
New Join Forum How to generate monsters automatically when they dead ? Mar 21, 2017
Script Support Command to generate the Exodus encounter? Dec 13, 2016
Archived Bug Reports Generate Factions Apr 17, 2013
Script Support Question regarding Gump Today at 10:32 AM
Bug Reports Raised Garden Bed doesn't work properly and missing gump Yesterday at 6:43 PM
Script Support Player Vendor Gump (modified) Mar 17, 2017