コード例 #1
0
void InitializeGame(int x_cur, int y_cur)
{
	int i,j;
	for (i=0; i<15; i++) {
		for (j=0; j<15; j++) {
		    board_state[i][j]=EMPTY;
		}
	}
	DrawNumber(level,3,2,EMPTY);
	DrawWinning(0,1, EMPTY);
	DrawStatus(1, 21, EMPTY,PVP);
	DrawBack(3,1119,EMPTY);
	count=0;
	time0=0;
	turn=HUMAN_PLAYER;
	step_flag=0;
	win_flag=0;

	DrawBoard();
	DrawChess(x_cur, y_cur, CURSOR);
	DrawTime(88, EMPTY);
	DrawTime(30, turn);
	DrawStatus(1, 21, COMPUTER_PLAYER,PVP);
	xil_printf("\r\nGame Start!\r\n");

}
コード例 #2
0
ファイル: ui.cpp プロジェクト: CecilHarvey/lord
int CUIManager::UIBid(int iAtLeast)
{
   CBox box(200, 260, 225, 32, 80, 50, 200, 128, false);
   CButton btn1(1, 205, 265, 50, 22, 250, 70, 250);
   CButton btn2(2, 260, 265, 50, 22, 250, 70, 250);
   CButton btn3(3, 315, 265, 50, 22, 250, 70, 250);
   CButton btn4(0, 370, 265, 50, 22, 250, 70, 250);

   gpGeneral->DrawImage(iAtLeast > 1 ? IMG_1PD : IMG_1P, 210, 267);
   gpGeneral->DrawImage(iAtLeast > 2 ? IMG_2PD : IMG_2P, 265, 267);
   gpGeneral->DrawImage(IMG_3P, 320, 267);
   gpGeneral->DrawImage(IMG_NOTCALL, 375, 267);

   time_t t;
   time(&t);

   while (time(NULL) - t < 30) {
      DrawTime(30 - (time(NULL) - t));
      int key = gpGeneral->ReadKey(false) - SDLK_LAST;
      if ((key >= iAtLeast && key <= 3) || !key) {
         return key;
      }
      // allow using the keyboard as well
      key += SDLK_LAST - '0';
      if ((key >= iAtLeast && key <= 3) || !key) {
         return key;
      }
   }

   return 0;
}
コード例 #3
0
ファイル: game.cpp プロジェクト: minamiliu/Time_To_Shoot
/*******************************************************************************
関数名:	void DrawGame(void)
引数:	なし
戻り値:	なし
説明:	ゲームの描画関数
*******************************************************************************/
void DrawGame(void)
{
	//カメラの設置
	SetCamera();

	//ステージの描画処理
	DrawStageManager();
	DrawMeshDome();
	
	//DrawModel();
	DrawParticle();
	DrawEnemy();
	DrawEnemyBullet();
	DrawItemBullet();

	if( IsDebugMode()) DrawPlayer();
	
	DrawPlayerBullet();
	DrawGun();
	DrawShadow();
	//DrawBillBoard();	

	DrawTime();
	DrawGunSight();
	DrawNumBullet();
	DrawNumLife();
	DrawClock();
	DrawEnemyNum();
}
コード例 #4
0
ファイル: ui.cpp プロジェクト: CecilHarvey/lord
// Return the number of the discarded cards, and store the discarded cards into d.
int CUIManager::UIDiscard(const CCard handcard[20], int count_hc, CCard *d, bool firsthand)
{
   int i, k;

   DeleteDiscardImages(PLAYER_LOCAL);
   gpGeneral->UpdateScreen();

   i = firsthand ? 287 : 260;
   k = firsthand ? 60 : 115;
   CButton btnOK(2, i, 315, 50, 22, 250, 70, 250);
   CButton *btnPass = firsthand ? NULL : new CButton(3, 315, 315, 50, 22, 250, 70, 250);
   gpGeneral->DrawImage(IMG_DISCARD, i + 5, 317);
   if (!firsthand) {
      gpGeneral->DrawImage(IMG_ABORT, 320, 317);
   }

   if (m_Time < 0) {
      time(&m_Time);
   }

   while (time(NULL) - m_Time < 30) {
      DrawTime(30 - (time(NULL) - m_Time));
      int k = gpGeneral->ReadKey(false) - SDLK_LAST;
      if (k == 2 || k == SDLK_RIGHT - SDLK_LAST) {
         // OK
         CCard *p = d;
         for (i = 0; i < count_hc; i++) {
            if (m_iSelectedCards & (1 << i)) {
               *p++ = handcard[i];
            }
         }
         if (p == d) {
            continue; // no cards selected
         }
         if (btnPass != NULL) {
            delete btnPass;
         }
         *p = 255;
         return p - d;
      } else if (k == 3) {
         // Pass
         delete btnPass;
         *d = 255;
         return 0;
      }
   }

   if (firsthand) {
      *d = handcard[0];
      *(d + 1) = 255;
      return 1;
   }

   delete btnPass;
   *d = 255;
   return 0;
}
コード例 #5
0
ファイル: screens.c プロジェクト: shaman7036/myevic
//=========================================================================
__myevic__ void ShowRTCAdjust()
{
	S_RTC_TIME_DATA_T rtd;

	DrawString( String_ClkAdjust, 4, 6 );
	DrawHLine( 0, 16, 63, 1 );

	GetRTC( &rtd );
	DrawTime( 5, 40, &rtd, 0x1F );
}
コード例 #6
0
void timer_int_handler(void * baseaddr_p) {
	unsigned int csr;
	int num;
    unsigned int MskAnodes;

	csr = XTmrCtr_GetControlStatusReg(XPAR_XPS_TIMER_0_BASEADDR, 0);
    if (csr & XTC_CSR_INT_OCCURED_MASK && win_flag==0) {
	    count++;
	    if (count%2==0) {
	    	MskAnodes=0x00000D00;
	    	num=(TIME_LIMIT-time0)/10;
	    }
	    else {
	    	MskAnodes=0x00000E00;
	    	num=(TIME_LIMIT-time0)%10;
	    }
    	ssBuf = MskAnodes | rgfsNumMap[num];
        Xil_Out32(XPAR_SEVSEG_DISP_12BITS_BASEADDR, ssBuf);
    }
    if (count==200) {
    	count=0;
    	time0++;
    	DrawBack(3,1119,EMPTY);
    	DrawTime(88, EMPTY);
        if (time0>20)
    	    DrawTime(TIME_LIMIT-time0, CURSOR);
    	else
    		DrawTime(TIME_LIMIT-time0, turn);
    }
    if (time0>TIME_LIMIT) {
    	time0=0;
    	if (turn==HUMAN_PLAYER) {
    		turn=COMPUTER_PLAYER;
    		xil_printf("\r\nComputer Player's turn!\r\n");
    	}
    	else {
    	    turn=HUMAN_PLAYER;
    	    xil_printf("\r\nHuman Player's turn!\r\n");
    	}
    }
    XTmrCtr_SetControlStatusReg(XPAR_XPS_TIMER_0_BASEADDR, 0, csr);
}
コード例 #7
0
void Game::DrawCongratTimeout(DEVCOLOR col, const std::string &text)
{
	for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
		(*i)->Draw();
	Render::device.PushMatrix();
	const math::Vector3 center(Core::appInstance->GAME_CONTENT_WIDTH / 2.0f, Core::appInstance->GAME_CONTENT_HEIGHT / 2.0f, 0);
	Render::device.MatrixTranslate(center);
	Render::device.SetTexturing(false);
	for (size_t i = 0; i < _countof(_buf); i++)
		_buf[i].color = col;
	Render::device.DrawPrimitives(_buf, 6);
	Render::device.SetTexturing(true);
	Render::BindFont("default");
	Render::PrintString(0, -10, text, 1, CenterAlign);
	Render::device.PopMatrix();
	DrawTime();
	StartCursor();
}
コード例 #8
0
//effettua la drow di tutta la UI tenendo conto dei livelli di disegno e della possibilità che il tamagotchi sia morto
//in tal caso disegna la scritta GAME OVER
void UIController::Draw(Bitmap* renderTarget)
{ 
	ui_interface_img.DrawTo(renderTarget, 0, 0);
	DrawTemperature(renderTarget);
	DrawTime(renderTarget);
	DrawCharacterStatistic(renderTarget);
	DrowPlayerInput(renderTarget);

	if (!ui_agent->getIsDead())
	{
		DrawTimeSpeed(renderTarget);
		DrawHotKey(renderTarget);
	}
	else
	{
		renderTarget->RenderText(110, 255, "GAME OVER", &ui_font_H3, 192, 0, 0);
	}
}
コード例 #9
0
ファイル: ovlimpl.c プロジェクト: CivilPol/sdcboot
STATIC void _UpdateInterfaceState(void)
{
    long now, diff;
    int  hour, minute, second;

    if (IsCounting)
    {
       GetTime(&hour, &minute, &second);

       now = hour * 3600 + minute * 60 + second;
       if (now > SavedTime)
	  diff   = now - SavedTime;
       else
	  diff = 86400l - SavedTime + now;

       hour   = (int) diff / 3600; diff %= 3600;
       minute = (int) diff / 60;   diff %= 60;
       second = (int) diff;

       DrawTime(hour, minute, second);
    }
}
コード例 #10
0
ファイル: DisplayObjects.cpp プロジェクト: bencz/OrangeC
void Board::Draw(HDC dc)
{
    DrawBackground(dc); 
    for (std::vector<Navaid *>::iterator it = navAids.begin(); it != navAids.end(); ++it)
    {
        (*it)->Draw(dc);
    }
    for (std::vector<Airport *>::iterator it = airports.begin(); it != airports.end(); ++it)
    {
        (*it)->Draw(dc);
    }
    for (std::vector<Fix *>::iterator it = fixes.begin(); it != fixes.end(); ++it)
    {
        (*it)->Draw(dc);
    }
    for (std::set<Plane *>::iterator it = planesIn.begin(); it != planesIn.end(); ++it)
    {
        (*it)->Draw(dc);
    }
    DrawEntryPlanes(dc);
    DrawTime(dc);
}
コード例 #11
0
// 출력
void Draw() {
  if(!(refresh_object || refresh_message || refresh_status || refresh_time)) {
    return;
  }
  if(refresh_object) {
    refresh_object = 0;
    DrawFloor(map_id);
    DrawObjects();
  }
  if(refresh_message) {
    refresh_message = 0;
    DrawMessage();
  }
  if(refresh_status) {
    refresh_status = 0;
    DrawStatus();
  }
  if(refresh_time) {
    refresh_time = 0;
    DrawTime();
  }
  mvaddch(22, 78, ' ');
  refresh();
}
コード例 #12
0
ファイル: shared_hud.cpp プロジェクト: Edward850/zdoom
void DrawHUD()
{
	player_t * CPlayer = StatusBar->CPlayer;

	players[consoleplayer].inventorytics = 0;
	if (hud_althudscale && SCREENWIDTH>640) 
	{
		hudwidth=SCREENWIDTH/2;
		if (hud_althudscale == 2) 
		{
			// Optionally just double the pixels to reduce scaling artifacts.
			hudheight=SCREENHEIGHT/2;
		}
		else 
		{
			if (WidescreenRatio == 4)
			{
				hudheight = hudwidth * 30 / BaseRatioSizes[WidescreenRatio][3];	// BaseRatioSizes is inverted for this mode
			}
			else
			{
				hudheight = hudwidth * 30 / (48*48/BaseRatioSizes[WidescreenRatio][3]);
			}
		}
	}
	else
	{
		hudwidth=SCREENWIDTH;
		hudheight=SCREENHEIGHT;
	}

	if (!automapactive)
	{
		int i;

		// No HUD in the title level!
		if (gamestate == GS_TITLELEVEL || !CPlayer) return;

		if (!deathmatch) DrawStatus(CPlayer, 5, hudheight-50);
		else
		{
			DrawStatus(CPlayer, 5, hudheight-75);
			DrawFrags(CPlayer, 5, hudheight-70);
		}
		DrawHealth(CPlayer, 5, hudheight-45);
		DrawArmor(CPlayer->mo->FindInventory<ABasicArmor>(), 
			CPlayer->mo->FindInventory<AHexenArmor>(),	5, hudheight-20);
		i=DrawKeys(CPlayer, hudwidth-4, hudheight-10);
		i=DrawAmmo(CPlayer, hudwidth-5, i);
		if (hud_showweapons) DrawWeapons(CPlayer, hudwidth - 5, i);
		DrawInventory(CPlayer, 144, hudheight-28);
		if (CPlayer->camera && CPlayer->camera->player)
		{
			StatusBar->DrawCrosshair();
		}
		if (idmypos) DrawCoordinates(CPlayer);

		DrawTime();
		DrawLatency();
	}
	else
	{
		FString mapname;
		char printstr[256];
		int seconds;
		int length=8*SmallFont->GetCharWidth('0');
		int fonth=SmallFont->GetHeight()+1;
		int bottom=hudheight-1;

		if (am_showtotaltime)
		{
			seconds = Tics2Seconds(level.totaltime);
			mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
			DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT);
			bottom -= fonth;
		}

		if (am_showtime)
		{
			if (level.clusterflags&CLUSTER_HUB)
			{
				seconds = Tics2Seconds(level.time);
				mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
				DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT);
				bottom -= fonth;
			}

			// Single level time for hubs
			seconds= Tics2Seconds(level.maptime);
			mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
			DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT);
		}

		ST_FormatMapName(mapname);
		screen->DrawText(SmallFont, hudcolor_titl, 1, hudheight-fonth-1, mapname,
			DTA_KeepRatio, true,
			DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);

		DrawCoordinates(CPlayer);
	}
}
コード例 #13
0
ファイル: GodComplex.cpp プロジェクト: Patapom/GodComplex
void WINAPI	EntryPoint()	
#endif
{

#ifdef ALLOW_WINDOWED
//	gs_WindowInfos.bFullscreen = MessageBox( 0, "Fullscreen?", pWindowClass, MB_YESNO | MB_ICONQUESTION ) == IDYES;
	gs_WindowInfos.bFullscreen = false;
#endif

	int	ErrorCode = 0;
	if ( (ErrorCode = WindowInit()) )
	{
		WindowExit();
		MessageBox( 0, pMessageError, 0, MB_OK | MB_ICONEXCLAMATION );
		ExitProcess( ErrorCode );
	}

	IntroProgressDelegate	Progress = { &gs_WindowInfos, ShowProgress };
	if ( (ErrorCode = IntroInit( Progress )) )
	{
		WindowExit();
		MessageBox( 0, pMessageError, 0, MB_OK | MB_ICONEXCLAMATION );
		ExitProcess( -ErrorCode );
	}

	// Start the music
#ifdef MUSIC
	gs_Music.Play();
#endif

	//////////////////////////////////////////////////////////////////////////
	// Run the message loop !
	bool	bFinished = false;
    float	StartTime = 0.001f * timeGetTime(); 
	float	LastTime = 0.0f;

	while ( !bFinished )
	{
		float	Time = 0.001f * timeGetTime() - StartTime;
	    float	DeltaTime = Time - LastTime;
		LastTime = Time;

		// Process Windows messages
		MSG		msg;
		while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) )
		{
			if ( msg.message == WM_QUIT )
			{
				bFinished = true;
				break;
			}
			DispatchMessage( &msg );
		}

