3 string mv_maps[MAPVOTE_COUNT];
4 string mv_pics[MAPVOTE_COUNT];
5 string mv_pk3[MAPVOTE_COUNT];
6 float mv_preview[MAPVOTE_COUNT];
7 float mv_votes[MAPVOTE_COUNT];
13 void MapVote_DrawMapItem(vector pos, float isize, string map, string pic, float count, float id)
16 //img_size_x = img_size_y = isize;
18 img_size_x = isize / 0.75; // 4:3 x can be stretched easily, height is defined in isize
20 drawpic(pos, pic, img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
22 // half size for the impulse number
23 img_size_x = img_size_y = isize*0.5;
24 pos_y += img_size_y*0.5;
27 drawstring(pos - '40 0', strcat(ftos(id+1), "."), img_size, '1 1 0', 1, DRAWFLAG_NORMAL);
29 drawstring(pos - '40 0', strcat(ftos(id+1), "."), img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
31 // half again for the mapname
32 img_size = img_size * 0.5; // *= broken???
33 pos_y += img_size_y*0.5;
34 pos_x += isize/0.75 + 10;
37 drawstring(pos, strcat(ftos(count), " : ", map), img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
39 drawstring(pos, map, img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
42 void MapVote_DrawMapNotAvailable(vector pos, float isize, string map, float count, float id)
44 vector img_size, a, b;
46 img_size_x = isize / 0.75;
48 a_x = img_size_x; // for the lines
50 drawfill(pos, img_size, '.5 .5 .5', .7, DRAWFLAG_NORMAL);
51 drawline(2, pos, pos + a, '1 1 1', 1, DRAWFLAG_NORMAL);
52 drawline(2, pos, pos + b, '1 1 1', 1, DRAWFLAG_NORMAL);
53 drawline(2, pos + img_size, pos + a, '1 1 1', 1, DRAWFLAG_NORMAL);
54 drawline(2, pos + img_size, pos + b, '1 1 1', 1, DRAWFLAG_NORMAL);
56 img_size_x = img_size_y = isize*0.5;
57 pos_y += img_size_y*0.5;
60 drawstring(pos - '40 0', strcat(ftos(id+1), "."), img_size, '1 1 0', 1, DRAWFLAG_NORMAL);
62 drawstring(pos - '40 0', strcat(ftos(id+1), "."), img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
64 img_size = img_size * 0.5; // *= broken???
65 pos_y += img_size_y*0.5;
66 pos_x += isize/0.75 + 10;
69 drawstring(pos, strcat(ftos(count), " : ", map), img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
71 drawstring(pos, map, img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
74 void MapVote_DrawAbstain(vector pos, float isize, float count, float id)
78 img_size_x = isize / 0.75;
80 img_size_x = img_size_y = isize*0.5;
81 pos_y += img_size_y*0.5;
84 drawstring(pos - '40 0', strcat(ftos(id+1), "."), img_size, '1 1 0', 1, DRAWFLAG_NORMAL);
86 drawstring(pos - '40 0', strcat(ftos(id+1), "."), img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
88 img_size = img_size * 0.5; // *= broken???
89 pos_y += img_size_y*0.5;
90 pos_x += isize/0.75 + 10;
93 drawstring(pos, strcat(ftos(count), " : Don't care"), img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
95 drawstring(pos, "Don't care", img_size, '1 1 1', 1, DRAWFLAG_NORMAL);
106 center = (vid_conwidth - 1)/2;
107 xmin = vid_conwidth*0.2;
108 xmax = vid_conwidth - xmin;
110 i = cvar("con_chatpos"); //*cvar("con_chatsize");
112 ymax = vid_conheight + (i - cvar("con_chat")) * cvar("con_chatsize");
113 if(i >= 0 || ymax < (vid_conheight*0.5))
114 ymax = vid_conheight - ymin;
116 drawfont = sbar_font;
117 sbar_fontsize = stov(cvar_string("sbar_fontsize"));
118 if(sbar_fontsize_x == 0)
119 sbar_fontsize = '8 8 0';
120 if(sbar_fontsize_y == 0)
121 sbar_fontsize_y = sbar_fontsize_x;
125 pos_x = center - stringwidth("Vote for a map", false) * 0.5 * 24;
126 drawstring(pos, "Vote for a map", '24 24', '1 1 1', 1, DRAWFLAG_NORMAL);
130 isize = (ymax - ymin - mv_num_maps*10) / mv_num_maps;
131 isize = min(isize, 64);
132 for(i = 0; i < (mv_num_maps - mv_abstain); ++i) // - mv_abstain safe? make sure it's 0 or 1
134 tmp = mv_votes[i]; // FTEQCC bug: too many array accesses in the function call screw it up
142 MapVote_DrawMapItem(pos, isize, map, mv_pics[i], tmp, i);
144 MapVote_DrawMapNotAvailable(pos, isize, map, tmp, i);
147 if(mv_abstain && i < mv_num_maps) {
149 MapVote_DrawAbstain(pos, isize, tmp, i);
153 void Cmd_MapVote_MapDownload(float argc)
158 if(argc != 2 || !mv_pk3list)
160 print("mv_mapdownload: ^3You're not supposed to use this command on your own!\n");
165 for(pak = mv_pk3list; pak; pak = pak.chain)
166 if(pak.sv_entnum == id)
169 if(!pak || pak.sv_entnum != id) {
170 print("^1Error:^7 Couldn't find pak index.\n");
174 //print(strcat("^3Adding: ", ftos(id), " - ", pak.message, " - "));
176 if(PreviewExists(pak.message))
178 mv_preview[id] = true;
179 //print("^2Found...\n");
181 } else if(csqc_flags & CSQC_FLAG_READPICTURE) {
182 print("Requesting preview...\n");
183 localcmd(strcat("\ncmd mv_getpic ", ftos(id), "\n"));
185 print("^3Missing map preview - Update to a newer build to be able to see them.\n");
189 void MapVote_CheckPK3(string pic, string pk3, float id)
197 pak.chain = mv_pk3list;
200 localcmd(strcat("\ncurl --pak ", pk3, "; wait; cl_cmd mv_download ", ftos(id), "\n"));
203 void MapVote_CheckPic(string pic, string pk3, float id)
205 if(PreviewExists(pic))
207 mv_preview[id] = true;
210 MapVote_CheckPK3(pic, pk3, id);
218 mv_num_maps = min(MAPVOTE_COUNT, ReadByte());
219 mv_abstain = ReadByte();
221 mv_abstain = 1; // must be 1 for bool-true, makes stuff easier
222 mv_detail = ReadByte();
231 // Assume mv_pk3list is NULL, there should only be 1 mapvote per round
232 mv_pk3list = NULL; // I'm still paranoid!
234 for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2)
240 map = strzone(ReadString());
241 pk3 = strzone(ReadString());
244 map = strzone(strcat(config_get("mv_screenshot_dir", "maps"), "/", map));
247 mv_preview[i] = false;
249 //print(strcat("RECV: ", map, " in ", pk3, "\n"));
250 MapVote_CheckPic(map, pk3, i);
254 mv_maps[i] = strzone("if-you-see-this-the-code-is-broken");
255 mv_pk3[i] = strzone("if-you-see-this-the-code-is-broken");
256 mv_pics[i] = strzone("if-you-see-this-the-code-is-broken");
257 mv_preview[i] = false;
262 void MapVote_Update()
270 for(i = 0, power = 1; i < mv_num_maps; ++i, power *= 2)
275 mv_votes[i] = ReadByte();
284 string Net_ReadPicture();
291 case MAPVOTE_NET_INIT:
293 // do we NEED this, or can we handle key presses directly in CSQC?
294 localcmd("\nin_bind 7 1 \"impulse 1\"; in_bind 7 2 \"impulse 2\"; in_bind 7 3 \"impulse 3\"; in_bind 7 4 \"impulse 4\"; in_bind 7 5 \"impulse 5\"; in_bind 7 6 \"impulse 6\"; in_bind 7 7 \"impulse 7\"; in_bind 7 8 \"impulse 8\"; in_bind 7 9 \"impulse 9\"; in_bind 7 0 \"impulse 10\"; in_bind 7 KP_1 \"impulse 1\"; in_bind 7 KP_2 \"impulse 2\"; in_bind 7 KP_3 \"impulse 3\"; in_bind 7 KP_4 \"impulse 4\"; in_bind 7 KP_5 \"impulse 5\"; in_bind 7 KP_6 \"impulse 6\"; in_bind 7 KP_7 \"impulse 7\"; in_bind 7 KP_8 \"impulse 8\"; in_bind 7 KP_9 \"impulse 9\"; in_bind 7 KP_0 \"impulse 10\"; in_bindmap 7 0\n");
296 case MAPVOTE_NET_UPDATE:
299 case MAPVOTE_NET_OWNVOTE:
300 mv_ownvote = ReadByte()-1;
302 case MAPVOTE_NET_PIC:
304 mv_preview[type] = true;
305 mv_pics[type] = strzone(Net_ReadPicture());