Compare commits

...

7 Commits

8 changed files with 243 additions and 172 deletions

View File

@@ -13,10 +13,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
*/ */
#include <ctype.h>
#include "common.h" #include "common.h"
#include "filesystem.h" #include "filesystem.h"
#include "client.h" #include "client.h"
#include "qfont.h" #include "qfont.h"
#include "utflib.h"
qboolean CL_FixedFont( cl_font_t *font ) qboolean CL_FixedFont( cl_font_t *font )
{ {
@@ -173,31 +175,27 @@ static int CL_CalcTabStop( const cl_font_t *font, int x )
return stop; return stop;
} }
int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_t *font, int flags ) static int CL_DrawBitmapCharacter( float x, float y, uint32_t uc, const rgba_t color, const cl_font_t *font, int flags )
{ {
wrect_t *rc; wrect_t *rc;
float w, h; float w, h;
float s1, t1, s2, t2, half = 0.5f; float s1, t1, s2, t2, half = 0.5f;
int texw, texh; int texw, texh;
uint32_t number;
if( !font || !font->valid || y < -font->charHeight ) // bitmap fonts need conversion. Do this and validate the result
if( g_codepage == 1251 )
number = Q_UnicodeToCP1251( uc );
else if( g_codepage == 1252 )
number = Q_UnicodeToCP1252( uc );
else
number = uc;
if( !number || number >= ARRAYSIZE( font->charWidths ))
return 0; return 0;
// check if printable // start rendering
if( number <= 32 ) if( !font->charWidths[number] )
{
if( number == ' ' )
return font->charWidths[' '];
else if( number == '\t' )
return CL_CalcTabStop( font, x );
return 0;
}
if( FBitSet( flags, FONT_DRAW_UTF8 ))
number = Con_UtfProcessChar( number & 255 );
else number &= 255;
if( !number || !font->charWidths[number])
return 0; return 0;
R_GetTextureParms( &texw, &texh, font->hFontTexture ); R_GetTextureParms( &texw, &texh, font->hFontTexture );
@@ -231,29 +229,60 @@ int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_
return font->charWidths[number]; return font->charWidths[number];
} }
int CL_DrawString( float x, float y, const char *s, const rgba_t color, cl_font_t *font, int flags ) static int CL_DrawTrueTypeCharacter( float x, float y, uint32_t uc, const rgba_t color, cl_font_t *font, int flags )
{
// stub
return 0;
}
int CL_DrawCharacter( float x, float y, uint32_t uc, const rgba_t color, const cl_font_t *font, int flags )
{
if( !font || !font->valid || y < -font->charHeight )
return 0;
// check if printable
if( uc <= 32 )
{
if( uc == ' ' )
return font->charWidths[' '];
else if( uc == '\t' )
return CL_CalcTabStop( font, x );
return 0;
}
if( font->type == FONT_TRUETYPE )
return CL_DrawTrueTypeCharacter( x, y, uc, color, font, flags );
return CL_DrawBitmapCharacter( x, y, uc, color, font, flags );
}
int CL_DrawString( float x, float y, const char *s, const rgba_t color, const cl_font_t *font, int flags )
{ {
rgba_t current_color; rgba_t current_color;
int draw_len = 0; int draw_len = 0;
utfstate_t utfstate = { 0 };
if( !font || !font->valid ) if( !font || !font->valid )
return 0; return 0;
if( FBitSet( flags, FONT_DRAW_UTF8 ))
Con_UtfProcessChar( 0 ); // clear utf state
if( !FBitSet( flags, FONT_DRAW_NORENDERMODE )) if( !FBitSet( flags, FONT_DRAW_NORENDERMODE ))
CL_SetFontRendermode( font ); CL_SetFontRendermode( font );
Vector4Copy( color, current_color ); Vector4Copy( color, current_color );
while( *s ) for( ; *s; s++ )
{ {
if( *s == '\n' ) uint32_t uc = (byte)*s;
{
s++;
if( !*s ) if( FBitSet( flags, FONT_DRAW_UTF8 ))
uc = Q_DecodeUTF8( &utfstate, uc );
if( !uc )
continue;
if( uc == '\n' )
{
if( !s[1] ) // ignore newline at end of string if next
break; break;
// some client functions ignore newlines // some client functions ignore newlines
@@ -264,30 +293,29 @@ int CL_DrawString( float x, float y, const char *s, const rgba_t color, cl_font_
} }
if( FBitSet( flags, FONT_DRAW_RESETCOLORONLF )) if( FBitSet( flags, FONT_DRAW_RESETCOLORONLF ))
Vector4Copy( color, current_color ); Vector4Copy( color, current_color );
continue; continue;
} }
if( IsColorString( s )) // check for colorstrings
if( uc == '^' && isdigit( s[1] ))
{ {
// don't copy alpha
if( !FBitSet( flags, FONT_DRAW_FORCECOL )) if( !FBitSet( flags, FONT_DRAW_FORCECOL ))
VectorCopy( g_color_table[ColorIndex(*( s + 1 ))], current_color ); VectorCopy( g_color_table[ColorIndex( s[1] )], current_color );
s += 2; s++;
continue; continue;
} }
// skip setting rendermode, it was changed for this string already // skip setting rendermode, it was changed for this string already
draw_len += CL_DrawCharacter( x + draw_len, y, (byte)*s, current_color, font, flags | FONT_DRAW_NORENDERMODE ); draw_len += CL_DrawCharacter( x + draw_len, y, uc, current_color, font, flags | FONT_DRAW_NORENDERMODE );
s++;
} }
return draw_len; return draw_len;
} }
int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... ) int CL_DrawStringf( const cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... )
{ {
va_list va; va_list va;
char buf[MAX_VA_STRING]; char buf[MAX_VA_STRING];
@@ -299,20 +327,63 @@ int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int f
return CL_DrawString( x, y, buf, color, font, flags ); return CL_DrawString( x, y, buf, color, font, flags );
} }
void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height ) static int CL_DrawBitmapCharacterLen( const cl_font_t *font, uint32_t uc )
{ {
if( !font || !font->valid ) return; int number;
if( width )
{ if( g_codepage == 1251 )
if( number == '\t' ) number = Q_UnicodeToCP1251( uc );
*width = CL_CalcTabStop( font, 0 ); // at least return max tabstop else if( g_codepage == 1252 )
else *width = font->charWidths[number & 255]; number = Q_UnicodeToCP1252( uc );
} else
if( height ) *height = font->charHeight; number = uc;
if( !number || number >= ARRAYSIZE( font->charWidths ))
return 0;
return font->charWidths[number];
} }
void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height, int flags ) static int CL_DrawTrueTypeCharacterLen( const cl_font_t *font, uint32_t uc )
{ {
// stub
return 0;
}
void CL_DrawCharacterLen( const cl_font_t *font, uint32_t uc, int *width, int *height )
{
if( !font || !font->valid )
return;
if( height )
*height = font->charHeight;
if( width )
{
// basically matches logic of CL_DrawCharacter
if( uc <= 32 )
{
if( uc == ' ' )
*width = font->charWidths[' '];
else if( uc == '\t' )
*width = CL_CalcTabStop( font, 0 ); // at least return max tabstop
else
*width = 0;
}
else if( font->type == FONT_TRUETYPE )
{
*width = CL_DrawTrueTypeCharacterLen( font, uc );
}
else
{
*width = CL_DrawBitmapCharacterLen( font, uc );
}
}
}
void CL_DrawStringLen( const cl_font_t *font, const char *s, int *width, int *height, int flags )
{
utfstate_t utfstate = { 0 };
int draw_len = 0; int draw_len = 0;
if( !font || !font->valid ) if( !font || !font->valid )
@@ -327,54 +398,45 @@ void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height,
if( !COM_CheckString( s )) if( !COM_CheckString( s ))
return; return;
if( FBitSet( flags, FONT_DRAW_UTF8 )) for( ; *s; s++ )
Con_UtfProcessChar( 0 ); // reset utf state
while( *s )
{ {
int number; uint32_t uc = (byte)*s;
int char_width = 0;
if( *s == '\n' ) if( FBitSet( flags, FONT_DRAW_UTF8 ))
uc = Q_DecodeUTF8( &utfstate, uc );
if( !uc )
continue;
if( uc == '\n' )
{ {
// BUG: no check for end string here // BUG: no check for end string here
// but high chances somebody's relying on this // but high chances somebody's relying on this
s++;
draw_len = 0; draw_len = 0;
// some client functions ignore newlines
if( !FBitSet( flags, FONT_DRAW_NOLF )) if( !FBitSet( flags, FONT_DRAW_NOLF ))
{ {
if( height ) if( height )
*height += font->charHeight; *height += font->charHeight;
} }
continue;
} }
else if( *s == '\t' )
// check for colorstrings
if( uc == '^' && isdigit( s[1] ))
{ {
draw_len += CL_CalcTabStop( font, 0 ); // at least return max tabstop
s++; s++;
continue; continue;
} }
if( IsColorString( s )) CL_DrawCharacterLen( font, uc, &char_width, NULL );
draw_len += char_width;
if( width )
{ {
s += 2; if( *width < draw_len )
continue; *width = draw_len;
} }
if( FBitSet( flags, FONT_DRAW_UTF8 ))
number = Con_UtfProcessChar( (byte)*s );
else number = (byte)*s;
if( number )
{
draw_len += font->charWidths[number];
if( width )
{
if( draw_len > *width )
*width = draw_len;
}
}
s++;
} }
} }

