]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Port a code I made in Xonotic, which displays "no preview" images if a map or player...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 25 Nov 2011 16:32:56 +0000 (18:32 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 25 Nov 2011 16:32:56 +0000 (18:32 +0200)
data/qcsrc/client/Main.qc
data/qcsrc/client/mapvoting.qc
data/qcsrc/common/util.qc
data/qcsrc/common/util.qh
data/qcsrc/menu/draw.qc
data/qcsrc/menu/draw.qh
data/qcsrc/menu/voret/campaign.c
data/qcsrc/menu/voret/dialog_multiplayer_create_mapinfo.c
data/qcsrc/menu/voret/maplist.c
data/qcsrc/menu/voret/playermodel.c

index 43ce8601e11ce7a2b648ef3f9feae21fcbc26359..d84f6ce5c801c674776d21b3fb61c7e9cc65a738 100644 (file)
@@ -182,6 +182,8 @@ void CSQC_Init(void)
        minimapname = strzone(minimapname);\r
 \r
        WarpZone_Init();\r
+\r
+       draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));\r
 }\r
 \r
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)\r
index bf60a868fcb4e5ebd991a079c6e5cb9f277312b0..655163da9d03adb176c040bce96600c323288fb6 100644 (file)
@@ -75,7 +75,10 @@ void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, strin
        img_size -= (sbar_border_thickness * 2) * '1 1 0';\r
        if(pic == "")\r
        {\r
-               drawfill(pos, img_size, '.5 .5 .5', .7, DRAWFLAG_NORMAL);\r
+               if(precache_pic(pic) == "")\r
+                       drawpic(pos, draw_UseSkinFor("nopreview_player"), img_size, '1 1 1', 0.7, DRAWFLAG_NORMAL);\r
+               else\r
+                       drawpic(pos, pic, img_size, '1 1 1', 0.7, DRAWFLAG_NORMAL);\r
        }\r
        else\r
        {\r
index 990e3c4d72d408f15289a35d7dfaf072af68f971..bcd8465e465e9a9c8b940ced2a74a5ad03b05ae5 100644 (file)
@@ -79,6 +79,16 @@ void wordwrap_sprint(string s, float l)
 #endif\r
 #endif\r
 \r
+#ifndef SVQC\r
+string draw_UseSkinFor(string pic)\r
+{\r
+       if(substring(pic, 0, 1) == "/")\r
+               return substring(pic, 1, strlen(pic)-1);\r
+       else\r
+               return strcat(draw_currentSkin, "/", pic);\r
+}\r
+#endif\r
+\r
 string unescape(string in)\r
 {\r
        local float i, len;\r
index fd4193e71c9450ce318fd5a8112b44aba6422abf..ec704494393eebf68662fd5f5a2e287391a31884 100644 (file)
@@ -17,6 +17,11 @@ void wordwrap_sprint(string s, float l);
 #endif\r
 void wordwrap_cb(string s, float l, void(string) callback)\r
 \r
+#ifndef SVQC\r
+string draw_currentSkin;\r
+string draw_UseSkinFor(string pic);\r
+#endif\r
+\r
 float GameCommand_Generic(string cmd);\r
 // returns TRUE if handled, FALSE otherwise\r
 // uses tokenize on its argument!\r
index 7ab53e2e9c2e0b3cd3e03456b6ee61087f96fede..ca6f0a29989764f614bcf37278305322eea7380f 100644 (file)
@@ -2,14 +2,6 @@ string draw_mousepointer;
 vector draw_mousepointer_offset;\r
 vector draw_mousepointer_size;\r
 \r
-string draw_UseSkinFor(string pic)\r
-{\r
-       if(substring(pic, 0, 1) == "/")\r
-               return substring(pic, 1, strlen(pic)-1);\r
-       else\r
-               return strcat(draw_currentSkin, "/", pic);\r
-}\r
-\r
 void draw_setMousePointer(string pic, vector theSize, vector theOffset)\r
 {\r
        draw_mousepointer = strzone(draw_UseSkinFor(pic));\r
@@ -61,10 +53,10 @@ vector boxToGlobalSize(vector v, vector theScale)
        return v;\r
 }\r
 \r
-void draw_PreloadPicture(string pic)\r
+string draw_PreloadPicture(string pic)\r
 {\r
        pic = draw_UseSkinFor(pic);\r
-       precache_pic(pic);\r
+       return precache_pic(pic);\r
 }\r
 \r
 void draw_Picture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha)\r
index 28fffe73ca8aad1e195dd0d63bed27825038de62..bea80561636635e70f9a84c3eebefe4d76970cc7 100644 (file)
@@ -14,7 +14,7 @@ void draw_reset(float cw, float ch, float ox, float oy);
 void draw_setMousePointer(string pic, vector theSize, vector theOffset);\r
 void draw_drawMousePointer(vector where);\r
 \r
-void draw_PreloadPicture(string pic);\r
+string draw_PreloadPicture(string pic);\r
 void draw_ButtonPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha);\r
 void draw_VertButtonPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha);\r
 void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector theColor, float theAlpha, vector theBorderSize);\r
