当前位置: 首页>>代码示例>>C++>>正文


C++ IBaseMenu类代码示例

本文整理汇总了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 *)&params[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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:29,代码来源:smn_menus.cpp

示例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);
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:25,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:28,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:34,代码来源:smn_menus.cpp

示例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 */
	}
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:12,代码来源:MenuManager.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:13,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:13,代码来源:smn_menus.cpp

示例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();
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:13,代码来源:smn_menus.cpp

示例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);

}
开发者ID:blaisebaileyfinnegan,项目名称:ZPS-RPG,代码行数:14,代码来源:rpgplayer.cpp

示例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 );
}
开发者ID:blaisebaileyfinnegan,项目名称:ZPS-RPG,代码行数:50,代码来源:rpgplayer.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:15,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:17,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:18,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:20,代码来源:smn_menus.cpp

示例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;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:20,代码来源:smn_menus.cpp


注:本文中的IBaseMenu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。