]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Gametype Votescreen: Fix icons for custom gamemodes and add option for custom icons
authorFreddy <schro.sb@gmail.com>
Sat, 20 Aug 2016 20:50:51 +0000 (22:50 +0200)
committerFreddy <schro.sb@gmail.com>
Sat, 20 Aug 2016 21:17:06 +0000 (23:17 +0200)
qcsrc/client/mapvoting.qc
qcsrc/server/mapvoting.qc

index 19c128a7da6db459c14e59c4b3737dd6cb965a36..e1b33158e64ad2b15a260dd6f4117d27bf3f114a 100644 (file)
@@ -610,12 +610,7 @@ void GameTypeVote_ReadOption(int i)
        mv_maps[i] = gt;
        mv_flags[i] = ReadByte();
 
-       string mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, gt);
-       if(precache_pic(mv_picpath) == "")
-               mv_picpath = strcat("gfx/menu/default/gametype_", gt);
-       string pic = strzone(mv_picpath);
-       mv_pics[i] = pic;
-       mv_preview[i] = PreviewExists(pic);
+       string mv_picpath = string_null;
 
        if ( mv_flags[i] & GTV_CUSTOM )
        {
@@ -624,6 +619,13 @@ void GameTypeVote_ReadOption(int i)
                        name = gt;
                mv_pk3[i] = strzone(name);
                mv_desc[i] = strzone(ReadString());
+               gt = strzone(ReadString());
+               mv_picpath = strzone(ReadString());
+               // "" or " " makes precache_pic crash, string_null doesn't
+               if (strreplace(" ", "", mv_picpath) == "")
+               {
+                       mv_picpath = string_null;
+               }
        }
        else
        {
@@ -631,6 +633,18 @@ void GameTypeVote_ReadOption(int i)
                mv_pk3[i] = strzone(MapInfo_Type_ToText(type));
                mv_desc[i] = MapInfo_Type_Description(type);
        }
+
+       if(!mv_picpath || precache_pic(mv_picpath) == "")
+       {
+               mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, gt);
+               if(precache_pic(mv_picpath) == "")
+               {
+                       mv_picpath = strcat("gfx/menu/default/gametype_", gt);
+               }
+       }
+       string pic = strzone(mv_picpath);
+       mv_pics[i] = pic;
+       mv_preview[i] = PreviewExists(pic);
 }
 
 void MapVote_Init()
index 7ffe4b934fbfa389bcac17b021855f97411d772c..b21186b57e88302ebdaa1816855f619da796f7c5 100644 (file)
@@ -336,6 +336,10 @@ void GameTypeVote_SendOption(int i)
                                strcat("sv_vote_gametype_",type_name,"_name")));
                        WriteString(MSG_ENTITY, cvar_string(
                                strcat("sv_vote_gametype_",type_name,"_description")));
+                       WriteString(MSG_ENTITY, cvar_string(
+                               strcat("sv_vote_gametype_",type_name,"_type")));
+                       WriteString(MSG_ENTITY, cvar_string(
+                               strcat("sv_vote_gametype_",type_name,"_icon")));
                }
        }
 }