#ifndef NDEBUG
		// Show FPS
		DrawTime( Time );
		HandleEvents();
#endif

#ifdef SURE_DEBUG
		// Check for hash collisions => We must never have too many of them !
		ASSERT( DictionaryU32::ms_MaxCollisionsCount < 2, "Too many collisions in hash tables! Either increase size or use different hashing scheme!" );

		// Reload in-file constants
		ReloadChangedTweakableValues();

		// Reload modified shaders
		WatchIncludesModifications();
		Shader::WatchShadersModifications();
		ComputeShader::WatchShadersModifications();
#endif

		// Run the intro
		bFinished |= !IntroDo( Time, DeltaTime );

// This was in iQ's framework, I don't know what it's for. I believe it's useful when using OpenGL but with DirectX it makes everything slow as hell (attempts to load/unload DLLs every frame) !
// I left it here so everyone knows it must NOT be called...
//		SwapBuffers( gs_WindowInfos.hDC );
	}
	//
	//////////////////////////////////////////////////////////////////////////

	// Stop the music
#ifdef MUSIC
	gs_Music.Stop();
#endif

 	IntroExit();

	WindowExit();

	// Clean exit...
	ExitProcess( 0 );
}
コード例 #14
0
ファイル: main.cpp プロジェクト: cefecto/fffde
int WINAPI WinMain( HINSTANCE instance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
//void entrypoint(void)
{
    MSG         msg;
    int         done=0;
    WININFO     *info = &wininfo;

	window_init(info);

	long st = GetTickCount();
	
	CLogger* myLogger;
	myLogger = new CLogger();

	GraphicsClass* m_Graphics;
	m_Graphics = new GraphicsClass();

	m_Graphics->Initialize(XRES,YRES,info->hWnd);

	// BASS
	BASS_Init(-1,44100,0,0,NULL);
	//char filename[400]="C:\\My_Projects\\frmwrk\\Debug\\lemonade-merry_xmas_nectas.xm";
	char filename[400]="C:\\My_Projects\\frmwrk\\Debug\\bass_system-questa_sera.xm";
	//char * filename= "dark_rat-xmas.xm";
	DWORD chan;
	float time;
	//chan=BASS_MusicLoad(FALSE,"dark_rat-xmas.xm",0,0,BASS_SAMPLE_LOOP|BASS_MUSIC_RAMPS|BASS_MUSIC_PRESCAN,0);
	if (!(chan=BASS_MusicLoad(FALSE,filename,0,0,BASS_MUSIC_RAMPS|BASS_MUSIC_PRESCAN,0)))
	{
		int k=5;
	}

	float dummy;
	int a;
	for (a=0;BASS_ChannelGetAttribute(chan,BASS_ATTRIB_MUSIC_VOL_CHAN+a,&dummy);a++);
	QWORD pos;
	pos=BASS_ChannelGetLength(chan,BASS_POS_BYTE);

	BASS_ChannelPlay(chan,FALSE);

	// programm loop
	long to=0;
	while( !done )
    {
		pos=BASS_ChannelGetPosition(chan,BASS_POS_BYTE);
		time=BASS_ChannelBytes2Seconds(chan,pos);
	
		myLogger->LogThis("pos");
		myLogger->LogThisFloat((float)pos);
		myLogger->LogThis("time");
		myLogger->LogThisFloat((float)time);

		if (time!=0)
		{
			int k=6;
		}
		long t = GetTickCount();
        if( !to ) to=t; 
        t-=to;

		while( PeekMessage(&msg,0,0,0,PM_REMOVE) )
        {
            if( msg.message==WM_QUIT ) done=1;
		    TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
        DrawTime( info, .001f*t );
		m_Graphics->Frame();
		m_Graphics->Render();
	}

	window_end(info);
	
    ExitProcess( 0 );
}
コード例 #15
0
ファイル: InterMis.c プロジェクト: ProjectZeroSlackr/hWolf3D
void LevelCompleted(void)
{
    Word k;

    /* setup */

    ParTime = MapListPtr->InfoArray[gamestate.mapon].ParTime;
    BonusScore = 0;		/* Init the bonus */

    IntermissionHack = TRUE;	/* Hack to keep score from drawing twice */
    NumberIndex = 47;		/* Hack to draw score using an alternate number set */
    NewGameWindow(1);		/* Force 512 mode screen */

    DisplayScreen(rIntermission, rInterPal);
    BlastScreen();

    InitInterMisPic();

    WhichBJ = 0;		/* Init BJ */
    BJTime = ReadTick()-50;		/* Force a redraw */
    BlastScreen();		/* Draw the screen */
    ShowBJ();			/* Draw BJ */
    StartSong(SongListPtr[1]);	/* Play the intermission song */
    SetAPalette(rInterPal);	/* Set the palette */
    DrawIScore();			/* Draw the current score */
    FlushKeys();			/* Flush the keyboard buffer */

    /* First an initial pause */

    BJBreath(60);

    /* Display Par Time, Player's Time, and show bonus if any. */

    if (gamestate.playtime>=(100*60*60UL)) {
        k =(99*60)+59;
    } else {
        k = gamestate.playtime/60;
    }
    DrawTime(TIMEX,TIMEY,k);		/* How much time has elapsed? */
    DrawTime(TIMEX,TIMEY2,ParTime);

    if (k < ParTime) {
        k = (ParTime-k) * 50;		/* 50 points per second */
        BonusScore += k;		/* Add to the bonus */
        DrawIBonus();			/* Draw the bonus */
        PlaySound(SND_EXTRA);
        BJBreath(60);			/* Breath a little */
    }

    /* Show ratios for "terminations", treasure, and secret stuff. */
    /* If 100% on all counts, Perfect Bonus! */

    k=0;		/* Not perfect (Yet) */
    RollRatio(RATIOX,RATIOY,(gamestate.treasurecount*100)/gamestate.treasuretotal);
    if (gamestate.treasurecount == gamestate.treasuretotal) {
        k++;			/* Perfect treasure */
    }
    if (!NoEnemies) {
        RollRatio(RATIOX,RATIOY2,(gamestate.killcount*100)/gamestate.killtotal);
        if (gamestate.killcount == gamestate.killtotal) {
            k++;			/* Perfect kills */
        }
    }
    RollRatio(RATIOX,RATIOY3,(gamestate.secretcount*100)/gamestate.secrettotal);
    if (gamestate.secretcount == gamestate.secrettotal) {
        k++;			/* Perfect secret */
    }
    if (BonusScore) {	/* Did you get a bonus? */
        RollScore();
        BJBreath(60);
    }
    if (k==3) {
        WhichBJ = 2;	/* Draw thumbs up for BJ */
        PlaySound(SND_THUMBSUP);
    }
    do {
        ShowBJ();		/* Animate BJ */
    } while (!WaitTicksEvent(1));		/* Wait for a keypress */

    FadeToBlack();		/* Fade away */

    FreeInitMisPic();
    IntermissionHack = FALSE;		/* Release the hack */
    NumberIndex = 36;			/* Restore the index */
}
コード例 #16
0
ファイル: yawmppp.c プロジェクト: d-torrance/dockapps
void
yawmppp_routine (int argc, char **argv)
{
    int i, j;

    int but_stat;

    long currenttime;
    long lasttime;
    long waittime;
    long ppptime;
    int hour, minute;
    long timetolog;

    long ppp_send, ppp_sl = -1;
    long ppp_recv, ppp_rl = -1;
    long ppp_sbytes, ppp_rbytes;
    long ppp_osbytes, ppp_orbytes;

    struct stat st;

    pid_t stop_child = 0;
    pid_t start_child = 0;
    int status;

    int isonline = 0;

    XEvent Event;

    int speed_ind = 10;

    /* Initialize some stuff */

    get_statistics (active_interface, &ppp_rl, &ppp_sl,
		    &ppp_orbytes, &ppp_osbytes);
    if (caution>0)
      close_ppp();

    grab_isp_info(1);

    /* Open the display */

    createXBMfromXPM (dock_mask_bits, dockxpm_xpm,
		      dock_mask_width, dock_mask_height);

    openXwindow (argc, argv, dockxpm_xpm, dock_mask_bits,
		 dock_mask_width, dock_mask_height);

    /* V Button */
    AddMouseRegion (0, 35, 48, 46, 58);
    /* x Button */
    AddMouseRegion (1, 47, 48, 58, 58);

    /* < Button */
    AddMouseRegion (2, 5, 48, 16, 58);
    /* > Button */
    AddMouseRegion (3, 17, 48, 28, 58);
    /* ISP display */
    AddMouseRegion (4, 5, 6, 59, 43);

    starttime = 0;
    currenttime = time (0);
    ppptime = 0;
    but_stat = -1;
    waittime = 0;
    timetolog=0;

    /* 888k8 on bottom */
    copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8, ERR_DEST_X, ERR_DEST_Y);

    DrawISPName ();

    while (1)
      {
	  lasttime = currenttime;
	  currenttime = time (0);

	  /* Check if any child has left the playground */
	  i = waitpid (0, &status, WNOHANG);
	  if (i == stop_child && stop_child != 0)
	    {

		starttime = 0;
		SetOffLED (LED_PPP_POWER);
		SetOffLED (LED_PPP_RX);
		SetOffLED (LED_PPP_TX);
		/* 888k8 on bottom */
		copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8,
			     ERR_DEST_X, ERR_DEST_Y);
		RedrawWindow ();

		stop_child = 0;
	    }
	  if (i == start_child && start_child != 0)
	    {
		if (WIFEXITED (status))
		  {
		      if (WEXITSTATUS (status) == 10)
			{

			    starttime = 0;
			    /* 88k8 on bottom */
			    copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8,
					 ERR_DEST_X, ERR_DEST_Y);
			    SetOffLED (LED_PPP_POWER);
			    DrawTime (0, 1);
			    RedrawWindow ();
			}
		      start_child = 0;
		  }
	    }

	  /* On-line detectie! 1x per second */

	  if (currenttime != lasttime)
	    {
		i = 0;

		if (stillonline (active_interface))
		  {
		      i = 1;
		      if (!starttime)
			{
			    starttime = currenttime;

			    if (stat (STAMP_FILE, &st) == 0)
				starttime = st.st_mtime;

			    SetOnLED (LED_PPP_POWER);
			    waittime = 0;

			    /* 88k8 on bottom */
			    copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9, 25, 8,
					 ERR_DEST_X, ERR_DEST_Y);

			    if (IspData[current_isp].SpeedAction)
				DrawSpeedInd (IspData[current_isp].SpeedAction);

			    speed_ind = currenttime + 10;

			    RedrawWindow ();
			}
		  }
		if (!i && starttime)
		  {
		      starttime = 0;
		      SetErrLED (LED_PPP_POWER);
		      logconn.status=1;

		      /* Error */
		      copyXPMArea (ERR_SRC_X, ERR_SRC_Y+9, 25, 8,
				   ERR_DEST_X, ERR_DEST_Y);

		      if (IspData[current_isp].IfDownAction)
			  execCommand (IspData[current_isp].IfDownAction);

		      RedrawWindow ();
		  }
	    }

	  if (waittime && waittime <= currenttime)
	    {
		SetOffLED (LED_PPP_POWER);
		RedrawWindow ();
		waittime = 0;
	    }

	  if ((starttime)&&(!isonline)) {
	    isonline=1;

	    logconn.start=time(NULL);
	    logconn.status=0;
	    strcpy(logconn.longname,IspData[current_isp].LongName);
	    strcpy(logconn.shortname,IspData[current_isp].ShortName);
	    strcpy(logconn.user,IspData[current_isp].User);
	    strcpy(logconn.phone,IspData[current_isp].Phone);

	    if (!strlen(logconn.shortname))
	      strcpy(logconn.shortname,"empty");
	    if (!strlen(logconn.longname))
	      strcpy(logconn.longname,"empty");
	    if (!strlen(logconn.user))
	      strcpy(logconn.user,"empty");
	    if (!strlen(logconn.phone))
	      strcpy(logconn.phone,"empty");

	    make_guards();
	  }
	  if ((!starttime)&&(isonline)) {
	    isonline=0;
	    logconn.end=time(NULL);
	    write_log();
	    if (got_sched)
	      make_delayed_update();
	    if (caution>0)
	      close_ppp();
	  }

	  /* If we are on-line. Print the time we are */
	  if (starttime)
	    {
		i = currenttime - starttime;

		i /= TimerDivisor;

		if (TimerDivisor == 1)
		    if (i > 59 * 60 + 59)
			i /= 60;

		minute = i % 60;
		hour = (i / 60) % 100;
		i = hour * 100 + minute;

		DrawTime (i, currenttime % 2);
		/* We are online, so we can check for send/recv packets */

		get_statistics (active_interface, &ppp_recv, &ppp_send,
				&ppp_rbytes, &ppp_sbytes);
		if (caution>1)
		  close_ppp();

		if (ppp_send != ppp_sl)
		    SetOnLED (LED_PPP_TX);
		else
		    SetOffLED (LED_PPP_TX);

		if (ppp_recv != ppp_rl)
		    SetOnLED (LED_PPP_RX);
		else
		    SetOffLED (LED_PPP_RX);

		ppp_sl = ppp_send;
		ppp_rl = ppp_recv;

		/* Every five seconds we check to load on the line */

		if (currenttime - timetolog >= 0) {
		  timetolog=currenttime + 60;
		  make_guards();
		}

		if ((currenttime - ppptime >= 0) || (ppptime == 0))
		  {

		      ppptime = currenttime + updaterate;

		      ppp_history[PPP_STATS_HIS][0] = ppp_rbytes - ppp_orbytes;
		      ppp_history[PPP_STATS_HIS][1] = ppp_sbytes - ppp_osbytes;

		      ppp_orbytes = ppp_rbytes;
		      ppp_osbytes = ppp_sbytes;

		      DrawStats (54, 17, 5, 32);

		      for (j = 1; j < 55; j++)
			{
			    ppp_history[j - 1][0] = ppp_history[j][0];
			    ppp_history[j - 1][1] = ppp_history[j][1];
			}
		      if (currenttime > speed_ind)
			{
			    DrawLoadInd ((ppp_history[54][0] + ppp_history[54][1]) / updaterate);
			}
		  }

		RedrawWindow ();
	    }


	  while (XPending (display))
	    {
		XNextEvent (display, &Event);
		switch (Event.type)
		  {
		  case Expose:
		      RedrawWindow ();
		      break;
		  case DestroyNotify:
		      XCloseDisplay (display);
		      while (start_child | stop_child)
			{
			    i = waitpid (0, &status, WNOHANG);
			    if (i == stop_child)
				stop_child = 0;
			    if (i == start_child)
				start_child = 0;
			    usleep (50000l);
			}
		      exit (0);
		      break;
		  case ButtonPress:
		      i = CheckMouseRegion (Event.xbutton.x, Event.xbutton.y);
		      switch (i)
			{
			case 0:
			    ButtonDown (BUT_V);
			    break;
			case 1:
			    ButtonDown (BUT_X);
			    break;
			case 2:
			    ButtonDown (BUT_REW);
			    break;
			case 3:
			    ButtonDown (BUT_FF);
			    break;
			}
		      but_stat = i;

		      RedrawWindow ();
		      break;
		  case ButtonRelease:
		      i = CheckMouseRegion (Event.xbutton.x, Event.xbutton.y);
		      // Button but_stat omhoogdoen!
		      switch (but_stat)
			{
			case 0:
			    ButtonUp (BUT_V);
			    break;
			case 1:
			    ButtonUp (BUT_X);
			    break;
			case 2:
			    ButtonUp (BUT_REW);
			    break;
			case 3:
			    ButtonUp (BUT_FF);
			    break;
			}

		      if (i == but_stat && but_stat >= 0)
			{
			    switch (i)
			      {
			      case 0:
				  if (!starttime)
				    {
				      /* 888k8 */
				      copyXPMArea (ERR_SRC_X+28, ERR_SRC_Y+9,
						   25, 8,
						   ERR_DEST_X, ERR_DEST_Y);
					DrawTime (0, 1);
					start_child = execCommand (IspData[current_isp].StartAction);
					SetWaitLED (LED_PPP_POWER);
					waittime = ORANGE_LED_TIMEOUT + currenttime;
				    }

				  break;
			      case 1:
				  if (stop_child == 0)
				    {
					stop_child = execCommand (IspData[current_isp].StopAction);
				    }
				  break;
			      case 2:
				  if (!starttime)
				    {
					current_isp--;
					if (current_isp < 0)
					    current_isp = num_isps - 1;
					if (current_isp < 0)
					  current_isp=0;
					DrawISPName ();
				    }
				  break;
			      case 3:
				  if (!starttime)
				    {
					current_isp++;
					if (current_isp == num_isps)
					    current_isp = 0;
					DrawISPName ();
				    }
				  break;
			      case 4:
				if (Event.xbutton.button==Button1)
				  run_pref_app();
				else
				  run_log_app();
				break;
			      }
			}
		      RedrawWindow ();

		      but_stat = -1;
		      break;
		  default:
		      break;
		  }
	    }
	  usleep (50000L);
      }
}
コード例 #17
0
ファイル: wmtime.c プロジェクト: cneira/dockapps
void wmtime_routine(int argc, char **argv) {

    rckeys		wmtime_keys[] = {
        { "left", &left_action },
        { "right", &right_action },
        { "middle", &middle_action },
        { NULL, NULL }
    };

    int			i;
    XEvent		Event;
    int			but_stat = -1;

    struct tm	*time_struct;

    long		starttime;
    long		curtime;

    char		*conffile = NULL;

    /* Scan through ~/.wmtimerc for the mouse button actions. */
    if (default_left_action) left_action = strdup(default_left_action);
    if (default_middle_action) middle_action = strdup(default_middle_action);
    if (default_right_action) right_action = strdup(default_right_action);

    /* Scan through the .rc files */
    if (asprintf(&conffile, "/etc/wmtimerc") >= 0) {
        parse_rcfile(conffile, wmtime_keys);
        free(conffile);
    }

    if (asprintf(&conffile, "%s/.wmtimerc", getenv("HOME")) >= 0) {
        parse_rcfile(conffile, wmtime_keys);
        free(conffile);
    }

    if (asprintf(&conffile, "/etc/wmtimerc.fixed") >= 0) {
        parse_rcfile(conffile, wmtime_keys);
        free(conffile);
    }

    /* set user-defined colors */
    if (color[0] != 0) {
        Window	Root;
        XColor col;
        XWindowAttributes attributes;
        int screen;
        Pixel pixel;
#define NUMSYMBOLS 10
        XpmColorSymbol user_color[NUMSYMBOLS] = {
            {NULL, "#2081B2CAAEBA", 0}, /* O */
            {NULL, "#000049244103", 0}, /* + */
            {NULL, "#00007DF771C6", 0}, /* @ */
            {NULL, "#18618A288617", 0}, /* # */
            {NULL, "#18619A699658", 0}, /* ; */
            {NULL, "#0820861779E7", 0}, /* : */
            {NULL, "#000071C66185", 0}, /* > */
            {NULL, "#000061855144", 0}, /* , */
            {NULL, "#00004D344103", 0}, /* < */
            {NULL, "#10407DF779E7", 0}  /* 1 */
        };


        /* code based on GetColor() from wmgeneral.c */
        /* we need a temporary display to parse the color */
        display = XOpenDisplay(NULL);
        screen = DefaultScreen(display);
        Root = RootWindow(display, screen);
        XGetWindowAttributes(display, Root, &attributes);

        col.pixel = 0;
        if (!XParseColor(display, attributes.colormap, color, &col)) {
            fprintf(stderr, "wmtime: can't parse %s.\n", color);
            goto draw_window;
        } else if (!XAllocColor(display, attributes.colormap, &col)) {
            fprintf(stderr, "wmtime: can't allocate %s.\n", color);
            goto draw_window;
        }

        pixel = col.pixel;

        /* replace colors from wmtime-master.xpm */
        user_color[0].pixel = pixel;
        user_color[1].pixel = scale_pixel(pixel, .4);
        user_color[2].pixel = scale_pixel(pixel, .7);
        user_color[3].pixel = scale_pixel(pixel, .8);
        user_color[4].pixel = scale_pixel(pixel, .9);
        user_color[5].pixel = scale_pixel(pixel, .8);
        user_color[6].pixel = scale_pixel(pixel, .6);
        user_color[7].pixel = scale_pixel(pixel, .5);
        user_color[8].pixel = scale_pixel(pixel, .4);
        user_color[9].pixel = scale_pixel(pixel, .7);

        wmgen.attributes.valuemask |= XpmColorSymbols;
        wmgen.attributes.numsymbols = NUMSYMBOLS;
        wmgen.attributes.colorsymbols = user_color;

        XCloseDisplay(display);
    }

draw_window:
    openXwindow(argc, argv, wmtime_master_xpm, (char*)wmtime_mask_bits, 128, 64);

    /* Mask out the right parts of the clock */
    copyXPMArea(0, 0, 128, 64, 0, 98);   /* Draw the borders */
    copyXPMArea(0, 0, 64, 64, 64, 0);    /* Draw the clock face */
    copyXPMArea(64, 98, 64, 64, 0, 0);   /* Draw the LCD background */
    setMaskXY(0, 0);

    /* add mouse region */
    AddMouseRegion(0, 5, 48, 58, 60);
    AddMouseRegion(1, 5, 5, 58, 46);

    starttime = time(0);

    curtime = time(0);
    time_struct = localtime(&curtime);

    while (1) {
        curtime = time(0);

        waitpid(0, NULL, WNOHANG);

        time_struct = localtime(&curtime);


        if (curtime >= starttime) {
            if (!digital) {
                /* Now to update the seconds */

                DrawWijzer(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec);

                DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon);

            } else {

                DrawTime(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec);

                DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon);
            }
            RedrawWindow();
        }


        while (XPending(display)) {
            XNextEvent(display, &Event);
            switch (Event.type) {
            case Expose:
                RedrawWindow();
                break;
            case DestroyNotify:
                XCloseDisplay(display);
                exit(0);
                break;
            case ButtonPress:
                but_stat = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
                break;
            case ButtonRelease:
                i = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
                if (but_stat == i && but_stat >= 0) {
                    switch (but_stat) {
                    case 0:
                        digital = 1-digital;

                        if (digital) {
                            copyXPMArea(64, 98, 64, 64, 0, 0);
                            DrawTime(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec);
                            DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon);
                        } else {
                            copyXPMArea(0, 98, 64, 64, 0, 0);
                            DrawWijzer(time_struct->tm_hour, time_struct->tm_min, time_struct->tm_sec);
                            DrawDate(time_struct->tm_wday, time_struct->tm_mday, time_struct->tm_mon);
                        }
                        RedrawWindow();
                        break;
                    case 1:
                        switch (Event.xbutton.button) {
                        case 1:
                            if (left_action)
                                execCommand(left_action);
                            break;
                        case 2:
                            if (middle_action)
                                execCommand(middle_action);
                            break;
                        case 3:
                            if (right_action)
                                execCommand(right_action);
                            break;
                        }
                    }
                }
                break;
            }
        }

        /* Sleep 0.3 seconds */
        usleep(300000L);
    }
}
コード例 #18
0
ファイル: gui.c プロジェクト: ctliu3/TicTacToe
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    static TCHAR szAppName[] = TEXT("SampleSRS");
    static int xBlock, yBlock;
    static HINSTANCE hInstance;
    static RECT rect_time1, rect_time2, rect_bk;
    static HBRUSH hBrushRed;

    SetRect(&rect_time1, PLAYER1_TIME_X1 - 10, PLAYER1_TIME_Y1 - 10, PLAYER1_TIME_X2, PLAYER1_TIME_Y2);
    SetRect(&rect_time2, PLAYER2_TIME_X1, PLAYER2_TIME_Y1 - 10, PLAYER2_TIME_X2 + 10, PLAYER2_TIME_Y2 - 10);
    SetRect(&rect_bk, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);

    switch(msg) {
    case WM_CREATE:
        hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
        DrawUI(hwnd, &lParam, hInstance);

        /* Load Image (Background && Chessboard) */
        LoadRc(hInstance);

        hBrushRed = CreateSolidBrush(RGB(255, 0, 0));

        MessageBox(hwnd, "Load Resource Successfully", "Info", MB_OK);
        break;
    case WM_SIZE:
        xBlock = (BOARD_X2 - BOARD_X1) / 3;
        yBlock = (BOARD_Y2 - BOARD_Y1) / 3;
        break;
    case WM_PAINT:
        InitRc(hwnd);
        break;
    case WM_LBUTTONDOWN:
        /* */
        break;
    case WM_TIMER:
        if (is_pause == FALSE) {
            if (n_chess & 1) {
                InvalidateRect(hwnd, &rect_time2, TRUE);
                DrawTime(hwnd, hBrushRed);
            } else {
                InvalidateRect(hwnd, &rect_time1, TRUE);
                DrawTime(hwnd, hBrushRed);
            }
        }
        break;
    case WM_COMMAND:
        log_to_text("Button Pressed: %d\n", LOWORD(wParam));

        if (LOWORD(wParam) == BTN_PLAYER1_RECORD) { /* Speech Recogniton for player 1*/
            player1_or_player2 = PLAYER1;
            ControlRecord(hwnd, hInstance, PLAYER1);

        } else if (LOWORD(wParam) == BTN_PLAYER2_RECORD) { /* Speech Recogniton for player 2*/
            player1_or_player2 = PLAYER2;
            ControlRecord(hwnd, hInstance, PLAYER2);

        } else if (LOWORD(wParam) == BTN_RESET) { /* Reset Button */
            InitGame(hwnd);

        } else if (LOWORD(wParam) == BTN_PAUSE) {  /* Pause Button */
            if (is_pause) {
                SetWindowText(GetDlgItem(hwnd, BTN_PAUSE), S_PAUSE);
            } else {
                SetWindowText(GetDlgItem(hwnd, BTN_PAUSE), S_CONTINUE);
            } 
            is_pause = !is_pause;

        } else if (LOWORD(wParam) == BTN_REDO) { /* Redo Button */
            back(hwnd, hInstance);
            GameCon();
        } else if (LOWORD(wParam) == BTN_EXIT) { /* Exit Button */
            if (IDYES == AskConfirmation(hwnd)) {
                DestroyWindow(hwnd) ;
            }
        }
        break;
    case WM_DESTROY:
        KillTimer(hwnd, ID1_TIMER);
		KillTimer(hwnd, ID2_TIMER);
        DeleteObject(hBkBitmap);
        DeleteObject(hBdBitmap);
        PostQuitMessage(0);
        break;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}
