]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/csqc_input_stuff' into 'master'
authorMario <mario.mario@y7mail.com>
Tue, 19 Jan 2021 10:21:47 +0000 (10:21 +0000)
committerMario <mario.mario@y7mail.com>
Tue, 19 Jan 2021 10:21:47 +0000 (10:21 +0000)
csqc input stuff

Closes #2496

See merge request xonotic/xonotic-data.pk3dir!872

12 files changed:
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/quickmenu.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/mapvoting.qc
qcsrc/common/minigames/cl_minigames_hud.qc
qcsrc/common/minigames/minigame/bd.qc
qcsrc/common/minigames/minigame/c4.qc
qcsrc/common/minigames/minigame/nmm.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/minigames/minigame/pp.qc
qcsrc/common/minigames/minigame/ps.qc
qcsrc/common/minigames/minigame/ttt.qc

index 36c4c9b6944fd7ab16297d4f3b87db96dccd5289..2c05285e282a13a3dbfdc582b57d0adbe709442d 100644 (file)
@@ -512,9 +512,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
        string s;
 
-       if(bInputType == 2)
-               return false;
-
        if(!autocvar__hud_configure)
                return false;
 
@@ -525,6 +522,12 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                return true;
        }
 
+       if(bInputType == 2)
+               return false;
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
        // block any input while a menu dialog is fading
        // don't block mousepos read as it leads to cursor jumps in the interaction with the menu
        if(autocvar__menu_alpha)
@@ -546,12 +549,12 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                        hit_con_bind = true;
        }
 
-       if(bInputType == 0) {
+       if(key_pressed) {
                if(nPrimary == K_ALT) hudShiftState |= S_ALT;
                if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
                if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
        }
-       else if(bInputType == 1) {
+       else {
                if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
                if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
                if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
@@ -559,7 +562,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
        if(nPrimary == K_CTRL)
        {
-               if (bInputType == 1) //ctrl has been released
+               if (!key_pressed) //ctrl has been released
                {
                        if (tab_panel)
                        {
@@ -575,35 +578,35 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
        if(nPrimary == K_MOUSE1)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE1;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE1);
        }
        else if(nPrimary == K_MOUSE2)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE2;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE2);
        }
        else if(nPrimary == K_ESCAPE)
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                        return true;
                hud_configure_menu_open = 1;
                localcmd("menu_showhudexit\n");
        }
        else if(nPrimary == K_BACKSPACE && hudShiftState & S_CTRL)
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                        return true;
                if (!hud_configure_menu_open)
                        HUD_Configure_Exit_Force();
        }
        else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // switch panel
        {
-               if (bInputType == 1 || mouseClicked)
+               if (!key_pressed || mouseClicked)
                        return true;
 
                // FIXME minor bug: if a panel is highlighted, has the same pos_x and
@@ -692,7 +695,7 @@ LABEL(find_tab_panel)
        }
        else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
        {
-               if (bInputType == 1 || mouseClicked)
+               if (!key_pressed || mouseClicked)
                        return true;
 
                if (highlightedPanel)
@@ -705,7 +708,7 @@ LABEL(find_tab_panel)
        }
        else if(nPrimary == 'c' && hudShiftState & S_CTRL) // copy highlighted panel size
        {
-               if (bInputType == 1 || mouseClicked)
+               if (!key_pressed || mouseClicked)
                        return true;
 
                if (highlightedPanel)
@@ -717,7 +720,7 @@ LABEL(find_tab_panel)
        }
        else if(nPrimary == 'v' && hudShiftState & S_CTRL) // past copied size on the highlighted panel
        {
-               if (bInputType == 1 || mouseClicked)
+               if (!key_pressed || mouseClicked)
                        return true;
 
                if (panel_size_copied == '0 0 0' || !highlightedPanel)
@@ -746,7 +749,7 @@ LABEL(find_tab_panel)
        }
        else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
        {
-               if (bInputType == 1 || mouseClicked)
+               if (!key_pressed || mouseClicked)
                        return true;
                //restore previous values
                if (highlightedPanel_backup)
@@ -760,13 +763,13 @@ LABEL(find_tab_panel)
        }
        else if(nPrimary == 's' && hudShiftState & S_CTRL) // save config
        {
-               if (bInputType == 1 || mouseClicked)
+               if (!key_pressed || mouseClicked)
                        return true;
                localcmd("hud save myconfig\n");
        }
        else if(nPrimary == K_UPARROW || nPrimary == K_DOWNARROW || nPrimary == K_LEFTARROW || nPrimary == K_RIGHTARROW)
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                {
                        pressed_key_time = 0;
                        return true;
index f9568de1031ed9cdfee28172007353b9b5982e72..e9e7fe831e0e92e1f68078cc6774b50e9f6d89f6 100644 (file)
@@ -424,9 +424,6 @@ void QuickMenu_Page_ActiveEntry(int entry_num)
 bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
 {
        TC(int, bInputType);
-       // we only care for keyboard events
-       if(bInputType == 2)
-               return false;
 
        if(!QuickMenu_IsOpened() || autocvar__hud_configure || mv_active)
                return false;
@@ -438,6 +435,12 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
                return true;
        }
 
+       if(bInputType == 2)
+               return false;
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
        // allow console bind to work
        string con_keys = findkeysforcommand("toggleconsole", 0);
        int keys = tokenize(con_keys); // findkeysforcommand returns data for this
@@ -449,12 +452,14 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
                        hit_con_bind = true;
        }
 
