Пример #1
0
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;
}
Пример #2
0
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 */
	}
}
Пример #3
0
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;
}