Update draw util

This commit is contained in:
a1batross 2016-04-03 21:40:57 +03:00
parent f1b897ffdf
commit dfb5d24d71
2 changed files with 32 additions and 22 deletions

View File

@ -36,7 +36,7 @@ version.
extern cvar_t *hud_textmode;
float DrawUtils::color[3];
int DrawUtils::DrawHudString( int xpos, int ypos, int iMaxX, const char *str, int r, int g, int b, bool drawing )
int DrawUtils::DrawHudString( int xpos, int ypos, int iMaxX, const char *str, int r, int g, int b, float scale, bool drawing )
{
char *szIt = (char *)str;
// draw the string until we hit the null character or a newline character
@ -68,31 +68,31 @@ int DrawUtils::DrawHudString( int xpos, int ypos, int iMaxX, const char *str, in
}
}
xpos += TextMessageDrawChar( xpos, ypos, *szIt, r, g, b );
xpos += TextMessageDrawChar( xpos, ypos, *szIt, r, g, b, scale );
}
return xpos;
}
int DrawUtils::HudStringLen( const char *szIt )
int DrawUtils::HudStringLen(const char *szIt , float scale)
{
int l = 0;
// draw the string until we hit the null character or a newline character
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
{
l += gHUD.m_scrinfo.charWidths[(unsigned char)*szIt]; // variable-width fonts look cool
l += gHUD.m_scrinfo.charWidths[(unsigned char)*szIt] * scale; // variable-width fonts look cool
}
return l;
}
int DrawUtils::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b )
int DrawUtils::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b, float scale )
{
char szString[32];
snprintf( szString, 32, "%d", iNumber );
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b );
return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b, scale );
}
int DrawUtils::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b, bool drawing )
int DrawUtils::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b, float scale, bool drawing )
{
// iterate throug the string in reverse
for ( signed int i = strlen( szString ); i >= 0; i-- )
@ -124,7 +124,7 @@ int DrawUtils::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *
continue;
}
TextMessageDrawChar( xpos, ypos, szString[i], r, g, b );
TextMessageDrawChar( xpos, ypos, szString[i], r, g, b, scale );
}
return xpos;
@ -331,9 +331,17 @@ int DrawUtils::ConsoleStringLen( const char *string )
}
}
int DrawUtils::TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
int DrawUtils::TextMessageDrawChar( int x, int y, int number, int r, int g, int b , float scale )
{
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
int ret;
if( scale && g_iMobileAPIVersion )
{
ret = gMobileAPI.pfnDrawScaledCharacter( x, y, number, r, g, b, scale );
}
else
{
ret = gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
}
}
void DrawUtils::Draw2DQuad( float x1, float y1, float x2, float y2 )

View File

@ -23,17 +23,18 @@ extern "C" {
#define MOBILITY_API_VERSION 2
#define MOBILITY_CLIENT_EXPORT "HUD_MobilityInterface"
#define VIBRATE_NORMAL (1 << 0) // just vibrate for given "life"
#define VIBRATE_NORMAL (1U << 0) // just vibrate for given "life"
#define TOUCH_FL_HIDE (1<<0)
#define TOUCH_FL_NOEDIT (1<<1)
#define TOUCH_FL_CLIENT (1<<2)
#define TOUCH_FL_MP (1<<3)
#define TOUCH_FL_SP (1<<4)
#define TOUCH_FL_DEF_SHOW (1<<5)
#define TOUCH_FL_DEF_HIDE (1<<6)
#define TOUCH_FL_DRAW_ADDITIVE (1<<7)
#define TOUCH_FL_STROKE (1<<8)
#define TOUCH_FL_HIDE (1U << 0)
#define TOUCH_FL_NOEDIT (1U << 1)
#define TOUCH_FL_CLIENT (1U << 2)
#define TOUCH_FL_MP (1U << 3)
#define TOUCH_FL_SP (1U << 4)
#define TOUCH_FL_DEF_SHOW (1U << 5)
#define TOUCH_FL_DEF_HIDE (1U << 6)
#define TOUCH_FL_DRAW_ADDITIVE (1U << 7)
#define TOUCH_FL_STROKE (1U << 8)
#define TOUCH_FL_PRECISION (1U << 9)
typedef struct mobile_engfuncs_s
{
@ -66,11 +67,12 @@ typedef struct mobile_engfuncs_s
// Clean defaults list
void (*pfnTouchResetDefaultButtons)();
// Draw scaled font for client
int (*pfnDrawScaledCharacter)( int x, int y, int number, int r, int g, int b, float scale );
// To be continued...
} mobile_engfuncs_t;
//extern mobile_engfuncs_t *gMobileEngfuncs;
// function exported from client
// returns 0 on no error otherwise error
typedef int (*pfnMobilityInterface)( mobile_engfuncs_t *gMobileEngfuncs );