2014-08-04 08:36:20 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
2005-09-10 00:38:42 +00:00
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
#ifndef _INCLUDE_NEWMENUS_H
|
|
|
|
#define _INCLUDE_NEWMENUS_H
|
|
|
|
|
2014-05-21 16:45:40 +00:00
|
|
|
#define MENU_TIMEOUT -4
|
2005-09-10 00:38:42 +00:00
|
|
|
#define MENU_EXIT -3
|
|
|
|
#define MENU_BACK -2
|
|
|
|
#define MENU_MORE -1
|
2005-07-29 06:33:57 +00:00
|
|
|
#define ITEM_IGNORE 0
|
|
|
|
#define ITEM_ENABLED 1
|
|
|
|
#define ITEM_DISABLED 2
|
|
|
|
|
2007-04-16 06:58:28 +00:00
|
|
|
#define MAX_MENU_ITEMS 10
|
2006-02-03 03:00:48 +00:00
|
|
|
|
|
|
|
#define MPROP_PERPAGE 1
|
|
|
|
#define MPROP_BACKNAME 2
|
|
|
|
#define MPROP_NEXTNAME 3
|
|
|
|
#define MPROP_EXITNAME 4
|
|
|
|
#define MPROP_TITLE 5
|
2006-02-06 13:22:33 +00:00
|
|
|
#define MPROP_EXITALL 6
|
2006-02-03 03:00:48 +00:00
|
|
|
#define MPROP_ORDER 7
|
|
|
|
#define MPROP_NOCOLORS 8
|
2006-02-08 22:09:31 +00:00
|
|
|
#define MPROP_PADMENU 9
|
2007-04-18 04:20:48 +00:00
|
|
|
#define MPROP_SET_NUMBER_COLOR 10
|
2017-04-04 08:29:18 +00:00
|
|
|
#define MPROP_PAGE_CALLBACK 11
|
2005-07-29 06:33:57 +00:00
|
|
|
|
|
|
|
typedef int (*MENUITEM_CALLBACK)(int, int, int);
|
|
|
|
|
2008-04-27 19:19:53 +00:00
|
|
|
class BlankItem
|
|
|
|
{
|
|
|
|
private:
|
2015-07-11 08:37:36 +00:00
|
|
|
ke::AString m_text;
|
2008-04-27 19:19:53 +00:00
|
|
|
bool m_num;
|
|
|
|
public:
|
2015-07-11 08:37:36 +00:00
|
|
|
BlankItem() : m_num(false)
|
|
|
|
{
|
|
|
|
}
|
2008-04-27 19:19:53 +00:00
|
|
|
|
2015-07-11 08:37:36 +00:00
|
|
|
BlankItem(BlankItem &&other)
|
2008-04-27 19:19:53 +00:00
|
|
|
{
|
2015-07-11 08:37:36 +00:00
|
|
|
m_text = ke::Forward<ke::AString>(other.m_text);
|
|
|
|
m_num = other.m_num;
|
2008-04-27 19:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* is this text instead of a blank */
|
2015-07-11 08:37:36 +00:00
|
|
|
bool IsText() { return m_text.chars() != nullptr; }
|
2008-04-27 19:19:53 +00:00
|
|
|
|
|
|
|
/* is this a blank instead of text */
|
2015-07-11 08:37:36 +00:00
|
|
|
bool IsBlank() { return m_text.chars() == nullptr; }
|
2008-04-27 19:19:53 +00:00
|
|
|
|
|
|
|
/* does this item take up a number */
|
|
|
|
bool EatNumber() { return m_num; }
|
|
|
|
|
|
|
|
/* the text this item is to display */
|
2015-07-11 08:37:36 +00:00
|
|
|
const char *GetDisplay() { return m_text.chars(); }
|
2008-04-27 19:19:53 +00:00
|
|
|
|
|
|
|
/* sets this item to use a blank */
|
2015-07-11 08:37:36 +00:00
|
|
|
void SetBlank() { m_text = nullptr; }
|
2008-04-27 19:19:53 +00:00
|
|
|
|
|
|
|
/* sets this item to display text */
|
2015-07-11 08:37:36 +00:00
|
|
|
void SetText(const char *text) { m_text = text; }
|
2008-04-27 19:19:53 +00:00
|
|
|
|
|
|
|
/* sets whether or not this item takes up a line */
|
|
|
|
void SetEatNumber(bool val) { m_num = val; }
|
|
|
|
|
|
|
|
};
|
2005-07-29 06:33:57 +00:00
|
|
|
struct menuitem
|
|
|
|
{
|
2015-07-11 08:37:36 +00:00
|
|
|
ke::AString name;
|
|
|
|
ke::AString cmd;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
int access;
|
|
|
|
int handler;
|
2013-07-02 12:54:07 +00:00
|
|
|
bool isBlank;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
MENUITEM_CALLBACK pfn;
|
|
|
|
size_t id;
|
2006-02-08 05:39:03 +00:00
|
|
|
|
2015-07-11 08:37:36 +00:00
|
|
|
ke::Vector<BlankItem> blanks;
|
2005-07-29 06:33:57 +00:00
|
|
|
};
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
typedef unsigned int menu_t;
|
|
|
|
typedef unsigned int item_t;
|
|
|
|
typedef unsigned int page_t;
|
2005-07-29 06:33:57 +00:00
|
|
|
|
|
|
|
class Menu
|
|
|
|
{
|
|
|
|
public:
|
2007-09-02 18:35:53 +00:00
|
|
|
Menu(const char *title, AMX *amx, int fid);
|
2005-07-29 06:33:57 +00:00
|
|
|
~Menu();
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
menuitem *GetMenuItem(item_t item);
|
|
|
|
size_t GetPageCount();
|
|
|
|
size_t GetItemCount();
|
|
|
|
menuitem *AddItem(const char *name, const char *cmd, int access);
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
const char *GetTextString(int player, page_t page, int &keys);
|
|
|
|
bool Display(int player, page_t page);
|
2014-05-21 16:51:55 +00:00
|
|
|
void Close(int player);
|
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
int PagekeyToItem(page_t page, item_t key);
|
|
|
|
int GetMenuMenuid();
|
2006-02-03 03:00:48 +00:00
|
|
|
public:
|
2015-07-11 08:37:36 +00:00
|
|
|
ke::Vector<menuitem * > m_Items;
|
2006-02-03 03:00:48 +00:00
|
|
|
|
2015-07-11 08:37:36 +00:00
|
|
|
ke::AString m_Title;
|
|
|
|
ke::AutoString m_Text;
|
|
|
|
ke::AString m_OptNames[4];
|
|
|
|
ke::AString m_ItemColor;
|
2006-02-03 03:00:48 +00:00
|
|
|
|
2006-02-06 13:22:33 +00:00
|
|
|
bool m_NeverExit;
|
2014-05-21 20:18:48 +00:00
|
|
|
bool m_ForceExit;
|
2006-02-03 03:00:48 +00:00
|
|
|
bool m_AutoColors;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-07-29 06:33:57 +00:00
|
|
|
int menuId;
|
|
|
|
int thisId;
|
2006-02-08 22:09:31 +00:00
|
|
|
int func;
|
2006-02-09 11:53:22 +00:00
|
|
|
bool isDestroying;
|
2017-04-04 08:29:18 +00:00
|
|
|
int pageCallback;
|
2006-02-03 03:00:48 +00:00
|
|
|
public:
|
|
|
|
unsigned int items_per_page;
|
2005-07-29 06:33:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void ClearMenus();
|
2014-05-27 08:33:53 +00:00
|
|
|
Menu *get_menu_by_id(int id);
|
2016-01-14 16:50:25 +00:00
|
|
|
bool CloseNewMenus(CPlayer *pPlayer);
|
2005-07-29 06:33:57 +00:00
|
|
|
|
2015-07-11 08:37:36 +00:00
|
|
|
extern ke::Vector<Menu *> g_NewMenus;
|
2005-07-29 06:33:57 +00:00
|
|
|
extern AMX_NATIVE_INFO g_NewMenuNatives[];
|
|
|
|
|
|
|
|
#endif //_INCLUDE_NEWMENUS_H
|