Exemplo n.º 1
0
long VGUI_SurfaceWndProc( SDL_Event *event )
{
	SurfaceBase *surface = NULL;
	CEnginePanel *panel = NULL;
	App *pApp= NULL;

	if( !VGui_GetPanel( ))
		return 0;

	panel = (CEnginePanel *)VGui_GetPanel();
	surface = panel->getSurfaceBase();
	pApp = panel->getApp();

	ASSERT( pApp != NULL );
	ASSERT( surface != NULL );

	switch( event->type )
	{
	/*case :
		VGUI_ActivateCurrentCursor();
		break;*/
	case SDL_MOUSEMOTION:
		pApp->internalCursorMoved(event->motion.x, event->motion.y, surface );
		break;
	case SDL_MOUSEBUTTONDOWN:
		if(event->button.clicks == 1)
			pApp->internalMousePressed( VGUI_MapMouseButton( event->button.button ), surface );
		else pApp->internalMouseDoublePressed( VGUI_MapMouseButton( event->button.button ), surface );
		break;
	case SDL_MOUSEBUTTONUP:
		pApp->internalMouseReleased( VGUI_MapMouseButton( event->button.button ), surface );
		break;
	case SDL_MOUSEWHEEL:
		pApp->internalMouseWheeled(event->wheel.x, surface );
		break;
	case SDL_KEYDOWN:
		if(!( event->key.keysym.sym & ( 1 << 30 )))
			pApp->internalKeyPressed( VGUI_MapKey( event->key.keysym.sym ), surface );
		pApp->internalKeyTyped( VGUI_MapKey( event->key.keysym.sym ), surface );
		break;
	case SDL_KEYUP:
		pApp->internalKeyReleased( VGUI_MapKey( event->key.keysym.sym ), surface );
		break;
	}
	return 1;
}
Exemplo n.º 2
0
long VGUI_SurfaceWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    SurfaceBase *surface = NULL;
    CEnginePanel *panel = NULL;
    App *pApp= NULL;

    if( !VGui_GetPanel( ))
        return 0;

    panel = (CEnginePanel *)VGui_GetPanel();
    surface = panel->getSurfaceBase();
    pApp = panel->getApp();

    ASSERT( pApp != NULL );
    ASSERT( surface != NULL );

    switch( uMsg )
    {
    case WM_SETCURSOR:
        VGUI_ActivateCurrentCursor();
        break;
    case WM_MOUSEMOVE:
        pApp->internalCursorMoved((short)LOWORD( lParam ), (short)HIWORD( lParam ), surface );
        break;
    case WM_LBUTTONDOWN:
        pApp->internalMousePressed( MOUSE_LEFT, surface );
        break;
    case WM_RBUTTONDOWN:
        pApp->internalMousePressed( MOUSE_RIGHT, surface );
        break;
    case WM_MBUTTONDOWN:
        pApp->internalMousePressed( MOUSE_MIDDLE, surface );
        break;
    case WM_LBUTTONUP:
        pApp->internalMouseReleased( MOUSE_LEFT, surface );
        break;
    case WM_RBUTTONUP:
        pApp->internalMouseReleased( MOUSE_RIGHT, surface );
        break;
    case WM_MBUTTONUP:
        pApp->internalMouseReleased( MOUSE_MIDDLE, surface );
        break;
    case WM_LBUTTONDBLCLK:
        pApp->internalMouseDoublePressed( MOUSE_LEFT, surface );
        break;
    case WM_RBUTTONDBLCLK:
        pApp->internalMouseDoublePressed( MOUSE_RIGHT, surface );
        break;
    case WM_MBUTTONDBLCLK:
        pApp->internalMouseDoublePressed( MOUSE_MIDDLE, surface );
        break;
    case WM_MOUSEWHEEL:
        pApp->internalMouseWheeled(((short)HIWORD( wParam )) / 120, surface );
        break;
    case WM_KEYDOWN:
    case WM_SYSKEYDOWN:
        if(!( lParam & ( 1 << 30 )))
            pApp->internalKeyPressed( VGUI_MapKey( wParam ), surface );
        pApp->internalKeyTyped( VGUI_MapKey( wParam ), surface );
        break;
    case WM_CHAR:
    case WM_SYSCHAR:
        // already handled in Key_Event
        break;
    case WM_KEYUP:
    case WM_SYSKEYUP:
        pApp->internalKeyReleased( VGUI_MapKey( wParam ), surface );
        break;
    }
    return 1;
}
Exemplo n.º 3
0
bool UIManager::Initialize(const TRDescriptionList& inDesc, CSchemeManager* inSchemeManager)
{
	bool theSuccess = false;

	// Clear out everything in case we have already been used once
	this->Clear();

	// Now loop through entities found 
	for(TRDescriptionList::const_iterator theListIter = inDesc.begin(); theListIter != inDesc.end(); theListIter++)
	{
		// See if the factory knows how to create such a thing. It is giving the memory to us forever so take care of it.
		UIComponent* theCurrentComponent = this->mFactory->BuildComponent(*theListIter, inSchemeManager);

		// Tell it to set all the tags it knows about
		if(theCurrentComponent)
		{
			// Check for named root tag, look up that component and set it
            Panel* theRoot = NULL;
            string theRootName;
            
            if(theListIter->GetTagValue("root", theRootName))
            {
                UIComponent* theUIComponent = NULL;
                theUIComponent = this->GetComponentNamed(theRootName);
                if(theUIComponent)
                {
                    theRoot = theUIComponent->GetComponentPointer();
                }
            }

            // If none specified or it couldn't be found, use default
            if(!theRoot)
            {
                theRoot = (Panel*)VGui_GetPanel();
            }

            // Set the root
   			theCurrentComponent->GetComponentPointer()->setParent(theRoot);

            // Add to menu if specified
            string theMenuName;
            if(theListIter->GetTagValue(UITagMenuAddItem, theMenuName))
            {
                Menu* theParentMenu = NULL;
                if(this->GetVGUIComponentNamed(theMenuName, theParentMenu))
                {
                    theParentMenu->addMenuItem(theCurrentComponent->GetComponentPointer());
                }
            }
            
            // Set up scheme if specified
            if(inSchemeManager)
            {
                this->SetSchemeValues(*theListIter, theCurrentComponent, inSchemeManager);
            }

            // <sigh> If we are currently using the regular VGUI instead of the manager, translate
			// this component out of the way so it doesn't suck up input
			if(this->mUsingVGUI)
			{
				this->TranslateComponent(theCurrentComponent->GetComponentPointer(), true);
			}
			
			// If gamma aware, tell it immediately
			GammaAwareComponent* theGammaAwareComponent = dynamic_cast<GammaAwareComponent*>(theCurrentComponent->GetComponentPointer());
			if(theGammaAwareComponent)
			{
				theGammaAwareComponent->NotifyGammaChange(this->mGammaSlope);
			}

            // Save it. It is now part of the world.
			this->mComponentList.push_back(theCurrentComponent);
			
			// Return success if we found at least one component
			theSuccess = true;
		}
	}
	
	// Build default blank cursor
	this->mBlankCursor = new Cursor(vgui_LoadTGA("blank"), 0, 0);
	
    // Register for notification for all input events
    //this->AddInputSignal(this);
	
	return theSuccess;
}