1 #include "mapvoting.qh"
3 #include <client/draw.qh>
4 #include <client/hud/_mod.qh>
5 #include <client/hud/panel/scoreboard.qh>
6 #include <common/mapinfo.qh>
7 #include <common/util.qh>
11 void MapVote_Draw_Export(int fh)
13 // allow saving cvars that aesthetically change the panel into hud skin files
14 HUD_Write_Cvar("hud_panel_mapvote_highlight_border");
19 string mv_maps[MAPVOTE_COUNT];
20 string mv_pics[MAPVOTE_COUNT];
21 string mv_pk3[MAPVOTE_COUNT]; // map pk3 name or gametype human readable name
22 string mv_desc[MAPVOTE_COUNT];
23 float mv_preview[MAPVOTE_COUNT];
24 float mv_votes[MAPVOTE_COUNT];
25 float mv_flags[MAPVOTE_COUNT];
26 float mv_flags_start[MAPVOTE_COUNT];
35 float mv_winner_alpha;
39 int mv_mouse_selection;
40 int mv_selection_keyboard;
43 string mapvote_chosenmap;
45 vector gtv_text_size_small;
47 const int NUM_SSDIRS = 4;
48 string ssdirs[NUM_SSDIRS];
51 bool PreviewExists(string name)
53 if(autocvar_cl_readpicture_force)
56 if (fexists(strcat(name, ".tga"))) return true;
57 if (fexists(strcat(name, ".png"))) return true;
58 if (fexists(strcat(name, ".jpg"))) return true;
59 if (fexists(strcat(name, ".pcx"))) return true;
64 string MapVote_FormatMapItem(int id, string map, float _count, float maxwidth, vector fontsize)
68 pre = sprintf("%d. ", id+1);
72 post = _(" (1 vote)");
73 else if(_count >= 0 && (mv_flags[id] & GTV_AVAILABLE))
74 post = sprintf(_(" (%d votes)"), _count);
80 maxwidth -= stringwidth(pre, false, fontsize) + stringwidth(post, false, fontsize);
81 map = textShortenToWidth(map, maxwidth, fontsize, stringwidth_nocolors);
82 return strcat(pre, map, post);
85 vector MapVote_RGB(int id)
88 if(!(mv_flags[id] & GTV_AVAILABLE))
92 else if (id == mv_selection)
98 void GameTypeVote_DrawGameTypeItem(vector pos, float maxh, float tsize, string gtype, string pic, float _count, int id)
101 // Find the correct alpha
103 if(!(mv_flags_start[id] & GTV_AVAILABLE))
104 alpha = 0.2; // The gametype isn't supported by the map
105 else if ( !(mv_flags[id] & GTV_AVAILABLE) && mv_top2_alpha)
106 alpha = mv_top2_alpha; // Fade away if not one of the top 2 choice
108 alpha = 1; // Normal, full alpha
109 alpha *= panel_fg_alpha;
111 // Bounding box details
112 float rect_margin = hud_fontsize.y / 2;
114 pos.x += rect_margin + autocvar_hud_panel_mapvote_highlight_border;
115 pos.y += rect_margin + autocvar_hud_panel_mapvote_highlight_border;
116 maxh -= 2 * (rect_margin + autocvar_hud_panel_mapvote_highlight_border);
117 tsize -= 2 * (rect_margin + autocvar_hud_panel_mapvote_highlight_border);
119 vector rect_pos = pos - '0.5 0.5 0' * rect_margin;
120 vector rect_size = '1 1 0';
121 rect_size.x = tsize + rect_margin;
122 rect_size.y = maxh + rect_margin;
124 // Highlight selected item
125 if(id == mv_selection && (mv_flags[id] & GTV_AVAILABLE))
127 drawfill(rect_pos, rect_size, '1 1 1', 0.1 * panel_fg_alpha, DRAWFLAG_NORMAL);
130 // Highlight current vote
131 vector rgb = MapVote_RGB(id);
134 drawfill(rect_pos, rect_size, rgb, 0.1 * alpha, DRAWFLAG_NORMAL);
135 drawborderlines(autocvar_hud_panel_mapvote_highlight_border, rect_pos, rect_size, rgb, alpha, DRAWFLAG_NORMAL);
140 float title_gap = gtv_text_size.y * 1.4; // distance between the title and the description
144 // Evaluate the image size
145 vector image_size = '1 1 0' * gtv_text_size.x * 3;
146 if ( maxh < image_size.y )
147 image_size = '1 1 0' * maxh;
149 float desc_padding = gtv_text_size.x * 0.6;
150 pos.x += image_size.x + desc_padding;
151 tsize -= image_size.x + desc_padding;
153 // Split the description into lines
156 title.message = MapVote_FormatMapItem(id, mv_pk3[id], _count, tsize, gtv_text_size);
158 string thelabel = mv_desc[id], ts;
164 float i,n = tokenizebyseparator(thelabel, "\n");
165 for(i = 0; i < n && maxh > (nlines+1)*gtv_text_size_small.y; ++i)
167 getWrappedLine_remaining = argv(i);
168 while(getWrappedLine_remaining && maxh > (nlines+1)*gtv_text_size_small.y)
170 ts = getWrappedLine(tsize, gtv_text_size_small, stringwidth_colors);
175 next.origin = pos-offset;
178 pos.y += gtv_text_size_small.y;
185 // Center the contents in the bounding box
186 maxh -= max(nlines*gtv_text_size_small.y,image_size.y);
191 drawstring(offset, title.message, gtv_text_size, rgb, alpha, DRAWFLAG_NORMAL);
195 drawpic('0 1 0'*title_gap+'0.5 0 0'*desc_padding+offset, pic, image_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
197 // Draw the description
198 for ( last = title.chain; last ; )
200 drawstring(last.origin+offset, last.message, gtv_text_size_small, '1 1 1', alpha, DRAWFLAG_NORMAL);
210 void MapVote_DrawMapPicture(string pic, vector pos, vector img_size, float theAlpha)
213 drawfill(pos, img_size, '.5 .5 .5', .7 * theAlpha, DRAWFLAG_NORMAL);
216 if(drawgetimagesize(pic) == '0 0 0')
217 drawpic(pos, draw_UseSkinFor("nopreview_map"), img_size, '1 1 1', theAlpha, DRAWFLAG_NORMAL);
219 drawpic(pos, pic, img_size, '1 1 1', theAlpha, DRAWFLAG_NORMAL);
223 void MapVote_DrawMapItem(vector pos, float isize, float tsize, string map, string pic, float _count, int id)
226 vector img_size = '0 0 0';
230 float rect_margin = hud_fontsize.y / 2;
232 pos.x += rect_margin + autocvar_hud_panel_mapvote_highlight_border;
233 pos.y += rect_margin + autocvar_hud_panel_mapvote_highlight_border;
234 isize -= 2 * (rect_margin + autocvar_hud_panel_mapvote_highlight_border);
235 tsize -= 2 * (rect_margin + autocvar_hud_panel_mapvote_highlight_border);
237 vector rect_pos = pos - '0.5 0.5 0' * rect_margin;
238 vector rect_size = '1 1 0';
239 rect_size.x = tsize + rect_margin;
240 rect_size.y = isize + rect_margin;
243 img_size.x = min(tsize, isize * img_ar);
244 img_size.y = img_size.x / img_ar;
245 img_size.y -= hud_fontsize.y;
246 img_size.x = img_size.y * img_ar;
248 pos.y += (isize - img_size.y - hud_fontsize.y) / 2;
250 label = MapVote_FormatMapItem(id, map, _count, tsize, hud_fontsize);
252 text_size = stringwidth(label, false, hud_fontsize);
254 float save_rect_sizex = rect_size.x;
255 rect_size.x = max(img_size.x, text_size) + rect_margin;
256 rect_pos.x += (save_rect_sizex - rect_size.x) / 2;
258 vector text_pos = '0 0 0';
259 text_pos.x = pos.x + (tsize - text_size) / 2;
260 text_pos.y = pos.y + img_size.y;
262 pos.x += (tsize - img_size.x) / 2;
265 if (!(mv_flags[id] & GTV_AVAILABLE) && mv_top2_alpha)
266 theAlpha = mv_top2_alpha;
267 else if (mv_winner && mv_winner_alpha)
268 theAlpha = mv_winner_alpha;
271 theAlpha *= panel_fg_alpha;
273 vector rgb = MapVote_RGB(id);
275 // Highlight selected item
278 if(id == mv_selection && (mv_flags[id] & GTV_AVAILABLE))
279 drawfill(rect_pos, rect_size, '1 1 1', 0.1 * panel_fg_alpha, DRAWFLAG_NORMAL);
281 // Highlight current vote
284 drawfill(rect_pos, rect_size, rgb, 0.1 * theAlpha, DRAWFLAG_NORMAL);
285 drawborderlines(autocvar_hud_panel_mapvote_highlight_border, rect_pos, rect_size, rgb, theAlpha, DRAWFLAG_NORMAL);
289 drawstring(text_pos, label, hud_fontsize, rgb, theAlpha, DRAWFLAG_NORMAL);
291 MapVote_DrawMapPicture(pic, pos, img_size, theAlpha);
294 void MapVote_DrawAbstain(vector pos, float isize, float tsize, float _count, int id)
301 rgb = MapVote_RGB(id);
303 label = MapVote_FormatMapItem(id, _("Don't care"), _count, tsize, hud_fontsize);
305 text_size = stringwidth(label, false, hud_fontsize);
307 pos.x -= text_size*0.5;
308 drawstring(pos, label, hud_fontsize, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
311 vector MapVote_GridVec(vector gridspec, int i, int m)
313 TC(int, i); TC(int, m);
316 '1 0 0' * (gridspec.x * r)
318 '0 1 0' * (gridspec.y * (i - r) / m);
321 float MapVote_Selection(vector topleft, vector cellsize, float rows, float columns)
327 mv_mouse_selection = -1;
329 for (r = 0; r < rows; ++r)
330 for (c = 0; c < columns; ++c)
332 if (mousepos.x >= topleft.x + cellsize.x * c &&
333 mousepos.x <= topleft.x + cellsize.x * (c + 1) &&
334 mousepos.y >= topleft.y + cellsize.y * r &&
335 mousepos.y <= topleft.y + cellsize.y * (r + 1))
337 mv_mouse_selection = r * columns + c;
342 if (mv_mouse_selection >= mv_num_maps)
343 mv_mouse_selection = -1;
345 if (mv_abstain && mv_mouse_selection < 0)
346 mv_mouse_selection = mv_num_maps;
348 if ( mv_selection_keyboard )
351 return mv_mouse_selection;
354 // draws map vote or gametype vote
363 vector dist = '0 0 0';
365 //if(intermission != 2) return;
369 HUD_Panel_LoadCvars();
371 center = (vid_conwidth - 1)/2;
372 xmin = vid_conwidth * 0.08;
373 xmax = vid_conwidth - xmin;
375 ymax = vid_conheight - ymin;
377 if(chat_posy + chat_sizey / 2 < vid_conheight / 2)
382 hud_fontsize = HUD_GetFontsize("hud_fontsize");
385 gtv_text_size = hud_fontsize * 1.4;
386 gtv_text_size_small = hud_fontsize * 1.1;
393 draw_beginBoldFont();
395 map = ((gametypevote) ? _("Decide the gametype") : _("Vote for a map"));
398 pos.x = center - stringwidth(map, false, hud_fontsize * 2) * 0.5;
399 drawstring(pos, map, hud_fontsize * 2, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
401 pos.y += hud_fontsize.y * 2;
403 if( mapvote_chosenmap != "" )
405 pos.y += hud_fontsize.y * 0.25;
406 pos.x = center - stringwidth(mapvote_chosenmap, false, hud_fontsize * 1.5) * 0.5;
407 drawstring(pos, mapvote_chosenmap, hud_fontsize * 1.5, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
408 pos.y += hud_fontsize.y * 1.5;
410 pos.y += hud_fontsize.y * 0.5;
414 i = ceil(max(1, mv_timeout - time)); // make sure 0 seconds left never shows up, not even for a frame
416 map = mv_maps[mv_winner - 1];
418 map = sprintf(_("%d seconds left"), i);
419 pos.x = center - stringwidth(map, false, hud_fontsize * 1.5) * 0.5;
420 drawstring(pos, map, hud_fontsize * 1.5, '0 1 0', panel_fg_alpha, DRAWFLAG_NORMAL);
421 pos.y += hud_fontsize.y * 1.5;
422 pos.y += hud_fontsize.y * 0.5;
424 // base for multi-column stuff...
425 pos.y += hud_fontsize.y;
428 float abstain_spacing = panel_bg_border + hud_fontsize.y;
432 ymax -= abstain_spacing;
435 // higher than the image itself ratio for mapvote items to reserve space for long map names
436 int item_aspect = (gametypevote) ? 3/1 : 5/3;
437 vector table_size = HUD_GetTableSize_BestItemAR(mv_num_maps, vec2(xmax - xmin, ymax - ymin), item_aspect);
438 mv_columns = table_size.x;
441 dist.x = (xmax - xmin) / mv_columns;
442 dist.y = (ymax - pos.y) / rows;
444 // reduce size of too wide items
445 tmp = vid_conwidth / 3; // max width
449 dist.y = min(dist.y, dist.x / item_aspect);
451 tmp = vid_conheight / 3; // max height
455 dist.x = min(dist.x, dist.y * item_aspect);
458 // reduce size to fix aspect ratio
459 if(dist.x / dist.y > item_aspect)
460 dist.x = dist.y * item_aspect;
462 dist.y = dist.x / item_aspect;
464 // adjust table pos and size according to the new size
466 offset = ((xmax - pos.x) - dist.x * mv_columns) / 2;
467 xmin = pos.x += offset;
469 offset = ((ymax - pos.y) - dist.y * rows) / 2;
472 // override panel_pos and panel_size
475 panel_size.x = xmax - xmin;
476 panel_size.y = ymax - ymin;
481 // FIXME item AR gets slightly changed here...
482 // it's rather hard to avoid it at this point
483 dist.x -= 2 * panel_bg_padding / mv_columns;
484 dist.y -= 2 * panel_bg_padding / rows;
485 xmin = pos.x += panel_bg_padding;
486 ymin = pos.y += panel_bg_padding;
487 xmax -= 2 * panel_bg_padding;
488 ymax -= 2 * panel_bg_padding;
491 mv_selection = MapVote_Selection(pos, dist, rows, mv_columns);
494 mv_top2_alpha = max(0.2, 1 - (time - mv_top2_time) ** 2);
497 mv_winner_alpha = max(0.2, 1 - sqrt(max(0, time - mv_winner_time)));
499 void (vector, float, float, string, string, float, float) DrawItem;
502 DrawItem = GameTypeVote_DrawGameTypeItem;
504 DrawItem = MapVote_DrawMapItem;
506 for(i = 0; i < mv_num_maps; ++i)
508 tmp = mv_votes[i]; // FTEQCC bug: too many array accesses in the function call screw it up
511 DrawItem(pos + MapVote_GridVec(dist, i, mv_columns), dist.y, dist.x, map, mv_pics[i], tmp, i);
513 DrawItem(pos + MapVote_GridVec(dist, i, mv_columns), dist.y, dist.x, map, "", tmp, i);
517 // expand winner map image
518 vector startsize = '0 0 0';
519 startsize.y = vid_conheight * 0.1;
520 startsize.x = startsize.y * 4/3;
521 vector startpos = panel_pos + (panel_size - startsize) / 2;
523 vector endsize = '0 0 0';
524 endsize.y = vid_conheight * 0.5;
525 endsize.x = endsize.y * 4/3;
526 vector endpos = '0 0 0';
527 endpos.y = panel_pos.y;
528 endpos.x = (vid_conwidth - endsize.x) * 0.5;
530 float f = bound(0, (time - mv_winner_time) * 2, 1);
534 vector img_pos = endpos * f + startpos * (1 - f);
535 vector img_size = endsize * f + startsize * (1 - f);
537 MapVote_DrawMapPicture(mv_pics[mv_winner - 1], img_pos, img_size, theAlpha);
543 if(mv_abstain && i < mv_num_maps) {
545 pos.y = ymax + abstain_spacing;
546 pos.x = (xmax+xmin)*0.5;
547 MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
551 void Cmd_MapVote_MapDownload(int argc)
556 if(argc != 2 || !mv_pk3list)
558 LOG_INFO(_("mv_mapdownload: ^3You're not supposed to use this command on your own!"));
562 int id = stof(argv(1));
563 for(pak = mv_pk3list; pak; pak = pak.chain)
564 if(pak.sv_entnum == id)
567 if(!pak || pak.sv_entnum != id) {
568 LOG_INFO(_("^1Error:^7 Couldn't find pak index."));
572 if(PreviewExists(pak.message))
574 mv_preview[id] = true;
577 LOG_INFO(_("Requesting preview..."));
578 localcmd(strcat("\ncmd mv_getpicture ", ftos(id), "\n"));
582 void MapVote_CheckPK3(string pic, string pk3, int id)
591 pak.chain = mv_pk3list;
596 localcmd(strcat("\ncurl --pak ", pk3, "; wait; cl_cmd mv_download ", ftos(id), "\n"));
600 Cmd_MapVote_MapDownload(tokenize_console(strcat("mv_download ", ftos(id))));
604 void MapVote_CheckPic(string pic, string pk3, int id)
607 // never try to retrieve a pic for the "don't care" 'map'
608 if(mv_abstain && id == mv_num_maps - 1)
611 if(PreviewExists(pic))
613 mv_preview[id] = true;
616 MapVote_CheckPK3(pic, pk3, id);
619 void MapVote_ReadMask()
622 if ( mv_num_maps < 24 )
627 else if(mv_num_maps < 16)
632 for(i = 0; i < mv_num_maps; ++i)
635 mv_flags[i] |= GTV_AVAILABLE;
637 mv_flags[i] &= ~GTV_AVAILABLE;
642 for(i = 0; i < mv_num_maps; ++i )
643 mv_flags[i] = ReadByte();
647 void MapVote_ReadOption(int i)
650 string map = strzone(ReadString());
651 string pk3 = strzone(ReadString());
652 int j = bound(0, ReadByte(), n_ssdirs - 1);
656 mv_flags[i] = GTV_AVAILABLE;
658 string pic = strzone(strcat(ssdirs[j], "/", map));
660 mv_preview[i] = false;
661 MapVote_CheckPic(pic, pk3, i);
664 void GameTypeVote_ReadOption(int i)
667 string gt = strzone(ReadString());
670 mv_flags[i] = ReadByte();
672 string basetype = "";
674 if ( mv_flags[i] & GTV_CUSTOM )
676 string name = ReadString();
677 if ( strlen(name) < 1 )
679 mv_pk3[i] = strzone(name);
680 mv_desc[i] = strzone(ReadString());
681 basetype = strzone(ReadString());
685 Gametype type = MapInfo_Type_FromString(gt, false, false);
686 mv_pk3[i] = strzone(MapInfo_Type_ToText(type));
687 mv_desc[i] = MapInfo_Type_Description(type);
690 string mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, gt);
691 if(precache_pic(mv_picpath) == "")
693 mv_picpath = strcat("gfx/menu/default/gametype_", gt);
694 if(precache_pic(mv_picpath) == "")
696 mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, basetype);
697 if(precache_pic(mv_picpath) == "")
699 mv_picpath = strcat("gfx/menu/default/gametype_", basetype);
703 string pic = strzone(mv_picpath);
705 mv_preview[i] = PreviewExists(pic);
711 if(!autocvar_hud_cursormode) mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
713 mv_selection_keyboard = 0;
716 for(n_ssdirs = 0; ; ++n_ssdirs)
721 if(n_ssdirs < NUM_SSDIRS)
722 ssdirs[n_ssdirs] = s;
724 n_ssdirs = min(n_ssdirs, NUM_SSDIRS);
726 mv_num_maps = min(MAPVOTE_COUNT, ReadByte());
727 mv_abstain = ReadByte();
729 mv_abstain = 1; // must be 1 for bool-true, makes stuff easier
730 mv_detail = ReadByte();
733 mv_timeout = ReadCoord();
735 int gametypevote_flags = ReadByte();
736 gametypevote = boolean(gametypevote_flags & BIT(0));
737 if(gametypevote_flags)
738 mapvote_chosenmap = strzone(ReadString());
742 for(i = 0; i < mv_num_maps; ++i )
743 mv_flags_start[i] = mv_flags[i];
745 // Assume mv_pk3list is NULL, there should only be 1 mapvote per round
746 mv_pk3list = NULL; // I'm still paranoid!
748 for(i = 0; i < mv_num_maps; ++i)
753 GameTypeVote_ReadOption(i);
755 MapVote_ReadOption(i);
758 for(i = 0; i < n_ssdirs; ++i)
759 ssdirs[n_ssdirs] = string_null;
763 void MapVote_SendChoice(int index)
766 localcmd(strcat("\nimpulse ", ftos(index+1), "\n"));
769 int MapVote_MoveLeft(int pos)
774 imp = mv_num_maps - 1;
776 imp = pos < 1 ? mv_num_maps - 1 : pos - 1;
777 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
778 imp = MapVote_MoveLeft(imp);
781 int MapVote_MoveRight(int pos)
788 imp = pos >= mv_num_maps - 1 ? 0 : pos + 1;
789 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
790 imp = MapVote_MoveRight(imp);
793 int MapVote_MoveUp(int pos)
798 imp = mv_num_maps - 1;
801 imp = pos - mv_columns;
804 int mv_rows = ceil(mv_num_maps / mv_columns);
805 if (imp == -mv_columns) // pos == 0
806 imp = mv_columns * mv_rows - 1;
808 imp = imp + mv_columns * mv_rows - 1;
811 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
812 imp = MapVote_MoveUp(imp);
815 int MapVote_MoveDown(int pos)
823 imp = pos + mv_columns;
824 if ( imp >= mv_num_maps )
826 if ((imp % mv_columns) == mv_columns - 1)
829 imp = imp % mv_columns + 1;
832 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
833 imp = MapVote_MoveDown(imp);
837 float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
841 static int first_digit = 0;
842 if (!mv_active || isdemo())
847 mousepos.x = nPrimary;
848 mousepos.y = nSecondary;
849 mv_selection_keyboard = 0;
855 mv_selection_keyboard = 0;
859 // at this point bInputType can only be 0 or 1 (key pressed or released)
860 bool key_pressed = (bInputType == 0);
864 if (nPrimary == K_ALT) hudShiftState |= S_ALT;
865 if (nPrimary == K_CTRL) hudShiftState |= S_CTRL;
866 if (nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
870 if (nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
871 if (nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
872 if (nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
874 if (nPrimary == K_CTRL)
878 // Key release events must be handled by the engine otherwise the on-press command such as +jump
879 // executed by pressing SPACE before entering the map voting screen won't be followed by the
880 // on-release command (-jump) on key release once entered the map voting screen, causing +jump
881 // to stay active even on the next map and automatically forcing the player to join
882 if (!key_pressed) return false;
890 mv_selection_keyboard = 1;
891 mv_selection = MapVote_MoveRight(mv_selection);
896 mv_selection_keyboard = 1;
897 mv_selection = MapVote_MoveLeft(mv_selection);
902 mv_selection_keyboard = 1;
903 mv_selection = MapVote_MoveDown(mv_selection);
908 mv_selection_keyboard = 1;
909 mv_selection = MapVote_MoveUp(mv_selection);
916 if ( mv_selection_keyboard )
917 MapVote_SendChoice(mv_selection);
919 case '1': case K_KP_1: imp = 1; break;
920 case '2': case K_KP_2: imp = 2; break;
921 case '3': case K_KP_3: imp = 3; break;
922 case '4': case K_KP_4: imp = 4; break;
923 case '5': case K_KP_5: imp = 5; break;
924 case '6': case K_KP_6: imp = 6; break;
925 case '7': case K_KP_7: imp = 7; break;
926 case '8': case K_KP_8: imp = 8; break;
927 case '9': case K_KP_9: imp = 9; break;
928 case '0': case K_KP_0: imp = 10; break;
931 if (imp && hudShiftState & S_CTRL)
935 first_digit = imp % 10;
939 imp = first_digit * 10 + (imp % 10);
942 if (nPrimary == K_MOUSE1)
944 mv_selection_keyboard = 0;
945 mv_selection = mv_mouse_selection;
946 if (mv_selection >= 0)
947 imp = min(mv_selection + 1, mv_num_maps);
950 if (nPrimary == K_MOUSE2)
951 return true; // do nothing
955 if (!mv_winner && imp <= mv_num_maps)
956 localcmd(strcat("\nimpulse ", ftos(imp), "\n"));
963 void MapVote_UpdateMask()
969 void MapVote_UpdateVotes()
972 for(i = 0; i < mv_num_maps; ++i)
974 if(mv_flags[i] & GTV_AVAILABLE)
977 mv_votes[i] = ReadByte();
985 mv_ownvote = ReadByte()-1;
988 NET_HANDLE(ENT_CLIENT_MAPVOTE, bool isnew)
998 MapVote_UpdateMask();
1001 MapVote_UpdateVotes();
1005 mv_winner = ReadByte();
1006 mv_winner_time = time;
1010 NET_HANDLE(TE_CSQC_PICTURE, bool isNew)
1012 Net_MapVote_Picture();
1016 void Net_MapVote_Picture()
1018 int type = ReadByte();
1019 mv_preview[type] = true;
1020 mv_pics[type] = strzone(ReadPicture());