X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fminigames%2Fcl_minigames_hud.qc;h=174bec63a91a309633b80a84f759707b5bf77ec1;hb=HEAD;hp=861e01be3dd3255aac47840e5b5fe165df5cf514;hpb=bda0a3b27c78be189fb47e7fcdd911c076df700e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 861e01be3..174bec63a 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -537,8 +537,7 @@ void HUD_MinigameMenu () if ( e.flags & 2 ) { - drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod, - panel_fg_alpha, DRAWFLAG_NORMAL); + drawfill(panel_pos, eX*panel_size_x + eY*itemh, e.colormod, panel_fg_alpha, DRAWFLAG_NORMAL); color = '0 0 0'; } @@ -555,7 +554,7 @@ void HUD_MinigameMenu () HUD_MinigameMenu_DrawEntry(panel_pos+offset,e.message,e.size,color); if ( e == HUD_MinigameMenu_activeitem ) - drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25, DRAWFLAG_ADDITIVE); + drawfill(panel_pos, eX*panel_size_x + eY*itemh,'1 1 1', 0.25 * panel_fg_alpha, DRAWFLAG_ADDITIVE); panel_pos_y += itemh; } @@ -626,14 +625,17 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary return false; } - if(bInputType == 0) { + // 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; if(nPrimary == K_MOUSE1) mouseClicked |= S_MOUSE1; if(nPrimary == K_MOUSE2) mouseClicked |= S_MOUSE2; } - 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); @@ -651,10 +653,10 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary return false; } - if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) ) + if ( active_minigame ) { string device = ""; - string action = bInputType == 0 ? "pressed" : "released"; + string action = key_pressed ? "pressed" : "released"; if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 ) { if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) ) @@ -668,50 +670,65 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary return true; } - if ( bInputType == 0 ) + if ( nPrimary == K_MOUSE2 ) { - if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem && - HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) ) - { - HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem); + return true; + } + if ( nPrimary == K_MOUSE1 ) + { + if (!key_pressed) 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; + 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; - } - 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; + 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; - } - else if ( nPrimary == K_HOME || nPrimary == K_KP_HOME ) - { + 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; - } - else if ( nPrimary == K_END || nPrimary == K_KP_END ) - { - HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries; + HUD_MinigameMenu_activeitem = HUD_MinigameMenu_entries; + return true; + } + else if ( nPrimary == K_END || nPrimary == K_KP_END ) + { + if (!key_pressed) return true; - } - else if ( nPrimary == K_KP_ENTER || nPrimary == K_ENTER || nPrimary == K_SPACE ) - { - HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem); + 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; - } - else if ( nPrimary == K_ESCAPE ) - { - HUD_MinigameMenu_Close(NULL, NULL, NULL); + 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;