From: terencehill Date: Sun, 20 Jun 2010 13:54:01 +0000 (+0200) Subject: Support for shift/ctrl/alt as keys modifiers in configuration mode X-Git-Tag: xonotic-v0.1.0preview~457^2~68 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=86513964ed27e97bea937969623400ed9a03a733;p=xonotic%2Fxonotic-data.pk3dir.git Support for shift/ctrl/alt as keys modifiers in configuration mode First use of it: ctrl+left button drag moves/resizes disabling collisions check Fixed an unnoticeable bug: the code of the ESC key was executed twice (when pressed and when released). --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 19932a3ec..17be3ee90 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -887,7 +887,7 @@ void HUD_Panel_SetPos(float id, vector pos) vector mySize; mySize = HUD_Panel_GetSize(id); - if(cvar("hud_configure_checkcollisions")) + if(hud_configure_checkcollisions) pos = HUD_Panel_CheckMove(id, pos, mySize); pos_x = bound(0, pos_x, vid_conwidth - mySize_x); @@ -1087,10 +1087,8 @@ void HUD_Panel_SetPosSize(float id) mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight; } - if(cvar("hud_configure_checkcollisions")) - { + if(hud_configure_checkcollisions) mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin); - } // minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then) mySize_x = max(0.025 * vid_conwidth, mySize_x); @@ -1112,7 +1110,6 @@ void HUD_Panel_SetPosSize(float id) } if(cvar("hud_configure_checkcollisions_debug")) - if(cvar("hud_configure_checkcollisions")) drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL); string s; @@ -1148,6 +1145,17 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) hit_con_bind = 1; } + if(bInputType == 0) { + 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) { + 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) { if(bInputType == 0) { // key pressed @@ -1161,6 +1169,8 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) } else if(nPrimary == K_ESCAPE) { + if (bInputType == 1) + return true; disable_menu_alphacheck = 1; menu_enabled = 1; menu_enabled_time = time; @@ -1273,6 +1283,8 @@ void HUD_Panel_Mouse() } } + hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions")); + if(cvar("hud_configure_checkcollisions_debug")) drawfill(panelPos, panelSize, '1 0 0', .3, DRAWFLAG_NORMAL); diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index 6768221a3..e6d73eb09 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -25,6 +25,12 @@ float hud_border_thickness; float hud_accuracy_border_thickness; float hud_configure; +float hud_configure_checkcollisions; + +float hudShiftState; +const float S_SHIFT = 1; +const float S_CTRL = 2; +const float S_ALT = 4; float disable_menu_alphacheck; // 0 = enable alpha check, 1 = disable for entire hud, 2 = disable for one panel float menu_fade_alpha;