-       if(bInputType == 0) {
+       if(key_pressed)
+       {
                if(nPrimary == K_ALT) hudShiftState |= S_ALT;
                if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
                if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
        }
-       else if(bInputType == 1) {
+       else
+       {
                if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
                if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
                if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
@@ -462,28 +467,28 @@ bool QuickMenu_InputEvent(int bInputType, float nPrimary, float nSecondary)
 
        if(nPrimary == K_ESCAPE)
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                        return true;
                QuickMenu_Close();
        }
        else if(nPrimary >= '0' && nPrimary <= '9')
        {
-               if (bInputType == 1)
+               if (!key_pressed)
                        return true;
                QuickMenu_Page_ActiveEntry(stof(chr2str(nPrimary)));
        }
        if(nPrimary == K_MOUSE1)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE1;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE1);
        }
        else if(nPrimary == K_MOUSE2)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE2;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE2);
        }
        else if(hit_con_bind)
index f73d5fa239c4b3ff972a61456c91c1ad6368e390..f4bae2024cca45fc9b95fe7b14c8ae09fd127408 100644 (file)
@@ -62,8 +62,7 @@ void HUD_Radar_Hide_Maximized()
 float HUD_Radar_InputEvent(int bInputType, float nPrimary, float nSecondary)
 {
        TC(int, bInputType);
-       if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
-               autocvar__hud_configure || mv_active)
+       if(!hud_panel_radar_maximized || !hud_panel_radar_mouse || autocvar__hud_configure || mv_active)
                return false;
 
        if(bInputType == 3)
@@ -73,21 +72,27 @@ float HUD_Radar_InputEvent(int bInputType, float nPrimary, float nSecondary)
                return true;
        }
 
+       if (bInputType == 2)
+               return false;
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
        if(nPrimary == K_MOUSE1)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE1;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE1);
        }
        else if(nPrimary == K_MOUSE2)
        {
-               if(bInputType == 0) // key pressed
+               if(key_pressed)
                        mouseClicked |= S_MOUSE2;
-               else if(bInputType == 1) // key released
+               else
                        mouseClicked -= (mouseClicked & S_MOUSE2);
        }
-       else if ( nPrimary == K_ESCAPE && bInputType == 0 )
+       else if (nPrimary == K_ESCAPE && key_pressed)
        {
                HUD_Radar_Hide_Maximized();
        }
@@ -106,21 +111,18 @@ float HUD_Radar_InputEvent(int bInputType, float nPrimary, float nSecondary)
                if ( STAT(HEALTH) <= 0 )
                {
                        // Show scoreboard
-                       if ( bInputType < 2 )
+                       con_keys = findkeysforcommand("+showscores", 0);
+                       keys = tokenize(con_keys);
+                       for (i = 0; i < keys; ++i)
                        {
-                               con_keys = findkeysforcommand("+showscores", 0);
-                               keys = tokenize(con_keys);
-                               for (i = 0; i < keys; ++i)
+                               if ( nPrimary == stof(argv(i)) )
                                {
-                                       if ( nPrimary == stof(argv(i)) )
-                                       {
-                                               hud_panel_radar_temp_hidden = bInputType == 0;
-                                               return false;
-                                       }
+                                       hud_panel_radar_temp_hidden = key_pressed;
+                                       return false;
                                }
                        }
                }
-               else if ( bInputType == 0 )
+               else if (key_pressed)
                        HUD_Radar_Hide_Maximized();
 
                return false;
index 40d8e0d0727cba6d900ad907010e2116c269e412..2a6f39f8a5ff50dcbe63c7fdc628328bcc1eb449 100644 (file)
@@ -339,7 +339,6 @@ float MapVote_Selection(vector topleft, vector cellsize, float rows, float colum
        return mv_mouse_selection;
 }
 
