Jump to content

Dynamic Multi-page Dialog (AKA Pagination)


Void Singer
 Share

You are about to reply to a thread that has been inactive for 4775 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts



  • Allows more than 12 button on a dialog by breaking them up into pages and adding page change buttons as needed
  • Supports up to 22 pages safely (220 items in the list)
  • Corrects the button order to [left to right, top to bottom]
  • Automatically wraps around from the last and first pages
  • Muliple silmultaneous users posible
  • Requires the button text(s) to be in a global list named gLstMnu (which you can fill however you like)


this function does NOT check that button text is valid (0 < button_text_length < 25), that's your job

 

list uDlgBtnLst( integer vIdxPag ){
list vLstRtn;
if ((gLstMnu != []) > 12){ //-- we have more than one possible page
integer vIntTtl = -~((~([] != gLstMnu)) / 10); //-- Total possible pages
integer vIdxBgn = (vIdxPag = (vIntTtl + vIdxPag) % vIntTtl) * 10; //-- first menu index
string vStrPag = llGetSubString( " ", 21 - vIdxPag, 21 ); //-- encode page number as spaces
//-- get ten (or less for the last page) entries from the list and insert back/fwd buttons
vLstRtn = llListInsertList( llList2List( gLstMnu, vIdxBgn, vIdxBgn + 9 ), (list)(" «" + vStrPag), 0xFFFFFFFF ) +
(list)(" »" + vStrPag);
}else{ //-- we only have 1 page
vLstRtn = gLstMnu; //-- just use the list as is
}
return //-- fix the order for [L2R,T2B] and send it out
llList2List( vLstRtn, -3, -1 ) + llList2List( vLstRtn, -6, -4 ) +
llList2List( vLstRtn, -9, -7 ) + llList2List( vLstRtn, -12, -10 );
}

example usage:

llDialog( Target_avatar_key, text_for_dialog_header, uDlgBtnLst( 0 ), chat_channel_to_use );

to detect the next page button use the following format

    listen( integer vIntChn, string vStrNom, key vKeySpk, string vStrMsg ){
if (!llSubStringIndex( vStrMsg, " " )){ //-- detects (hidden) leading space of page change buttons
llDialog( vKeySpk,
"your dialog text goes here",
uDlgBtnLst( llStringLength( vStrMsg ) + llSubStringIndex( vStrMsg, "»" ) - 2 ),
vIntChn );
}else{
//-- button was not a page button, your code goes here,
//-- use (llListFindList( gLstMnu, (list)vStrMsg ) / 10) for remenu command if present
}
}
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4775 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...