vector mv_mousepos;
float mv_selection;
float mv_columns;
+float mv_mouse_selection;
+float mv_selection_keyboard;
float gametypevote;
-string mapvote_choosenmap;
+string mapvote_chosenmap;
vector gtv_text_size;
vector gtv_text_size_small;
float MapVote_Selection(vector topleft, vector cellsize, float rows, float columns)
{
- float cell;
+
float c, r;
- cell = -1;
+ mv_mouse_selection = -1;
for (r = 0; r < rows; ++r)
for (c = 0; c < columns; ++c)
mv_mousepos_y >= topleft_y + cellsize_y * r &&
mv_mousepos_y <= topleft_y + cellsize_y * (r + 1))
{
- cell = r * columns + c;
+ mv_mouse_selection = r * columns + c;
break;
}
}
- if (cell >= mv_num_maps)
- cell = -1;
+ if (mv_mouse_selection >= mv_num_maps)
+ mv_mouse_selection = -1;
- if (mv_abstain && cell < 0)
- return mv_num_maps;
+ if (mv_abstain && mv_mouse_selection < 0)
+ mv_mouse_selection = mv_num_maps;
- return cell;
+ if ( mv_selection_keyboard )
+ return mv_selection;
+
+ return mv_mouse_selection;
}
void MapVote_Draw()
if (!autocvar_hud_cursormode)
{
- mv_mousepos = mv_mousepos + getmousepos();
+ vector mpos = mv_mousepos + getmousepos();
+ mpos_x = bound(0, mpos_x, vid_conwidth);
+ mpos_y = bound(0, mpos_y, vid_conheight);
+
+ if ( mpos_x != mv_mousepos_x || mpos_y != mv_mousepos_y )
+ mv_selection_keyboard = 0;
+ mv_mousepos = mpos;
- mv_mousepos_x = bound(0, mv_mousepos_x, vid_conwidth);
- mv_mousepos_y = bound(0, mv_mousepos_y, vid_conheight);
}
center = (vid_conwidth - 1)/2;
drawstring(pos, map, '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
pos_y += 26;
- if(gametypevote && mapvote_choosenmap != "" )
+ if( mapvote_chosenmap != "" )
{
- pos_x = center - stringwidth(mapvote_choosenmap, false, hud_fontsize);
- drawstring(pos, mapvote_choosenmap, hud_fontsize*2, '1 1 1', 1, DRAWFLAG_NORMAL);
+ pos_x = center - stringwidth(mapvote_chosenmap, false, hud_fontsize*1.5/2);
+ drawstring(pos, mapvote_chosenmap, hud_fontsize*1.5, '1 1 1', 1, DRAWFLAG_NORMAL);
pos_y += hud_fontsize_y*2;
}
if(autocvar_hud_cursormode) { setcursormode(1); }
else { mv_mousepos = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight; }
mv_selection = -1;
+ mv_selection_keyboard = 0;
for(n_ssdirs = 0; ; ++n_ssdirs)
{
if(gametypevote)
{
- // read map name in case we have nextmap set
- mapvote_choosenmap = strzone(ReadString());
-
+ mapvote_chosenmap = strzone(ReadString());
+ if ( gametypevote == 2 )
+ gametypevote = 0;
+
gtv_text_size = hud_fontsize*1.4;
gtv_text_size_small = hud_fontsize*1.1;
{
mv_mousepos_x = nPrimary;
mv_mousepos_y = nSecondary;
+ mv_selection_keyboard = 0;
return true;
}
case K_KP_0: localcmd("\nimpulse 10\n"); return true;
case K_RIGHTARROW:
- MapVote_SendChoice(MapVote_MoveRight(mv_ownvote));
+ mv_selection_keyboard = 1;
+ mv_selection = MapVote_MoveRight(mv_selection);
return true;
case K_LEFTARROW:
- MapVote_SendChoice(MapVote_MoveLeft(mv_ownvote));
+ mv_selection_keyboard = 1;
+ mv_selection = MapVote_MoveLeft(mv_selection);
return true;
case K_DOWNARROW:
- MapVote_SendChoice(MapVote_MoveDown(mv_ownvote));
+ mv_selection_keyboard = 1;
+ mv_selection = MapVote_MoveDown(mv_selection);
return true;
case K_UPARROW:
- MapVote_SendChoice(MapVote_MoveUp(mv_ownvote));
+ mv_selection_keyboard = 1;
+ mv_selection = MapVote_MoveUp(mv_selection);
+ return true;
+ case K_KP_ENTER:
+ case K_ENTER:
+ case K_SPACE:
+ if ( mv_selection_keyboard )
+ MapVote_SendChoice(mv_selection);
return true;
}
if (nPrimary == K_MOUSE1)
+ {
+ mv_selection_keyboard = 0;
+ mv_selection = mv_mouse_selection;
if (mv_selection >= 0)
{
imp = min(mv_selection + 1, mv_num_maps);
localcmd(strcat("\nimpulse ", ftos(imp), "\n"));
return true;
}
+ }
return false;
}