Revert adminmenu API changes.

This commit is contained in:
David Anderson 2014-12-11 23:34:00 -08:00
parent 5b69efe5d4
commit 61bf7de101
10 changed files with 44 additions and 9 deletions

View File

@ -449,6 +449,21 @@ static cell_t TopMenu_AddCategory(IPluginContext *pContext, const cell_t *params
return AddToTopMenu(pContext, new_params); return AddToTopMenu(pContext, new_params);
} }
static cell_t TopMenu_FromHandle(IPluginContext *pContext, const cell_t *params)
{
HandleError err;
TopMenu *pMenu;
HandleSecurity sec(pContext->GetIdentity(), myself->GetIdentity());
if ((err = handlesys->ReadHandle(params[1], hTopMenuType, &sec, (void **)&pMenu))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
}
return params[1];
}
sp_nativeinfo_t g_TopMenuNatives[] = sp_nativeinfo_t g_TopMenuNatives[] =
{ {
{"AddToTopMenu", AddToTopMenu}, {"AddToTopMenu", AddToTopMenu},
@ -474,6 +489,7 @@ sp_nativeinfo_t g_TopMenuNatives[] =
{"TopMenu.GetInfoString", GetTopMenuInfoString}, {"TopMenu.GetInfoString", GetTopMenuInfoString},
{"TopMenu.GetObjName", GetTopMenuName}, {"TopMenu.GetObjName", GetTopMenuName},
{"TopMenu.CacheTitles.set", SetTopMenuTitleCaching}, {"TopMenu.CacheTitles.set", SetTopMenuTitleCaching},
{"TopMenu.FromHandle", TopMenu_FromHandle},
{NULL, NULL}, {NULL, NULL},
}; };

View File

@ -124,8 +124,10 @@ LoadBanReasons()
} }
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {

View File

@ -100,8 +100,10 @@ public OnPluginStart()
} }
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {

View File

@ -146,8 +146,10 @@ bool:IsClientAllowedToChangeCvar(client, const String:cvarname[])
return allowed; return allowed;
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {

View File

@ -132,8 +132,10 @@ public OnConfigsExecuted()
g_mapCount = LoadMapList(g_MapList); g_mapCount = LoadMapList(g_MapList);
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {

View File

@ -258,8 +258,10 @@ public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast
KillAllDrugs(); KillAllDrugs();
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {

View File

@ -135,8 +135,10 @@ public OnPluginStart()
} }
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {

View File

@ -65,7 +65,7 @@
* @param topmenu Handle to the admin menu's TopMenu. * @param topmenu Handle to the admin menu's TopMenu.
* @noreturn * @noreturn
*/ */
forward OnAdminMenuCreated(TopMenu topmenu); forward OnAdminMenuCreated(Handle topmenu);
/** /**
* Called when the admin menu is ready to have items added. * Called when the admin menu is ready to have items added.
@ -73,7 +73,7 @@ forward OnAdminMenuCreated(TopMenu topmenu);
* @param topmenu Handle to the admin menu's TopMenu. * @param topmenu Handle to the admin menu's TopMenu.
* @noreturn * @noreturn
*/ */
forward OnAdminMenuReady(TopMenu topmenu); forward OnAdminMenuReady(Handle topmenu);
/** /**
* Retrieves the Handle to the admin top menu. * Retrieves the Handle to the admin top menu.

View File

@ -146,6 +146,11 @@ methodmap TopMenu < Handle
// @return A new TopMenu. // @return A new TopMenu.
public native TopMenu(TopMenuHandler handler); public native TopMenu(TopMenuHandler handler);
// Returns a TopMenu handle from a generic handle. If the given handle is
// a TopMenu, the handle is simply casted back. Otherwise, an error is
// raised.
public static native TopMenu FromHandle(Handle handle);
// Re-sorts the items in a TopMenu via a configuration file. // Re-sorts the items in a TopMenu via a configuration file.
// //
// The format of the configuration file should be a Valve Key-Values // The format of the configuration file should be a Valve Key-Values

View File

@ -76,8 +76,10 @@ public OnPluginStart()
} }
} }
public OnAdminMenuReady(TopMenu topmenu) public OnAdminMenuReady(Handle aTopMenu)
{ {
TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
/* Block us from being called twice */ /* Block us from being called twice */
if (topmenu == hTopMenu) if (topmenu == hTopMenu)
{ {