当前位置: 首页>>代码示例>>C++>>正文


C++ CG_DrawPic函数代码示例

本文整理汇总了C++中CG_DrawPic函数的典型用法代码示例。如果您正苦于以下问题:C++ CG_DrawPic函数的具体用法?C++ CG_DrawPic怎么用?C++ CG_DrawPic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CG_DrawPic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CG_DrawWeaponSelect


//.........这里部分代码省略.........
	trap->R_SetColor( &colorTable[CT_WHITE] );
	// Work backwards from current icon
	holdX = x - ((bigIconSize / 2) + pad + smallIconSize) * cgs.widthRatioCoef;
	drewConc = qfalse;

	for ( iconCnt = 1; iconCnt < (sideLeftIconCnt + 1); i-- ) {
		if ( i == WP_CONCUSSION )
			i--;
		else if ( i == WP_FLECHETTE && !drewConc && cg.weaponSelect != WP_CONCUSSION )
			i = WP_CONCUSSION;
		if ( i < 1 )
			i = LAST_USEABLE_WEAPON;

		// Does he have this weapon?
		if ( !(bits & (1 << i)) ) {
			if ( i == WP_CONCUSSION ) {
				drewConc = qtrue;
				i = WP_ROCKET_LAUNCHER;
			}
			continue;
		}

		// Don't show thermal and tripmine when out of them
		if ( !CG_WeaponSelectable( i ) && (i == WP_THERMAL || i == WP_TRIP_MINE) )
			continue;

		++iconCnt;					// Good icon

		if ( media.gfx.interface.weaponIcons[i] ) {
			CG_RegisterWeapon( i );

			trap->R_SetColor( &colorTable[CT_WHITE] );
			if ( !CG_WeaponCheck( i ) )
				CG_DrawPic(holdX, y + 10 + yOffset, smallIconSize * cgs.widthRatioCoef, smallIconSize, media.gfx.interface.weaponIconsInactive[i]);
			else
				CG_DrawPic(holdX, y + 10 + yOffset, smallIconSize * cgs.widthRatioCoef, smallIconSize, media.gfx.interface.weaponIcons[i]);

			holdX -= (smallIconSize + pad) * cgs.widthRatioCoef;
		}
		if ( i == WP_CONCUSSION ) {
			drewConc = qtrue;
			i = WP_ROCKET_LAUNCHER;
		}
	}

	// Current Center Icon
	if ( media.gfx.interface.weaponIcons[cg.weaponSelect] ) {
		CG_RegisterWeapon( cg.weaponSelect );

		trap->R_SetColor( &colorTable[CT_WHITE] );
		if ( !CG_WeaponCheck( cg.weaponSelect ) )
			CG_DrawPic(x - (bigIconSize / 2 * cgs.widthRatioCoef), (y - ((bigIconSize - smallIconSize) / 2)) + 10 + yOffset, bigIconSize * cgs.widthRatioCoef, bigIconSize, media.gfx.interface.weaponIconsInactive[cg.weaponSelect]);
		else
			CG_DrawPic(x - (bigIconSize / 2 * cgs.widthRatioCoef), (y - ((bigIconSize - smallIconSize) / 2)) + 10 + yOffset, bigIconSize * cgs.widthRatioCoef, bigIconSize, media.gfx.interface.weaponIcons[cg.weaponSelect]);
	}

	if ( cg.weaponSelect == WP_CONCUSSION )
		i = WP_ROCKET_LAUNCHER;
	else
		i = cg.weaponSelect + 1;

	if ( i > LAST_USEABLE_WEAPON )
		i = 1;

	// Right side ICONS
	// Work forwards from current icon
开发者ID:Razish,项目名称:japp,代码行数:67,代码来源:cg_weapons.cpp

示例2: CG_DrawOldScoreboard

