From: terencehill Date: Sun, 27 Dec 2020 22:38:31 +0000 (+0100) Subject: Reduce indentation of a code block in HUD_Minigame_InputEvent X-Git-Tag: xonotic-v0.8.5~597^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9628167de6b1e17b14cd6f1217439fb615d28525;p=xonotic%2Fxonotic-data.pk3dir.git Reduce indentation of a code block in HUD_Minigame_InputEvent --- diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 5cc1defd1..ee7e63414 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -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,99 @@ 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; + } + 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 + 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(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); - } + if(nPrimary == stof(argv(i))) + return false; + } - // 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 ( active_minigame && ( bInputType == 0 || bInputType == 1 ) ) + { + string device = ""; + string action = bInputType == 0 ? "pressed" : "released"; + if ( nPrimary >= K_MOUSE1 && nPrimary <= K_MOUSE16 ) { - if(nPrimary == stof(argv(i))) - return false; + if ( HUD_mouse_over(HUD_PANEL(MINIGAMEBOARD)) ) + device = "mouse"; } + else + device = "key"; - 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"; + if ( device && active_minigame.minigame_event( + active_minigame,strcat(device,"_",action),nPrimary) ) + return true; - if ( device && active_minigame.minigame_event( - active_minigame,strcat(device,"_",action),nPrimary) ) - return true; + /// TODO: bInputType == 2? + } - /// TODO: bInputType == 2? + if ( bInputType == 0 ) + { + if ( nPrimary == K_MOUSE1 && HUD_MinigameMenu_activeitem && + HUD_mouse_over(HUD_PANEL(MINIGAMEMENU)) ) + { + HUD_MinigameMenu_Click(HUD_MinigameMenu_activeitem); + return true; } - - if ( bInputType == 0 ) + if ( nPrimary == K_UPARROW || nPrimary == K_KP_UPARROW ) { - 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 ) - { + 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_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; - } + 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; } } return false; - } void HUD_Minigame_Mouse()