本文整理汇总了C++中CG_Text_Width_Ext函数的典型用法代码示例。如果您正苦于以下问题:C++ CG_Text_Width_Ext函数的具体用法?C++ CG_Text_Width_Ext怎么用?C++ CG_Text_Width_Ext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CG_Text_Width_Ext函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CG_LoadPanel_RenderCampaignNameText
void CG_LoadPanel_RenderCampaignNameText(panel_button_t *button)
{
const char *cs;
float w;
float scaleF;
if (cgs.gametype == GT_WOLF_CAMPAIGN)
{
cs = DC->nameForCampaign();
if (!cs)
{
return;
}
cs = va("%s %iof%i", cs, cgs.currentCampaignMap + 1, cgs.campaignData.mapCount);
scaleF = campaignNameTextScaleFactor(Q_PrintStrlen(cs));
w = CG_Text_Width_Ext(cs, button->font->scalex * scaleF, 0, button->font->font);
CG_Text_Paint_Ext(button->rect.x + (button->rect.w - w) * 0.5f, button->rect.y, button->font->scalex * scaleF, button->font->scaley * scaleF, button->font->colour, cs, 0, 0, 0, button->font->font);
}
else
{
if (!cgs.arenaInfoLoaded)
{
return;
}
scaleF = campaignNameTextScaleFactor(Q_PrintStrlen(cgs.arenaData.longname)); // FIXME: up to 128 chars !
w = CG_Text_Width_Ext(cgs.arenaData.longname, button->font->scalex * scaleF, 0, button->font->font);
CG_Text_Paint_Ext(button->rect.x + (button->rect.w - w) * 0.5f, button->rect.y, button->font->scalex * scaleF, button->font->scaley * scaleF, button->font->colour, cgs.arenaData.longname, 0, 0, 0, button->font->font);
}
}
示例2: CG_LoadPanel_RenderCampaignNameText
void CG_LoadPanel_RenderCampaignNameText( panel_button_t* button ) {
const char* cs;
float w;
//char buffer[1024];
//int gametype;
//DC->getConfigString( CS_SERVERINFO, buffer, sizeof( buffer ) );
//cs = Info_ValueForKey( buffer, "g_gametype" );
//gametype = atoi(cs);
if( cgs.gametype == GT_WOLF_CAMPAIGN ) {
cs = DC->nameForCampaign();
if( !cs ) {
return;
}
cs = va( "%s %iof%i", cs, cgs.currentCampaignMap+1, cgs.campaignData.mapCount );
w = CG_Text_Width_Ext( cs, button->font->scalex, 0, button->font->font );
CG_Text_Paint_Ext( button->rect.x + (button->rect.w - w)*0.5f, button->rect.y, button->font->scalex, button->font->scaley, button->font->colour, cs, 0, 0, 0, button->font->font );
} else {
if( !cgs.arenaInfoLoaded ) {
return;
}
w = CG_Text_Width_Ext( cgs.arenaData.longname, button->font->scalex, 0, button->font->font );
CG_Text_Paint_Ext( button->rect.x + (button->rect.w - w)*0.5f, button->rect.y, button->font->scalex, button->font->scaley, button->font->colour, cgs.arenaData.longname, 0, 0, 0, button->font->font );
}
}
示例3: CG_ViewingDraw
qboolean CG_ViewingDraw() {
if ( cg.mvTotalClients < 1 ) {
return( qfalse );
} else {
int w, wTag;
int tSpacing = 15; // Should derive from CG_Text_Height_Ext
int pID = cg.mvCurrentMainview->mvInfo & MV_PID;
char *viewInfo = "Viewing:";
wTag = CG_Text_Width_Ext( viewInfo, VD_SCALE_X_HDR, 0, FONT_HEADER );
w = wTag + 3 + CG_Text_Width_Ext( cgs.clientinfo[pID].name, VD_SCALE_X_NAME, 0, FONT_TEXT );
CG_DrawRect( VD_X - 2, VD_Y, w + 7, tSpacing + 4, 1, color_border );
CG_FillRect( VD_X - 2, VD_Y, w + 7, tSpacing + 4, color_bg );
CG_Text_Paint_Ext( VD_X, VD_Y + tSpacing, // x, y
VD_SCALE_X_HDR, VD_SCALE_Y_HDR, // scale_x, scale_y
color_hdr,
viewInfo,
0.0f, 0,
ITEM_TEXTSTYLE_SHADOWED,
FONT_HEADER );
CG_Text_Paint_Ext( VD_X + wTag + 5, VD_Y + tSpacing, // x, y
VD_SCALE_X_NAME, VD_SCALE_Y_NAME, // scale_x, scale_y
color_name,
cgs.clientinfo[pID].name,
0.0f, 0,
ITEM_TEXTSTYLE_SHADOWED,
FONT_TEXT );
return( qtrue );
}
}
示例4: CG_PanelButton_RenderEdit
void CG_PanelButton_RenderEdit( panel_button_t* button ) {
qboolean useCvar = button->data[0] ? qfalse : qtrue;
int offset = -1;
if( useCvar ) {
char buffer[256 + 1];
trap_Cvar_VariableStringBuffer( button->text, buffer, sizeof(buffer) );
if( cg_focusButton == button && ((cg.time / 1000) % 2)) {
if( trap_Key_GetOverstrikeMode() )
Q_strcat( buffer, sizeof(buffer), "^0|" );
else
Q_strcat( buffer, sizeof(buffer), "^0_" );
} else {
Q_strcat( buffer, sizeof(buffer), " " );
}
do {
offset++;
if( buffer + offset == '\0' )
break;
} while( CG_Text_Width_Ext( buffer + offset, button->font->scalex, 0, button->font->font ) > button->rect.w );
CG_Text_Paint_Ext( button->rect.x, button->rect.y + button->rect.h, button->font->scalex, button->font->scaley, button->font->colour, va( "^7%s", buffer + offset ), 0, 0, button->font->style, button->font->font );
// CG_FillRect( button->rect.x, button->rect.y, button->rect.w, button->rect.h, colorRed );
} else {
int maxlen = button->data[0];
char *s;
if( cg_focusButton == button && ((cg.time / 1000) % 2)) {
if( trap_Key_GetOverstrikeMode() )
s = va( "^7%s^0|", button->text );
else
s = va( "^7%s^0_", button->text );
} else {
s = va( "^7%s ", button->text ); // space hack to make the text not blink
}
do {
offset++;
if( s + offset == '\0' )
break;
} while( CG_Text_Width_Ext( s + offset, button->font->scalex, 0, button->font->font ) > button->rect.w );
CG_Text_Paint_Ext( button->rect.x, button->rect.y + button->rect.h, button->font->scalex, button->font->scaley, button->font->colour, s + offset, 0, 0, button->font->style, button->font->font );
// CG_FillRect( button->rect.x, button->rect.y, button->rect.w, button->rect.h, colorRed );
}
}
示例5: CG_DrawPMItemsBig
void CG_DrawPMItemsBig(void)
{
vec4_t colour = { 0.f, 0.f, 0.f, 1.f };
vec4_t colourText = { 1.f, 1.f, 1.f, 1.f };
float t;
float y = 270;
float w;
if (!cg_pmWaitingListBig)
{
return;
}
t = cg_pmWaitingListBig->time + PM_BIGPOPUP_TIME + PM_WAITTIME_BIG;
if (cg.time > t)
{
colourText[3] = colour[3] = 1 - ((cg.time - t) / (float)PM_FADETIME_BIG);
}
trap_R_SetColor(colourText);
CG_DrawPic(Ccg_WideX(SCREEN_WIDTH) - 56, y, 48, 48, cg_pmWaitingListBig->shader);
trap_R_SetColor(NULL);
w = CG_Text_Width_Ext(cg_pmWaitingListBig->message, 0.22f, 0, &cgs.media.limboFont2);
CG_Text_Paint_Ext(Ccg_WideX(SCREEN_WIDTH) - 4 - w, y + 56, 0.22f, 0.24f, colourText, cg_pmWaitingListBig->message, 0, 0, 0, &cgs.media.limboFont2);
}
示例6: CG_LimboPanel_ClassBar_Draw
void CG_LimboPanel_ClassBar_Draw(panel_button_t *button) {
const char *text = NULL;
char buffer[64];
float w;
if (CG_LimboPanel_GetTeam() == TEAM_SPECTATOR) {
text = "JOIN A TEAM";
} else if (BG_CursorInRect(&classButton0.rect)) {
text = BG_ClassnameForNumber(0);
} else if (BG_CursorInRect(&classButton1.rect)) {
text = BG_ClassnameForNumber(1);
} else if (BG_CursorInRect(&classButton2.rect)) {
text = BG_ClassnameForNumber(2);
} else if (BG_CursorInRect(&classButton3.rect)) {
text = BG_ClassnameForNumber(3);
} else if (BG_CursorInRect(&classButton4.rect)) {
text = BG_ClassnameForNumber(4);
}
if (!text) {
text = BG_ClassnameForNumber(CG_LimboPanel_GetClass());
}
Q_strncpyz(buffer, text, sizeof (buffer));
Q_strupr(buffer);
w = CG_Text_Width_Ext(buffer, button->font->scalex, 0, button->font->font);
CG_Text_Paint_Ext(button->rect.x + (button->rect.w - w) * 0.5f, button->rect.y, button->font->scalex, button->font->scaley, button->font->colour, buffer, 0, 0, button->font->style, button->font->font);
}
示例7: CG_DrawPMItemsBig
void CG_DrawPMItemsBig( void ) {
vec4_t colour = { 0.f, 0.f, 0.f, 1.f };
vec4_t colourText = { 1.f, 1.f, 1.f, 1.f };
float t;
float y = 270;
float w;
if( !cg_pmWaitingListBig ) {
return;
}
if (!tj_drawCPM.integer)
return;
t = cg_pmWaitingListBig->time + CG_TimeForBigPopup( cg_pmWaitingListBig->type ) + PM_WAITTIME_BIG;
if( cg.time > t ) {
colourText[3] = colour[3] = 1 - ((cg.time - t) / (float)PM_FADETIME_BIG);
}
trap_R_SetColor( colourText );
CG_DrawPic( 640 - 56, y, 48, 48, cg_pmWaitingListBig->shader );
trap_R_SetColor( NULL );
w = CG_Text_Width_Ext( cg_pmWaitingListBig->message, 0.22f, 0, &cgs.media.limboFont2 );
CG_Text_Paint_Ext( 640 - 4 - w, y + 56, 0.22f, 0.24f, colourText, cg_pmWaitingListBig->message, 0, 0, 0, &cgs.media.limboFont2 );
}
示例8: CG_DrawTimer
/*
=================
CG_DrawTimer
=================
*/
static float CG_DrawTimer(float y)
{
char *s;
int w, w2;
vec4_t color = { 0.625f, 0.625f, 0.6f, 1.0f };
int tens;
char *rt = (cgs.gametype != GT_WOLF_LMS && (cgs.clientinfo[cg.clientNum].team != TEAM_SPECTATOR || cg.snap->ps.pm_flags & PMF_FOLLOW) && cg_drawReinforcementTime.integer > 0) ?
va("^F%d%s", CG_CalculateReinfTime(qfalse), ((cgs.timelimit <= 0.0f) ? "" : " ")) : "";
int x;
int msec = (cgs.timelimit * 60.f * 1000.f) - (cg.time - cgs.levelStartTime);
int seconds = msec / 1000;
int mins = seconds / 60;
seconds -= mins * 60;
tens = seconds / 10;
seconds -= tens * 10;
if (cgs.gamestate != GS_PLAYING)
{
s = va("^7%s", CG_TranslateString("WARMUP")); // don't draw reinforcement time in warmup mode // ^*
color[3] = fabs(sin(cg.time * 0.002));
}
else if (msec < 0 && cgs.timelimit > 0.0f)
{
s = "^N0:00";
color[3] = fabs(sin(cg.time * 0.002));
}
else
{
if (cgs.timelimit <= 0.0f)
{
s = va("%s", rt);
}
else
{
s = va("%s^7%i:%i%i", rt, mins, tens, seconds); // ^*
}
color[3] = 1.f;
}
// spawntimer
seconds = msec / 1000;
if (cg_spawnTimer_set.integer != -1 && cg_spawnTimer_period.integer > 0)
{
s = va("^1%d %s", cg_spawnTimer_period.integer + (seconds - cg_spawnTimer_set.integer) % cg_spawnTimer_period.integer, s);
}
// end spawntimer
w = CG_Text_Width_Ext(s, 0.19f, 0, &cgs.media.limboFont1);
w2 = (UPPERRIGHT_W > w) ? UPPERRIGHT_W : w;
x = Ccg_WideX(UPPERRIGHT_X) - w2 - 2;
CG_FillRect(x, y, w2 + 5, 12 + 2, HUD_Background);
CG_DrawRect_FixedBorder(x, y, w2 + 5, 12 + 2, 1, HUD_Border);
CG_Text_Paint_Ext(x + ((w2 - w) / 2) + 2, y + 11, 0.19f, 0.19f, color, s, 0, 0, 0, &cgs.media.limboFont1);
return y + 12 + 4;
}
示例9: CG_DrawPlayerHealth
static void CG_DrawPlayerHealth(float x, float y)
{
const char *str = va("%i", cg.snap->ps.stats[STAT_HEALTH]);
float w = CG_Text_Width_Ext(str, 0.25f, 0, &cgs.media.limboFont1);
CG_Text_Paint_Ext(x - w, y, 0.25f, 0.25f, colorWhite, str, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont1);
CG_Text_Paint_Ext(x + 2, y, 0.2f, 0.2f, colorWhite, "HP", 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont1);
}
示例10: CG_FitTextToWidth_Ext
void CG_FitTextToWidth_Ext(char *instr, float scale, float w, int size, fontInfo_t * font)
{
char buffer[1024];
char *s, *p, *c, *ls;
int l;
Q_strncpyz(buffer, instr, 1024);
memset(instr, 0, size);
c = s = instr;
p = buffer;
ls = NULL;
l = 0;
while(*p)
{
*c = *p++;
l++;
if(*c == ' ')
{
ls = c;
} // store last space, to try not to break mid word
c++;
if(*p == '\n')
{
s = c + 1;
l = 0;
}
else if(CG_Text_Width_Ext(s, scale, 0, font) > w)
{
if(ls)
{
*ls = '\n';
s = ls + 1;
}
else
{
*c = *(c - 1);
*(c - 1) = '\n';
s = c++;
}
ls = NULL;
l = 0;
}
}
if(c != buffer && (*(c - 1) != '\n'))
{
*c++ = '\n';
}
*c = '\0';
}
示例11: CG_DrawSnapshot
/*
==================
CG_DrawSnapshot
==================
*/
static float CG_DrawSnapshot(float y)
{
char *s = va("t:%i sn:%i cmd:%i", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence);
int w = CG_Text_Width_Ext(s, 0.19f, 0, &cgs.media.limboFont1);
int w2 = (UPPERRIGHT_W > w) ? UPPERRIGHT_W : w;
int x = Ccg_WideX(UPPERRIGHT_X) - w2 - 2;
CG_FillRect(x, y, w2 + 5, 12 + 2, HUD_Background);
CG_DrawRect_FixedBorder(x, y, w2 + 5, 12 + 2, 1, HUD_Border);
CG_Text_Paint_Ext(x + ((w2 - w) / 2) + 2, y + 11, 0.19f, 0.19f, HUD_Text, s, 0, 0, 0, &cgs.media.limboFont1);
return y + 12 + 4;
}
示例12: CG_DrawAmmoCount
static void CG_DrawAmmoCount(float x, float y)
{
int value, value2, value3;
char buffer[32];
// Draw ammo
CG_PlayerAmmoValue(&value, &value2, &value3);
if (value3 >= 0)
{
Com_sprintf(buffer, sizeof(buffer), "%i|%i/%i", value3, value, value2);
CG_Text_Paint_Ext(x - CG_Text_Width_Ext(buffer, .25f, 0, &cgs.media.limboFont1), y, .25f, .25f, colorWhite, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont1);
}
else if (value2 >= 0)
{
Com_sprintf(buffer, sizeof(buffer), "%i/%i", value, value2);
CG_Text_Paint_Ext(x - CG_Text_Width_Ext(buffer, .25f, 0, &cgs.media.limboFont1), y, .25f, .25f, colorWhite, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont1);
}
else if (value >= 0)
{
Com_sprintf(buffer, sizeof(buffer), "%i", value);
CG_Text_Paint_Ext(x - CG_Text_Width_Ext(buffer, .25f, 0, &cgs.media.limboFont1), y, .25f, .25f, colorWhite, buffer, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont1);
}
}
示例13: WM_DrawInfoLine
static int WM_DrawInfoLine( int x, int y, float fade ) {
int w, defender, winner;
const char *s;
vec4_t tclr = { 0.6f, 0.6f, 0.6f, 1.0f };
if ( cg.snap->ps.pm_type != PM_INTERMISSION ) {
return y;
}
w = 360;
// CG_DrawPic( 320 - w/2, y, w, INFO_LINE_HEIGHT, trap_R_RegisterShaderNoMip( "ui/assets/mp_line_strip.tga" ) );
s = CG_ConfigString( CS_MULTI_INFO );
defender = atoi( Info_ValueForKey( s, "defender" ) );
s = CG_ConfigString( CS_MULTI_MAPWINNER );
winner = atoi( Info_ValueForKey( s, "winner" ) );
if ( cgs.currentRound ) {
// first round
s = va( CG_TranslateString( "CLOCK IS NOW SET TO %s!" ), WM_TimeToString( cgs.nextTimeLimit * 60.f * 1000.f ) );
}
else {
// second round
if ( !defender ) {
if ( winner != defender )
s = "ALLIES SUCCESSFULLY BEAT THE CLOCK!";
else
s = "ALLIES COULDN'T BEAT THE CLOCK!";
}
else {
if ( winner != defender )
s = "AXIS SUCCESSFULLY BEAT THE CLOCK!";
else
s = "AXIS COULDN'T BEAT THE CLOCK!";
}
s = CG_TranslateString( s );
}
CG_FillRect( 320 - w/2, y, w, 20, clrUiBar );
CG_DrawRect_FixedBorder( 320 - w/2, y, w, 20, 1, colorBlack );
w = CG_Text_Width_Ext( s, 0.25f, 0, &cgs.media.limboFont1 );
CG_Text_Paint_Ext( 320 - w*0.5f, y + 15, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 );
// CG_DrawSmallString( 320 - w/2, ( y + INFO_LINE_HEIGHT / 2 ) - SMALLCHAR_HEIGHT / 2, s, fade );
return y + INFO_LINE_HEIGHT + 6;
}
示例14: CG_windowNormalizeOnText
// Set the window width and height based on the windows text/font parameters
void CG_windowNormalizeOnText( cg_window_t *w ) {
int i, tmp;
if ( w == NULL ) {
return;
}
w->w = 0;
w->h = 0;
if ( !( w->effects & WFX_TRUETYPE ) ) {
w->fontWidth = w->fontScaleX * WINDOW_FONTWIDTH;
w->fontHeight = w->fontScaleY * WINDOW_FONTHEIGHT;
}
for ( i = 0; i < w->lineCount; i++ ) {
if ( w->effects & WFX_TRUETYPE ) {
tmp = CG_Text_Width_Ext( (char*)w->lineText[i], w->fontScaleX, 0, &cgs.media.limboFont2 );
} else {
tmp = CG_DrawStrlen( (char*)w->lineText[i] ) * w->fontWidth;
}
if ( tmp > w->w ) {
w->w = tmp;
}
}
for ( i = 0; i < w->lineCount; i++ ) {
if ( w->effects & WFX_TRUETYPE ) {
w->lineHeight[i] = CG_Text_Height_Ext( (char*)w->lineText[i], w->fontScaleY, 0, &cgs.media.limboFont2 );
} else {
w->lineHeight[i] = w->fontHeight;
}
w->h += w->lineHeight[i] + 3;
}
// Border + margins
w->w += 10;
w->h += 3;
// Set up bottom alignment
if ( w->x < 0 ) {
w->x += 640 - w->w;
}
if ( w->y < 0 ) {
w->y += 480 - w->h;
}
}
示例15: CG_LimboPanel_WeaponPanel_DrawWeapon
void CG_LimboPanel_WeaponPanel_DrawWeapon(rectDef_t *rect, weapon_t weap, qboolean highlight, const char *ofTxt, qboolean disabled) {
weaponType_t *wt = WM_FindWeaponTypeForWeapon(weap);
qhandle_t shader = cgs.media.limboWeaponCard;
int width = CG_Text_Width_Ext(ofTxt, 0.2f, 0, &cgs.media.limboFont2);
float x = rect->x + rect->w - width - 4;
vec4_t clr;
if (!wt) {
return;
}
CG_DrawPic(rect->x, rect->y, rect->w, rect->h, shader);
if (wt->desc) {
if (highlight && BG_CursorInRect(rect)) {
Vector4Copy(weaponPanelNameFont.colour, clr);
clr[3] *= 1.5;
CG_Text_Paint_Ext(rect->x + 4, rect->y + 12, weaponPanelNameFont.scalex, weaponPanelNameFont.scaley, clr, wt->desc, 0, 0, weaponPanelNameFont.style, weaponPanelNameFont.font);
} else {
CG_Text_Paint_Ext(rect->x + 4, rect->y + 12, weaponPanelNameFont.scalex, weaponPanelNameFont.scaley, weaponPanelNameFont.colour, wt->desc, 0, 0, weaponPanelNameFont.style, weaponPanelNameFont.font);
}
}
{
float x2, y2, w, h, s0, s1, t0, t1;
trap_R_SetColor(NULL);
x2 = rect->x;
y2 = rect->y + (rect->h * 0.25f);
CG_LimboPanel_GetWeaponCardIconData(weap, &shader, &w, &h, &s0, &t0, &s1, &t1);
w *= rect->w;
h *= rect->h * 0.75f;
CG_DrawPicST(x2, y2, w, h, s0, t0, s1, t1, shader);
if (disabled) {
vec4_t clr = { 1.f, 1.f, 1.f, 0.6f };
trap_R_SetColor(clr);
CG_DrawPic(x2, y2 + 4 + (h - 16) * 0.5f, w, 16, cgs.media.limboWeaponCardOOS);
trap_R_SetColor(NULL);
}
}
CG_Text_Paint_Ext(x, rect->y + rect->h - 2, 0.2f, 0.2f, colorBlack, ofTxt, 0, 0, 0, &cgs.media.limboFont2);
}