-vector prev_mousepos;
 // draws map vote or gametype vote
 void MapVote_Draw()
 {
@@ -357,15 +356,6 @@ void MapVote_Draw()
 
        HUD_Panel_LoadCvars();
 
-       if (!autocvar_hud_cursormode)
-       {
-               if (mousepos.x != prev_mousepos.x || mousepos.y != prev_mousepos.y)
-               {
-                       mv_selection_keyboard = 0;
-                       prev_mousepos = mousepos;
-               }
-       }
-
        center = (vid_conwidth - 1)/2;
        xmin = vid_conwidth * 0.08;
        xmax = vid_conwidth - xmin;
@@ -819,13 +809,22 @@ float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
                return true;
        }
 
-       if (bInputType == 0)
+       if (bInputType == 2)
+       {
+               mv_selection_keyboard = 0;
+               return false;
+       }
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
+       if (key_pressed)
        {
                if (nPrimary == K_ALT) hudShiftState |= S_ALT;
                if (nPrimary == K_CTRL) hudShiftState |= S_CTRL;
                if (nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
        }
-       else if (bInputType == 1)
+       else
        {
                if (nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
                if (nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
@@ -835,31 +834,33 @@ float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
                        first_digit = 0;
        }
 
-       if (bInputType != 0)
-               return false;
-
        int imp = 0;
        switch(nPrimary)
        {
                case K_RIGHTARROW:
+                       if (!key_pressed) return true;
                        mv_selection_keyboard = 1;
                        mv_selection = MapVote_MoveRight(mv_selection);
                        return true;
                case K_LEFTARROW:
+                       if (!key_pressed) return true;
                        mv_selection_keyboard = 1;
                        mv_selection = MapVote_MoveLeft(mv_selection);
                        return true;
                case K_DOWNARROW:
+                       if (!key_pressed) return true;
                        mv_selection_keyboard = 1;
                        mv_selection = MapVote_MoveDown(mv_selection);
                        return true;
                case K_UPARROW:
+                       if (!key_pressed) return true;
                        mv_selection_keyboard = 1;
                        mv_selection = MapVote_MoveUp(mv_selection);
                        return true;
                case K_KP_ENTER:
                case K_ENTER:
                case K_SPACE:
+                       if (!key_pressed) return true;
                        if ( mv_selection_keyboard )
                                MapVote_SendChoice(mv_selection);
                        return true;
@@ -879,6 +880,8 @@ float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
        {
                if (!first_digit)
                {
+                       if (!key_pressed)
+                               return true;
                        first_digit = imp % 10;
                        return true;
                }
@@ -888,14 +891,21 @@ float MapVote_InputEvent(int bInputType, float nPrimary, float nSecondary)
 
        if (nPrimary == K_MOUSE1)
        {
+               if (!key_pressed)
+                       return true;
                mv_selection_keyboard = 0;
                mv_selection = mv_mouse_selection;
                if (mv_selection >= 0)
                        imp = min(mv_selection + 1, mv_num_maps);
        }
 
+       if (nPrimary == K_MOUSE2)
+               return true; // do nothing
+
        if (imp)
        {
+               if (!key_pressed)
+                       return true;
                if (imp <= mv_num_maps)
                        localcmd(strcat("\nimpulse ", ftos(imp), "\n"));
                return true;
index 5cc1defd16d1d5388b1304ab4bfeadda44b19990..973ca428ab59b487c878a0f899220d4c028ba4d3 100644 (file)
@@ -138,7 +138,6 @@ void HUD_MinigameMenu_InsertEntry(entity newentry, entity prev)
        else
                HUD_MinigameMenu_last_entry = newentry;
        prev.list_next = newentry;
-
 }
 
 
@@ -618,103 +617,122 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary
                if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
                        active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
                return true;
-
        }
-       else
-       {
-               if(bInputType == 0) {
-                       if(nPrimary == K_ALT) hudShiftState |= S_ALT;
-                       if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
-                       if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
-                       if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
-                       if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
-               }
-               else if(bInputType == 1) {
-                       if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
-                       if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
-                       if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
-                       if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
-                       if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
-               }
 
-               // allow some binds
-               string con_keys = findkeysforcommand("toggleconsole", 0);
-               int keys = tokenize(con_keys); // findkeysforcommand returns data for this
-               int i;
-               for (i = 0; i < keys; ++i)
-               {
-                       if(nPrimary == stof(argv(i)))
-                               return false;
-               }
+       if(bInputType == 2)
+       {
+               if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
+                       active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos);
+               return false;
+       }
 
-               if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) )
-               {
-                       string device = "";
-                       string action = bInputType == 0 ? "pressed" : "released";
-                       if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
-                       {
-                               if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
-                                       device = "mouse";
-                       }
-                       else
-                               device = "key";
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
 
-                       if ( device && active_minigame.minigame_event(
-                                       active_minigame,strcat(device,"_",action),nPrimary) )
-                               return true;
+       if(key_pressed) {
+               if(nPrimary == K_ALT) hudShiftState |= S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+               if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1;
+               if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2;
+       }
+       else {
+               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
+               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
+               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+               if(nPrimary == K_MOUSE1) mouseClicked -= (mouseClicked & S_MOUSE1);
+               if(nPrimary == K_MOUSE2) mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
 
-                       /// TODO: bInputType == 2?
-               }
+       // allow some binds
+       string con_keys = findkeysforcommand("toggleconsole", 0);
+       int keys = tokenize(con_keys); // findkeysforcommand returns data for this
+       int i;
+       for (i = 0; i < keys; ++i)
+       {
+               if(nPrimary == stof(argv(i)))
+                       return false;
+       }
 
-               if ( bInputType == 0 )
+       if ( active_minigame )
+       {
+               string device = "";
+               string action = key_pressed ? "pressed" : "released";
+               if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 )
                {
-                       if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem &&
-                               HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) )
-                       {
-                               HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
-                               return true;
-                       }
-                       if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW )
-                       {
-                               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_prev )
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_prev;
-                               else
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_last_entry;
-                               return true;
-                       }
-                       else if ( nPrimary == K_DOWNARROW || nPrimary == K_KP_DOWNARROW )
-                       {
-                               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_next )
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_next;
-                               else
-                                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
-                               return true;
-                       }
-                       else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME )
-                       {
-                               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
-                               return true;
-                       }
-                       else if ( nPrimary == K_END || nPrimary == K_KP_END )
-                       {
-                               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
-                               return true;
-                       }
-                       else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE )
-                       {
-                               HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
-                               return true;
-                       }
-                       else if ( nPrimary == K_ESCAPE )
-                       {
-                               HUD_MinigameMenu_Close(NULL, NULL, NULL);
-                               return true;
-                       }
+                       if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) )
+                               device = "mouse";
                }
