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


C++ IBaseMenu::GetHandle方法代码示例

本文整理汇总了C++中IBaseMenu::GetHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ IBaseMenu::GetHandle方法的具体用法?C++ IBaseMenu::GetHandle怎么用?C++ IBaseMenu::GetHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBaseMenu的用法示例。


在下文中一共展示了IBaseMenu::GetHandle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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

示例2: CreateMenu

static cell_t CreateMenu(IPluginContext *pContext, const cell_t *params)
{
    IMenuStyle *style = g_Menus.GetDefaultStyle();
    IPluginFunction *pFunction;

    if ((pFunction=pContext->GetFunctionById(params[1])) == NULL)
    {
        return pContext->ThrowNativeError("Function id %x is invalid", params[1]);
    }

    CMenuHandler *handler = g_MenuHelpers.GetMenuHandler(pFunction, params[2]);
    IBaseMenu *menu = style->CreateMenu(handler, pContext->GetIdentity());

    Handle_t hndl = menu->GetHandle();
    if (!hndl)
    {
        menu->Destroy();
        return BAD_HANDLE;
    }

    return hndl;
}
开发者ID:War3Evo,项目名称:sourcemod,代码行数:22,代码来源:smn_menus.cpp

示例3: ClientPressedKey


//.........这里部分代码省略.........
			clients[0] = client;
			filter.Initialize(clients, 1);

			const char *sound = g_Menus.GetMenuSound(type);

			if (sound != NULL)
			{
				edict_t *pEdict = PEntityOfEntIndex(client);
				if (pEdict)
				{
					ICollideable *pCollideable = pEdict->GetCollideable();

					if (pCollideable)
					{
						const Vector & pos = pCollideable->GetCollisionOrigin();
						enginesound->EmitSound(filter, 
							client, 
							CHAN_AUTO, 
#if SOURCE_ENGINE >= SE_PORTAL2
							sound, 
							-1, 
#endif
							sound, 
							VOL_NORM, 
							ATTN_NORM, 
#if SOURCE_ENGINE >= SE_PORTAL2
							0, 
#endif
							0, 
							PITCH_NORM, 
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
	|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2
							0,
#endif
							&pos);
					}
				}
			}
		}

		/* For navigational items, we're going to redisplay */
		if (type == ItemSel_Back)
		{
			if (!RedoClientMenu(client, ItemOrder_Descending))
			{
				cancel = true;
				reason = MenuCancel_NoDisplay;
				end_reason = MenuEnd_Cancelled;
			} else {
				return;
			}
		} else if (type == ItemSel_Next) {
			if (!RedoClientMenu(client, ItemOrder_Ascending))
			{
				cancel = true;						/* I like Saltines. */
				reason = MenuCancel_NoDisplay;
				end_reason = MenuEnd_Cancelled;
			} else {
				return;
			}
		} else if (type == ItemSel_Exit || type == ItemSel_None) {
			cancel = true;
			reason = MenuCancel_Exit;
			end_reason = MenuEnd_Exit;
		} else if (type == ItemSel_ExitBack) {
			cancel = true;
			reason = MenuCancel_ExitBack;
			end_reason = MenuEnd_ExitBack;
		} else {
			item = states.slots[key_press].item;
		}
	}

	/* Clear states */
	player->bInMenu = false;
	if (player->menuHoldTime)
	{
		RemoveClientFromWatch(client);
	}

	Handle_t hndl = menu ? menu->GetHandle() : BAD_HANDLE;
	AutoHandleRooter ahr(hndl);

	if (cancel)
	{
		mh->OnMenuCancel(menu, client, reason);
	} else {
		mh->OnMenuSelect(menu, client, item);
		if (mh->GetMenuAPIVersion2() >= 13)
		{
			mh->OnMenuSelect2(menu, client, item, item_on_page);
		}
	}

	/* Only fire end for valid menus */
	if (menu)
	{
		mh->OnMenuEnd(menu, end_reason);
	}
}
开发者ID:404UserNotFound,项目名称:sourcemod,代码行数:101,代码来源:MenuStyle_Base.cpp


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