View File

@@ -33,6 +33,7 @@ GNU General Public License for more details.
#include "vgui_draw.h" #include "vgui_draw.h"
#include "sound.h" // SND_STOP_LOOPING #include "sound.h" // SND_STOP_LOOPING
#include "platform/platform.h" #include "platform/platform.h"
#include "utflib.h"
#define MAX_LINELENGTH 80 #define MAX_LINELENGTH 80
#define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels) #define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
@@ -408,8 +409,10 @@ void CL_DrawCenterPrint( void )
char *pText; char *pText;
int i, j, x, y; int i, j, x, y;
int width, lineLength; int width, lineLength;
byte *colorDefault, line[MAX_LINELENGTH]; byte *colorDefault;
uint32_t line[MAX_LINELENGTH];
int charWidth, charHeight; int charWidth, charHeight;
utfstate_t utfstate = { 0 };
if( !clgame.centerPrint.time ) if( !clgame.centerPrint.time )
return; return;
@@ -432,14 +435,19 @@ void CL_DrawCenterPrint( void )
lineLength = 0; lineLength = 0;
width = 0; width = 0;
while( *pText && *pText != '\n' && lineLength < MAX_LINELENGTH ) for( ; *pText && *pText != '\n' && lineLength < MAX_LINELENGTH; pText++ )
{ {
byte c = *pText; byte c = *pText;
line[lineLength] = c; uint32_t uc = Q_DecodeUTF8( &utfstate, c );
CL_DrawCharacterLen( font, c, &charWidth, NULL );
if( !uc )
continue;
line[lineLength] = uc;
CL_DrawCharacterLen( font, uc, &charWidth, NULL );
width += charWidth; width += charWidth;
lineLength++; lineLength++;
pText++;
} }
if( lineLength == MAX_LINELENGTH ) if( lineLength == MAX_LINELENGTH )
@@ -453,7 +461,7 @@ void CL_DrawCenterPrint( void )
for( j = 0; j < lineLength; j++ ) for( j = 0; j < lineLength; j++ )
{ {
if( x >= 0 && y >= 0 && x <= refState.width ) if( x >= 0 && y >= 0 && x <= refState.width )
x += CL_DrawCharacter( x, y, line[j], colorDefault, font, FONT_DRAW_UTF8 | FONT_DRAW_HUD | FONT_DRAW_NORENDERMODE ); x += CL_DrawCharacter( x, y, line[j], colorDefault, font, FONT_DRAW_HUD | FONT_DRAW_NORENDERMODE );
} }
y += charHeight; y += charHeight;
} }
@@ -1989,7 +1997,13 @@ static int GAME_EXPORT pfnDrawCharacter( int x, int y, int number, int r, int g,
int flags = FONT_DRAW_HUD; int flags = FONT_DRAW_HUD;
if( hud_utf8.value ) if( hud_utf8.value )
flags |= FONT_DRAW_UTF8; {
static utfstate_t utfstate;
number = Q_DecodeUTF8( &utfstate, number );
if( !number )
return 0;
}
return CL_DrawCharacter( x, y, number, color, &cls.creditsFont, flags ); return CL_DrawCharacter( x, y, number, color, &cls.creditsFont, flags );
} }
@@ -3052,12 +3066,8 @@ pfnDrawString
*/ */
static int GAME_EXPORT pfnDrawString( int x, int y, const char *str, int r, int g, int b ) static int GAME_EXPORT pfnDrawString( int x, int y, const char *str, int r, int g, int b )
{ {
rgba_t color = { r, g, b, 255 }; const rgba_t color = { r, g, b, 255 };
int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF; int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF | FONT_DRAW_UTF8;
if( hud_utf8.value )
SetBits( flags, FONT_DRAW_UTF8 );
return CL_DrawString( x, y, str, color, &cls.creditsFont, flags ); return CL_DrawString( x, y, str, color, &cls.creditsFont, flags );
} }
@@ -3069,13 +3079,10 @@ pfnDrawStringReverse
*/ */
static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int r, int g, int b ) static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int r, int g, int b )
{ {
rgba_t color = { r, g, b, 255 }; const rgba_t color = { r, g, b, 255 };
int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF; int flags = FONT_DRAW_HUD | FONT_DRAW_NOLF | FONT_DRAW_UTF8;
int width; int width;
if( hud_utf8.value )
SetBits( flags, FONT_DRAW_UTF8 );
CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags ); CL_DrawStringLen( &cls.creditsFont, str, &width, NULL, flags );
x -= width; x -= width;

View File

@@ -1324,10 +1324,21 @@ static int pfnIsCvarReadOnly( const char *name )
return FBitSet( cv->flags, FCVAR_READ_ONLY ) ? 1 : 0; return FBitSet( cv->flags, FCVAR_READ_ONLY ) ? 1 : 0;
} }
static int GAME_EXPORT pfnUtfProcessChar( int in )
{
// compatibility export, deprecated, do not use
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return in;
// otherwise, decode it and convert to selected codepage
return Con_UtfProcessCharForce( in );
}
static ui_extendedfuncs_t gExtendedfuncs = static ui_extendedfuncs_t gExtendedfuncs =
{ {
pfnEnableTextInput, pfnEnableTextInput,
Con_UtfProcessChar, pfnUtfProcessChar,
Con_UtfMoveLeft, Con_UtfMoveLeft,
Con_UtfMoveRight, Con_UtfMoveRight,
pfnGetRenderers, pfnGetRenderers,

View File

@@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "library.h" #include "library.h"
#include "input.h" #include "input.h"
#include "platform/platform.h" #include "platform/platform.h"
#include "utflib.h"
static CVAR_DEFINE_AUTO( vibration_length, "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "vibration length" ); static CVAR_DEFINE_AUTO( vibration_length, "1.0", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "vibration length" );
static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" ); static CVAR_DEFINE_AUTO( vibration_enable, "1", FCVAR_ARCHIVE | FCVAR_PRIVILEGED, "enable vibration" );
@@ -58,7 +59,13 @@ static int pfnDrawScaledCharacter( int x, int y, int number, int r, int g, int b
int flags = FONT_DRAW_HUD; int flags = FONT_DRAW_HUD;
if( hud_utf8.value ) if( hud_utf8.value )
SetBits( flags, FONT_DRAW_UTF8 ); {
static utfstate_t utfstate;
number = Q_DecodeUTF8( &utfstate, number );
if( !number )
return 0;
}
if( fabs( g_font_scale - scale ) > 0.1f || if( fabs( g_font_scale - scale ) > 0.1f ||
g_scaled_font.hFontTexture != cls.creditsFont.hFontTexture ) g_scaled_font.hFontTexture != cls.creditsFont.hFontTexture )

View File

@@ -326,8 +326,12 @@ typedef struct
pfnEventHook func; // user-defined function pfnEventHook func; // user-defined function
} cl_user_event_t; } cl_user_event_t;
#define FONT_FIXED 0 enum
#define FONT_VARIABLE 1 {
FONT_FIXED,
FONT_VARIABLE,
FONT_TRUETYPE
};
#define FONT_DRAW_HUD BIT( 0 ) // pass to drawing function to apply hud_scale #define FONT_DRAW_HUD BIT( 0 ) // pass to drawing function to apply hud_scale
#define FONT_DRAW_UTF8 BIT( 1 ) // call UtfProcessChar #define FONT_DRAW_UTF8 BIT( 1 ) // call UtfProcessChar
@@ -807,11 +811,12 @@ qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font, float sc
qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags ); qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font, float scale, convar_t *rendermode, uint texFlags );
void CL_FreeFont( cl_font_t *font ); void CL_FreeFont( cl_font_t *font );
void CL_SetFontRendermode( cl_font_t *font ); void CL_SetFontRendermode( cl_font_t *font );
int CL_DrawCharacter( float x, float y, int number, const rgba_t color, cl_font_t *font, int flags ); int CL_DrawCharacter( float x, float y, uint32_t uc, const rgba_t color, const cl_font_t *font, int flags );
int CL_DrawString( float x, float y, const char *s, const rgba_t color, cl_font_t *font, int flags ); void CL_DrawCharacterLen( const cl_font_t *font, uint32_t uc, int *width, int *height );
void CL_DrawCharacterLen( cl_font_t *font, int number, int *width, int *height );
void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height, int flags ); int CL_DrawString( float x, float y, const char *s, const rgba_t color, const cl_font_t *font, int flags );
int CL_DrawStringf( cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... ) FORMAT_CHECK( 6 ); int CL_DrawStringf( const cl_font_t *font, float x, float y, const rgba_t color, int flags, const char *fmt, ... ) FORMAT_CHECK( 6 );
void CL_DrawStringLen( const cl_font_t *font, const char *s, int *width, int *height, int flags );
// //
@@ -1090,6 +1095,7 @@ void CL_ReadLineFile_f( void );
// console.c // console.c
// //
extern convar_t con_fontsize; extern convar_t con_fontsize;
extern int g_codepage;
int Con_Visible( void ); int Con_Visible( void );
qboolean Con_FixedFont( void ); qboolean Con_FixedFont( void );
void Con_VidInit( void ); void Con_VidInit( void );
@@ -1100,7 +1106,6 @@ void Con_DrawDebug( void );
void Con_RunConsole( void ); void Con_RunConsole( void );
void Con_DrawConsole( void ); void Con_DrawConsole( void );
void Con_DrawVersion( void ); void Con_DrawVersion( void );
int Con_UtfProcessChar( int in );
int Con_UtfProcessCharForce( int in ); int Con_UtfProcessCharForce( int in );
int Con_UtfMoveLeft( char *str, int pos ); int Con_UtfMoveLeft( char *str, int pos );
int Con_UtfMoveRight( char *str, int pos, int length ); int Con_UtfMoveRight( char *str, int pos, int length );

