コード例 #1
0
ファイル: window.cpp プロジェクト: Ezeer/VegaStrike_win32FR
//Draw all visible windows.
void WindowManager::draw()
{
    GFXHudMode( true );            //Load identity matrices.
    GFXColorf( GUI_OPAQUE_WHITE() );

    GFXDisable( DEPTHTEST );
    GFXEnable( DEPTHWRITE );
    GFXDisable( LIGHTING );
    GFXDisable( CULLFACE );
    GFXClear( GFXTRUE );
    GFXDisable( DEPTHWRITE );
    GFXBlendMode( SRCALPHA, INVSRCALPHA );
    GFXDisable( TEXTURE1 );
    GFXEnable( TEXTURE0 );
    //Just loop through all the windows, and remember if anything gets drawn.
    //Since the first window in the list is drawn first, z-order is
    //maintained.  First entry is the bottom window, last is the top window.
    //FIXME mbyron -- I think the event manager needs to get involved with window z-order.
    //(Mouse events should go to windows in zorder, shouldn't they?)
    for (size_t i = 0; i < m_windows.size(); i++) 
    {
        if ( m_windows[i]->controller() )//it's a controller
            m_windows[i]->controller()->draw();//that can draw
        if ( i < m_windows.size() ) 
        m_windows[i]->draw();
    }
    //Emulate EndGUIFrame.
    static VSSprite MouseVSSprite( "mouse.spr", BILINEAR, GFXTRUE );
    static Texture  dummy( "white.bmp", 0, NEAREST, TEXTURE2D, TEXTURE_2D, GFXTRUE );
    GFXDisable( CULLFACE );
    ConditionalCursorDraw( true );
    //Figure position of cursor sprite.
    float sizex     = 0.0, sizey = 0.0;
    const Point loc = globalEventManager().mouseLoc();
    MouseVSSprite.GetSize( sizex, sizey );
    float tempx     = 0.0, tempy = 0.0;
    MouseVSSprite.GetPosition( tempx, tempy );
    MouseVSSprite.SetPosition( tempx+loc.x+sizex/2, tempy+loc.y+sizey/2 );

    dummy.MakeActive();
    GFXBlendMode( SRCALPHA, INVSRCALPHA );
    GFXColorf( GUI_OPAQUE_WHITE() );

    //Draw the cursor sprite.
    GFXEnable( TEXTURE0 );
    GFXDisable( DEPTHTEST );
    GFXDisable( TEXTURE1 );
    MouseVSSprite.Draw();

    GFXHudMode( false );
    GFXEnable( CULLFACE );
    MouseVSSprite.SetPosition( tempx, tempy );
}
コード例 #2
0
ファイル: homiesProc_win.cpp プロジェクト: PtrickH/homies
PROTECTED RETCODE WinProc(DWORD msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case GMSG_INIT:
		g_exit=eEXIT_NO;
		g_timeAmt = (int)lParam;
		g_bkgrnd = TextureSearch((unsigned int)wParam);
		TextureAddRef(g_bkgrnd);

		g_fnt=MenuFontGet(WINFNTIND);

		TimerInit(&g_delay, 1, WINDELAY);
		TimerInit(&g_counterDelay, 1000, 10);
		break;

	case GMSG_UPDATE:
		if(g_exit==eEXIT_NO)
		{
			if(TimerEllapse(&g_counterDelay))
			{
				if(g_timeAmt > 0)
				{
					g_gameScore++;
					g_timeAmt--;
				}
			}

			if(TimerEllapse(&g_delay) || InputKbAnyKeyReleased())
			{
				g_gameScore += g_timeAmt;
				g_timeAmt=0;
				g_exit=eEXIT_OK;
			}

			if(g_exit!=eEXIT_NO)
				_GUTBKFXExitProc(eBKFX_FADEINOUT,0);
		}
		break;

	case GMSG_DISPLAY:
		{
			GFXClear(0, 0, 0);   //clears screen within rects with given color

			char buff[MAXCHARBUFF];

			SIZE fntSz;

			float x=GFXGetScrnSize().cx/2;
			float y=GFXGetScrnSize().cy/4;

			GFXBltModeEnable(false);
			
			TextureStretchBlt(g_bkgrnd, 0,0, GFXGetScrnSize().cx, GFXGetScrnSize().cy, 0,0,0);

			sprintf(buff, "Time: %d", g_timeAmt);
			FontGetStrSize(g_fnt, buff, &fntSz);
			FontPrintf2D(g_fnt, x-(fntSz.cx/2), y, 0x7fffffff, buff);

			sprintf(buff, "Score: %d", g_gameScore);
			FontGetStrSize(g_fnt, buff, &fntSz);
			FontPrintf2D(g_fnt, x-(fntSz.cx/2), y+fntSz.cy, 0x7fffffff, buff);
			GFXBltModeDisable();

			if(_GUTBKFXUpdate() == RETCODE_BREAK && g_exit != eEXIT_NO)
			{
				SENDPROCMSG(GMSG_DESTROY, 0, 0);

				g_gameMaps.curMap++;

				switch(g_exit)
				{
				case eEXIT_OK:
					//max level
					if(g_gameMaps.curMap >= g_gameMaps.numMap)
					{
						//we finished all the maps!
						SETPROCTYPE(eWinAll);
						SENDPROCMSG(GMSG_INIT, 0, 0);
					}
					else
					{
						SETPROCTYPE(eGame);
						SENDPROCMSG(GMSG_INIT, 0, 0);
					}
					break;
				}
			}
			
			GFXUpdate(0, 0, 0);  //update frame on display
		}
		break;

	case GMSG_LOAD:
		break;

	case GMSG_DESTROY:
		TextureDestroy(&g_bkgrnd);
		break;
	}

	return RETCODE_SUCCESS;
}
コード例 #3
0
ファイル: homiesProc_edit.cpp プロジェクト: PtrickH/homies
PROTECTED RETCODE EditorProc(DWORD msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case GMSG_INIT:
		g_exit=eEXIT_NO;

		_GUTBKFXEnterProc(eBKFX_FADEINOUT,0);

		g_win = MenuGetItem(MID_EDITOR);

		if(!g_win)
		{
			char path[MAXCHARBUFF];

			//load up the menu
			strcpy(path, WINDOWDIR);
			strcat(path, EDITORFILE);

			FILE *fp = fopen(path, "rt");
			MenuLoadFromFile (fp);
			fclose(fp);

			g_win = MenuGetItem(MID_EDITOR);

			WindowChangeSize((HWINDOW)g_win, GFXGetScrnSize().cx, GFXGetScrnSize().cy);
			WindowNewProc((HWINDOW)g_win, EditorWinProc);
		}
		else
			MenuShowItem(g_win, HMC_ACTIVE, 1);

		char buff[MAXCHARBUFF];
		sprintf(buff, "%d. %s", g_gameMaps.curMap, GetFilePart(g_gameMaps.maps[g_gameMaps.curMap].mapFile));
		TextBoxChangeText((HTEXTBOX)MenuGetItem(MID_EDITOR_TXTBOX), buff);

		break;

	case GMSG_UPDATE:
		if(g_exit==eEXIT_NO)
		{
			MenuProc();			 //update the windows

			if(g_exit!=eEXIT_NO)
				_GUTBKFXExitProc(eBKFX_FADEINOUT,0);
		}
		break;

	case GMSG_DISPLAY:
		GFXClear(0, 0, 0);   //clears screen within rects with given color

		GFXBltModeEnable(false);
		MenuDraw();			 //draw all menus
		GFXBltModeDisable();

		if(_GUTBKFXUpdate() == RETCODE_BREAK && g_exit != eEXIT_NO)
		{
			SENDPROCMSG(GMSG_DESTROY, 0, 0);

			mapEditInfo mapEdit={0};

			switch(g_exit)
			{
			case eEXIT_EDIT:
				SETPROCTYPE(eEditMap);

				//hardcoded for now...
				strcpy(mapEdit.mapName, GetFilePart(g_gameMaps.maps[g_gameMaps.curMap].mapFile));

				SENDPROCMSG(GMSG_INIT, (WPARAM)&mapEdit, 0);
				break;
			case eEXIT_NEW:
				SETPROCTYPE(eEditNew);
				SENDPROCMSG(GMSG_INIT, 0, 0);
				break;
			case eEXIT_CANCEL:
				SETPROCTYPE(eMainMenu);
				SENDPROCMSG(GMSG_INIT, 0, 0);
				break;
			}
		}
		
		GFXUpdate(0, 0, 0);  //update frame on display
		break;

	case GMSG_LOAD:
		break;

	case GMSG_DESTROY:
		if(g_win)
			MenuShowItem(g_win, HMC_INVIS, 1);
		break;
	}

	return RETCODE_SUCCESS;
}