本文整理汇总了C++中IBaseMenu类的典型用法代码示例。如果您正苦于以下问题:C++ IBaseMenu类的具体用法?C++ IBaseMenu怎么用?C++ IBaseMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IBaseMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetVoteResultCallback
static cell_t SetVoteResultCallback(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
IPluginFunction *pFunction = pContext->GetFunctionById(params[2]);
if (!pFunction)
{
return pContext->ThrowNativeError("Invalid function %x", params[2]);
}
void *array[2];
array[0] = pFunction;
array[1] = (void *)¶ms[2];
IMenuHandler *pHandler = menu->GetHandler();
if (!pHandler->OnSetHandlerOption("set_vote_results_handler", (const void *)array))
{
return pContext->ThrowNativeError("The given menu does not support this option");
}
return 1;
}
示例2: SetMenuNoVoteButton
static cell_t SetMenuNoVoteButton(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
unsigned int flags = menu->GetMenuOptionFlags();
if (params[2])
{
flags |= MENUFLAG_BUTTON_NOVOTE;
} else {
flags &= ~MENUFLAG_BUTTON_NOVOTE;
}
menu->SetMenuOptionFlags(flags);
unsigned int new_flags = menu->GetMenuOptionFlags();
return (flags == new_flags);
}
示例3: GetMenuItem
static cell_t GetMenuItem(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
ItemDrawInfo dr;
const char *info;
if ((info=menu->GetItemInfo(params[2], &dr)) == NULL)
{
return 0;
}
pContext->StringToLocalUTF8(params[3], params[4], info, NULL);
pContext->StringToLocalUTF8(params[6], params[7], dr.display ? dr.display : "", NULL);
cell_t *addr;
pContext->LocalToPhysAddr(params[5], &addr);
*addr = dr.style;
return 1;
}
示例4: CreateMenuEx
static cell_t CreateMenuEx(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IMenuStyle *style;
if (hndl != 0)
{
if ((err=g_Menus.ReadStyleHandle(params[1], &style)) != HandleError_None)
{
return pContext->ThrowNativeError("MenuStyle handle %x is invalid (error %d)", hndl, err);
}
} else {
style = g_Menus.GetDefaultStyle();
}
IPluginFunction *pFunction;
if ((pFunction=pContext->GetFunctionById(params[2])) == NULL)
{
return pContext->ThrowNativeError("Function id %x is invalid", params[2]);
}
CMenuHandler *handler = g_MenuHelpers.GetMenuHandler(pFunction, params[3]);
IBaseMenu *pMenu = style->CreateMenu(handler, pContext->GetIdentity());
hndl = pMenu->GetHandle();
if (!hndl)
{
pMenu->Destroy();
return BAD_HANDLE;
}
return hndl;
}
示例5: OnHandleDestroy
void MenuManager::OnHandleDestroy(HandleType_t type, void *object)
{
if (type == m_MenuType)
{
IBaseMenu *menu = (IBaseMenu *)object;
menu->Destroy(false);
}
else if (type == m_StyleType)
{
/* Do nothing */
}
}
示例6: GetMenuExitBackButton
static cell_t GetMenuExitBackButton(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
return ((menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXITBACK) == MENUFLAG_BUTTON_EXIT) ? 1 : 0;
}
示例7: DisplayMenuAtItem
static cell_t DisplayMenuAtItem(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
return menu->DisplayAtItem(params[2], params[4], params[3]) ? 1 : 0;
}
示例8: GetMenuItemCount
static cell_t GetMenuItemCount(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
return menu->GetItemCount();
}
示例9: ShowBaseMenu
void CRPGPlayer::ShowBaseMenu()
{
IMenuStyle *style = menus->GetDefaultStyle();
IBaseMenu *menu = style->CreateMenu(&g_RPGPlugin, myself->GetIdentity());
menu->SetDefaultTitle(MENU_BASE_TITLE);
for (int i = 0; i < BASEMENUCHOICES; i++)
{
menu->AppendItem(BaseMenuChoices[i], ItemDrawInfo(BaseMenuChoices[i]));
}
//menu->SetMenuOptionFlags( menu->GetMenuOptionFlags() | MENUFLAG_BUTTON_EXIT );
menu->Display(this->GetIndex(), MENU_TIME_FOREVER);
}
示例10: ShowChar
void CRPGPlayer::ShowChar()
{
IMenuStyle *style = menus->GetDefaultStyle();
IBaseMenu *menu = style->CreateMenu(&g_RPGPlugin, myself->GetIdentity());
IMenuPanel *panel = menu->CreatePanel();
menu->SetDefaultTitle(MENU_CHAR_TITLE);
panel->DrawTitle(MENU_CHAR_TITLE);
char text[255];
sprintf(text, "Player ID: %d", GetSQLIndex());
panel->DrawItem(ItemDrawInfo(text));
int classnum = GetCurrentClass();
if (classnum > RPG_CLASS_NONE)
{
int team = GetCachedTeam();
if ( team == TEAM_SURVIVORS)
{
sprintf(text, "Class: %s", HumanClasses[classnum]);
}
else if (team == TEAM_UNDEAD)
{
sprintf(text, "Class: %s", ZombieClasses[classnum]);
}
else
{
sprintf(text, "Class: None");
}
panel->DrawItem(ItemDrawInfo(text)); // item 1
sprintf(text, "Level: %d", GetLevel());
panel->DrawItem(ItemDrawInfo(text)); // item 2
sprintf(text, "Experience: %d", GetExperience());
panel->DrawItem(ItemDrawInfo(text)); // item 3
for (int i = 0; i < MAX_SKILLS; i++) // item 4-7
{
sprintf(text, "%s - (Level %d)", SkillNames[skills[i].iIndex], skills[i].iLevel);
panel->DrawItem(ItemDrawInfo(text));
}
}
panel->SendDisplay(GetIndex(), &g_RPGPlugin, MENU_TIME_FOREVER );
}
示例11: SetMenuOptionFlags
static cell_t SetMenuOptionFlags(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
menu->SetMenuOptionFlags(params[2]);
return 1;
}
示例12: GetMenuTitle
static cell_t GetMenuTitle(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
size_t written;
const char *title = menu->GetDefaultTitle();
pContext->StringToLocalUTF8(params[2], params[3], title, &written);
return (cell_t)written;
}
示例13: SetMenuTitle
static cell_t SetMenuTitle(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
char buffer[1024];
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
menu->SetDefaultTitle(buffer);
return 1;
}
示例14: CreatePanelFromMenu
static cell_t CreatePanelFromMenu(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
IMenuPanel *panel = menu->CreatePanel();
hndl = MakePanelHandle(panel, pContext);
if (!hndl)
{
panel->DeleteThis();
}
return hndl;
}
示例15: InsertMenuItem
static cell_t InsertMenuItem(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
char *info;
ItemDrawInfo dr;
pContext->LocalToString(params[3], &info);
pContext->LocalToString(params[4], (char **)&dr.display);
dr.style = params[5];
return menu->InsertItem(params[2], info, dr) ? 1 : 0;
}