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
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
#ifndef MENUS_H
|
|
|
|
#define MENUS_H
|
|
|
|
|
|
|
|
// *****************************************************
|
|
|
|
// class MenuMngr
|
|
|
|
// *****************************************************
|
|
|
|
|
|
|
|
class MenuMngr
|
|
|
|
{
|
2005-09-10 00:38:42 +00:00
|
|
|
struct MenuIdEle
|
|
|
|
{
|
2015-07-11 08:37:36 +00:00
|
|
|
ke::AString name;
|
2005-09-10 00:38:42 +00:00
|
|
|
AMX* amx;
|
|
|
|
MenuIdEle* next;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
int id;
|
|
|
|
static int uniqueid;
|
|
|
|
|
|
|
|
MenuIdEle(const char* n, AMX* a, MenuIdEle* m) : name(n), amx(a), next(m)
|
|
|
|
{
|
|
|
|
id = ++uniqueid;
|
|
|
|
}
|
|
|
|
} *headid;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
public:
|
2005-09-10 00:38:42 +00:00
|
|
|
class iterator;
|
2004-01-31 20:56:22 +00:00
|
|
|
private:
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
class MenuCommand
|
|
|
|
{
|
|
|
|
friend class iterator;
|
|
|
|
friend class MenuMngr;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
CPluginMngr::CPlugin *plugin;
|
|
|
|
int menuid;
|
|
|
|
int keys;
|
|
|
|
int function;
|
2007-09-02 18:35:53 +00:00
|
|
|
int is_new_menu;
|
2005-09-16 23:48:51 +00:00
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
MenuCommand* next;
|
2007-09-02 18:35:53 +00:00
|
|
|
MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f, bool new_menu=false);
|
2005-09-10 00:38:42 +00:00
|
|
|
public:
|
|
|
|
inline int getFunction() { return function; }
|
|
|
|
inline CPluginMngr::CPlugin* getPlugin() { return plugin; }
|
2007-09-02 18:35:53 +00:00
|
|
|
inline bool matchCommand(int m, int k)
|
|
|
|
{
|
|
|
|
return ((m == menuid) && (keys & k));
|
|
|
|
}
|
2005-09-10 00:38:42 +00:00
|
|
|
} *headcmd;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
|
|
|
public:
|
2006-11-21 23:59:21 +00:00
|
|
|
MenuMngr() : m_watch_iter(end())
|
|
|
|
{ headid = NULL; headcmd = NULL; }
|
2004-01-31 20:56:22 +00:00
|
|
|
~MenuMngr();
|
|
|
|
|
|
|
|
// Interface
|
|
|
|
|
|
|
|
int findMenuId(const char* name, AMX* a = 0);
|
2005-09-10 00:38:42 +00:00
|
|
|
int registerMenuId(const char* n, AMX* a);
|
2007-09-02 18:35:53 +00:00
|
|
|
void registerMenuCmd(CPluginMngr::CPlugin *a, int mi, int k, int f, bool from_new_menu=false);
|
2004-01-31 20:56:22 +00:00
|
|
|
void clear();
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
class iterator
|
|
|
|
{
|
2006-11-21 23:59:21 +00:00
|
|
|
friend class MenuMngr;
|
2004-01-31 20:56:22 +00:00
|
|
|
MenuCommand* a;
|
|
|
|
public:
|
|
|
|
iterator(MenuCommand*aa) : a(aa) {}
|
|
|
|
iterator& operator++() { a = a->next; return *this; }
|
|
|
|
bool operator==(const iterator& b) const { return a == b.a; }
|
|
|
|
bool operator!=(const iterator& b) const { return !operator==(b); }
|
|
|
|
operator bool () const { return a ? true : false; }
|
|
|
|
MenuCommand& operator*() { return *a; }
|
|
|
|
};
|
2005-09-10 00:38:42 +00:00
|
|
|
|
2004-01-31 20:56:22 +00:00
|
|
|
inline iterator begin() const { return iterator(headcmd); }
|
|
|
|
inline iterator end() const { return iterator(0); }
|
2006-11-21 23:59:21 +00:00
|
|
|
|
|
|
|
MenuMngr::iterator SetWatchIter(MenuMngr::iterator iter);
|
|
|
|
inline MenuMngr::iterator GetWatchIter() { return m_watch_iter; }
|
|
|
|
private:
|
|
|
|
MenuMngr::iterator m_watch_iter;
|
2004-01-31 20:56:22 +00:00
|
|
|
};
|
|
|
|
|
2007-09-02 18:35:53 +00:00
|
|
|
extern MenuMngr g_menucmds;
|
|
|
|
|
2005-09-10 00:38:42 +00:00
|
|
|
#endif //MENUS_H
|