26.05.2015, 06:14
This include don't work on the basis of pages, its actually listitems.
If you had noticed, i don't give option to start a menu from any numbered listitem, thats because you would have to calculate a lot and get page ids from a listitem.
But you may check out the dialogs include.
So basically we start from page 1. You must have a macro or defination of listitems per page. For example:
Now using ceildiv(a function from y_utils)
Just get the total amount of listitems your menu or dialog have and input in the macro. For example:
Assuming you have total 50 items in your menu.
Will return the page id.
___
Where in this include, I simply use arrays to store player and menu data.
^^ This for total lisitems.
^^ This for player's current lisitem highlighted.
For detecting the page, i use two additional enums
These stores the first most item and the last most item, so its easy for me to calculate the next page or previous page.
If you had noticed, i don't give option to start a menu from any numbered listitem, thats because you would have to calculate a lot and get page ids from a listitem.
But you may check out the dialogs include.
So basically we start from page 1. You must have a macro or defination of listitems per page. For example:
pawn Code:
#define LISTITEMS_PER_PAGE 10
pawn Code:
#define ceildiv(%0,%1) (((%0)-1)/(%1)+1)//thansk to ******
Assuming you have total 50 items in your menu.
pawn Code:
ceildiv(50, LISTITEMS_PER_PAGE);
___
Where in this include, I simply use arrays to store player and menu data.
pawn Code:
gMenu[<menuid>][M_LISTITEMS];
pawn Code:
gPlayerMenu[<playerid>][PM_LISTITEM];
For detecting the page, i use two additional enums
pawn Code:
gPlayerMenu[<playerid>][PM_LISTITEM_FIRST];
gPlayerMenu[<playerid>][PM_LISTITEM_LAST];