Esempio n. 1
0
bool CShaderProgram::Enable()
{
  if (OK())
  {
    glUseProgram(m_shaderProgram);
    if (OnEnabled())
    {
      if (!m_validated)
      {
        // validate the program
        GLint params[4];
        glValidateProgram(m_shaderProgram);
        glGetProgramiv(m_shaderProgram, GL_VALIDATE_STATUS, params);
        if (params[0] != GL_TRUE)
        {
          GLchar log[LOG_SIZE];
          kodi::Log(ADDON_LOG_ERROR, "GL: Error validating shader");
          glGetProgramInfoLog(m_shaderProgram, LOG_SIZE, nullptr, log);
          kodi::Log(ADDON_LOG_ERROR, "%s", log);
        }
        m_validated = true;
      }
      return true;
    }
    else
    {
      glUseProgram(0);
      return false;
    }
    return true;
  }
  return false;
}
Esempio n. 2
0
	void Tool::SetEnabled(bool iEnabled)
	{
		mIsEnabled = iEnabled;

		if(mIsEnabled)
		{
			OnEnabled();
		}
		else
		{
			OnDisabled();
		}
	}
Esempio n. 3
0
void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) {
  if (m_bEnabled != bEnable) {
    for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
      if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
        pChild->EnableWindow(bEnable);
      }
    }

    m_bEnabled = bEnable;

    if (bEnable)
      OnEnabled();
    else
      OnDisabled();
  }
}
void CSmartMine::HandleEvent( const SGameObjectEvent& gameObjectEvent )
{
	const uint32 eventId = gameObjectEvent.event;
	void* pParam = gameObjectEvent.param;
	if ((eventId == eGFE_ScriptEvent) && (pParam != NULL))
	{
		const char* eventName = static_cast<const char*>(pParam);
		if (strcmp(eventName, "enable") == 0)
		{
			OnEnabled();
		}
		else if (strcmp(eventName, "disable") == 0)
		{
			OnDisabled();
		}
		else if (strcmp(eventName, "detonate") == 0)
		{
			StateMachineHandleEventBehavior( SStateEvent(STATE_EVENT_SMARTMINE_TRIGGER_DETONATE) );
		}
	}
	else if ((eventId == eMineGameObjectEvent_RegisterListener) && (pParam != NULL))
	{
		const EntityId listenerEntity = *((EntityId*)(pParam));
		CRY_ASSERT(listenerEntity != 0);
		if (listenerEntity != 0)
		{
			stl::push_back_unique( m_mineEventListeners, listenerEntity );
			UpdateTacticalIcon();
		}
	}
	else if ((eventId == eMineGameObjectEvent_UnRegisterListener) && (pParam != NULL))
	{
		const EntityId listenerEntity = *((EntityId*)(pParam));
		CRY_ASSERT(listenerEntity != 0);
		if (listenerEntity != 0)
		{
			stl::find_and_erase( m_mineEventListeners, listenerEntity );
		}
	}
	else if (eventId == eMineGameObjectEvent_OnNotifyDestroy)
	{
		StateMachineHandleEventBehavior( SStateEvent(STATE_EVENT_SMARTMINE_TRIGGER_DETONATE) );
	}
}
ECode AppWidgetProvider::OnReceive(
    /* [in] */ IContext* context,
    /* [in] */ IIntent* intent)
{
    // Protect against rogue update broadcasts (not really a security issue,
    // just filter bad broacasts out so subclasses are less likely to crash).
    String action;
    intent->GetAction(&action);
    if (IAppWidgetManager::ACTION_APPWIDGET_UPDATE.Equals(action)) {
        AutoPtr<IBundle> extras;
        intent->GetExtras((IBundle**)&extras);
        if (extras != NULL) {
            AutoPtr< ArrayOf<Int32> > appWidgetIds;
            extras->GetInt32Array(
                    IAppWidgetManager::EXTRA_APPWIDGET_IDS, (ArrayOf<Int32>**)&appWidgetIds);
            if (appWidgetIds != NULL && appWidgetIds->GetLength() > 0) {
                AutoPtr<IAppWidgetManagerHelper> helper;
                CAppWidgetManagerHelper::AcquireSingleton((IAppWidgetManagerHelper**)&helper);
                AutoPtr<IAppWidgetManager> manager;
                helper->GetInstance(context, (IAppWidgetManager**)&manager);
                OnUpdate(context, manager, *appWidgetIds);
            }
        }
    }
    else if (IAppWidgetManager::ACTION_APPWIDGET_DELETED.Equals(action)) {
        AutoPtr<IBundle> extras;
        intent->GetExtras((IBundle**)&extras);
        Boolean result;
        if (extras != NULL && (extras->ContainsKey(IAppWidgetManager::EXTRA_APPWIDGET_ID, &result), result)) {
            Int32 appWidgetId;
            extras->GetInt32(IAppWidgetManager::EXTRA_APPWIDGET_ID, &appWidgetId);
            AutoPtr< ArrayOf<Int32> > idsArray = ArrayOf<Int32>::Alloc(1);
            (*idsArray)[0] = appWidgetId;
            OnDeleted(context, *idsArray);
        }
    }
    else if (IAppWidgetManager::ACTION_APPWIDGET_OPTIONS_CHANGED.Equals(action)) {
        AutoPtr<IBundle> extras;
        intent->GetExtras((IBundle**)&extras);
        Boolean result;
        if (extras != NULL && (extras->ContainsKey(IAppWidgetManager::EXTRA_APPWIDGET_ID, &result), result)
                && (extras->ContainsKey(IAppWidgetManager::EXTRA_APPWIDGET_OPTIONS, &result), result)) {
            Int32 appWidgetId;
            extras->GetInt32(IAppWidgetManager::EXTRA_APPWIDGET_ID, &appWidgetId);
            AutoPtr<IBundle> widgetExtras;
            extras->GetBundle(IAppWidgetManager::EXTRA_APPWIDGET_OPTIONS, (IBundle**)&widgetExtras);
            AutoPtr<IAppWidgetManagerHelper> helper;
            CAppWidgetManagerHelper::AcquireSingleton((IAppWidgetManagerHelper**)&helper);
            AutoPtr<IAppWidgetManager> manager;
            helper->GetInstance(context, (IAppWidgetManager**)&manager);
            OnAppWidgetOptionsChanged(context, manager, appWidgetId, widgetExtras);
        }
    }
    else if (IAppWidgetManager::ACTION_APPWIDGET_ENABLED.Equals(action)) {
        OnEnabled(context);
    }
    else if (IAppWidgetManager::ACTION_APPWIDGET_DISABLED.Equals(action)) {
        OnDisabled(context);
    }

    return NOERROR;
}