/*
=======================================================================================================================================
CG_DrawOldScoreboard

Draw the normal in-game scoreboard.
=======================================================================================================================================
*/
qboolean CG_DrawOldScoreboard(void) {
	int x, y, w, i, n1, n2;
	float fade;
	float *fadeColor;
	char *s;
	int maxClients;
	int lineHeight;
	int topBorderSize, bottomBorderSize;

	// don't draw amuthing if the menu or console is up
	if (cg_paused.integer) {
		cg.deferredPlayerLoading = 0;
		return qfalse;
	}

	if (cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_INTERMISSION) {
		cg.deferredPlayerLoading = 0;
		return qfalse;
	}
	// don't draw scoreboard during death while warmup up
	if (cg.warmup && !cg.showScores) {
		return qfalse;
	}

	if (cg.showScores || cg.predictedPlayerState.pm_type == PM_DEAD || cg.predictedPlayerState.pm_type == PM_INTERMISSION) {
		fade = 1.0;
		fadeColor = colorWhite;
	} else {
		fadeColor = CG_FadeColor(cg.scoreFadeTime, FADE_TIME);

		if (!fadeColor) {
			// next time scoreboard comes up, don't print killer
			cg.deferredPlayerLoading = 0;
			cg.killerName[0] = 0;
			return qfalse;
		}

		fade = *fadeColor;
	}
	// fragged by ... line
	if (cg.killerName[0]) {
		s = va("Fragged by %s", cg.killerName);
		w = CG_DrawStrlen(s) * BIGCHAR_WIDTH;
		x = (SCREEN_WIDTH - w) / 2;
		y = 40;
		CG_DrawBigString(x, y, s, fade);
	}
	// current rank
	if (cgs.gametype < GT_TEAM) {
		if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR) {
			s = va("%s place with %i", CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1), cg.snap->ps.persistant[PERS_SCORE]);
			w = CG_DrawStrlen(s) * BIGCHAR_WIDTH;
			x = (SCREEN_WIDTH - w) / 2;
			y = 60;
			CG_DrawBigString(x, y, s, fade);
		}
	} else {
		if (cg.teamScores[0] == cg.teamScores[1]) {
			s = va("Teams are tied at %i", cg.teamScores[0]);
		} else if (cg.teamScores[0] >= cg.teamScores[1]) {
			s = va("Red leads %i to %i", cg.teamScores[0], cg.teamScores[1]);
		} else {
			s = va("Blue leads %i to %i", cg.teamScores[1], cg.teamScores[0]);
		}

		w = CG_DrawStrlen(s) * BIGCHAR_WIDTH;
		x = (SCREEN_WIDTH - w) / 2;
		y = 60;
		CG_DrawBigString(x, y, s, fade);
	}
	// scoreboard
	y = SB_HEADER;

	CG_DrawPic(SB_SCORE_X + (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardScore);
	CG_DrawPic(SB_PING_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardPing);
	CG_DrawPic(SB_TIME_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardTime);
	CG_DrawPic(SB_NAME_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardName);

	y = SB_TOP;
	// If there are more than SB_MAXCLIENTS_NORMAL, use the interleaved scores
	if (cg.numScores > SB_MAXCLIENTS_NORMAL) {
		maxClients = SB_MAXCLIENTS_INTER;
		lineHeight = SB_INTER_HEIGHT;
		topBorderSize = 8;
		bottomBorderSize = 16;
	} else {
		maxClients = SB_MAXCLIENTS_NORMAL;
		lineHeight = SB_NORMAL_HEIGHT;
		topBorderSize = 16;
		bottomBorderSize = 16;
	}

	localClient = qfalse;
//.........这里部分代码省略.........
开发者ID:ioid3-games,项目名称:ioid3-q3,代码行数:101,代码来源:cg_scoreboard.c

示例3: CG_DrawConnectScreen

void CG_DrawConnectScreen(qboolean interactive, qboolean forcerefresh)
{
    static qboolean inside = qfalse;
    char            buffer[1024];

    if (!DC)
    {
        return;
    }

    if (inside)
    {
        return;
    }

    inside = qtrue;

    if (!bg_loadscreeninited)
    {
        trap_Cvar_Set("ui_connecting", "0");

        RegisterFont("ariblk", 27, &cgs.media.bg_loadscreenfont1);
        RegisterFont("courbd", 30, &cgs.media.bg_loadscreenfont2);

        bg_axispin    = DC->registerShaderNoMip("gfx/loading/pin_axis");
        bg_alliedpin  = DC->registerShaderNoMip("gfx/loading/pin_allied");
        bg_neutralpin = DC->registerShaderNoMip("gfx/loading/pin_neutral");
        bg_pin        = DC->registerShaderNoMip("gfx/loading/pin_shot");

        bg_filter_bo = DC->registerShaderNoMip("ui/assets/filter_bots");
        bg_filter_ff = DC->registerShaderNoMip("ui/assets/filter_ff");
        bg_filter_hw = DC->registerShaderNoMip("ui/assets/filter_weap");
        bg_filter_lv = DC->registerShaderNoMip("ui/assets/filter_lives");
        bg_filter_al = DC->registerShaderNoMip("ui/assets/filter_antilag");
        bg_filter_bt = DC->registerShaderNoMip("ui/assets/filter_balance");

        bg_mappic = 0;

        BG_PanelButtonsSetup(loadpanelButtons);
        C_PanelButtonsSetup(loadpanelButtons, cgs.wideXoffset);

        bg_loadscreeninited = qtrue;
    }

    BG_PanelButtonsRender(loadpanelButtons);

    if (interactive)
    {
        DC->drawHandlePic(DC->cursorx, DC->cursory, 32, 32, DC->Assets.cursor);
    }

    DC->getConfigString(CS_SERVERINFO, buffer, sizeof(buffer));
    if (*buffer)
    {
        const char *str;
        float      x = 540.0f + cgs.wideXoffset;
        float      y = 322;
        int        i;
        qboolean   enabled = qfalse;

        CG_Text_Paint_Centred_Ext(x, y, 0.22f, 0.22f, clr3, ("^1" LEGACY_MOD " ^0" ETLEGACY_VERSION), 0, 0, 0, &cgs.media.bg_loadscreenfont1);

        y   = 340;
        str = Info_ValueForKey(buffer, "sv_hostname");
        CG_Text_Paint_Centred_Ext(x, y, 0.2f, 0.2f, colorWhite, str && *str ? str : "ETHost", 0, 26, 0, &cgs.media.bg_loadscreenfont2);


        y += 14;
        for (i = 0; i < MAX_MOTDLINES; i++)
        {
            str = CG_ConfigString(CS_CUSTMOTD + i);
            if (!str || !*str)
            {
                break;
            }

            CG_Text_Paint_Centred_Ext(x, y, 0.2f, 0.2f, colorWhite, str, 0, 26, 0, &cgs.media.bg_loadscreenfont2);

            y += 10;
        }

        y = 417;

        str = Info_ValueForKey(buffer, "g_friendlyfire");
        if (str && *str && atoi(str))
        {
            x = 461 + cgs.wideXoffset;
            CG_DrawPic(x, y, 16, 16, bg_filter_ff);
        }

        if (atoi(Info_ValueForKey(buffer, "g_gametype")) != GT_WOLF_LMS)
        {
            str = Info_ValueForKey(buffer, "g_maxlives");
            if (str && *str && atoi(str))
            {
                enabled = qtrue;
            }

            if (!enabled)
            {
//.........这里部分代码省略.........
开发者ID:rafal1137,项目名称:etlegacy,代码行数:101,代码来源:cg_loadpanel.c

示例4: CG_DrawCursorhint


//.........这里部分代码省略.........
		break;
	case HINT_ARMOR:
		icon = cgs.media.armorHintShader;
		break;
	case HINT_POWERUP:
		icon = cgs.media.powerupHintShader;
		break;
	case HINT_HOLDABLE:
		icon = cgs.media.holdableHintShader;
		break;
	case HINT_INVENTORY:
		icon = cgs.media.inventoryHintShader;
		break;
	case HINT_PLYR_FRIEND:
	case HINT_PLYR_NEUTRAL:
	case HINT_PLYR_ENEMY:
	case HINT_PLYR_UNKNOWN:
		return;

	// multiplayer hints
	case HINT_BUILD:
		icon = cgs.media.buildHintShader;
		break;
	case HINT_DISARM:
		icon = cgs.media.disarmHintShader;
		break;
	case HINT_REVIVE:
		icon = cgs.media.reviveHintShader;
		break;
	case HINT_DYNAMITE:
		icon = cgs.media.dynamiteHintShader;
		break;

	case HINT_ACTIVATE:
	case HINT_PLAYER:
	default:
		icon = cgs.media.usableHintShader;
		break;
	}

	if (!icon)
	{
		return;
	}

	// color
	color = CG_FadeColor(cg.cursorHintTime, cg.cursorHintFade);
	if (!color)
	{
		trap_R_SetColor(NULL);
		return;
	}

	if (cg_cursorHints.integer == 3)
	{
		color[3] *= 0.5 + 0.5 * sin((float)cg.time / 150.0);
	}

	// size
	if (cg_cursorHints.integer >= 3)       // no size pulsing
	{
		scale = halfscale = 0;
	}
	else
	{
		if (cg_cursorHints.integer == 2)
		{
			scale = (float)((cg.cursorHintTime) % 1000) / 100.0f;     // one way size pulse
		}
		else
		{
			scale = CURSORHINT_SCALE * (0.5 + 0.5 * sin((float)cg.time / 150.0));     // sin pulse

		}
		halfscale = scale * 0.5f;
	}

	// set color and draw the hint
	trap_R_SetColor(color);
	CG_DrawPic(middle - halfscale, rect->y - halfscale, rect->w + scale, rect->h + scale, icon);

	if (icon2)
	{
		CG_DrawPic(middle - halfscale, rect->y - halfscale, rect->w + scale, rect->h + scale, icon2);
	}

	trap_R_SetColor(NULL);

	// draw status bar under the cursor hint
	if (cg.cursorHintValue)
	{
		vec4_t backG    = { 1, 1, 1, 0.3f };
		float  curValue = (float)cg.cursorHintValue / 255.0f;

		if (curValue > 0.01f)
		{
			CG_FilledBar(middle, rect->y + rect->h + 4, rect->w, 8, colorRed, colorGreen, backG, curValue, BAR_BORDER_SMALL | BAR_LERP_COLOR);
		}
	}
}
开发者ID:Ponce,项目名称:etlegacy,代码行数:101,代码来源:cg_newDraw.c

示例5: CG_Scanner

/*
=============
CG_Scanner
=============
*/
void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color )
{
  int     i;
  vec3_t  origin;
  vec3_t  relOrigin;
  vec4_t  hIabove;
  vec4_t  hIbelow;
  vec4_t  aIabove = { 1.0f, 0.0f, 0.0f, 0.75f };
  vec4_t  aIbelow = { 1.0f, 0.0f, 0.0f, 0.5f };

  Vector4Copy( color, hIabove );
  hIabove[ 3 ] *= 1.5f;
  Vector4Copy( color, hIbelow );

  VectorCopy( entityPositions.origin, origin );

  //draw human buildables below scanner plane
  for( i = 0; i < entityPositions.numHumanBuildables; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.humanBuildablePos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] < 0 ) )
      CG_DrawBlips( rect, relOrigin, hIbelow );
  }

  //draw alien buildables below scanner plane
  for( i = 0; i < entityPositions.numAlienBuildables; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.alienBuildablePos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] < 0 ) )
      CG_DrawBlips( rect, relOrigin, aIbelow );
  }

  //draw human clients below scanner plane
  for( i = 0; i < entityPositions.numHumanClients; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.humanClientPos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] < 0 ) )
      CG_DrawBlips( rect, relOrigin, hIbelow );
  }

  //draw alien buildables below scanner plane
  for( i = 0; i < entityPositions.numAlienClients; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.alienClientPos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] < 0 ) )
      CG_DrawBlips( rect, relOrigin, aIbelow );
  }

  if( !cg_disableScannerPlane.integer )
  {
    trap_R_SetColor( color );
    CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader );
    trap_R_SetColor( NULL );
  }

  //draw human buildables above scanner plane
  for( i = 0; i < entityPositions.numHumanBuildables; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.humanBuildablePos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] > 0 ) )
      CG_DrawBlips( rect, relOrigin, hIabove );
  }

  //draw alien buildables above scanner plane
  for( i = 0; i < entityPositions.numAlienBuildables; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.alienBuildablePos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] > 0 ) )
      CG_DrawBlips( rect, relOrigin, aIabove );
  }

  //draw human clients above scanner plane
  for( i = 0; i < entityPositions.numHumanClients; i++ )
  {
    VectorClear( relOrigin );
    VectorSubtract( entityPositions.humanClientPos[ i ], origin, relOrigin );

    if( VectorLength( relOrigin ) < SCANNER_RANGE && ( relOrigin[ 2 ] > 0 ) )
      CG_DrawBlips( rect, relOrigin, hIabove );
  }

  //draw alien clients above scanner plane
  for( i = 0; i < entityPositions.numAlienClients; i++ )