+               else
+                       device = "key";
+
+               if ( device && active_minigame.minigame_event(
+                               active_minigame,strcat(device,"_",action),nPrimary) )
+                       return true;
        }
 
-       return false;
+       if ( nPrimary == K_MOUSE2 )
+       {
+               return true;
+       }
+       if ( nPrimary == K_MOUSE1 )
+       {
+               if (!key_pressed)
+                       return true;
+               if (HUD_MinigameMenu_activeitem && HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)))
+                       HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
+               return true;
+       }
+       if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW )
+       {
+               if (!key_pressed)
+                       return true;
+               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_prev )
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_prev;
+               else
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_last_entry;
+               return true;
+       }
+       else if ( nPrimary == K_DOWNARROW || nPrimary == K_KP_DOWNARROW )
+       {
+               if (!key_pressed)
+                       return true;
+               if ( HUD_MinigameMenu_activeitem && HUD_MinigameMenu_activeitem.list_next )
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_activeitem.list_next;
+               else
+                       HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
+               return true;
+       }
+       else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
+               return true;
+       }
+       else if ( nPrimary == K_END || nPrimary == K_KP_END )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries;
+               return true;
+       }
+       else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem);
+               return true;
+       }
+       else if ( nPrimary == K_ESCAPE )
+       {
+               if (!key_pressed)
+                       return true;
+               HUD_MinigameMenu_Close(NULL, NULL, NULL);
+               return true;
+       }
 
+       return false;
 }
 
 void HUD_Minigame_Mouse()
index a7a123243dc2a193a4bee1d12a01ecc5936f3600..50054edb96b53d73f4693b8ee74e9351c6a43820 100644 (file)
@@ -1212,31 +1212,6 @@ void bd_set_curr_pos(string s)
        bd_curr_pos = s;
 }
 
-bool bd_normal_move(entity minigame, int themove)
-{
-       switch ( themove )
-       {
-               case K_RIGHTARROW:
-               case K_KP_RIGHTARROW:
-                       bd_make_move(minigame, "r");
-                       return true;
-               case K_LEFTARROW:
-               case K_KP_LEFTARROW:
-                       bd_make_move(minigame, "l");
-                       return true;
-               case K_UPARROW:
-               case K_KP_UPARROW:
-                       bd_make_move(minigame, "u");
-                       return true;
-               case K_DOWNARROW:
-               case K_KP_DOWNARROW:
-                       bd_make_move(minigame, "d");
-                       return true;
-       }
-
-       return false;
-}
-
 bool bd_change_dozer_angle(entity minigame)
 {
        entity dozer = bd_find_piece(minigame, bd_curr_pos, false);
@@ -1257,54 +1232,6 @@ bool bd_change_dozer_angle(entity minigame)
        return true;
 }
 
