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_x = (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_x - 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
139 MapVote_DrawMapItem(pos, isize, map, mv_pics[i], tmp, i);
141 MapVote_DrawMapNotAvailable(pos, isize, map, tmp, i);
144 if(mv_abstain && i < mv_num_maps) {
146 MapVote_DrawAbstain(pos, isize, tmp, i);
150 void Cmd_MapVote_MapDownload(float argc)
155 if(argc != 2 || !mv_pk3list)
157 print("mv_mapdownload: ^3You're not supposed to use this command on your own!\n");
162 for(pak = mv_pk3list; pak; pak = pak.chain)
163 if(pak.sv_entnum == id)
166 if(!pak || pak.sv_entnum != id) {
167 print("^1Error:^7 Couldn't find pak index.\n");
171 //print(strcat("^3Adding: ", ftos(id), " - ", pak.message, " - "));
173 if(PreviewExists(pak.message))
175 mv_preview[id] = true;
176 //print("^2Found...\n");
178 } else if(csqc_flags & CSQC_FLAG_READPICTURE) {
179 print("Requesting preview...\n");
180 localcmd(strcat("\ncmd mv_getpic ", ftos(id), "\n"));
182 print("^3Missing map preview - Update to a newer build to be able to see them.\n");
186 void MapVote_CheckPK3(string pic, string pk3, float id)
194 pak.chain = mv_pk3list;
197 localcmd(strcat("\ncurl --pak ", pk3, "; wait; cl_cmd mv_download ", ftos(id), "\n"));
200 void MapVote_CheckPic(string pic, string pk3, float id)
202 if(PreviewExists(pic))
204 //print(strcat("^2Exists... ", pic, "\n"));
205 mv_preview[id] = true;
208 MapVote_CheckPK3(pic, pk3, id);
216 mv_num_maps = min(MAPVOTE_COUNT, ReadByte());
217 mv_abstain = ReadByte();
219 mv_abstain = 1; // must be 1
220 mv_detail = ReadByte();
223 // Assume mv_pk3list is NULL, there should only be 1 mapvote per round
224 mv_pk3list = NULL; // I'm still paranoid!
226 for(i = 0; i < mv_num_maps; ++i)
229 map = strzone(ReadString());
230 pk3 = strzone(ReadString());
233 map = strzone(strcat("maps/", map));
236 mv_preview[i] = false;
238 //print(strcat("RECV: ", map, " in ", pk3, "\n"));
239 MapVote_CheckPic(map, pk3, i);
243 void MapVote_Update()
246 for(i = 0; i < mv_num_maps; ++i)
249 mv_votes[i] = ReadByte();
261 case MAPVOTE_NET_INIT:
264 case MAPVOTE_NET_UPDATE:
267 case MAPVOTE_NET_OWNVOTE:
268 mv_ownvote = ReadByte()-1;
270 case MAPVOTE_NET_PIC:
272 mv_preview[type] = true;
273 //print(strcat("MAPVOTE_NET_PIC: ^2", ftos(type), "\n"));