@@ -38,7 +38,5 @@ vector globalToBoxSize(vector v, vector scale);
 \r
 float draw_NeedResizeNotify;\r
 \r
-string draw_currentSkin;\r
-\r
 float draw_TextWidth_WithColors(string s, vector size);\r
 float draw_TextWidth_WithoutColors(string s, vector size);\r
index e3a4315bb713ef163fe99324125cd40f9c8e6e22..ba65cd2c5b94e1a0743d2fdd5e69967409f19295 100644 (file)
@@ -275,10 +275,13 @@ void drawListBoxItemVoretCampaignList(entity me, float i, vector absSize, float
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);\r
 \r
        s = ftos(p);\r
-       if(i <= me.campaignIndex)\r
-               draw_Picture(me.columnPreviewOrigin * eX, strcat("/maps/", campaign_mapname[i]), me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
-       else\r
+       if(i > me.campaignIndex)\r
                draw_Picture(me.columnPreviewOrigin * eX, "/gfx/campaign_hidden", me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
+       else if(draw_PreloadPicture(strcat("/maps/", campaign_mapname[i])) == "")\r
+               draw_Picture(me.columnPreviewOrigin * eX, "nopreview_map", me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
+       else\r
+               draw_Picture(me.columnPreviewOrigin * eX, strcat("/maps/", campaign_mapname[i]), me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
+\r
        if(i < me.campaignIndex)\r
                draw_Picture(me.checkMarkOrigin, "checkmark", me.checkMarkSize, '1 1 1', 1);\r
        if(i <= me.campaignIndex)\r
index b640ee8687cd85fe128e71ce36c67cf335b59221..7925b80ed9a030ec87c8ddd958a8a15d3ecae179 100644 (file)
@@ -66,7 +66,10 @@ void loadMapInfoVoretMapInfoDialog(entity me, float i, entity mlb)
        me.authorLabel.setText(me.authorLabel, me.currentMapAuthor);\r
        me.descriptionLabel.setText(me.descriptionLabel, me.currentMapDescription);\r
        me.featuresLabel.setText(me.featuresLabel, me.currentMapFeaturesText);\r
-       me.previewImage.src = me.currentMapPreviewImage;\r
+       if(draw_PreloadPicture(me.currentMapPreviewImage) == "")\r
+               me.previewImage.src = "nopreview_map";\r
+       else\r
+               me.previewImage.src = me.currentMapPreviewImage;\r
 \r
        me.typeDeathmatchLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH);\r
        me.typeTDMLabel.disabled = !(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH);\r
index 413b0b46c5c50cd8744d7a0a6cde2d7ae7c670ec..d4b77c39b2fbf525574d1a1eb92b71d072467bf2 100644 (file)
@@ -186,7 +186,11 @@ void drawListBoxItemVoretMapList(entity me, float i, vector absSize, float isSel
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_MAPLIST_INCLUDEDBG, SKINALPHA_MAPLIST_INCLUDEDBG);\r
 \r
        s = ftos(p);\r
-       draw_Picture(me.columnPreviewOrigin * eX, strcat("/maps/", MapInfo_Map_bspname), me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
+       if(draw_PreloadPicture(strcat("/maps/", MapInfo_Map_bspname)) == "")\r
+               draw_Picture(me.columnPreviewOrigin * eX, "nopreview_map", me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
+       else\r
+               draw_Picture(me.columnPreviewOrigin * eX, strcat("/maps/", MapInfo_Map_bspname), me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);\r
+\r
        if(included)\r
                draw_Picture(me.checkMarkOrigin, "checkmark", me.checkMarkSize, '1 1 1', 1);\r
        s = draw_TextShortenToWidth(strcat(MapInfo_Map_bspname, ": ", MapInfo_Map_title), me.columnNameSize, 0, me.realFontSize);\r
index fb48f1a2e7de00aedc20356b2a362c4dc0505967..639f625db23d239071a3899f69f975b0dc58f820 100644 (file)
@@ -176,7 +176,10 @@ void drawVoretPlayerModelSelector(entity me)
        float i, n;\r
        vector o;\r
 \r
-       me.src = me.currentModelName;\r
+       if(draw_PreloadPicture(me.currentModelName) == "")\r
+               me.src = "nopreview_player";\r
+       else\r
+               me.src = me.currentModelName;\r
        drawImage(me);\r
        me.src = string_null;\r
 \r