コード例 #19
0
void Game::Function()
{
	switch (_machine)
	{
	case STATE_DEFAULT:
		break;
	case STATE_START:
		StartCursor();
		break;
	case STATE_INITGAME:
		InitGameAux();
		break;
	case STATE_GAME:
		ProcessNewDestroy();
		break;
	case STATE_DRAW:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->Draw();
		DrawTime();
		break;
	case STATE_UPDATE:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->Update(_delta);
		_time -= _delta;
		break;
	case STATE_MOUSEDOWN:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->MouseDown(_mouseDown);
		break;
	case STATE_CONGRAT:
		ProcessNewDestroy();
		break;
	case STATE_CONGRATDRAW:
		DrawCongratTimeout(MAKECOLOR4(255, 0, 128, 255), _congrat);
		break;
	case STATE_TIMEOUT:
		ProcessNewDestroy();
		break;
	case STATE_TIMEOUTDRAW:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->Draw();
		DrawCongratTimeout(MAKECOLOR4(255, 255, 128, 128), _timeout);
		break;
	case STATE_TIMEOUTUPDATE:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->Update(_delta);
		break;
	case STATE_ALLHIT:
		ProcessNewDestroy();
		break;
	case STATE_ALLHITDRAW:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->Draw();
		DrawTime();
		break;
	case STATE_ALLHITUPDATE:
		for (std::vector<std::tr1::shared_ptr<Object > >::iterator i(_objects.begin()); i != _objects.end(); i++)
			(*i)->Update(_delta);
		break;
	}
}
コード例 #20
0
void DrawHUD()
{
	player_t * CPlayer = StatusBar->CPlayer;

	// [BB] The player may not have a body while connecting.
	if ( CPlayer->mo == NULL )
		return;

	players[consoleplayer].inventorytics = 0;
	if (hud_althudscale && SCREENWIDTH>640) 
	{
		hudwidth=SCREENWIDTH/2;
		if (hud_althudscale == 2) 
		{
			// Optionally just double the pixels to reduce scaling artifacts.
			hudheight=SCREENHEIGHT/2;
		}
		else 
		{
			if (WidescreenRatio == 4)
			{
				hudheight = hudwidth * 30 / BaseRatioSizes[WidescreenRatio][3];	// BaseRatioSizes is inverted for this mode
			}
			else
			{
				hudheight = hudwidth * 30 / (48*48/BaseRatioSizes[WidescreenRatio][3]);
			}
		}
	}
	else
	{
		hudwidth=SCREENWIDTH;
		hudheight=SCREENHEIGHT;
	}

	if (!automapactive)
	{
		int i;

		// No HUD in the title level!
		if (gamestate == GS_TITLELEVEL || !CPlayer) return;

		if (!deathmatch) DrawStatus(CPlayer, 5, hudheight-50);
		else
		{
			DrawStatus(CPlayer, 5, hudheight-75);

			// [TP] Only draw frags if not playing in teams
			if (( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSONTEAMS ) == 0 )
				DrawFrags(CPlayer, 5, hudheight-70);
		}

		// [TP] Only draw health and armor if we are allowed to know those stats. Also don't
		// draw spectator's health/armor stats.
		if ( ShouldDrawHealth( CPlayer ))
		{
			DrawHealth(CPlayer, 5, hudheight-45);
			DrawArmor(CPlayer->mo->FindInventory<ABasicArmor>(), 
				CPlayer->mo->FindInventory<AHexenArmor>(),	5, hudheight-20);
		}

		// [TP] Draw team stuff.
		DrawTeamScores( 10, hudheight - 90 );

		i=DrawKeys(CPlayer, hudwidth-4, hudheight-10);
		i=DrawAmmo(CPlayer, hudwidth-5, i);
		DrawWeapons(CPlayer, hudwidth-5, i);
		DrawInventory(CPlayer, 144, hudheight-28);
		if (CPlayer->camera && CPlayer->camera->player)
		{
			StatusBar->DrawCrosshair();
		}
		if (idmypos) DrawCoordinates(CPlayer);

		DrawTime();
	}
	else
	{
		FString mapname;
		char printstr[256];
		int seconds;
		int length=8*SmallFont->GetCharWidth('0');
		int fonth=SmallFont->GetHeight()+1;
		int bottom=hudheight-1;

		if (am_showtotaltime)
		{
			seconds = level.totaltime / TICRATE;
			mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
			DrawHudText(SmallFont, hudcolor_ttim, printstr, hudwidth-length, bottom, FRACUNIT);
			bottom -= fonth;
		}

		if (am_showtime)
		{
			if (level.clusterflags&CLUSTER_HUB)
			{
				seconds = level.time /TICRATE;
				mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
				DrawHudText(SmallFont, hudcolor_time, printstr, hudwidth-length, bottom, FRACUNIT);
				bottom -= fonth;
			}

			// Single level time for hubs
			seconds= level.maptime /TICRATE;
			mysnprintf(printstr, countof(printstr), "%02i:%02i:%02i", seconds/3600, (seconds%3600)/60, seconds%60);
			DrawHudText(SmallFont, hudcolor_ltim, printstr, hudwidth-length, bottom, FRACUNIT);
		}

		ST_FormatMapName(mapname);
		screen->DrawText(SmallFont, hudcolor_titl, 1, hudheight-fonth-1, mapname,
			DTA_KeepRatio, true,
			DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);

		DrawCoordinates(CPlayer);
	}
}
コード例 #21
0
ファイル: GameClientView.cpp プロジェクト: 275958081/netfox
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);
	CImageHandle HandleHeadBg(&m_ImageHeadBg);
	
	//放弃标志
	CImageHandle HnadleUserPass(&m_ImageUserPass);
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if (m_bPass[i]) 
		{
			m_ImageUserPass.AlphaDrawImage(pDC,m_pPass[i].x,m_pPass[i].y,RGB(255,0,255));
		}
	}

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);
		pDC->SetTextColor(RGB(0,255,255));

		//绘画用户
		if (pUserData!=NULL)
		{
			//m_ImageHeadBg.BitBlt(pDC->m_hDC,m_ptFace[i].x-2,m_ptFace[i].y-2);
			//用户名字
			//pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			//pDC->SetTextAlign(i==0||i==2?TA_RIGHT:TA_LEFT);
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y,pUserData->szName,lstrlen(pUserData->szName));
			pDC->TextOut(m_pZhanPaiName[i].x,m_pZhanPaiName[i].y-30,pUserData->szName,lstrlen(pUserData->szName));
			pDC->TextOut(nWidth/2-2*m_nXFace-2*m_nXBorder,2*m_nYFace+m_nYBorder-2*16+i*16+26,pUserData->szName,lstrlen(pUserData->szName));
			//设置上一局成绩
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lForeScore[i]);
			pDC->TextOut(nWidth/2+7,2*m_nYFace+m_nYBorder-2*16+i*16+26,szBuffer,lstrlen(szBuffer));
			//设置总成绩
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lAllScore[i]);
			pDC->TextOut(nWidth/2+2*m_nXFace+2*m_nXBorder,2*m_nYFace+m_nYBorder-2*16+i*16+26,szBuffer,lstrlen(szBuffer));
		
			
			

			//剩余扑克
			if (pUserData->cbUserStatus>=US_PLAY)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("(%ld 张)"),m_bCardCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+17*m_nXFace+6*m_nXBorder,m_pZhanPaiName[i].y-30,szBuffer,lstrlen(szBuffer));

				//设置掀人次数
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("掀牌:%d次"),m_bXianCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+12*m_nXFace+2*m_nXBorder,m_pZhanPaiName[i].y-30,szBuffer,lstrlen(szBuffer));
				//设置被掀次数
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("被掀:%d次"),m_bBeiXianCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+12*m_nXFace+2*m_nXBorder,m_pZhanPaiName[i].y-43,szBuffer,lstrlen(szBuffer));
				//设置占牌数目
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("%d"),m_bZhanPaiCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+500+4*m_nXBorder,m_pZhanPaiName[i].y-25,szBuffer);

					//绘画时间标志
			   DrawTime(pDC,nWidth,nHeight);

			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData->wFaceID,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
			
		}
	}
	
	

	//描述信息
	for(BYTE i=0;i<GAME_PLAYER;i++)
		if (m_bCouPaiTitle[i]==true)
		{
			//创建资源
			CFont InfoFont;
			InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

			//设置 DC
			pDC->SetTextColor(RGB(201,229,133));
			pDC->SetTextAlign(TA_CENTER|TA_TOP);
			CFont * pOldFont=pDC->SelectObject(&InfoFont);

			//绘画信息
			if(i%2)
				pDC->TextOut(nWidth/2,m_ptFace[i].y-6*m_nYFace-8,"扣牌");
			else if(m_ptFace[i].x<nWidth/2)
				pDC->TextOut(m_ptFace[i].x+5*m_nXFace,m_ptFace[i].y-8,"扣牌");
			else 
				pDC->TextOut(m_ptFace[i].x-4*m_nXFace,m_ptFace[i].y-8,"扣牌");


			//清理资源
			pDC->SelectObject(pOldFont);
			InfoFont.DeleteObject();
		}
	//描述信息
	for(BYTE i=0;i<GAME_PLAYER;i++)
		if (m_bXianPaiTitle[i]==true)
		{
			//创建资源
			CFont InfoFont;
			InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

			//设置 DC
			pDC->SetTextColor(RGB(201,229,133));
			pDC->SetTextAlign(TA_CENTER|TA_TOP);
			CFont * pOldFont=pDC->SelectObject(&InfoFont);

			//绘画信息
			if(i%2)
				pDC->TextOut(nWidth/2,m_ptFace[i].y-6*m_nYFace-8,"掀牌");
			else if(m_ptFace[i].x<nWidth/2)
				pDC->TextOut(m_ptFace[i].x+5*m_nXFace,m_ptFace[i].y-8,"掀牌");
			else 
				pDC->TextOut(m_ptFace[i].x-4*m_nXFace,m_ptFace[i].y-8,"掀牌");


			//清理资源
			pDC->SelectObject(pOldFont);
			InfoFont.DeleteObject();
		}
	//描述信息
	for(BYTE i=0;i<GAME_PLAYER;i++)
		if (m_bQiangCiTitle[i]==true)
		{
			//创建资源
			CFont InfoFont;
			InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

			//设置 DC
			pDC->SetTextColor(RGB(201,229,133));
			pDC->SetTextAlign(TA_CENTER|TA_TOP);
			CFont * pOldFont=pDC->SelectObject(&InfoFont);

			//绘画信息
			if(i%2)
				pDC->TextOut(nWidth/2,m_ptFace[i].y-6*m_nYFace-8,"抢刺");
			else if(m_ptFace[i].x<nWidth/2)
				pDC->TextOut(m_ptFace[i].x+5*m_nXFace,m_ptFace[i].y-8,"抢刺");
			else 
				pDC->TextOut(m_ptFace[i].x-4*m_nXFace,m_ptFace[i].y-8,"抢刺");


			//清理资源
			pDC->SelectObject(pOldFont);
			InfoFont.DeleteObject();
		}

	return;
}
コード例 #22
0
ファイル: CCockpit.cpp プロジェクト: programmerMOT/gunhound
void CCockpit::Draw()
{
	//---------------------------------
	//描画処理
	//---------------------------------
	Sint32 bx=0,by=0;
	Sint32 wx,wy;

	if( m_sNowLoadingWait )
	{
		DrawNowLoading();
	}

	if( m_bSplash )
	{
		DrawSplash();
	}

	wx = 0;
	wy = m_sHeight;

	m_pRaderDamage->SetHitPoint( m_sDispHitPoint );

	if( m_bArrow )                     DrawArrow(WINDOW_W/2,WINDOW_H/2);
	
	if( m_bSwitch[enSwitchRader]    )  m_pRaderControl->Draw(0,WINDOW_H+wy);
	if( m_bSwitch[enSwitchRed]      )  m_pRaderDamage->DrawSekigaisen(470+24,5);

	//左上U.I
	if( m_bSwitch[enSwitchBullet]   ) DrawRelord(36,36-wy);	//HP表示
	if( m_bSwitch[enSwitchPosition] ) m_pRaderDamage->Draw(8,10+by-wy);

	if( m_bSwitch[enSwitchTime]     )  DrawTime(400-16,24-wy);
	if( m_bSwitch[enSwitchScore]    )  DrawScore(400-32,8-wy);
	if( m_bOutogRange )                DrawOutOfArea(320,240+wy);
	if( m_bSwitch[enSwitchMessage]   ) DrawShortMessage(64,44-wy);

	if( m_sBlackMask ) 				   DrawBlackmask();

	if( m_bSwitch[enSwitchDamage]   ) 
	{
		//DrawHitPoint();
	}
	else
	{
		m_sDispHitPoint = 0;
	}

	if( m_sWhiteFade )
	{
		DrawGameOver();
	}

//		enSwitchDamage,		//残りHP(ON/OFF)
//		enSwitchMessage,	//ショートメッセージ(ON/OFF)
//		enSwitchBullet,		//残弾数(ON/OFF)
//		enSwitchHigher,		//敵高度表示(ON/OFF)

	m_pMsgWindow->Draw(6,WINDOW_H-74-m_sBlackMask*28/100);

	if( m_pStageClear ) m_pStageClear->Draw();

}