]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
add a cl_cmd cl_vyes/vno command for checking whether a vote should go through the...
authorFruitieX <fruitiex@gmail.com>
Mon, 22 Nov 2010 16:15:23 +0000 (18:15 +0200)
committerFruitieX <fruitiex@gmail.com>
Mon, 22 Nov 2010 16:15:23 +0000 (18:15 +0200)
defaultXonotic.cfg
keybinds.txt
qcsrc/client/Main.qc
qcsrc/client/hud.qc

index 25e3209cd36cf6cb542a8ac257e01ca631197176..90f4849d32e044104440889a66c83fbcd32a1401 100644 (file)
@@ -1074,8 +1074,8 @@ alias vdoend "vdo endmatch"
 
 alias lsmaps "cmd lsmaps" // lists all maps on server (for vmap, suggestmap, vnextmap)
 alias lsnewmaps "cmd lsnewmaps" // lists all maps on server that do not yet have a record set (race/cts)
-bind F1 vyes
-bind F2 vno
+bind F1 cl_vyes
+bind F2 cl_vno
 
 //used for spectate/observer mode
 alias spec "cmd spectate"
index 028547ac27ac68b76f66c1c3696228247888e659..7738584dd1d7d57128577d9035667ccd254c58d9 100644 (file)
@@ -38,8 +38,8 @@
 "messagemode"                           "public chat"
 "messagemode2"                          "team chat"
 "+con_chat_maximize"                    "show chat history"
-"vyes"                                  "vote YES"
-"vno"                                   "vote NO"
+"cl_cmd cl_vyes"                        "vote YES"
+"cl_cmd cl_vno"                         "vote NO"
 "ready"                                 "ready"
 ""                                      ""
 ""                                      "Client"
index ced8061ba9e2a58137580c79d715590165fa09a6..24ab85585bf5f00cfbefa8c8868737f28eb9bacf 100644 (file)
@@ -608,6 +608,35 @@ void GameCommand(string msg)
                e.draw = DrawDebugModel;
                e.classname = "debugmodel";
        }
+    else if(cmd == "cl_vyes")
+    {
+        if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE) && panel_fg_alpha && !scoreboard_active) // don't lock keys before we actually see what's going on
+        {
+            vote_active = 0; // force the panel to disappear right as we have selected the value (to prevent it from fading out in the normal vote panel pos)
+            vote_prev = 0;
+            cvar_set("cl_allow_uid2name", "1");
+            vote_change = -9999;
+        }
+        else
+        {
+            localcmd("vyes\n");
+        }
+    }
+    else if(cmd == "cl_vno")
+    {
+        if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE) && panel_fg_alpha && !scoreboard_active) // don't lock keys before we actually see what's going on
+        {
+            vote_active = 0;
+            vote_prev = 0;
+            cvar_set("cl_allow_uid2name", "0");
+            vote_change = -9999;
+        }
+        else
+        {
+            localcmd("vno\n");
+        }
+    }
+
        else
        {
                print("Invalid command. For a list of supported commands, try cl_cmd help.\n");
@@ -627,56 +656,6 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
        local float bSkipKey;
        bSkipKey = false;
 
-       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE) && panel_fg_alpha && !scoreboard_active) // don't lock keys before we actually see what's going on
-       {
-               /*
-               string vyes_keys;
-               float keys;
-               vyes_keys = findkeysforcommand("vyes");
-               keys = tokenize(vyes_keys);
-
-               float i;
-               for (i = 0; i < keys; ++i)
-               {
-                       print(ftos(nPrimary), " ", argv(i), "\n"); 
-                       if(nPrimary == stof(argv(i)))
-                       {
-                               vote_active = 0;
-                               cvar_set("cl_allow_uid2name", "1");
-                               return TRUE;
-                       }
-               }
-
-               string vno_keys;
-               vno_keys = findkeysforcommand("vno");
-               keys = tokenize(vno_keys);
-
-               float i;
-               for (i = 0; i < keys; ++i)
-               {
-                       if(nPrimary == stof(argv(i)))
-                       {
-                               vote_active = 0;
-                               cvar_set("cl_allow_uid2name", "0");
-                               return TRUE;
-                       }
-               }
-               */ // If only I could grab F1-F12 in CSQC... but no
-
-               if(nPrimary == 121) // ascii value for y
-               {
-                       vote_active = 0;
-                       cvar_set("cl_allow_uid2name", "1");
-                       return TRUE;
-               }
-               else if(nPrimary == 110) // ascii value for n
-               {
-                       vote_active = 0;
-                       cvar_set("cl_allow_uid2name", "0");
-                       return TRUE;
-               }
-       }
-
        if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
                return true;
 
index f77f1c1c1af2b1009147f2f7a27978126c2fc580..7419f52b8d1de92166afe879c6f60739ec21c107 100644 (file)
@@ -3893,9 +3893,6 @@ void HUD_VoteWindow(void)
 
        active_panel = HUD_PANEL_VOTE;
        HUD_Panel_UpdateCvars(vote);
-       vector pos, mySize;
-       pos = panel_pos;
-       mySize = panel_size;
 
        if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
        {
@@ -3903,6 +3900,11 @@ void HUD_VoteWindow(void)
                panel_size = eX * 0.4 * vid_conwidth + eY * 0.3 * vid_conheight;
        }
 
+    // these must be below above block
+       vector pos, mySize;
+       pos = panel_pos;
+       mySize = panel_size;
+
        a = vote_alpha * bound(cvar("hud_panel_vote_alreadyvoted_alpha"), 1 - vote_highlighted, 1);
        HUD_Panel_DrawBg(a);
        a = panel_fg_alpha * a;
@@ -3941,13 +3943,9 @@ void HUD_VoteWindow(void)
        drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
 
        // print the yes/no counts
-       s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
-       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
-               s = strcat("Yes: (press y)");
+    s = strcat("Yes (", getcommandkey("cl_cmd cl_vyes", "cl_cmd cl_vyes"), "): ", ftos(vote_yescount));
        drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
-       s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
-       if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
-               s = strcat("No: (press n)");
+    s = strcat("No (", getcommandkey("cl_cmd cl_vno", "cl_cmd cl_vno"), "): ", ftos(vote_nocount));
        drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
 
        // draw the progress bar backgrounds