]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Menu: fix issues with hidden gametypes
authorterencehill <piuntn@gmail.com>
Tue, 6 Sep 2016 15:08:07 +0000 (17:08 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 6 Sep 2016 15:08:07 +0000 (17:08 +0200)
qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc
qcsrc/menu/xonotic/gametypelist.qc
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index 8fcb975eab6764c5b43d44061102d4ff0132b7b3..2f2ab901a84239a9c37c21866552b449f7089ed6 100644 (file)
@@ -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)
                {
index 254f1c0012563edf052503b74a6a7cc819c75dc9..a08e4dbbc5fa13dc4eb51680a1bb551a25780fc0 100644 (file)
@@ -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);
        }
 
index ec76d389e6cd8d9206162aa7645dc8527a8ab3b8..e746bd725746a2a93a6e84812e8810b3cf74deac 100644 (file)
@@ -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;
 }
 
index c7e7c0cd70b96d138e8f7c09fdf70a7d61693343..96fef2ad4006f553a3bd8a5b22dd594b684df5c3 100644 (file)
@@ -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() \