//.........这里部分代码省略.........
开发者ID:norfenstein,项目名称:umbra,代码行数:101,代码来源:cg_scanner.c

示例6: CG_LimboPanel_WeaponPanel

void CG_LimboPanel_WeaponPanel(panel_button_t *button) {
	weapon_t weap = CG_LimboPanel_GetSelectedWeapon();
	int      cnt  = CG_LimboPanel_WeaponCount();

	if (cgs.ccSelectedWeapon2 >= CG_LimboPanel_WeaponCount_ForSlot(0)) {
		cgs.ccSelectedWeapon2 = CG_LimboPanel_WeaponCount_ForSlot(0) - 1;
	}

	if (CG_LimboPanel_GetTeam() == TEAM_SPECTATOR) {
		vec4_t clr = { 0.f, 0.f, 0.f, 0.4f };

		CG_DrawPic(button->rect.x, button->rect.y, button->rect.w, button->rect.h, cgs.media.limboWeaponCard);

		trap_R_SetColor(clr);
		CG_DrawPic(button->rect.x, button->rect.y, button->rect.w, button->rect.h, cgs.media.limboWeaponBlendThingy);
		trap_R_SetColor(NULL);

		CG_Text_Paint_Ext(button->rect.x + 4, button->rect.y + 12, weaponPanelNameFont.scalex, weaponPanelNameFont.scaley, weaponPanelNameFont.colour, "SPECTATOR", 0, 0, weaponPanelNameFont.style, weaponPanelNameFont.font);

		return;
	}

	if (BG_PanelButtons_GetFocusButton() == button && cnt > 1) {
		int       i, x;
		rectDef_t rect;
		memcpy(&rect, &button->rect, sizeof (rect));

		CG_LimboPanel_WeaponPanel_DrawWeapon(&rect, weap, qtrue, va("%iof%i", CG_LimboPanel_GetSelectedWeaponNum() + 1, cnt), CG_LimboPanel_RealWeaponIsDisabled(weap));
		if (BG_CursorInRect(&rect) && button->data[7] != 0) {
			SOUND_FOCUS;
			button->data[7] = 0;
		}
		rect.y -= rect.h;

		// render in expanded mode ^
		for (i = 0, x = 1; i < cnt; ++i) {
			weapon_t cycleWeap = CG_LimboPanel_GetWeaponForNumber(i, cgs.ccSelectedWeaponNumber, qtrue);
			if (cycleWeap != weap) {
				CG_LimboPanel_WeaponPanel_DrawWeapon(&rect, cycleWeap, qtrue, va("%iof%i", i + 1, cnt), CG_LimboPanel_RealWeaponIsDisabled(cycleWeap));

				if (BG_CursorInRect(&rect) && button->data[7] != x) {
					SOUND_FOCUS;
					button->data[7] = x;
				}

				rect.y -= rect.h;
				x++;
			}
		}

		CG_DrawBorder(button->rect.x, button->rect.y - ((cnt - 1) * button->rect.h), button->rect.w, button->rect.h * cnt, qfalse, qfalse);
	} else {
		vec4_t clr = { 0.f, 0.f, 0.f, 0.4f };

		// render in normal mode
		CG_LimboPanel_WeaponPanel_DrawWeapon(&button->rect, weap, cnt > 1 ? qtrue : qfalse, va("%iof%i", CG_LimboPanel_GetSelectedWeaponNum() + 1, cnt), CG_LimboPanel_RealWeaponIsDisabled(weap));

		if (cnt <= 1 || !BG_CursorInRect(&button->rect)) {
			vec4_t clr2 = { 1.f, 1.f, 1.f, 0.4f };

			trap_R_SetColor(clr2);
		}
		CG_DrawPic(button->rect.x + button->rect.w - 20, button->rect.y + 4, 16, 12, cgs.media.limboWeaponCardArrow);

		trap_R_SetColor(clr);
		CG_DrawPic(button->rect.x, button->rect.y, button->rect.w, button->rect.h, cgs.media.limboWeaponBlendThingy);
		trap_R_SetColor(NULL);
	}
}
开发者ID:ETrun,项目名称:ETrun,代码行数:69,代码来源:cg_limbopanel.c

