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);
519 if(mv_abstain && i < mv_num_maps) {
521 pos.y = ymax + abstain_spacing;
522 pos.x = (xmax + xmin) * 0.5;
523 MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
528 // expand winner map image
529 vector startsize = '0 0 0';
530 startsize.y = vid_conheight * 0.1;
531 startsize.x = startsize.y * 4/3;
532 vector startpos = panel_pos + (panel_size - startsize) / 2;
534 vector endsize = '0 0 0';
535 endsize.y = vid_conheight * 0.5;
536 endsize.x = endsize.y * 4/3;
537 vector endpos = '0 0 0';
538 endpos.y = panel_pos.y;
539 endpos.x = (vid_conwidth - endsize.x) * 0.5;
541 float f = bound(0, (time - mv_winner_time) * 2, 1);
545 vector img_pos = endpos * f + startpos * (1 - f);
546 vector img_size = endsize * f + startsize * (1 - f);
548 MapVote_DrawMapPicture(mv_pics[mv_winner - 1], img_pos, img_size, theAlpha);
552 void Cmd_MapVote_MapDownload(int argc)
557 if(argc != 2 || !mv_pk3list)
559 LOG_INFO(_("mv_mapdownload: ^3You're not supposed to use this command on your own!"));
563 int id = stof(argv(1));
564 for(pak = mv_pk3list; pak; pak = pak.chain)
565 if(pak.sv_entnum == id)
568 if(!pak || pak.sv_entnum != id) {
569 LOG_INFO(_("^1Error:^7 Couldn't find pak index."));
573 if(PreviewExists(pak.message))
575 mv_preview[id] = true;
578 LOG_INFO(_("Requesting preview..."));
579 localcmd(strcat("\ncmd mv_getpicture ", ftos(id), "\n"));
583 void MapVote_CheckPK3(string pic, string pk3, int id)
592 pak.chain = mv_pk3list;
597 localcmd(strcat("\ncurl --pak ", pk3, "; wait; cl_cmd mv_download ", ftos(id), "\n"));
601 Cmd_MapVote_MapDownload(tokenize_console(strcat("mv_download ", ftos(id))));
605 void MapVote_CheckPic(string pic, string pk3, int id)
608 // never try to retrieve a pic for the "don't care" 'map'
609 if(mv_abstain && id == mv_num_maps - 1)
612 if(PreviewExists(pic))
614 mv_preview[id] = true;
617 MapVote_CheckPK3(pic, pk3, id);
620 void MapVote_ReadMask()
623 if ( mv_num_maps < 24 )
628 else if(mv_num_maps < 16)
633 for(i = 0; i < mv_num_maps; ++i)
636 mv_flags[i] |= GTV_AVAILABLE;
638 mv_flags[i] &= ~GTV_AVAILABLE;
643 for(i = 0; i < mv_num_maps; ++i )
644 mv_flags[i] = ReadByte();
648 void MapVote_ReadOption(int i)
651 string map = strzone(ReadString());
652 string pk3 = strzone(ReadString());
653 int j = bound(0, ReadByte(), n_ssdirs - 1);
657 mv_flags[i] = GTV_AVAILABLE;
659 string pic = strzone(strcat(ssdirs[j], "/", map));
661 mv_preview[i] = false;
662 MapVote_CheckPic(pic, pk3, i);
665 void GameTypeVote_ReadOption(int i)
668 string gt = strzone(ReadString());
671 mv_flags[i] = ReadByte();
673 string basetype = "";
675 if ( mv_flags[i] & GTV_CUSTOM )
677 string name = ReadString();
678 if ( strlen(name) < 1 )
680 mv_pk3[i] = strzone(name);
681 mv_desc[i] = strzone(ReadString());
682 basetype = strzone(ReadString());
686 Gametype type = MapInfo_Type_FromString(gt, false, false);
687 mv_pk3[i] = strzone(MapInfo_Type_ToText(type));
688 mv_desc[i] = MapInfo_Type_Description(type);
691 string mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, gt);
692 if(precache_pic(mv_picpath) == "")
694 mv_picpath = strcat("gfx/menu/default/gametype_", gt);
695 if(precache_pic(mv_picpath) == "")
697 mv_picpath = sprintf("gfx/menu/%s/gametype_%s", autocvar_menu_skin, basetype);
698 if(precache_pic(mv_picpath) == "")
700 mv_picpath = strcat("gfx/menu/default/gametype_", basetype);
704 string pic = strzone(mv_picpath);
706 mv_preview[i] = PreviewExists(pic);
712 if(!autocvar_hud_cursormode) mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
714 mv_selection_keyboard = 0;
717 for(n_ssdirs = 0; ; ++n_ssdirs)
722 if(n_ssdirs < NUM_SSDIRS)
723 ssdirs[n_ssdirs] = s;
725 n_ssdirs = min(n_ssdirs, NUM_SSDIRS);
727 mv_num_maps = min(MAPVOTE_COUNT, ReadByte());
728 mv_abstain = ReadByte();
730 mv_abstain = 1; // must be 1 for bool-true, makes stuff easier
731 mv_detail = ReadByte();
734 mv_timeout = ReadCoord();
736 int gametypevote_flags = ReadByte();
737 gametypevote = boolean(gametypevote_flags & BIT(0));
738 if(gametypevote_flags)
739 mapvote_chosenmap = strzone(ReadString());
743 for(i = 0; i < mv_num_maps; ++i )
744 mv_flags_start[i] = mv_flags[i];
746 // Assume mv_pk3list is NULL, there should only be 1 mapvote per round
747 mv_pk3list = NULL; // I'm still paranoid!
749 for(i = 0; i < mv_num_maps; ++i)
754 GameTypeVote_ReadOption(i);
756 MapVote_ReadOption(i);
759 for(i = 0; i < n_ssdirs; ++i)
760 ssdirs[n_ssdirs] = string_null;
764 void MapVote_SendChoice(int index)
767 localcmd(strcat("\nimpulse ", ftos(index+1), "\n"));
770 int MapVote_MoveLeft(int pos)
775 imp = mv_num_maps - 1;
777 imp = pos < 1 ? mv_num_maps - 1 : pos - 1;
778 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
779 imp = MapVote_MoveLeft(imp);
782 int MapVote_MoveRight(int pos)
789 imp = pos >= mv_num_maps - 1 ? 0 : pos + 1;
790 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
791 imp = MapVote_MoveRight(imp);
794 int MapVote_MoveUp(int pos)
799 imp = mv_num_maps - 1;
802 imp = pos - mv_columns;
805 int mv_rows = ceil(mv_num_maps / mv_columns);
806 if (imp == -mv_columns) // pos == 0
807 imp = mv_columns * mv_rows - 1;
809 imp = imp + mv_columns * mv_rows - 1;
812 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
813 imp = MapVote_MoveUp(imp);
816 int MapVote_MoveDown(int pos)
824 imp = pos + mv_columns;
825 if ( imp >= mv_num_maps )
827 if ((imp % mv_columns) == mv_columns - 1)
830 imp = imp % mv_columns + 1;
833 if ( !(mv_flags[imp] & GTV_AVAILABLE) && imp != mv_ownvote )
834 imp = MapVote_MoveDown(imp);
838 float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
842 static int first_digit = 0;
843 if (!mv_active || isdemo())
848 mousepos.x = nPrimary;
849 mousepos.y = nSecondary;
850 mv_selection_keyboard = 0;
856 mv_selection_keyboard = 0;
860 // at this point bInputType can only be 0 or 1 (key pressed or released)
861 bool key_pressed = (bInputType == 0);
865 if (nPrimary == K_ALT) hudShiftState |= S_ALT;
866 if (nPrimary == K_CTRL) hudShiftState |= S_CTRL;
867 if (nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
871 if (nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
872 if (nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
873 if (nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
875 if (nPrimary == K_CTRL)
879 // Key release events must be handled by the engine otherwise the on-press command such as +jump
880 // executed by pressing SPACE before entering the map voting screen won't be followed by the
881 // on-release command (-jump) on key release once entered the map voting screen, causing +jump
882 // to stay active even on the next map and automatically forcing the player to join
883 if (!key_pressed) return false;
891 mv_selection_keyboard = 1;
892 mv_selection = MapVote_MoveRight(mv_selection);
897 mv_selection_keyboard = 1;
898 mv_selection = MapVote_MoveLeft(mv_selection);
903 mv_selection_keyboard = 1;
904 mv_selection = MapVote_MoveDown(mv_selection);
909 mv_selection_keyboard = 1;
910 mv_selection = MapVote_MoveUp(mv_selection);
917 if ( mv_selection_keyboard )
918 MapVote_SendChoice(mv_selection);
920 case '1': case K_KP_1: imp = 1; break;
921 case '2': case K_KP_2: imp = 2; break;
922 case '3': case K_KP_3: imp = 3; break;
923 case '4': case K_KP_4: imp = 4; break;
924 case '5': case K_KP_5: imp = 5; break;
925 case '6': case K_KP_6: imp = 6; break;
926 case '7': case K_KP_7: imp = 7; break;
927 case '8': case K_KP_8: imp = 8; break;
928 case '9': case K_KP_9: imp = 9; break;
929 case '0': case K_KP_0: imp = 10; break;
932 if (imp && hudShiftState & S_CTRL)
936 first_digit = imp % 10;
940 imp = first_digit * 10 + (imp % 10);
943 if (nPrimary == K_MOUSE1)
945 mv_selection_keyboard = 0;
946 mv_selection = mv_mouse_selection;
947 if (mv_selection >= 0)
948 imp = min(mv_selection + 1, mv_num_maps);
951 if (nPrimary == K_MOUSE2)
952 return true; // do nothing
956 if (!mv_winner && imp <= mv_num_maps)
957 localcmd(strcat("\nimpulse ", ftos(imp), "\n"));
964 void MapVote_UpdateMask()
970 void MapVote_UpdateVotes()
973 for(i = 0; i < mv_num_maps; ++i)
975 if(mv_flags[i] & GTV_AVAILABLE)
978 mv_votes[i] = ReadByte();
986 mv_ownvote = ReadByte()-1;
989 NET_HANDLE(ENT_CLIENT_MAPVOTE, bool isnew)
999 MapVote_UpdateMask();
1002 MapVote_UpdateVotes();
1006 mv_winner = ReadByte();
1007 mv_winner_time = time;
1011 NET_HANDLE(TE_CSQC_PICTURE, bool isNew)
1013 Net_MapVote_Picture();
1017 void Net_MapVote_Picture()
1019 int type = ReadByte();
1020 mv_preview[type] = true;
1021 mv_pics[type] = strzone(ReadPicture());