-bool bd_editor_move(entity minigame, int themove)
-{
-       switch ( themove )
-       {
-               case K_RIGHTARROW:
-               case K_KP_RIGHTARROW:
-                       if ( ! bd_curr_pos )
-                               bd_set_curr_pos("a3");
-                       else
-                               bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,1,0,BD_NUM_CNT,BD_LET_CNT));
-                       return true;
-               case K_LEFTARROW:
-               case K_KP_LEFTARROW:
-                       if ( ! bd_curr_pos )
-                               bd_set_curr_pos("c3");
-                       else
-                               bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,-1,0,BD_NUM_CNT,BD_LET_CNT));
-                       return true;
-               case K_UPARROW:
-               case K_KP_UPARROW:
-                       if ( ! bd_curr_pos )
-                               bd_set_curr_pos("a1");
-                       else
-                               bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,0,1,BD_NUM_CNT,BD_LET_CNT));
-                       return true;
-               case K_DOWNARROW:
-               case K_KP_DOWNARROW:
-                       if ( ! bd_curr_pos )
-                               bd_set_curr_pos("a3");
-                       else
-                               bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,0,-1,BD_NUM_CNT,BD_LET_CNT));
-                       return true;
-               case K_ENTER:
-               case K_KP_ENTER:
-                       bd_editor_make_move(minigame, "");
-                       return true;
-               case K_SPACE:
-                       if(bd_change_dozer_angle(minigame))
-                               return true;
-                       bd_curr_tile += 1;
-                       if(bd_curr_tile > BD_TILE_LAST)
-                               bd_curr_tile = 1;
-                       return true;
-       }
-
-       return false;
-}
-
 // Required function, handle client events
 int bd_client_event(entity minigame, string event, ...)
 {
@@ -1323,17 +1250,97 @@ int bd_client_event(entity minigame, string event, ...)
                        return false;
                }
                case "key_pressed":
+               case "key_released":
                {
-                       if(minigame.minigame_flags & BD_TURN_MOVE)
+                       bool event_blocked = ((event == "key_released")
+                               || !(minigame.minigame_flags & BD_TURN_MOVE));
+                       if (!(minigame.minigame_flags & BD_TURN_WIN) && !(minigame.minigame_flags & BD_TURN_LOSS))
                        {
-                               if(bd_normal_move(minigame, ...(0,int)))
-                                       return true;
+                               switch ( ...(0,int) )
+                               {
+                                       case K_RIGHTARROW:
+                                       case K_KP_RIGHTARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               bd_make_move(minigame, "r");
+                                               return true;
+                                       case K_LEFTARROW:
+                                       case K_KP_LEFTARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               bd_make_move(minigame, "l");
+                                               return true;
+                                       case K_UPARROW:
+                                       case K_KP_UPARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               bd_make_move(minigame, "u");
+                                               return true;
+                                       case K_DOWNARROW:
+                                       case K_KP_DOWNARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               bd_make_move(minigame, "d");
+                                               return true;
+                               }
                        }
 
                        if(minigame.minigame_flags & BD_TURN_EDIT)
                        {
-                               if(bd_editor_move(minigame, ...(0,int)))
-                                       return true;
+                               switch ( ...(0,int) )
+                               {
+                                       case K_RIGHTARROW:
+                                       case K_KP_RIGHTARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               if ( ! bd_curr_pos )
+                                                       bd_set_curr_pos("a3");
+                                               else
+                                                       bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,1,0,BD_NUM_CNT,BD_LET_CNT));
+                                               return true;
+                                       case K_LEFTARROW:
+                                       case K_KP_LEFTARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               if ( ! bd_curr_pos )
+                                                       bd_set_curr_pos("c3");
+                                               else
+                                                       bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,-1,0,BD_NUM_CNT,BD_LET_CNT));
+                                               return true;
+                                       case K_UPARROW:
+                                       case K_KP_UPARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               if ( ! bd_curr_pos )
+                                                       bd_set_curr_pos("a1");
+                                               else
+                                                       bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,0,1,BD_NUM_CNT,BD_LET_CNT));
+                                               return true;
+                                       case K_DOWNARROW:
+                                       case K_KP_DOWNARROW:
+                                               if (event_blocked)
+                                                       return true;
+                                               if ( ! bd_curr_pos )
+                                                       bd_set_curr_pos("a3");
+                                               else
+                                                       bd_set_curr_pos(minigame_relative_tile(bd_curr_pos,0,-1,BD_NUM_CNT,BD_LET_CNT));
+                                               return true;
+                                       case K_ENTER:
+                                       case K_KP_ENTER:
+                                               if (event_blocked)
+                                                       return true;
+                                               bd_editor_make_move(minigame, "");
+                                               return true;
+                                       case K_SPACE:
+                                               if (event_blocked)
+                                                       return true;
+                                               if(bd_change_dozer_angle(minigame))
+                                                       return true;
+                                               bd_curr_tile += 1;
+                                               if(bd_curr_tile > BD_TILE_LAST)
+                                                       bd_curr_tile = 1;
+                                               return true;
+                               }
                        }
 
                        return false;
