X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fmapvoting.qc;h=a354bacf28d9ecbec0b259bb5055f2989c889a98;hp=94f4809698b0c16bd3c81ca11682f6bd0d1d70f7;hb=00473777440f7a13bb5e726f2be95f51d31e3178;hpb=aabf77c33d43be0a35c7347ae361357d60af85fb diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 94f480969..a354bacf2 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -19,9 +19,11 @@ float mv_top2_alpha; 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; @@ -241,10 +243,10 @@ vector MapVote_GridVec(vector gridspec, float i, float m) 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) @@ -254,18 +256,21 @@ float MapVote_Selection(vector topleft, vector cellsize, float rows, float colum 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() @@ -284,10 +289,14 @@ 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; @@ -311,10 +320,10 @@ void MapVote_Draw() 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; } @@ -499,6 +508,7 @@ void MapVote_Init() 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) { @@ -525,9 +535,10 @@ void MapVote_Init() 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; @@ -665,6 +676,7 @@ float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary) { mv_mousepos_x = nPrimary; mv_mousepos_y = nSecondary; + mv_selection_keyboard = 0; return true; } @@ -692,26 +704,40 @@ float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary) 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; }