SA-MP Forums Archive
[Include] TextList - Text Draw list system. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] TextList - Text Draw list system. (/showthread.php?tid=622842)



TextList - Text Draw list system. - ZiGGi - 27.11.2016

TextList
GitHub
About
Text Draw list system.

Screens
Working vehicle tuning system from Open-GTO gamemode. You can see sources here.


Functions
Show created TextList
PHP код:
TextList_Show(playerid, function[]) 
Open TextList
PHP код:
TextList_Open(playerid, function[], list_items[][], list_size sizeof(list_items), header[] = "",
              
button1[] = ""button2[] = ""Float:pos_x 89.0Float:pos_y 140.0,
              
select_color 0xFFA500FF,
              
lists_bg_color[TEXTLIST_MAX_ITEMS] = {0x212121A0, ...},
              
lists_fg_color[TEXTLIST_MAX_ITEMS] = {0xFFFFFFFF, ...},
              
header_bg_color 0xB71C1CAAheader_fg_color 0xFFFFFFFF,
              
paginator_bg_color 0x21212160paginator_fg_color 0xFFFFFFFF,
              
button1_bg_color 0x6D4C41AAbutton1_fg_color 0xFFFFFFFF,
              
button2_bg_color 0x6D4C41AAbutton2_fg_color 0xFFFFFFFF
Close TextList
PHP код:
TextList_Close(playerid); 
Is TextList opened
PHP код:
TextList_IsOpen(playerid); 
Callbacks
Each TextList has its own handler function, it looks as follows:
PHP код:
TextListResponse:example_tl(playeridTextListType:responseitemiditemvalue[])
{
    return 
1;

This function is called when a user interacts with TextList.

TextListType can have these values:
- TextList_None
- TextList_Button1
- TextList_Button2
- TextList_ListItem
- TextList_ListUp
- TextList_ListDown
- TextList_Cancel

Defines
Directive
Default value
Can be redefined
TEXTLIST_MAX_ITEMS 30 yes
TEXTLIST_MAX_ITEMS_ON_LIST 10 yes
TEXTLIST_MAX_ITEM_NAME 32 no
TEXTLIST_MAX_FUNCTION_NAME 31 no
TEXTLIST_MAX_BUTTON_NAME 12 no
Usage
The system provides the ability to create a function to open TextList, this is useful when multiple calls one list (mostly used when creating nested menus):
PHP код:
TextListCreate:example_tl(playerid)
{
    new 
items[][TEXTLIST_MAX_ITEM_NAME] = {
        
"Test 1",
        
"Big Test 2"
    
};
    new 
bg_colors[TEXTLIST_MAX_ITEMS] = {
        
0xFF0000FF,
        
0x00FF00FF
    
};
    
TextList_Open(playeridTextList:example_tlitemssizeof(items),
                  
"Example header",
                  
"Button 1""Button 2",
                  .
lists_bg_color bg_colors);
}
TextListResponse:example_tl(playeridTextListType:responseitemiditemvalue[])
{
    new 
string[128];
    
format(stringsizeof(string), " %d | %d | %d | %s"playerid_:responseitemiditemvalue);
    
SendClientMessage(playerid, -1string);
    return 
1;

And you should use TextList_Show for opening created TextList:
PHP код:
TextList_Show(playeridTextList:example_tl); 
Of course you can not use the system, you can do everything without TextListCreate.

Download
- GitHub download page: https://github.com/Open-GTO/textlist/releases


Re: TextList - Text Draw list system. - JustMe.77 - 27.11.2016

Beautiful and excellent work!


Re: TextList - Text Draw list system. - Pottus - 27.11.2016

I like it but I don't like it let me explain it looks good the code is good but where it falls short is the whole project sidesteps the big picture of a rich GUI system.


Re: TextList - Text Draw list system. - Chaprnks - 10.02.2019

Is there any way to create a list dynamically? Like populate the list items based on a mysql query. AFAIK, it looks like it can only be populated statically, in its own function. Basically using this as a more appealing replacement for a dialog textlist.


Re: TextList - Text Draw list system. - Logic_ - 10.02.2019

Modify it to work with pawn memory plugin.


Re: TextList - Text Draw list system. - Variable™ - 10.02.2019

Quote:
Originally Posted by Chaprnks
Посмотреть сообщение
Is there any way to create a list dynamically? Like populate the list items based on a mysql query. AFAIK, it looks like it can only be populated statically, in its own function. Basically using this as a more appealing replacement for a dialog textlist.
You can create an array and story the query result in it then show the list.