@@ -1344,12 +1351,14 @@ int bd_client_event(entity minigame, string event, ...)
                        {
                                if(...(0,int) == K_MOUSE1)
                                {
+                                       bd_client_event(minigame, "mouse_moved");
                                        bd_editor_make_move(minigame, "");
                                        return true;
                                }
 
                                if(...(0,int) == K_MOUSE2)
                                {
+                                       bd_client_event(minigame, "mouse_moved");
                                        bd_editor_fill(minigame);
                                        return true;
                                }
index 5aeb7dfb2e4cf13f02de9b5b2e0c6796f78d343a..01adebea9f2a4509ec3c0d30ac38c9e4aaf3900f 100644 (file)
@@ -422,13 +422,18 @@ int c4_client_event(entity minigame, string event, ...)
                        return false;
                }
                case "key_pressed":
+               case "key_released":
                {
-                       if((minigame.minigame_flags & C4_TURN_TEAM) == minigame_self.team)
+                       bool event_blocked = ((event == "key_released")
+                               || ((minigame.minigame_flags & C4_TURN_TEAM) != minigame_self.team));
+                       if (!(minigame.minigame_flags & C4_TURN_WIN) && !(minigame.minigame_flags & C4_TURN_DRAW))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos(c4_get_lowest_tile(minigame, "a3"));
                                                else
@@ -436,13 +441,22 @@ int c4_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos(c4_get_lowest_tile(minigame, "c3"));
                                                else
                                                        c4_set_curr_pos(c4_get_lowest_tile(minigame, minigame_relative_tile(c4_curr_pos,-1,0,C4_NUM_CNT,C4_LET_CNT)));
                                                return true;
+                                       case K_UPARROW:
+                                       case K_KP_UPARROW:
+                                       case K_DOWNARROW:
+                                       case K_KP_DOWNARROW:
+                                               return true;
                                        /*case K_UPARROW:
                                        case K_KP_UPARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos("a1");
                                                else
@@ -450,6 +464,8 @@ int c4_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! c4_curr_pos )
                                                        c4_set_curr_pos("a3");
                                                else
@@ -458,6 +474,8 @@ int c4_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
+                                               if (event_blocked)
+                                                       return true;
                                                c4_make_move(minigame);
                                                return true;
                                }
@@ -469,6 +487,7 @@ int c4_client_event(entity minigame, string event, ...)
                {
                        if(...(0,int) == K_MOUSE1)
                        {
+                               c4_client_event(minigame, "mouse_moved");
                                c4_make_move(minigame);
                                return true;
                        }
index 5b0d39455da220b88d2f1055f9d48ce4a939a2ae..ab35deaf9656fa35842c4ca53acd1182df2cb16f 100644 (file)
@@ -632,80 +632,96 @@ int nmm_client_event(entity minigame, string event, ...)
                nmm_kill_tiles(minigame);
                strfree(minigame.message);
        }
-       else if ( event == "key_pressed" && (minigame.minigame_flags&NMM_TURN_TEAM) == minigame_self.team )
+       else if ( (event == "key_pressed" || event == "key_released") )
        {
-               switch ( ...(0,int) )
+               bool event_blocked = ((event == "key_released")
+                       || ((minigame.minigame_flags & NMM_TURN_TEAM) != minigame_self.team));
+               if (!(minigame.minigame_flags & NMM_TURN_WIN))
                {
-                       case K_RIGHTARROW:
-                       case K_KP_RIGHTARROW:
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"a7");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                       switch ( ...(0,int) )
+                       {
+                               case K_RIGHTARROW:
+                               case K_KP_RIGHTARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"a7");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,1,0,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,1,0,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_LEFTARROW:
-                       case K_KP_LEFTARROW:
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"g7");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                                       return 1;
+                               case K_LEFTARROW:
+                               case K_KP_LEFTARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"g7");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,-1,0,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,-1,0,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_UPARROW:
-                       case K_KP_UPARROW:
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"a1");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                                       return 1;
+                               case K_UPARROW:
+                               case K_KP_UPARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"a1");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,0,1,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,0,1,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_DOWNARROW:
-                       case K_KP_DOWNARROW:
-                               if ( ! nmm_currtile )
-                                       nmm_currtile = nmm_find_tile(active_minigame,"a7");
-                               else
-                               {
-                                       string tileid = nmm_currtile.netname;
-                                       nmm_currtile = NULL;
-                                       while ( !nmm_currtile )
+                                       return 1;
+                               case K_DOWNARROW:
+                               case K_KP_DOWNARROW:
+                                       if (event_blocked)
+                                               return true;
+                                       if ( ! nmm_currtile )
+                                               nmm_currtile = nmm_find_tile(active_minigame,"a7");
+                                       else
                                        {
-                                               tileid = minigame_relative_tile(tileid,0,-1,7,7);
-                                               nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               string tileid = nmm_currtile.netname;
+                                               nmm_currtile = NULL;
+                                               while ( !nmm_currtile )
+                                               {
+                                                       tileid = minigame_relative_tile(tileid,0,-1,7,7);
+                                                       nmm_currtile = nmm_find_tile(active_minigame,tileid);
+                                               }
                                        }
-                               }
-                               return 1;
-                       case K_ENTER:
-                       case K_KP_ENTER:
-                       case K_SPACE:
-                               nmm_make_move(minigame);
-                               return 1;
+                                       return 1;
+                               case K_ENTER:
+                               case K_KP_ENTER:
+                               case K_SPACE:
+                                       if (event_blocked)
+                                               return true;
+                                       nmm_make_move(minigame);
+                                       return 1;
+                       }
                }
                return 0;
        }
        else if ( event == "mouse_pressed" && ...(0,int) == K_MOUSE1 )
        {
+               nmm_client_event(minigame, "mouse_moved");
                nmm_make_move(minigame);
                return 1;
        }
index 6b9b0480451a12758fc05c836f0702947319cde6..30bdd80665ff739f8e97daa4f6c640db8efc233a 100644 (file)
@@ -620,42 +620,41 @@ int pong_client_event(entity minigame, string event, ...)
                        return false;
                }
                case "key_pressed":
-                       switch ( ...(0,int) )
-                       {
-                               case K_UPARROW:
-                               case K_KP_UPARROW:
-                               case K_LEFTARROW:
-                               case K_KP_LEFTARROW:
-                                       //minigame_cmd("+moved");
-                                       pong_keys_pressed |= PONG_KEY_DECREASE;
-                                       return true;
-                               case K_DOWNARROW:
-                               case K_KP_DOWNARROW:
-                               case K_RIGHTARROW:
-                               case K_KP_RIGHTARROW:
-                                       //minigame_cmd("+movei");
-                                       pong_keys_pressed |= PONG_KEY_INCREASE;
-                                       return true;
-                       }
-                       return false;
                case "key_released":
-                       switch ( ...(0,int) )
-                       {
-                               case K_UPARROW:
-                               case K_KP_UPARROW:
-                               case K_LEFTARROW:
-                               case K_KP_LEFTARROW:
-                                       //minigame_cmd("-moved");
-                                       pong_keys_pressed &= ~PONG_KEY_DECREASE;
-                                       return true;
-                               case K_DOWNARROW:
-                               case K_KP_DOWNARROW:
-                               case K_RIGHTARROW:
-                               case K_KP_RIGHTARROW:
-                                       //minigame_cmd("-movei");
-                                       pong_keys_pressed &= ~PONG_KEY_INCREASE;
-                                       return true;
-                       }
+                       if ((minigame.minigame_flags & PONG_STATUS_PLAY))
+                               switch ( ...(0,int) )
+                               {
+                                       case K_UPARROW:
+                                       case K_KP_UPARROW:
+                                       case K_LEFTARROW:
+                                       case K_KP_LEFTARROW:
+                                               if (event == "key_pressed")
+                                               {
+                                                       //minigame_cmd("+moved");
+                                                       pong_keys_pressed |= PONG_KEY_DECREASE;
+                                               }
+                                               else
+                                               {
+                                                       //minigame_cmd("-moved");
+                                                       pong_keys_pressed &= ~PONG_KEY_DECREASE;
+                                               }
+                                               return true;
+                                       case K_DOWNARROW:
+                                       case K_KP_DOWNARROW:
+                                       case K_RIGHTARROW:
+                                       case K_KP_RIGHTARROW:
+                                               if (event == "key_pressed")
+                                               {
+                                                       //minigame_cmd("+movei");
+                                                       pong_keys_pressed |= PONG_KEY_INCREASE;
+                                               }
+                                               else
+                                               {
+                                                       //minigame_cmd("-movei");
+                                                       pong_keys_pressed &= ~PONG_KEY_INCREASE;
+                                               }
+                                               return true;
+                               }
                        return false;
                case "network_receive":
                {
index 5a46aa91452f1ef37882514be28d20b52f48ae8e..4a445fa45c3a356f93d54e1367f84f1facd279cd 100644 (file)
@@ -495,13 +495,18 @@ int pp_client_event(entity minigame, string event, ...)
                        return false;
                }
                case "key_pressed":
+               case "key_released":
                {
-                       if((minigame.minigame_flags & PP_TURN_TEAM) == minigame_self.team)
+                       bool event_blocked = ((event == "key_released")
+                               || ((minigame.minigame_flags & PP_TURN_TEAM) != minigame_self.team));
+                       if (!(minigame.minigame_flags & PP_TURN_WIN) && !(minigame.minigame_flags & PP_TURN_DRAW))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("a3");
                                                else
@@ -509,6 +514,8 @@ int pp_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("c3");
                                                else
@@ -516,6 +523,8 @@ int pp_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("a1");
                                                else
@@ -523,6 +532,8 @@ int pp_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! pp_curr_pos )
                                                        pp_set_curr_pos("a3");
                                                else
@@ -531,6 +542,8 @@ int pp_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
+                                               if (event_blocked)
+                                                       return true;
                                                pp_make_move(minigame);
                                                return true;
                                }
@@ -542,6 +555,7 @@ int pp_client_event(entity minigame, string event, ...)
                {
                        if(...(0,int) == K_MOUSE1)
                        {
+                               pp_client_event(minigame, "mouse_moved");
                                pp_make_move(minigame);
                                return true;
                        }
index b9762464a88514949317f463567d9aed1a225fa0..c976819dc4dfe2afff2f4baf0cce03cb1ada5570 100644 (file)
@@ -541,13 +541,17 @@ int ps_client_event(entity minigame, string event, ...)
                        return false;
                }
                case "key_pressed":
+               case "key_released":
                {
-                       //if((minigame.minigame_flags & PS_TURN_TEAM) == minigame_self.team)
+                       bool event_blocked = (event == "key_released");
+                       if (!(minigame.minigame_flags & PS_TURN_WIN) && !(minigame.minigame_flags & PS_TURN_DRAW))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("a3");
                                                else
@@ -555,6 +559,8 @@ int ps_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("c3");
                                                else
@@ -562,6 +568,8 @@ int ps_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("a1");
                                                else
@@ -569,6 +577,8 @@ int ps_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ps_curr_pos )
                                                        ps_set_curr_pos("a3");
                                                else
@@ -577,6 +587,8 @@ int ps_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
+                                               if (event_blocked)
+                                                       return true;
                                                ps_make_move(minigame);
                                                return true;
                                }
@@ -588,6 +600,7 @@ int ps_client_event(entity minigame, string event, ...)
                {
                        if(...(0,int) == K_MOUSE1)
                        {
+                               ps_client_event(minigame, "mouse_moved");
                                ps_make_move(minigame);
                                return true;
                        }
index bb642a282aa6c9acb9634d96b7f8d17422c3c74f..530243dc3a870f1bc58e6255320813ca71b85a9e 100644 (file)
@@ -565,13 +565,18 @@ int ttt_client_event(entity minigame, string event, ...)
                        return false;
                }
                case "key_pressed":
+               case "key_released":
                {
-                       if((minigame.minigame_flags & TTT_TURN_TEAM) == minigame_self.team)
+                       bool event_blocked = ((event == "key_released")
+                               || ((minigame.minigame_flags & TTT_TURN_TEAM) != minigame_self.team));
+                       if (!(minigame.minigame_flags & TTT_TURN_WIN) && !(minigame.minigame_flags & TTT_TURN_DRAW))
                        {
                                switch ( ...(0,int) )
                                {
                                        case K_RIGHTARROW:
                                        case K_KP_RIGHTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("a3");
                                                else
@@ -579,6 +584,8 @@ int ttt_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_LEFTARROW:
                                        case K_KP_LEFTARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("c3");
                                                else
@@ -586,6 +593,8 @@ int ttt_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_UPARROW:
                                        case K_KP_UPARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("a1");
                                                else
@@ -593,6 +602,8 @@ int ttt_client_event(entity minigame, string event, ...)
                                                return true;
                                        case K_DOWNARROW:
                                        case K_KP_DOWNARROW:
+                                               if (event_blocked)
+                                                       return true;
                                                if ( ! ttt_curr_pos )
                                                        ttt_set_curr_pos("a3");
                                                else
@@ -601,6 +612,8 @@ int ttt_client_event(entity minigame, string event, ...)
                                        case K_ENTER:
                                        case K_KP_ENTER:
                                        case K_SPACE:
+                                               if (event_blocked)
+                                                       return true;
                                                ttt_make_move(minigame);
                                                return true;
                                }
@@ -612,6 +625,7 @@ int ttt_client_event(entity minigame, string event, ...)
                {
                        if(...(0,int) == K_MOUSE1)
                        {
+                               ttt_client_event(minigame, "mouse_moved");
                                ttt_make_move(minigame);
                                return true;
                        }