示例7: CG_windowDraw


//.........这里部分代码省略.........
        if ( w->effects & WFX_TEXTSIZING ) {
            CG_windowNormalizeOnText( w );
            w->effects &= ~WFX_TEXTSIZING;
        }

        bg = ( ( w->effects & WFX_FLASH ) && ( milli % w->flashPeriod ) > w->flashMidpoint ) ? &w->colorBackground2 : &w->colorBackground;

        h = w->h;
        x = w->x;
        y = w->y;
        t_offset = milli - w->time;
        textColor[3] = 1.0f;
        memcpy( &borderColor, w->colorBorder, sizeof( vec4_t ) );
        memcpy( &bgColor, bg, sizeof( vec4_t ) );

        // TODO: Add in support for ALL scrolling effects
        if ( w->state == WSTATE_START ) {
            tmp = w->targetTime - t_offset;
            if ( w->effects & WFX_SCROLLUP ) {
                if ( tmp > 0 ) {
                    y += ( 480 - y ) * tmp / w->targetTime; //(100 * tmp / w->targetTime) / 100;
                } else {
                    w->state = WSTATE_COMPLETE;
                }

                w->curY = y;
            }
            if ( w->effects & WFX_FADEIN ) {
                if ( tmp > 0 ) {
                    textColor[3] = (float)( (float)t_offset / (float)w->targetTime );
                } else {
                    w->state = WSTATE_COMPLETE;
                }
            }
        } else if ( w->state == WSTATE_SHUTDOWN ) {
            tmp = w->targetTime - t_offset;
            if ( w->effects & WFX_SCROLLUP ) {
                if ( tmp > 0 ) {
                    y = w->curY + ( 480 - w->y ) * t_offset / w->targetTime;      //(100 * t_offset / w->targetTime) / 100;
                }
                if ( tmp < 0 || y >= 480 ) {
                    w->state = WSTATE_OFF;
                    fCleanup = qtrue;
                    continue;
                }
            }
            if ( w->effects & WFX_FADEIN ) {
                if ( tmp > 0 ) {
                    textColor[3] -= (float)( (float)t_offset / (float)w->targetTime );
                } else {
                    textColor[3] = 0.0f;
                    w->state = WSTATE_OFF;
                }
            }
        }

        borderColor[3] *= textColor[3];
        bgColor[3] *= textColor[3];

        CG_FillRect( x, y, w->w, h, bgColor );
        CG_DrawRect( x, y, w->w, h, 1, borderColor );

        x += 5;
        y -= ( w->effects & WFX_TRUETYPE ) ? 3 : 0;

        for ( j = w->lineCount - 1; j >= 0; j-- ) {
            if ( w->effects & WFX_TRUETYPE ) {
//				CG_Text_Paint(x, y + h, w->fontScale, textColor, (char*)w->lineText[j], 0.0f, 0, 0);
                CG_Text_Paint_Ext( x, y + h, w->fontScaleX, w->fontScaleY, textColor,
                                   (char*)w->lineText[j], 0.0f, 0, 0, &cgs.media.limboFont2 );
            }

            h -= ( w->lineHeight[j] + 3 );

            if ( !( w->effects & WFX_TRUETYPE ) ) {
                CG_DrawStringExt2( x, y + h, (char*)w->lineText[j], textColor,
                                   qfalse, qtrue, w->fontWidth, w->fontHeight, 0 );
            }
        }
    }

    // Wedge in MV info overlay
    if ( cg.mvTotalClients > 0 && fAllowMV ) {
        CG_mvOverlayDisplay();
    }

    // Extra rate info
    CG_demoAviFPSDraw();
    CG_demoTimescaleDraw();

    // Mouse cursor lays on top of everything
    if ( cg.mvTotalClients > 0 && cg.time < cgs.cursorUpdate && fAllowMV ) {
        //CG_DrawPic(cgs.cursorX - CURSOR_OFFSETX, cgs.cursorY - CURSOR_OFFSETY, 32, 32, cgs.media.cursor);
        CG_DrawPic( cgDC.cursorx, cgDC.cursory, 32, 32, cgs.media.cursorIcon );
    }

    if ( fCleanup ) {
        CG_windowCleanup();
    }
}
开发者ID:GgyuB3,项目名称:Enemy-Territory,代码行数:101,代码来源:cg_window.c

