Skip to content

Commit

Permalink
update UI server browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomenor committed Oct 15, 2021
1 parent b93817f commit da04c8e
Show file tree
Hide file tree
Showing 8 changed files with 1,112 additions and 224 deletions.
1 change: 1 addition & 0 deletions code/common/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ typedef enum {
#define UI_TINYFONT 0x00010000
#define UI_SHOWCOLOR 0x00020000
#define UI_FORCECOLOR 0x00040000
#define UI_NO_BLACK 0x00080000 // replace black color sequence with brown, for drawing on black backgrounds


/*
Expand Down
3 changes: 3 additions & 0 deletions code/common/vm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
qboolean VMExt_GVCommand( char *buffer, unsigned int bufferSize, const char *command );
int VMExt_GVCommandInt( const char *command, int defaultValue );

qboolean VMExt_FNAvailable_LAN_ServerStatus_Ext( void );
int VMExt_FN_LAN_ServerStatus_Ext( const char *serverAddress, char *serverStatus, int maxLen, char *extString, int extLen );

#endif // __VM_COMMON_H__
50 changes: 50 additions & 0 deletions code/common/vm_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,53 @@ int VMExt_GVCommandInt( const char *command, int defaultValue ) {

return defaultValue;
}

typedef struct {
qboolean queried;
int value; // null if invalid
} vmext_cached_value_t;

/*
================
VMExt_UpdateCachedValue
Updates cached value if not already queried.
================
*/
static void VMExt_UpdateCachedValue( const char *key, vmext_cached_value_t *output ) {
if ( !output->queried ) {
output->value = VMExt_GVCommandInt( key, 0 );
output->queried = qtrue;
}
}

static vmext_cached_value_t trap_lan_serverstatus;

/*
================
VMExt_FNAvailable_LAN_ServerStatus_Ext
Returns qtrue if function is available.
================
*/
qboolean VMExt_FNAvailable_LAN_ServerStatus_Ext( void ) {
VMExt_UpdateCachedValue( "trap_lan_serverstatus_ext", &trap_lan_serverstatus );
return trap_lan_serverstatus.value ? qtrue : qfalse;
}

/*
================
VMExt_FN_LAN_ServerStatus_Ext
================
*/
int VMExt_FN_LAN_ServerStatus_Ext( const char *serverAddress, char *serverStatus, int maxLen, char *extString, int extLen ) {
VMExt_UpdateCachedValue( "trap_lan_serverstatus_ext", &trap_lan_serverstatus );
if ( trap_lan_serverstatus.value ) {
return SYSCALL( trap_lan_serverstatus.value,
( const char *serverAddress, char *serverStatus, int maxLen, char *extString, int extLen ),
( serverAddress, serverStatus, maxLen, extString, extLen ),
( trap_lan_serverstatus.value, serverAddress, serverStatus, maxLen, extString, extLen )
);
}
return 0;
}
77 changes: 71 additions & 6 deletions code/ui/ui_atoms.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,34 @@ void UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color
}


/*
=================
UI_TruncateStringWidth
Truncates string to fit within specified pixel width when drawn with UI_SMALLFONT.
=================
*/
void UI_TruncateStringWidth( char *source, int width ) {
while ( *source ) {
if ( Q_IsColorString( source ) ) {
source += 2;
continue;
} else {
int ch = *source & 255;
int charWidth = propMap[ch][2];
if ( charWidth > 0 ) {
width -= charWidth;
}
width -= PROP_GAP_WIDTH;
if ( width < 0 ) {
*source = '\0';
return;
}
source++;
}
}
}

/*
=================
UI_ProportionalStringWidth
Expand Down Expand Up @@ -529,7 +557,11 @@ static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t co
if ( Q_IsColorString( s ) )
{
colorI = ColorIndex( *(s+1) );
trap_R_SetColor( g_color_table[colorI] );
if ( colorI == 0 && ( style & UI_NO_BLACK ) ) {
trap_R_SetColor( colorTable[CT_DKBROWN1] );
} else {
trap_R_SetColor( g_color_table[colorI] );
}
s += 2;
continue;
}
Expand Down Expand Up @@ -571,7 +603,11 @@ static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t co
if ( Q_IsColorString( s ) )
{
colorI = ColorIndex( *(s+1) );
trap_R_SetColor( g_color_table[colorI] );
if ( colorI == 0 && ( style & UI_NO_BLACK ) ) {
trap_R_SetColor( colorTable[CT_DKBROWN1] );
} else {
trap_R_SetColor( g_color_table[colorI] );
}
s += 2;
continue;
}
Expand Down Expand Up @@ -612,7 +648,11 @@ static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t co
if ( Q_IsColorString( s ) )
{
colorI = ColorIndex( *(s+1) );
trap_R_SetColor( g_color_table[colorI] );
if ( colorI == 0 && ( style & UI_NO_BLACK ) ) {
trap_R_SetColor( colorTable[CT_DKBROWN1] );
} else {
trap_R_SetColor( g_color_table[colorI] );
}
s += 2;
continue;
}
Expand Down Expand Up @@ -750,15 +790,15 @@ void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t

if (style & UI_TINYFONT)
{
UI_DrawProportionalString2( x, y, str, color, charstyle, uis.charsetPropTiny );
UI_DrawProportionalString2( x, y, str, color, charstyle | ( style & UI_NO_BLACK ), uis.charsetPropTiny );
}
else if (style & UI_BIGFONT)
{
UI_DrawProportionalString2( x, y, str, color, charstyle, uis.charsetPropBig );
UI_DrawProportionalString2( x, y, str, color, charstyle | ( style & UI_NO_BLACK ), uis.charsetPropBig );
}
else
{
UI_DrawProportionalString2( x, y, str, color, charstyle, uis.charsetProp );
UI_DrawProportionalString2( x, y, str, color, charstyle | ( style & UI_NO_BLACK ), uis.charsetProp );
}
}

Expand Down Expand Up @@ -2026,6 +2066,12 @@ void UI_LoadMenuText()
menu_normal_text[MNT_IGNORES_TITLE] = "ELITE FORCE HOLOMATCH : IGNORED PLAYERS";
menu_normal_text[MNT_IGNORES] = "IGNORED PLAYERS";
menu_normal_text[MNT_IGNORES_PLAYERLIST] = "PLAYERLIST";
menu_normal_text[MNT_BROWSER_PLAYER_COUNT] = "PLAYER COUNT";
menu_normal_text[MNT_BROWSER_HUMANS_ONLY] = "HUMAN PLAYERS ONLY";
menu_normal_text[MNT_BROWSER_BOTS_AND_HUMANS] = "BOTS OR HUMANS";
menu_normal_text[MNT_BROWSER_MOD] = "MOD";
menu_normal_text[MNT_BROWSER_BOTS] = "BOTS";
menu_normal_text[MNT_BROWSER_SCAN_PROGRESS] = "Scanning %d of %d Servers...";
menu_normal_text[MNT_ALTSWAP_AUTO] = "AUTO";
menu_normal_text[MNT_ALTSWAP_CUSTOM] = "CUSTOM";

Expand All @@ -2036,6 +2082,11 @@ void UI_LoadMenuText()
menu_normal_text[MNT_IGNORES_TITLE] = "ELITE FORCE HOLOMATCH: IGNORIERTE SPIELER";
menu_normal_text[MNT_IGNORES] = "IGNORIERTE SPIELER";
menu_normal_text[MNT_IGNORES_PLAYERLIST] = "SPIELERLISTE";
menu_normal_text[MNT_BROWSER_PLAYER_COUNT] = "SPIELERZAHL";
menu_normal_text[MNT_BROWSER_HUMANS_ONLY] = "NUR MENSCHLICHE SPIELER";
menu_normal_text[MNT_BROWSER_BOTS_AND_HUMANS] = "BOTS ODER MENSCHEN";
menu_normal_text[MNT_BROWSER_MOD] = "MODIFIKATION";
menu_normal_text[MNT_BROWSER_SCAN_PROGRESS] = "Scannen von %d von %d Servern...";
menu_normal_text[MNT_ALTSWAP_AUTO] = "AUTOMATISCH";
menu_normal_text[MNT_ALTSWAP_CUSTOM] = "BENUTZER";

Expand All @@ -2062,6 +2113,11 @@ void UI_LoadMenuText()
menu_normal_text[MNT_IGNORES_TITLE] = "ELITE FORCE HOLOMATCH : JOUEURS IGNOREE";
menu_normal_text[MNT_IGNORES] = "JOUEURS IGNOREE";
menu_normal_text[MNT_IGNORES_PLAYERLIST] = "LISTE DES JOUEURS";
menu_normal_text[MNT_BROWSER_PLAYER_COUNT] = "NOMBRE DE JOUEURS";
menu_normal_text[MNT_BROWSER_HUMANS_ONLY] = "JOUEURS HUMAINS UNIQUEMENT";
menu_normal_text[MNT_BROWSER_BOTS_AND_HUMANS] = "BOTS OU HUMAINS";
menu_normal_text[MNT_BROWSER_MOD] = "MODIF.";
menu_normal_text[MNT_BROWSER_SCAN_PROGRESS] = "Analyse de %d des %d serveurs...";
menu_normal_text[MNT_ALTSWAP_AUTO] = "AUTO";
menu_normal_text[MNT_ALTSWAP_CUSTOM] = "SUR MESURE";
}
Expand Down Expand Up @@ -2179,6 +2235,7 @@ void UI_LoadButtonText()
// add some new definitions not in the text file
trap_Cvar_VariableStringBuffer( "g_language", language, 32 );

menu_button_text[MBT_INGAMESERVERDATA][1] = "SHOW SERVER INFORMATION";
menu_button_text[MBT_MOTD][0] = "HOST MOTD :";
menu_button_text[MBT_MOTD][1] = "MESSAGE OF THE DAY DURING CONNECTION BUILDUP";
menu_button_text[MBT_INGAMEIGNORES][0] = "IGNORES";
Expand All @@ -2195,6 +2252,8 @@ void UI_LoadButtonText()
menu_button_text[MBT_ASPECTCORRECTION][1] = "ENABLE OR DISABLE ASPECT RATIO CORRECTION";
menu_button_text[MBT_CENTERHUD][0] = "CENTER HUD";
menu_button_text[MBT_CENTERHUD][1] = "MOVE HUD TOWARDS CENTER OF SCREEN";
menu_button_text[MBT_BROWSER_PLAYERTYPE][0] = "PLAYER TYPE";
menu_button_text[MBT_BROWSER_PLAYERTYPE][1] = "FILTER BY AMOUNT OF PLAYERS ON SERVER";

menu_button_text[MBT_ALTSWAP_CONTROL][0] = "ALT FIRE SWAPPING";
menu_button_text[MBT_ALTSWAP_CONTROL][1] = "SELECT ALT FIRE BUTTON SWAPPING MODE";
Expand All @@ -2220,6 +2279,7 @@ void UI_LoadButtonText()
}

if ( !Q_stricmp( language, "deutsch" ) ) {
menu_button_text[MBT_INGAMESERVERDATA][1] = "SERVER-INFORMATION ANZEIGEN";
menu_button_text[MBT_MOTD][0] = "HOST MOTD :";
menu_button_text[MBT_MOTD][1] = "NACHRICHT DES TAGES WAEHREND DES VERBINDUNGSAUFBAUS";
menu_button_text[MBT_INGAMEIGNORES][0] = "IGNORES";
Expand All @@ -2236,6 +2296,8 @@ void UI_LoadButtonText()
menu_button_text[MBT_ASPECTCORRECTION][1] = "AKTIVIEREN ODER DEAKTIVIEREN DER SEITENVERHÄLTNISKORREKTUR";
menu_button_text[MBT_CENTERHUD][0] = "ZENTRUM HUD";
menu_button_text[MBT_CENTERHUD][1] = "HUD ZUR MITTE DES BILDSCHIRMS VERSCHIEBEN";
menu_button_text[MBT_BROWSER_PLAYERTYPE][0] = "SPIELERTYP";
menu_button_text[MBT_BROWSER_PLAYERTYPE][1] = "FILTER NACH ANZAHL DER SPIELER AUF DEM SERVER";

menu_button_text[MBT_ALTSWAP_CONTROL][0] = "ALT FEUER WECHSELN";
menu_button_text[MBT_ALTSWAP_CONTROL][1] = "MODUS FÜR DAS ALTERNATIVE FEUER AUSWÄHLEN";
Expand All @@ -2261,6 +2323,7 @@ void UI_LoadButtonText()
}

} else if ( !Q_stricmp( language, "francais" ) ) {
menu_button_text[MBT_INGAMESERVERDATA][1] = "AFFICHER INFORMATIONS SERVEUR";
menu_button_text[MBT_ASSIMILATION][1] = "JOUEURS TUE JOINDRENT LES BORG";
menu_button_text[MBT_SPECIALTIES][1] = "JOUERS DOIVENT SELECTER UNE CLASSE";
menu_button_text[MBT_DISINTEGRATION][1] = "UN SEUL COUP REUSSI CAUSE LE MORT IMMEDIATEMENT";
Expand Down Expand Up @@ -2288,6 +2351,8 @@ void UI_LoadButtonText()
menu_button_text[MBT_ASPECTCORRECTION][1] = "ACTIVER OU DÉSACTIVER LA CORRECTION DU RATIO D'AFFICHAGE";
menu_button_text[MBT_CENTERHUD][0] = "HUD CENTRAL";
menu_button_text[MBT_CENTERHUD][1] = "DÉPLACER LE HUD VERS LE CENTRE DE L'ÉCRAN";
menu_button_text[MBT_BROWSER_PLAYERTYPE][0] = "TYPE DE JOUEUR";
menu_button_text[MBT_BROWSER_PLAYERTYPE][1] = "FILTREZ PAR QUANTITÉ DE JOUEURS SUR SERVEUR";

menu_button_text[MBT_ALTSWAP_CONTROL][0] = "ÉCHANGE DE FEU ALT";
menu_button_text[MBT_ALTSWAP_CONTROL][1] = "SÉLECTIONNER LE MODE D'ÉCHANGE DU BOUTON ALT FIRE";
Expand Down
10 changes: 9 additions & 1 deletion code/ui/ui_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ typedef enum
MNT_IGNORES_TITLE,
MNT_IGNORES,
MNT_IGNORES_PLAYERLIST,
MNT_BROWSER_PLAYER_COUNT,
MNT_BROWSER_HUMANS_ONLY,
MNT_BROWSER_BOTS_AND_HUMANS,
MNT_BROWSER_MOD,
MNT_BROWSER_BOTS,
MNT_BROWSER_SCAN_PROGRESS,
MNT_ALTSWAP_AUTO,
MNT_ALTSWAP_CUSTOM,

Expand Down Expand Up @@ -923,6 +929,7 @@ typedef enum
MBT_FOV,
MBT_ASPECTCORRECTION,
MBT_CENTERHUD,
MBT_BROWSER_PLAYERTYPE,
MBT_ALTSWAP_CONTROL,
MBT_ALTSWAP_EDIT,
MBT_ALTSWAP_ALL_STANDARD,
Expand Down Expand Up @@ -1011,8 +1018,8 @@ extern vmCvar_t ui_spSelection;
extern vmCvar_t ui_browserMaster;
extern vmCvar_t ui_browserGameType;
extern vmCvar_t ui_browserSortKey;
extern vmCvar_t ui_browserShowFull;
extern vmCvar_t ui_browserShowEmpty;
extern vmCvar_t ui_browserPlayerType;

extern vmCvar_t ui_brassTime;
extern vmCvar_t ui_drawCrosshair;
Expand Down Expand Up @@ -1684,6 +1691,7 @@ extern void UI_DrawRect( float x, float y, float width, float height, const fl
extern void UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color );
extern float UI_ProportionalSizeScale( int style );
extern void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color );
void UI_TruncateStringWidth( char *source, int width );
extern int UI_ProportionalStringWidth( const char* str,int style );
extern void UI_DrawString( int x, int y, const char* str, int style, vec4_t color );
extern void UI_DrawChar( int x, int y, int ch, int style, vec4_t color );
Expand Down
4 changes: 2 additions & 2 deletions code/ui/ui_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ vmCvar_t ui_spSelection;
vmCvar_t ui_browserMaster;
vmCvar_t ui_browserGameType;
vmCvar_t ui_browserSortKey;
vmCvar_t ui_browserShowFull;
vmCvar_t ui_browserShowEmpty;
vmCvar_t ui_browserPlayerType;

vmCvar_t ui_drawCrosshair;
vmCvar_t ui_drawCrosshairNames;
Expand Down Expand Up @@ -219,8 +219,8 @@ cvarTable_t cvarTable[] = {
{ &ui_browserMaster, "ui_browserMaster", "0", CVAR_ARCHIVE },
{ &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE },
{ &ui_browserSortKey, "ui_browserSortKey", "4", CVAR_ARCHIVE },
{ &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE },
{ &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE },
{ &ui_browserPlayerType, "ui_browserPlayerType", "1", CVAR_ARCHIVE },

{ &ui_drawCrosshair, "cg_drawCrosshair", "1", CVAR_ARCHIVE },
{ &ui_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
Expand Down
8 changes: 4 additions & 4 deletions code/ui/ui_qmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,10 @@ void Bitmap_Draw( menubitmap_s *b )
{
b->shader = trap_R_RegisterShaderNoMip( b->generic.name );

// if (!b->shader && b->errorpic)
// {
/// b->shader = trap_R_RegisterShaderNoMip( b->errorpic );
// }
if (!b->shader && b->errorpic)
{
b->shader = trap_R_RegisterShaderNoMip( b->errorpic );
}
}

if (b->focuspic && !b->focusshader)
Expand Down
Loading

0 comments on commit da04c8e

Please sign in to comment.