View File

@@ -34,7 +34,7 @@ static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom c
static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" ); static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" );
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" ); static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
static int g_codepage = 0; int g_codepage = 0;
static qboolean g_messagemode_privileged = true; static qboolean g_messagemode_privileged = true;
@@ -632,15 +632,6 @@ int Con_UtfProcessCharForce( int in )
return '?'; // not implemented yet return '?'; // not implemented yet
} }
int GAME_EXPORT Con_UtfProcessChar( int in )
{
if( !cls.accept_utf8 ) // incoming character is not a UTF-8 sequence
return in;
// otherwise, decode it and convert to selected codepage
return Con_UtfProcessCharForce( in );
}
/* /*
================= =================
Con_UtfMoveLeft Con_UtfMoveLeft

View File

@@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "math.h" #include "math.h"
#include "vgui_draw.h" #include "vgui_draw.h"
#include "mobility_int.h" #include "mobility_int.h"
#include "utflib.h"
typedef enum typedef enum
{ {
@@ -1298,73 +1299,62 @@ static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 )
} }
} }
static float Touch_DrawCharacter( float x, float y, int number, float size ) static void Touch_DrawText( float x1, float y1, float x2, float y2, const char *s, byte *color, float size )
{ {
float s1, s2, t1, t2, width, height; float minx, maxy, maxx;
int w, h; const float scale = TO_SCRN_X( size / 1024.0f );
wrect_t *prc; const float backup_scale = cls.creditsFont.scale;
utfstate_t utfstate = { 0 };
rgba_t current_color;
if( !cls.creditsFont.valid ) if( !cls.creditsFont.valid )
return 0; return;
number &= 255; x1 = TO_SCRN_X( x1 );
number = Con_UtfProcessChar( number ); y1 = TO_SCRN_Y( y1 );
x2 = TO_SCRN_X( x2 );
y2 = TO_SCRN_Y( y2 );
if( !number ) minx = x1;
return 0; maxy = y2;
R_GetTextureParms( &w, &h, cls.creditsFont.hFontTexture );
prc = &cls.creditsFont.fontRc[number];
s1 = prc->left / (float)w;
t1 = prc->top / (float)h;
s2 = prc->right / (float)w;
t2 = prc->bottom / (float)h;
width = ( prc->right - prc->left ) / 1024.0f * size;
height = ( prc->bottom - prc->top ) / 1024.0f * size;
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( x ), TO_SCRN_Y( y ), TO_SCRN_X( width ), TO_SCRN_X( height ),
s1, t1, s2, t2, cls.creditsFont.hFontTexture );
return width;
}
static float Touch_DrawText( float x1, float y1, float x2, float y2, const char *s, byte *color, float size )
{
float x = x1;
float maxy = y2;
float maxx;
float alpha = color[3] / 255.0f;
if( x2 ) if( x2 )
maxx = x2 - cls.creditsFont.charWidths['M'] / 1024.0f * size; maxx = x2 - cls.creditsFont.charWidths['M'] * scale;
else else
maxx = 1; maxx = 1;
if( !cls.creditsFont.valid ) cls.creditsFont.scale = scale;
return GRID_X * 2;
Con_UtfProcessChar( 0 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
// text is additive and alpha does not work // text is additive and alpha does not work
ref.dllFuncs.Color4ub( color[0] * alpha, color[1] * alpha, color[2] * alpha, 255 ); ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
VectorScale( color, color[3] / 255.0f, current_color );
current_color[3] = 255;
while( *s ) for( ; *s; s++ )
{ {
while( *s && ( *s != '\n' ) && ( *s != ';' ) && ( x1 < maxx )) int draw_len;
x1 += Touch_DrawCharacter( x1, y1, *s++, size ); uint32_t uc = Q_DecodeUTF8( &utfstate, (byte)*s );
y1 += cls.creditsFont.charHeight / 1024.f * size / Touch_AspectRatio();
if( y1 >= maxy ) if( !uc )
break; continue;
if( *s == '\n' || *s == ';' ) if( uc == '\n' || uc == ';' || x1 >= maxx )
s++; {
x1 = x; x1 = minx;
y1 += cls.creditsFont.charHeight * scale;
if( y1 >= maxy )
break;
continue;
}
// because we override font scale without changing charWidths, scale it ourselves
draw_len = CL_DrawCharacter( x1, y1, uc, current_color, &cls.creditsFont, FONT_DRAW_NORENDERMODE );
x1 += draw_len * scale;
} }
return x1;
cls.creditsFont.scale = backup_scale;
} }
static void Touch_DrawButtons( touchbuttonlist_t *list ) static void Touch_DrawButtons( touchbuttonlist_t *list )

View File

@@ -957,6 +957,7 @@ enum
OSK_ENTER, OSK_ENTER,
OSK_SPECKEY_LAST OSK_SPECKEY_LAST
}; };
static const char *osk_keylayout[][4] = static const char *osk_keylayout[][4] =
{ {
{ {
@@ -973,7 +974,7 @@ static const char *osk_keylayout[][4] =
} }
}; };
struct osk_s static struct osk_s
{ {
qboolean enable; qboolean enable;
int curlayout; int curlayout;
@@ -1007,7 +1008,6 @@ static qboolean OSK_KeyEvent( int key, int down )
return false; return false;
} }
switch ( key ) switch ( key )
{ {
case K_ENTER: case K_ENTER:
@@ -1050,10 +1050,6 @@ static qboolean OSK_KeyEvent( int key, int down )
ch = (byte)osk.curbutton.val; ch = (byte)osk.curbutton.val;
// do not pass UTF-8 sequence into the engine, convert it here
if( !cls.accept_utf8 )
ch = Con_UtfProcessCharForce( ch );
if( !ch ) if( !ch )
break; break;
@@ -1188,13 +1184,15 @@ void OSK_Draw( void )
X_STEP * MAX_OSK_ROWS * refState.width, X_STEP * MAX_OSK_ROWS * refState.width,
Y_STEP * MAX_OSK_LINES * refState.height, 100, 100, 100, 100 ); Y_STEP * MAX_OSK_LINES * refState.height, 100, 100, 100, 100 );
OSK_DrawSpecialButton( "-]", X_START, Y_START + Y_STEP * 2, X_STEP, Y_STEP ); OSK_DrawSpecialButton( "-]", X_START, Y_START + Y_STEP * 2, X_STEP, Y_STEP );
OSK_DrawSpecialButton( "<-", X_START + X_STEP * 12, Y_START + Y_STEP * 2, X_STEP, Y_STEP ); OSK_DrawSpecialButton( "<-", X_START + X_STEP * 12, Y_START + Y_STEP * 2, X_STEP, Y_STEP );
OSK_DrawSpecialButton( "sh", X_START, Y_START + Y_STEP * 3, X_STEP, Y_STEP ); OSK_DrawSpecialButton( "sh", X_START, Y_START + Y_STEP * 3, X_STEP, Y_STEP );
OSK_DrawSpecialButton( "en", X_START + X_STEP * 12, Y_START + Y_STEP * 3, X_STEP, Y_STEP ); OSK_DrawSpecialButton( "en", X_START + X_STEP * 12, Y_START + Y_STEP * 3, X_STEP, Y_STEP );
for( y = Y_START, j = 0; j < MAX_OSK_LINES; j++, y += Y_STEP ) for( y = Y_START, j = 0; j < MAX_OSK_LINES; j++, y += Y_STEP )
{
for( x = X_START, i = 0; i < MAX_OSK_ROWS; i++, x += X_STEP ) for( x = X_START, i = 0; i < MAX_OSK_ROWS; i++, x += X_STEP )
OSK_DrawSymbolButton( curlayout[j][i], x, y, X_STEP, Y_STEP ); OSK_DrawSymbolButton( curlayout[j][i], x, y, X_STEP, Y_STEP );
}
} }