示例8: CG_DrawAmmo

/*
================
CG_DrawAmmo
================
*/
static void CG_DrawAmmo( centity_t	*cent,menuDef_t *menuHUD)
{
	playerState_t	*ps;
	int				ammo;
	itemDef_t		*focusItem;
	float			width;
	const char		*text;
	vec4_t			opacity;
	const weaponInfo_t *weaponInfo;

	if( cg.jkg_WHUDOpacity  < 1.0f )
	{
		MAKERGBA(opacity, 1,1,1, cg.jkg_WHUDOpacity);
	}
	else
	{
		MAKERGBA(opacity, 1,1,1, cg.jkg_HUDOpacity);
	}

	ps = &cg.snap->ps;

	// Can we find the menu?
	if (!menuHUD)
	{
		return;
	}

	if (!cent->currentState.weapon ) // We don't have a weapon right now
	{
		return;
	}

#ifndef NO_SP_STYLE_AMMO
	// Figure out whether or not we want to do the thing where we highlight the text whenever we consume ammo or change firing mode (or, change weapon)
	if (cg.lastAmmo != cg.predictedPlayerState.stats[STAT_AMMO] || cg.lastAmmoGun != cg.predictedPlayerState.weaponId)
	{
		cg.lastAmmo = cg.predictedPlayerState.stats[STAT_AMMO];
		cg.lastAmmoTime = cg.time + 200; // matches SP 1:1
		cg.lastAmmoGun = cg.predictedPlayerState.weaponId;
	}

	if(cg.lastAmmoTime > cg.time)
	{
		vec4_t colorCopy = { 0.2, 0.72, 0.86, 1 };
		Q_RGBCopy(&opacity, colorCopy);
	}
#endif
	
	weaponInfo = CG_WeaponInfo (cent->currentState.weapon, cent->currentState.weaponVariation);

	if ( GetWeaponData( cent->currentState.weapon, cent->currentState.weaponVariation )->firemodes[0].cost == 0 && GetWeaponData( cent->currentState.weapon, cent->currentState.weaponVariation )->firemodes[1].cost == 0)
	{ //just draw "infinite"
		text = "Ammo: Infinite";
	}
	else
	{
		if ( GetWeaponAmmoClip( cent->currentState.weapon, cent->currentState.weaponVariation ))
		{
			ammo = ps->stats[STAT_AMMO];
		}
		else
		{
			ammo = ps->ammo;
		}

		if ( GetWeaponAmmoClip( cent->currentState.weapon, cent->currentState.weaponVariation ))
		{
			// Display the amount of clips too
			float temp;
			temp = ceil(( float ) ps->ammo / ( float ) GetWeaponAmmoClip( cent->currentState.weapon, cent->currentState.weaponVariation ));
			text = va( "Ammo: %i (%i)", ammo, ( int ) temp );
		}
		else
		{
			text = va( "Ammo: %i", ammo );
		}	
	}

	// Now then, lets render this text ^_^

	width = (float)trap_R_Font_StrLenPixels(text, cgDC.Assets.qhSmallFont, 1) * 0.6f;
				
	focusItem = Menu_FindItemByName(menuHUD, "infobar");
	if (focusItem)
	{
		trap_R_Font_DrawString(focusItem->window.rect.x + ((focusItem->window.rect.w/2) - (width/2)), focusItem->window.rect.y, text, opacity, cgDC.Assets.qhSmall3Font, -1, 0.5f);
	}

	focusItem = Menu_FindItemByName(menuHUD, "weapicon");
	if (focusItem)
	{
		trap_R_SetColor( opacity );	
		CG_DrawPic( 
			focusItem->window.rect.x, 
			focusItem->window.rect.y, 
//.........这里部分代码省略.........
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:101,代码来源:jkg_hud.cpp

示例9: saber

/*
================
CG_DrawSaberStyle

If the weapon is a light saber (which needs no ammo) then draw a graphic showing
the saber style (fast, medium, strong)
================
*/
static void CG_DrawSaberStyle( centity_t *cent, menuDef_t *menuHUD)
{

	const weaponInfo_t *weaponInfo;
	itemDef_t		*focusItem;
	const char		*text;
	float			width;


	if (!cent->currentState.weapon ) // We don't have a weapon right now
	{
		return;
	}

	if ( cent->currentState.weapon != WP_SABER )
	{
		return;
	}

	// Can we find the menu?
	if (!menuHUD)
	{
		return;
	}

    weaponInfo = CG_WeaponInfo (WP_SABER, 0);

	// draw the current saber style in this window
	// TODO: cvar plz
	if(jkg_simpleHUD.integer)
	{
		text = va( "Style: %s", SaberStances[cg.predictedPlayerState.fd.saberDrawAnimLevel].saberName_simple );
	}
	else
	{
		text = va( "Stance: %s", SaberStances[cg.predictedPlayerState.fd.saberDrawAnimLevel].saberName_technical );
	}
	/*switch ( cg.predictedPlayerState.fd.saberDrawAnimLevel )
	{

	case 1: //FORCE_LEVEL_1: Fast
		text = "Style: Fast";
		break;
	case 2: //FORCE_LEVEL_2: Medium
		text = "Style: Medium";
		break;
	case 3: //FORCE_LEVEL_3: Strong
		text = "Style: Strong";
		break;
	case 4: //FORCE_LEVEL_4://Desann
		text = "Style: Desann";
		break;
	case 5: //FORCE_LEVEL_5://Tavion
		text = "Style: Tavion";
		break;
	case 6: //SS_DUAL
		text = "Style: Dual";
		break;
	case 7: //SS_STAFF
		text = "Style: Staff";
		break;
	default:	// ??? Should never happen
		text = "Style: Unknown";
		break;
	}*/

	// Now then, lets render this text ^_^

	width = (float)trap_R_Font_StrLenPixels(text, cgDC.Assets.qhSmall3Font, 1) * 0.6f;
				
	focusItem = Menu_FindItemByName(menuHUD, "infobar");
	if (focusItem)
	{
		trap_R_Font_DrawString(focusItem->window.rect.x + ((focusItem->window.rect.w/2) - (width/2)), focusItem->window.rect.y, text, colorWhite, cgDC.Assets.qhSmall3Font, -1, 0.6f);
	}

	focusItem = Menu_FindItemByName(menuHUD, "weapicon");
	if (focusItem)
	{
		trap_R_SetColor( NULL );	
		CG_DrawPic( 
			focusItem->window.rect.x, 
			focusItem->window.rect.y, 
			focusItem->window.rect.w, 
			focusItem->window.rect.h, 
			weaponInfo->hudIcon
			);			
	}
}
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:97,代码来源:jkg_hud.cpp

示例10: CG_DrawCursorhint


//.........这里部分代码省略.........
		break;
	case HINT_HOLDABLE:
		icon = cgs.media.holdableHintShader;
		break;
	case HINT_INVENTORY:
		icon = cgs.media.inventoryHintShader;
		break;
	case HINT_PLYR_FRIEND:
		icon = cgs.media.hintPlrFriendShader;
		break;
	case HINT_PLYR_NEUTRAL:
		icon = cgs.media.hintPlrNeutralShader;
		break;
	case HINT_PLYR_ENEMY:
		icon = cgs.media.hintPlrEnemyShader;
		break;
	case HINT_PLYR_UNKNOWN:
		icon = cgs.media.hintPlrUnknownShader;
		break;

		// DHM - Nerve :: multiplayer hints
	case HINT_BUILD:
		icon = cgs.media.buildHintShader;
		break;
	case HINT_DISARM:
		icon = cgs.media.disarmHintShader;
		break;
	case HINT_REVIVE:
		icon = cgs.media.reviveHintShader;
		break;
	case HINT_DYNAMITE:
		icon = cgs.media.dynamiteHintShader;
		break;
		// dhm - end

		// Mad Doc - TDF
	case HINT_LOCKPICK:
		icon = cgs.media.doorLockHintShader;            // TAT 1/30/2003 - use the locked door hint cursor
		yellowbar = true;      // draw the status bar in yellow so it shows up better
		break;

	case HINT_ACTIVATE:
	case HINT_PLAYER:
	default:
		icon = cgs.media.usableHintShader;
		break;
	}


	if ( !icon ) {
		return;
	}


	// color
	color = CG_FadeColor( cg.cursorHintTime, cg.cursorHintFade );
	if ( !color ) {
		trap_R_SetColor( NULL );
		return;
	}

	if ( cg_cursorHints.integer == 3 ) {
		color[3] *= 0.5 + 0.5 * sin( (float)cg.time / 150.0 );
	}


	// size
	if ( cg_cursorHints.integer >= 3 ) {   // no size pulsing
		scale = halfscale = 0;
	} else {
		if ( cg_cursorHints.integer == 2 ) {
			scale = (float)( ( cg.cursorHintTime ) % 1000 ) / 100.0f; // one way size pulse
		} else {
			scale = CURSORHINT_SCALE * ( 0.5 + 0.5 * sin( (float)cg.time / 150.0 ) ); // sin pulse

		}
		halfscale = scale * 0.5f;
	}

	// set color and draw the hint
	trap_R_SetColor( color );
	CG_DrawPic( rect->x - halfscale, rect->y - halfscale, rect->w + scale, rect->h + scale, icon );

	if ( icon2 ) {
		CG_DrawPic( rect->x - halfscale, rect->y - halfscale, rect->w + scale, rect->h + scale, icon2 );
	}

	trap_R_SetColor( NULL );

	// draw status bar under the cursor hint
	if ( cg.cursorHintValue ) {
		if ( yellowbar ) {
			Vector4Set( color, 1, 1, 0, 1.0f );
		} else {
			Vector4Set( color, 0, 0, 1, 0.5f );
		}
		CG_FilledBar( rect->x, rect->y + rect->h + 4, rect->w, 8, color, NULL, NULL, (float)cg.cursorHintValue / 255.0f, 0 );
	}

}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:101,代码来源:cg_newDraw.cpp

示例11: CG_DrawHotkeyBar

static void CG_DrawHotkeyBar ( menuDef_t *menuHUD, vec4_t opacity )
{
    itemDef_t *focusItem;
	int i;

    if (!menuHUD)
	{
	    return;
	}

	focusItem = Menu_FindItemByName(menuHUD, "frame");
	if (focusItem)
	{
		trap_R_SetColor(opacity);
		CG_DrawPic( 
			focusItem->window.rect.x, 
			focusItem->window.rect.y, 
			focusItem->window.rect.w, 
			focusItem->window.rect.h, 
			focusItem->window.background 
			);			
	}

	// Print background of the bars
	for (i=0; i<11; i++) {
		focusItem = Menu_FindItemByName(menuHUD, va("slot%i", i));
		if (focusItem)
		{
			vec4_t col = {0.11f, 0.11f, 0.11f, 1.0f};
			qhandle_t shader = cgs.media.whiteShader;	//dummy
			col[3] *= cg.jkg_HUDOpacity;
			if ( i < MAX_ACI_SLOTS && cg.playerACI[i] >= 0 && cg.playerInventory[cg.playerACI[i]].id && cg.playerInventory[cg.playerACI[i]].id->itemID )
			{
			    int weapon, variation;
				if(cg.playerInventory[cg.playerACI[i]].id->itemType == ITEM_WEAPON)
				{
					if ( BG_GetWeaponByIndex (cg.playerInventory[cg.playerACI[i]].id->varID, &weapon, &variation) )
					{
						const weaponInfo_t *weaponInfo = CG_WeaponInfo (weapon, variation);
						shader = weaponInfo->hudIcon;
						col[0] = 1.0f;
						col[1] = 1.0f;
						col[2] = 1.0f;
				        
						/*trap_R_SetColor (colorTable[CT_MDGREY]);
						trap_R_DrawStretchPic(focusItem->window.rect.x, focusItem->window.rect.y, focusItem->window.rect.w, focusItem->window.rect.h, 0, 0, 1, 1, cgs.media.whiteShader);*/
						if(i == cg.weaponSelect)
						{
							trap_R_SetColor (opacity);
							//TODO: precache me!
							trap_R_DrawStretchPic(focusItem->window.rect.x, focusItem->window.rect.y, focusItem->window.rect.w, focusItem->window.rect.h, 0, 0, 1, 1, trap_R_RegisterShaderNoMip("gfx/jkghud/aciselect"));
						}
					}
				}
				else
				{
					col[0] = 1.0f;
					col[1] = 1.0f;
					col[2] = 1.0f;
					shader = trap_R_RegisterShaderNoMip(cg.playerInventory[cg.playerACI[i]].id->itemIcon);
				}
			}
			if(shader != cgs.media.whiteShader)
			{
				trap_R_SetColor( col );
				trap_R_DrawStretchPic(focusItem->window.rect.x, focusItem->window.rect.y, focusItem->window.rect.w, focusItem->window.rect.h, 0, 0, 1, 1, shader);
			}
			//CG_DrawRect(focusItem->window.rect.x, focusItem->window.rect.y, focusItem->window.rect.w, focusItem->window.rect.h, 1, colorWhite);
		}

		focusItem = Menu_FindItemByName(menuHUD, va("slotl%i", i));
		if (focusItem)
		{
			trap_R_Font_DrawString(focusItem->window.rect.x, focusItem->window.rect.y, va("%i", i), opacity, cgDC.Assets.qhSmallFont, -1, 0.4f);
		}
	}

	focusItem = Menu_FindItemByName(menuHUD, "frame_overlay");
	if(focusItem)
	{
		trap_R_SetColor(opacity);
		CG_DrawPic( 
			focusItem->window.rect.x, 
			focusItem->window.rect.y, 
			focusItem->window.rect.w, 
			focusItem->window.rect.h, 
			focusItem->window.background 
			);	
	}
}
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:90,代码来源:jkg_hud.cpp

示例12: CG_DrawScoreboard

/*
=======================================================================================================================================
CG_DrawScoreboard

Draw the normal in-game scoreboard.
=======================================================================================================================================
*/
qboolean CG_DrawScoreboard(void) {
	int x = 0, y = 0, w;    // TTimo init
	float fade;
	float *fadeColor;
	char *s;

	if (cg_fixedAspect.integer) {
		CG_SetScreenPlacement(PLACE_CENTER, PLACE_CENTER);
	}
	// don't draw anything if the menu or console is up
	if (cg_paused.integer) {
		cg.deferredPlayerLoading = 0;
		return qfalse;
	}
	// still need to see 'mission failed' message in SP
	if (cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_DEAD) {
		return qfalse;
	}

	if (cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_INTERMISSION) {
		cg.deferredPlayerLoading = 0;
		return qfalse;
	}
	// don't draw scoreboard during death while warmup up
	if (cg.warmup && !cg.showScores) {
		return qfalse;
	}

	if (cg.showScores || cg.predictedPlayerState.pm_type == PM_DEAD || cg.predictedPlayerState.pm_type == PM_INTERMISSION) {
		fade = 1.0;
	} else {
		fadeColor = CG_FadeColor(cg.scoreFadeTime, FADE_TIME);

		if (!fadeColor) {
			// next time scoreboard comes up, don't print killer
			cg.deferredPlayerLoading = 0;
			cg.killerName[0] = 0;
			return qfalse;
		}

		fade = *fadeColor;
	}
	// fragged by ... line
	if (cg.killerName[0]) {
		s = va("Killed by %s", cg.killerName);
		w = CG_DrawStrlen(s) * BIGCHAR_WIDTH;
		x = (SCREEN_WIDTH - w) / 2;
		y = 40;
		CG_DrawBigString(x, y, s, fade);
	}
	// current rank

	// ---- (SA) enclosed this so it doesn't draw for SP
	if (cgs.gametype != GT_SINGLE_PLAYER && cgs.gametype != GT_WOLF) { // added wolf multiplayer check
		if (cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR) {
			if (cgs.gametype < GT_TEAM) {
				s = va("%s place with %i", CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1), cg.snap->ps.persistant[PERS_SCORE]);
				w = CG_DrawStrlen(s) * BIGCHAR_WIDTH;
				x = (SCREEN_WIDTH - w) / 2;
				y = 60;
				CG_DrawBigString(x, y, s, fade);
			} else {
				if (cg.teamScores[0] == cg.teamScores[1]) {
					s = va("Teams are tied at %i", cg.teamScores[0]);
				} else if (cg.teamScores[0] >= cg.teamScores[1]) {
					s = va("Red leads %i to %i", cg.teamScores[0], cg.teamScores[1]);
				} else {
					s = va("Blue leads %i to %i", cg.teamScores[1], cg.teamScores[0]);
				}

				w = CG_DrawStrlen(s) * BIGCHAR_WIDTH;
				x = (SCREEN_WIDTH - w) / 2;
				y = 60;
				CG_DrawBigString(x, y, s, fade);
			}
		}
		// scoreboard
		x = 320 - SCOREBOARD_WIDTH / 2;
		y = 86;

	#if 0
		CG_DrawBigStringColor(x, y, "SCORE PING TIME NAME", fadeColor);
		CG_DrawBigStringColor(x, y + 12, "---- - ---- ---- -------------- - ", fadeColor);
	#endif
		CG_DrawPic(x + 1 * 16, y, 64, 32, cgs.media.scoreboardScore);
		CG_DrawPic(x + 6 * 16 + 8, y, 64, 32, cgs.media.scoreboardPing);
		CG_DrawPic(x + 11 * 16 + 8, y, 64, 32, cgs.media.scoreboardTime);
		CG_DrawPic(x + 16 * 16, y, 64, 32, cgs.media.scoreboardName);

		y += 32;
	}
	// NERVE - SMF
	if (cgs.gametype == GT_WOLF) {
//.........这里部分代码省略.........
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:101,代码来源:cg_scoreboard.c

示例13: CG_DrawClientScore

/*
=======================================================================================================================================
CG_DrawScoreboard
=======================================================================================================================================
*/
static void CG_DrawClientScore(int x, int y, score_t *score, float *color, float fade) {
	char string[1024];
	vec3_t headAngles;
	clientInfo_t *ci;

	if (score->client < 0 || score->client >= cgs.maxclients) {
		Com_Printf("Bad score->client: %i\n", score->client);
		return;
	}

	ci = &cgs.clientinfo[score->client];
	// draw the handicap or bot skill marker
	if (ci->botSkill > 0 && ci->botSkill <= 5) {
		CG_DrawPic(0, y - 8, 32, 32, cgs.media.botSkillShaders[ci->botSkill - 1]);
	} else if (ci->handicap < 100) {
		Com_sprintf(string, sizeof(string), "%i", ci->handicap);
		CG_DrawSmallStringColor(8, y, string, color);
	}
	// draw the wins / losses
	if (cgs.gametype == GT_TOURNAMENT) {
		Com_sprintf(string, sizeof(string), "%i/%i", ci->wins, ci->losses);
		CG_DrawSmallStringColor(x + SCOREBOARD_WIDTH + 2, y, string, color);
	}
	// draw the face
	VectorClear(headAngles);
	headAngles[YAW] = 180;

	CG_DrawHead(x - ICON_SIZE, y - (ICON_SIZE - BIGCHAR_HEIGHT) / 2, ICON_SIZE, ICON_SIZE, score->client, headAngles);

	if (ci->powerups & (1 << PW_REDFLAG)) {
		CG_DrawFlagModel(x - ICON_SIZE - ICON_SIZE / 2, y - (ICON_SIZE - BIGCHAR_HEIGHT) / 2, ICON_SIZE, ICON_SIZE, TEAM_RED);
	} else if (ci->powerups & (1 << PW_BLUEFLAG)) {
		CG_DrawFlagModel(x - ICON_SIZE - ICON_SIZE / 2, y - (ICON_SIZE - BIGCHAR_HEIGHT) / 2, ICON_SIZE, ICON_SIZE, TEAM_BLUE);
	}
	// draw the score line
	if (score->ping == -1) {
		Com_sprintf(string, sizeof(string), "connecting     %s", ci->name);
	} else if (ci->team == TEAM_SPECTATOR) {
		Com_sprintf(string, sizeof(string), "SPECT %4i %4i %s", score->ping, score->time, ci->name);
	} else {
		Com_sprintf(string, sizeof(string), "%5i %4i %4i %s", score->score, score->ping, score->time, ci->name);
	}
	// highlight your position
	if (score->client == cg.snap->ps.clientNum) {
		float hcolor[4];
		int rank;

		if (cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR
			 || cgs.gametype >= GT_TEAM) {
			rank = -1;
		} else {
			rank = cg.snap->ps.persistant[PERS_RANK] & ~RANK_TIED_FLAG;
		}

		if (rank == 0) {
			hcolor[0] = 0;
			hcolor[1] = 0;
			hcolor[2] = 0.7;
		} else if (rank == 1) {
			hcolor[0] = 0.7;
			hcolor[1] = 0;
			hcolor[2] = 0;
		} else if (rank == 2) {
			hcolor[0] = 0.7;
			hcolor[1] = 0.7;
			hcolor[2] = 0;
		} else {
			hcolor[0] = 0.7;
			hcolor[1] = 0.7;
			hcolor[2] = 0.7;
		}

		hcolor[3] = fade * 0.7;
		CG_FillRect(x - 2, y, SCOREBOARD_WIDTH, BIGCHAR_HEIGHT + 1, hcolor);
	}

	CG_DrawBigString(x, y, string, fade);
	// add the "ready" marker for intermission exiting
	if (cg.snap->ps.stats[STAT_CLIENTS_READY] & (1 << score->client)) {
		CG_DrawBigStringColor(0, y, "READY", color);
	}
}
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:87,代码来源:cg_scoreboard.c

示例14: CG_DrawHandlePicDc

void CG_DrawHandlePicDc (float x, float y, float w, float h, qhandle_t asset, int widescreen, rectDef_t menuRect)
{
    wsset();
	CG_DrawPic(x, y, w, h, asset);
    wsoff();
}
开发者ID:brugal,项目名称:wolfcamql,代码行数:6,代码来源:cg_drawdc.c

示例15: CG_DrawNumField

/*
==============
CG_DrawNumField

Take x,y positions as if 640 x 480 and scales them to the proper resolution

==============
*/
void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill) 
{
	char	num[16], *ptr;
	int		l;
	int		frame;
	int		xWidth;

	if (width < 1) {
		return;
	}

	// draw number string
	if (width > 5) {
		width = 5;
	}

	switch ( width ) {
	case 1:
		value = value > 9 ? 9 : value;
		value = value < 0 ? 0 : value;
		break;
	case 2:
		value = value > 99 ? 99 : value;
		value = value < -9 ? -9 : value;
		break;
	case 3:
		value = value > 999 ? 999 : value;
		value = value < -99 ? -99 : value;
		break;
	case 4:
		value = value > 9999 ? 9999 : value;
		value = value < -999 ? -999 : value;
		break;
	}

	Com_sprintf (num, sizeof(num), "%i", value);
	l = strlen(num);
	if (l > width)
		l = width;

	// FIXME: Might need to do something different for the chunky font??
	switch(style)
	{
	case NUM_FONT_SMALL:
		xWidth = charWidth;
		break;
	case NUM_FONT_CHUNKY:
		xWidth = (charWidth/1.2f) + 2;
		break;
	default:
	case NUM_FONT_BIG:
		xWidth = (charWidth/2) + 7;//(charWidth/6);
		break;
	}

	if ( zeroFill )
	{
		for (int i = 0; i < (width - l); i++ )
		{
			switch(style)
			{
			case NUM_FONT_SMALL:
				CG_DrawPic( x,y, charWidth, charHeight, cgs.media.smallnumberShaders[0] );
				break;
			case NUM_FONT_CHUNKY:
				CG_DrawPic( x,y, charWidth, charHeight, cgs.media.chunkyNumberShaders[0] );
				break;
			default:
			case NUM_FONT_BIG:
				CG_DrawPic( x,y, charWidth, charHeight, cgs.media.numberShaders[0] );
				break;
			}
			x += 2 + (xWidth);
		}
	}
	else
	{
		x += 2 + (xWidth)*(width - l);
	}

	ptr = num;
	while (*ptr && l)
	{
		if (*ptr == '-')
			frame = STAT_MINUS;
		else
			frame = *ptr -'0';

		switch(style)
		{
		case NUM_FONT_SMALL:
			CG_DrawPic( x,y, charWidth, charHeight, cgs.media.smallnumberShaders[frame] );
//.........这里部分代码省略.........
开发者ID:Chedo,项目名称:OpenJK,代码行数:101,代码来源:cg_drawtools.cpp


注:本文中的CG_DrawPic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。