From: terencehill Date: Tue, 6 Sep 2016 15:08:07 +0000 (+0200) Subject: Menu: fix issues with hidden gametypes X-Git-Tag: xonotic-v0.8.2~619 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=13290c4a68297d7a2488f0fd91353bcc4c567b70;p=xonotic%2Fxonotic-data.pk3dir.git Menu: fix issues with hidden gametypes --- diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc index 8fcb975ea..2f2ab901a 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc @@ -35,7 +35,7 @@ void XonoticMapInfoDialog_loadMapInfo(entity me, int i, entity mlb) else me.previewImage.src = me.currentMapPreviewImage; - for(i = 0; i < GameType_GetCount(); ++i) + for(i = 0; i < GameType_GetTotalCount(); ++i) { entity e; e = me.(typeLabels[i]); @@ -69,9 +69,9 @@ void XonoticMapInfoDialog_fill(entity me) me.TR(me); me.TD(me, 1, w, e = makeXonoticTextLabel(0, _("Game types:"))); - n = ceil(GameType_GetCount() / (me.rows - 6)); + n = ceil(GameType_GetTotalCount() / (me.rows - 6)); wgt = (w - 0.2) / n; - for(i = 0; i < GameType_GetCount(); ++i) + for(i = 0; i < GameType_GetTotalCount(); ++i) { if(mod(i, n) == 0) { diff --git a/qcsrc/menu/xonotic/gametypelist.qc b/qcsrc/menu/xonotic/gametypelist.qc index 254f1c001..a08e4dbbc 100644 --- a/qcsrc/menu/xonotic/gametypelist.qc +++ b/qcsrc/menu/xonotic/gametypelist.qc @@ -17,7 +17,7 @@ void XonoticGametypeList_configureXonoticGametypeList(entity me) if(SKINBOOL_GAMETYPELIST_ICON_BLUR) { - for(int i = 0; i < GameType_GetCount(); ++i) + for(int i = 0; i < GameType_GetTotalCount(); ++i) draw_PreloadPictureWithFlags(GameType_GetIcon(i), PRECACHE_PIC_MIPMAP); } diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index ec76d389e..e746bd725 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -685,16 +685,21 @@ float updateCompression() GAMETYPE(MAPINFO_TYPE_NEXBALL) \ GAMETYPE(MAPINFO_TYPE_ONSLAUGHT) \ GAMETYPE(MAPINFO_TYPE_ASSAULT) \ - if (cvar("developer")) GAMETYPE(MAPINFO_TYPE_RACE) \ - if (cvar("developer")) GAMETYPE(MAPINFO_TYPE_CTS) \ /* GAMETYPE(MAPINFO_TYPE_INVASION) */ \ /**/ +// hidden gametypes come last so indexing always works correctly +#define HIDDEN_GAMETYPES \ + GAMETYPE(MAPINFO_TYPE_RACE) \ + GAMETYPE(MAPINFO_TYPE_CTS) \ + /**/ + Gametype GameType_GetID(int cnt) { int i = 0; #define GAMETYPE(it) { if (i++ == cnt) return it; } GAMETYPES + HIDDEN_GAMETYPES #undef GAMETYPE return NULL; } @@ -705,6 +710,19 @@ int GameType_GetCount() #define GAMETYPE(id) ++i; GAMETYPES #undef GAMETYPE + #define GAMETYPE(it) if (cvar("developer")) ++i; + HIDDEN_GAMETYPES + #undef GAMETYPE + return i; +} + +int GameType_GetTotalCount() +{ + int i = 0; + #define GAMETYPE(id) ++i; + GAMETYPES + HIDDEN_GAMETYPES + #undef GAMETYPE return i; } diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index c7e7c0cd7..96fef2ad4 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -34,6 +34,7 @@ string GameType_GetName(int cnt); string GameType_GetIcon(int cnt); //string GameType_GetTeams(float cnt); int GameType_GetCount(); +int GameType_GetTotalCount(); void dialog_hudpanel_common_notoggle(entity me, string panelname); #define DIALOG_HUDPANEL_COMMON_NOTOGGLE() \