This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Pagination in menu only if more than 9 entries


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chrisber
AlliedModders Donor
Join Date: Jul 2007
Location: localhost
Old 10-20-2014 , 08:52   Pagination in menu only if more than 9 entries
Reply With Quote #1

Hello,

is there a builtin function in the menus to say "only add pagination if absolutely necessary", so for CS:S if more than 9 entries and for CS:GO if more than 8 entries are available?

I'd like to ask before I manually count my entries and then call
PHP Code:
SetMenuPagination(menuMENU_NO_PAGINATION); 
dependent on the count.

Oh, a second question comes into my mind. Am I able to display more metadata e. g. always before entry #5? To show metadata on the top, I use SetMenuTitle together with some \n for new lines. Are there better ways?

Thanks!
Chrisber is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 10-27-2014 , 07:34   Re: Pagination in menu only if more than 9 entries
Reply With Quote #2

Maybe https://sm.alliedmods.net/api/index.php?fastload=show&id=190& will help you.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-27-2014 , 12:57   Re: Pagination in menu only if more than 9 entries
Reply With Quote #3

I'm not somewhere where I can test this, but this should take into account all the weird corner cases.

PHP Code:
stock AutoPaginate(Handle:menu)
{
    if (
menu == INVALID_HANDLE)
    {
        
ThrowError("Invalid menu Handle");
        return;
    }
    
    
// GetMaxPageItems reads from GameData for game-specific corrections and should be correct for CS:GO
    
new itemsPerPage GetMaxPageItems(GetMenuStyle(menu));
    
    new 
bool:pageOneHasExtraItem false;
    
    if (
GetMenuExitButton(menu))
    {
        
itemsPerPage--;
    }
    
    if (
GetMenuOptionFlags(menu) | MENUFLAG_BUTTON_NOVOTE)
    {
        
pageOneHasExtraItem true;
    }
    
    new 
count GetMenuItemCount(menu);
    
    if (
count <= (pageOneHasExtraItem itemsPerPage itemsPerPage ))
    {
        
SetMenuPagination(menuMENU_NO_PAGINATION);
    }
    else
    {
        
SetMenuPagination(menuitemsPerPage 2);
    }

As for meta-data, you can (probably) add it as an ITEMDRAW_RAWLINE and it will be printed without a number. However, it still counts as a menu item.

Edit: fixed the above since No Vote only appears on the first page of a vote.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-27-2014 at 13:23.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode