From c6a1207f099a5e2855944c9c94a0d70e0c624211 Mon Sep 17 00:00:00 2001 From: Freddy Date: Thu, 3 Jan 2019 15:17:38 +0100 Subject: [PATCH] More prominently show if server has stats enabled --- qcsrc/common/constants.qh | 13 +++++++------ qcsrc/common/playerstats.qc | 4 ++++ .../dialog_multiplayer_join_serverinfo.qc | 9 +++++++++ .../dialog_multiplayer_join_serverinfo.qh | 2 ++ qcsrc/menu/xonotic/serverlist.qc | 17 +++++++++++++++-- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index a7e7da546..7d5a5ca4d 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -16,9 +16,9 @@ const int KEY_ATCK2 = BIT(7); /////////////////////////// // cvar constants -const int CVAR_SAVE = 1; -const int CVAR_NOTIFY = 2; -const int CVAR_READONLY = 4; +const int CVAR_SAVE = BIT(0); +const int CVAR_NOTIFY = BIT(1); +const int CVAR_READONLY = BIT(2); /////////////////////////// // csqc communication stuff @@ -43,9 +43,10 @@ const int FRAGS_SPECTATOR = -666; const int FRAGS_PLAYER_OUT_OF_GAME = -616; // server flags -const int SERVERFLAG_ALLOW_FULLBRIGHT = 1; -const int SERVERFLAG_TEAMPLAY = 2; -const int SERVERFLAG_PLAYERSTATS = 4; +const int SERVERFLAG_ALLOW_FULLBRIGHT = BIT(0); +const int SERVERFLAG_TEAMPLAY = BIT(1); +const int SERVERFLAG_PLAYERSTATS = BIT(2); +const int SERVERFLAG_PLAYERSTATS_CUSTOM = BIT(3); // a bit more constant const vector PL_MAX_CONST = '16 16 45'; diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index 511ac46e6..c065e6e29 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -224,6 +224,10 @@ void PlayerStats_GameReport_Init() // initiated before InitGameplayMode so that PlayerStats_GameReport_DelayMapVote = true; serverflags |= SERVERFLAG_PLAYERSTATS; + if(autocvar_g_playerstats_gamereport_uri != "http://stats.xonotic.org/stats/submit") + { + serverflags |= SERVERFLAG_PLAYERSTATS_CUSTOM; + } PlayerStats_GameReport_AddEvent(PLAYERSTATS_ALIVETIME); PlayerStats_GameReport_AddEvent(PLAYERSTATS_AVGLATENCY); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc index 5745ce072..3f39077c8 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc @@ -169,6 +169,10 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i) if (!s) { s = _("N/A"); } me.currentServerKey = strzone(s); me.keyLabel.setText(me.keyLabel, me.currentServerKey); + + me.currentServerStatsStatus = ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? ((sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) ? _("custom stats server") : _("stats enabled")) : _("stats disabled")); + me.currentServerStatsStatus = strzone(me.currentServerStatsStatus); + me.statsLabel.setText(me.statsLabel, me.currentServerStatsStatus); } void XonoticServerInfoDialog_fill(entity me) @@ -246,6 +250,11 @@ void XonoticServerInfoDialog_fill(entity me) me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, "")); e.allowCut = 1; me.idLabel = e; + me.TR(me); + me.TD(me, 1, 0.8, e = makeXonoticTextLabel(0, _("Stats:"))); + me.TD(me, 1, 5.4, e = makeXonoticTextLabel(0, "")); + e.allowCut = 1; + me.statsLabel = e; me.gotoRC(me, 2, 2.2); me.setFirstColumn(me, me.currentColumn); me.TD(me, 1, 3, e = makeXonoticTextLabel(0, _("Players:"))); diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qh b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qh index 68f5ab8ca..f4f422991 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qh +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qh @@ -24,6 +24,7 @@ CLASS(XonoticServerInfoDialog, XonoticDialog) ATTRIB(XonoticServerInfoDialog, currentServerID, string); ATTRIB(XonoticServerInfoDialog, currentServerEncrypt, string); ATTRIB(XonoticServerInfoDialog, currentServerPure, string); + ATTRIB(XonoticServerInfoDialog, currentServerStatsStatus, string); ATTRIB(XonoticServerInfoDialog, nameLabel, entity); ATTRIB(XonoticServerInfoDialog, cnameLabel, entity); @@ -40,6 +41,7 @@ CLASS(XonoticServerInfoDialog, XonoticDialog) ATTRIB(XonoticServerInfoDialog, encryptLabel, entity); ATTRIB(XonoticServerInfoDialog, canConnectLabel, entity); ATTRIB(XonoticServerInfoDialog, pureLabel, entity); + ATTRIB(XonoticServerInfoDialog, statsLabel, entity); ENDCLASS(XonoticServerInfoDialog) void Join_Click(entity btn, entity me); diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 021e97651..684cef920 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -1033,7 +1033,20 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is // Stats if(sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) - draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1); + { + if (sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) + { + draw_Picture(iconPos, "icon_mod_", iconSize, '1 1 1', 1); // TODO: icon + } + else + { + draw_Picture(iconPos, "icon_stats1", iconSize, '1 1 1', 1); + } + } + else + { + draw_Picture(iconPos, "icon_mod_jeff", iconSize, '1 1 1', 1); // TODO: icon + } if(isFocused && me.mouseOverIcons && !me.tooltip) { @@ -1045,7 +1058,7 @@ void XonoticServerList_drawListBoxItem(entity me, int i, vector absSize, bool is if(pure_available) t = strcat(t, sprintf(" (%s)", (pure) ? _("official settings") : _("modified settings"))); t = strcat(t, ", "); - t = strcat(t, ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? _("stats enabled") : _("stats disabled"))); + t = strcat(t, ((sflags >= 0 && (sflags & SERVERFLAG_PLAYERSTATS)) ? ((sflags & SERVERFLAG_PLAYERSTATS_CUSTOM) ? _("custom stats server") : _("stats enabled")) : _("stats disabled"))); setZonedTooltip(me, t, string_null); } // -------------- -- 2.39.2