mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-14 00:40:39 +00:00
* Patch from Tilman Sauerbeck that fixes some UI code that does not take
account of non-4:3 aspect ratios
This commit is contained in:
parent
ede5c811c2
commit
ac01b3fdc8
2 changed files with 24 additions and 22 deletions
|
@ -353,15 +353,15 @@ static void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )
|
||||||
// draw the colored text
|
// draw the colored text
|
||||||
trap_R_SetColor( color );
|
trap_R_SetColor( color );
|
||||||
|
|
||||||
ax = x * uis.scale + uis.bias;
|
ax = x * uis.xscale + uis.bias;
|
||||||
ay = y * uis.scale;
|
ay = y * uis.yscale;
|
||||||
|
|
||||||
s = str;
|
s = str;
|
||||||
while ( *s )
|
while ( *s )
|
||||||
{
|
{
|
||||||
ch = *s & 127;
|
ch = *s & 127;
|
||||||
if ( ch == ' ' ) {
|
if ( ch == ' ' ) {
|
||||||
ax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* uis.scale;
|
ax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* uis.xscale;
|
||||||
}
|
}
|
||||||
else if ( ch >= 'A' && ch <= 'Z' ) {
|
else if ( ch >= 'A' && ch <= 'Z' ) {
|
||||||
ch -= 'A';
|
ch -= 'A';
|
||||||
|
@ -369,10 +369,10 @@ static void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )
|
||||||
frow = (float)propMapB[ch][1] / 256.0f;
|
frow = (float)propMapB[ch][1] / 256.0f;
|
||||||
fwidth = (float)propMapB[ch][2] / 256.0f;
|
fwidth = (float)propMapB[ch][2] / 256.0f;
|
||||||
fheight = (float)PROPB_HEIGHT / 256.0f;
|
fheight = (float)PROPB_HEIGHT / 256.0f;
|
||||||
aw = (float)propMapB[ch][2] * uis.scale;
|
aw = (float)propMapB[ch][2] * uis.xscale;
|
||||||
ah = (float)PROPB_HEIGHT * uis.scale;
|
ah = (float)PROPB_HEIGHT * uis.yscale;
|
||||||
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, uis.charsetPropB );
|
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, uis.charsetPropB );
|
||||||
ax += (aw + (float)PROPB_GAP_WIDTH * uis.scale);
|
ax += (aw + (float)PROPB_GAP_WIDTH * uis.xscale);
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
@ -463,27 +463,27 @@ static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t co
|
||||||
// draw the colored text
|
// draw the colored text
|
||||||
trap_R_SetColor( color );
|
trap_R_SetColor( color );
|
||||||
|
|
||||||
ax = x * uis.scale + uis.bias;
|
ax = x * uis.xscale + uis.bias;
|
||||||
ay = y * uis.scale;
|
ay = y * uis.yscale;
|
||||||
|
|
||||||
s = str;
|
s = str;
|
||||||
while ( *s )
|
while ( *s )
|
||||||
{
|
{
|
||||||
ch = *s & 127;
|
ch = *s & 127;
|
||||||
if ( ch == ' ' ) {
|
if ( ch == ' ' ) {
|
||||||
aw = (float)PROP_SPACE_WIDTH * uis.scale * sizeScale;
|
aw = (float)PROP_SPACE_WIDTH * uis.xscale * sizeScale;
|
||||||
}
|
}
|
||||||
else if ( propMap[ch][2] != -1 ) {
|
else if ( propMap[ch][2] != -1 ) {
|
||||||
fcol = (float)propMap[ch][0] / 256.0f;
|
fcol = (float)propMap[ch][0] / 256.0f;
|
||||||
frow = (float)propMap[ch][1] / 256.0f;
|
frow = (float)propMap[ch][1] / 256.0f;
|
||||||
fwidth = (float)propMap[ch][2] / 256.0f;
|
fwidth = (float)propMap[ch][2] / 256.0f;
|
||||||
fheight = (float)PROP_HEIGHT / 256.0f;
|
fheight = (float)PROP_HEIGHT / 256.0f;
|
||||||
aw = (float)propMap[ch][2] * uis.scale * sizeScale;
|
aw = (float)propMap[ch][2] * uis.xscale * sizeScale;
|
||||||
ah = (float)PROP_HEIGHT * uis.scale * sizeScale;
|
ah = (float)PROP_HEIGHT * uis.yscale * sizeScale;
|
||||||
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset );
|
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset );
|
||||||
}
|
}
|
||||||
|
|
||||||
ax += (aw + (float)PROP_GAP_WIDTH * uis.scale * sizeScale);
|
ax += (aw + (float)PROP_GAP_WIDTH * uis.xscale * sizeScale);
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,10 +654,10 @@ static void UI_DrawString2( int x, int y, const char* str, vec4_t color, int cha
|
||||||
// draw the colored text
|
// draw the colored text
|
||||||
trap_R_SetColor( color );
|
trap_R_SetColor( color );
|
||||||
|
|
||||||
ax = x * uis.scale + uis.bias;
|
ax = x * uis.xscale + uis.bias;
|
||||||
ay = y * uis.scale;
|
ay = y * uis.yscale;
|
||||||
aw = charw * uis.scale;
|
aw = charw * uis.xscale;
|
||||||
ah = charh * uis.scale;
|
ah = charh * uis.yscale;
|
||||||
|
|
||||||
s = str;
|
s = str;
|
||||||
while ( *s )
|
while ( *s )
|
||||||
|
@ -1068,7 +1068,8 @@ void UI_Init( void ) {
|
||||||
trap_GetGlconfig( &uis.glconfig );
|
trap_GetGlconfig( &uis.glconfig );
|
||||||
|
|
||||||
// for 640x480 virtualized screen
|
// for 640x480 virtualized screen
|
||||||
uis.scale = uis.glconfig.vidHeight * (1.0/480.0);
|
uis.xscale = uis.glconfig.vidWidth * (1.0/640.0);
|
||||||
|
uis.yscale = uis.glconfig.vidHeight * (1.0/480.0);
|
||||||
if ( uis.glconfig.vidWidth * 480 > uis.glconfig.vidHeight * 640 ) {
|
if ( uis.glconfig.vidWidth * 480 > uis.glconfig.vidHeight * 640 ) {
|
||||||
// wide screen
|
// wide screen
|
||||||
uis.bias = 0.5 * ( uis.glconfig.vidWidth - ( uis.glconfig.vidHeight * (640.0/480.0) ) );
|
uis.bias = 0.5 * ( uis.glconfig.vidWidth - ( uis.glconfig.vidHeight * (640.0/480.0) ) );
|
||||||
|
@ -1094,10 +1095,10 @@ Adjusted for resolution and screen aspect ratio
|
||||||
*/
|
*/
|
||||||
void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||||
// expect valid pointers
|
// expect valid pointers
|
||||||
*x = *x * uis.scale + uis.bias;
|
*x = *x * uis.xscale + uis.bias;
|
||||||
*y *= uis.scale;
|
*y *= uis.yscale;
|
||||||
*w *= uis.scale;
|
*w *= uis.xscale;
|
||||||
*h *= uis.scale;
|
*h *= uis.yscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {
|
void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {
|
||||||
|
|
|
@ -547,7 +547,8 @@ typedef struct {
|
||||||
qhandle_t cursor;
|
qhandle_t cursor;
|
||||||
qhandle_t rb_on;
|
qhandle_t rb_on;
|
||||||
qhandle_t rb_off;
|
qhandle_t rb_off;
|
||||||
float scale;
|
float xscale;
|
||||||
|
float yscale;
|
||||||
float bias;
|
float bias;
|
||||||
qboolean demoversion;
|
qboolean demoversion;
|
||||||
qboolean firstdraw;
|
qboolean firstdraw;
|
||||||
|
|
Loading…
Reference in a new issue