summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_main.c9
-rw-r--r--src/ui/ui_shared.c55
-rw-r--r--src/ui/ui_shared.h4
3 files changed, 29 insertions, 39 deletions
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index b4e4a82c..f9c2d7f4 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -219,17 +219,16 @@ void AssetCache( void )
if( ui_emoticons.integer )
{
uiInfo.uiDC.Assets.emoticonCount = BG_LoadEmoticons(
- uiInfo.uiDC.Assets.emoticons,
- uiInfo.uiDC.Assets.emoticonWidths );
+ uiInfo.uiDC.Assets.emoticons, MAX_EMOTICONS );
}
else
uiInfo.uiDC.Assets.emoticonCount = 0;
for( i = 0; i < uiInfo.uiDC.Assets.emoticonCount; i++ )
{
- uiInfo.uiDC.Assets.emoticonShaders[ i ] = trap_R_RegisterShaderNoMip(
- va( "emoticons/%s_%dx1.tga", uiInfo.uiDC.Assets.emoticons[ i ],
- uiInfo.uiDC.Assets.emoticonWidths[ i ] ) );
+ uiInfo.uiDC.Assets.emoticons[ i ].shader = trap_R_RegisterShaderNoMip(
+ va( "emoticons/%s_%dx1.tga", uiInfo.uiDC.Assets.emoticons[ i ].name,
+ uiInfo.uiDC.Assets.emoticons[ i ].width ) );
}
}
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index f24e91eb..3b3466db 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -1880,50 +1880,43 @@ void UI_EscapeEmoticons( char *dest, const char *src, int destsize )
qboolean UI_Text_IsEmoticon( const char *s, qboolean *escaped,
int *length, qhandle_t *h, int *width )
{
- char name[ MAX_EMOTICON_NAME_LEN ] = {""};
const char *p = s;
- int i = 0;
- int j = 0;
+ int i;
if( *p != '[' )
return qfalse;
p++;
- *escaped = qfalse;
if( *p == '[' )
{
*escaped = qtrue;
p++;
}
+ else
+ *escaped = qfalse;
- while( *p && i < ( MAX_EMOTICON_NAME_LEN - 1 ) )
- {
- if( *p == ']' )
- {
- for( j = 0; j < DC->Assets.emoticonCount; j++ )
- {
- if( !Q_stricmp( DC->Assets.emoticons[ j ], name ) )
- {
- if( *escaped )
- {
- *length = 1;
- return qtrue;
- }
- if( h )
- *h = DC->Assets.emoticonShaders[ j ];
- if( width )
- *width = DC->Assets.emoticonWidths[ j ];
- *length = i + 2;
- return qtrue;
- }
- }
+ for( *length = 0; p[ *length ] != ']'; ( *length )++ )
+ if( !p[ *length ] )
return qfalse;
- }
- name[ i++ ] = *p;
- name[ i ] = '\0';
- p++;
- }
- return qfalse;
+
+ for( i = 0; i < DC->Assets.emoticonCount; i++ )
+ if( !Q_stricmpn( DC->Assets.emoticons[ i ].name, p, *length ) )
+ break;
+
+ if( i == DC->Assets.emoticonCount )
+ return qfalse;
+
+ if( h )
+ *h = DC->Assets.emoticons[ i ].shader;
+ if( width )
+ *width = DC->Assets.emoticons[ i ].width;
+
+ ( *length ) += 2;
+
+ if( *escaped )
+ ( *length )++;
+
+ return qtrue;
}
static float UI_Parse_Indent( const char **text )
diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h
index aa49a8a0..154325dd 100644
--- a/src/ui/ui_shared.h
+++ b/src/ui/ui_shared.h
@@ -378,9 +378,7 @@ typedef struct
vec4_t shadowColor;
float shadowFadeClamp;
qboolean fontRegistered;
- char emoticons[ MAX_EMOTICONS ][ MAX_EMOTICON_NAME_LEN ];
- qhandle_t emoticonShaders[ MAX_EMOTICONS ];
- int emoticonWidths[ MAX_EMOTICONS ];
+ emoticon_t emoticons[ MAX_EMOTICONS ];
int emoticonCount;
}
cachedAssets_t;