diff --git a/addons/arsenal/XEH_PREP.hpp b/addons/arsenal/XEH_PREP.hpp index 76c77c8a7c..7596b769d8 100644 --- a/addons/arsenal/XEH_PREP.hpp +++ b/addons/arsenal/XEH_PREP.hpp @@ -14,6 +14,7 @@ PREP(clearSearchbar); PREP(fillLeftPanel); PREP(fillLoadoutsList); PREP(fillRightPanel); +PREP(handleLoadoutsSearchbar); PREP(handleMouse); PREP(handleScrollWheel); PREP(handleSearchbar); diff --git a/addons/arsenal/XEH_postInit.sqf b/addons/arsenal/XEH_postInit.sqf index e18afc6cc0..dcc5c7c7b5 100644 --- a/addons/arsenal/XEH_postInit.sqf +++ b/addons/arsenal/XEH_postInit.sqf @@ -4,6 +4,7 @@ GVAR(EH_ID) = 0; GVAR(lastSearchTextLeft) = ""; GVAR(lastSearchTextRight) = ""; +GVAR(lastSearchTextLoadouts) = ""; [QGVAR(initBox), {_this call FUNC(initBox)}] call CBA_fnc_addEventHandler; [QGVAR(removeBox), {_this call FUNC(removeBox)}] call CBA_fnc_addEventHandler; diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index 60b99a99f6..5cc25796bd 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -107,6 +107,7 @@ #define IDC_buttonShare 306 #define IDC_buttonDelete 307 #define IDC_buttonRename 308 +#define IDC_loadoutsSearchbar 309 #define IDC_buttonMyLoadoutsBackground 401 #define IDC_buttonMyLoadouts 402 #define IDC_buttonDefaultLoadoutsBackground 403 diff --git a/addons/arsenal/functions/fnc_handleLoadoutsSearchbar.sqf b/addons/arsenal/functions/fnc_handleLoadoutsSearchbar.sqf new file mode 100644 index 0000000000..07a42c4fd5 --- /dev/null +++ b/addons/arsenal/functions/fnc_handleLoadoutsSearchbar.sqf @@ -0,0 +1,45 @@ +/* + * Author: Alganthe + * Handles keyboard inputs inside the searchbars text boxes. + * + * Arguments: + * 0: Loadouts display + * 1: Searchbar control + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" +#include "..\defines.hpp" + +params ["_display", "_control"]; + +private _textString = ctrlText _control; + +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; + +if !(GVAR(lastSearchTextLoadouts) isEqualTo "" || {(_textString find GVAR(lastSearchTextLoadouts)) == 0}) then {//don't refill if there is no need + [_display, _display displayCtrl GVAR(currentLoadoutsTab)] call FUNC(fillLoadoutsList); +}; + +GVAR(lastSearchTextLoadouts) = _textString; +if (count _textString == 0) exitWith {}; + +private _contentPanelCtrl = _display displayCtrl IDC_contentPanel; + +private _itemsToGo = (lnbSize _contentPanelCtrl) select 0; +private _lbIndex = 0; +while {_itemsToGo > 0} do { + private _currentData = _contentPanelCtrl lnbText [_lbIndex, 1]; + private _currentClassname = _contentPanelCtrl lnbData [_lbIndex, 0]; + + if ((_currentData isEqualTo "") || {(((toUpper _currentData) find (toUpper _textString)) == -1) && {((toUpper _currentClassname) find (toUpper _textString)) == -1}}) then { + _contentPanelCtrl lnbDeleteRow _lbIndex; + } else { + _lbIndex = _lbIndex + 1; + }; + _itemsToGo = _itemsToGo - 1; +}; +_contentPanelCtrl lnbSetCurSelRow -1; diff --git a/addons/arsenal/functions/fnc_onKeyDown.sqf b/addons/arsenal/functions/fnc_onKeyDown.sqf index 6b1916e694..b963974033 100644 --- a/addons/arsenal/functions/fnc_onKeyDown.sqf +++ b/addons/arsenal/functions/fnc_onKeyDown.sqf @@ -21,83 +21,41 @@ params ["", "_args"]; _args params ["_display", "_keyPressed", "_shiftState", "_ctrlState", "_altState"]; -if !((findDisplay IDD_loadouts_display) isEqualTo displayNull) exitWith {}; - GVAR(shiftState) = _shiftState; - private _return = true; +private _loadoutsDisplay = findDisplay IDD_loadouts_display; -if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then { - - switch true do { - // Close button - case (_keyPressed == DIK_ESCAPE): { - _display closeDisplay 2; - }; - // Hide button - case (_keyPressed == DIK_BACKSPACE): { - [_display] call FUNC(buttonHide); - }; - // Export button - case (_keyPressed == DIK_C && {_ctrlState}): { - [_display] call FUNC(buttonExport); - }; - // Import button - case (_keyPressed == DIK_V && {_ctrlState}): { - [_display] call FUNC(buttonImport); - }; - // Search fields - case (_keyPressed == DIK_F && {_ctrlState}): { - ctrlSetFocus (_display displayCtrl IDC_leftSearchbar); - }; - // Switch vision mode - case (_keyPressed in (actionkeys "nightvision")): { - if (isNil QGVAR(visionMode)) then { - GVAR(visionMode) = 0; +if !(_loadoutsDisplay isEqualTo displayNull) then { + if !(GVAR(loadoutsSearchbarFocus)) then { + switch true do { + // Close button + case (_keyPressed == DIK_ESCAPE): { + _display closeDisplay 2; }; - GVAR(visionMode) = (GVAR(visionMode) + 1) % 3; - - switch GVAR(visionMode) do { - //--- Normal - case 0: { - camusenvg false; - false setCamUseTi 0; - }; - //--- NVG - case 1: { - camusenvg true; - false setCamUseTi 0; - }; - //--- TI - default { - camusenvg false; - true setCamUseTi 0; - }; + // Search field + case (_keyPressed == DIK_F && {_ctrlState}): { + ctrlSetFocus (_loadoutsDisplay displayCtrl IDC_loadoutsSearchbar); + }; + }; + } else { + switch true do { + case (_keyPressed == DIK_ESCAPE): { + _display closeDisplay 2; + }; + case (_keyPressed == DIK_BACKSPACE): { + _return = false; + }; + case (_keyPressed == DIK_NUMPADENTER); + case (_keyPressed == DIK_RETURN): { + [_loadoutsDisplay, _loadoutsDisplay displayCtrl IDC_loadoutsSearchbar] call FUNC(handleLoadoutsSearchBar); + }; + case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): { + _return = false; }; - - playsound ["RscDisplayCurator_visionMode",true]; }; }; -} else { + switch true do { - case (_keyPressed == DIK_ESCAPE): { - _display closeDisplay 2; - }; - case (_keyPressed == DIK_BACKSPACE): { - _return = false; - }; - case (_keyPressed == DIK_NUMPADENTER); - case (_keyPressed == DIK_RETURN): { - if (GVAR(leftSearchbarFocus)) then { - [_display, _display displayCtrl IDC_leftSearchbar] call FUNC(handleSearchBar); - }; - if (GVAR(rightSearchbarFocus)) then { - [_display, _display displayCtrl IDC_rightSearchbar] call FUNC(handleSearchBar); - }; - }; - case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): { - _return = false; - }; case (_keyPressed == DIK_C && {_ctrlState}): { _return = false; }; @@ -110,31 +68,121 @@ if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then { case (_keyPressed == DIK_X && {_ctrlState}): { _return = false; }; - // Search fields - case (_keyPressed == DIK_F && {_ctrlState}): { - if (GVAR(rightSearchbarFocus)) then { + case (GVAR(loadoutsPanelFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}): { + _return = false; + }; + }; +} else { + + if (!GVAR(leftSearchbarFocus) && {!GVAR(rightSearchbarFocus)}) then { + + switch true do { + // Close button + case (_keyPressed == DIK_ESCAPE): { + _display closeDisplay 2; + }; + // Hide button + case (_keyPressed == DIK_BACKSPACE): { + [_display] call FUNC(buttonHide); + }; + // Export button + case (_keyPressed == DIK_C && {_ctrlState}): { + [_display] call FUNC(buttonExport); + }; + // Import button + case (_keyPressed == DIK_V && {_ctrlState}): { + [_display] call FUNC(buttonImport); + }; + // Search fields + case (_keyPressed == DIK_F && {_ctrlState}): { ctrlSetFocus (_display displayCtrl IDC_leftSearchbar); - } else { - ctrlSetFocus (_display displayCtrl IDC_rightSearchbar); + }; + // Switch vision mode + case (_keyPressed in (actionkeys "nightvision")): { + if (isNil QGVAR(visionMode)) then { + GVAR(visionMode) = 0; + }; + GVAR(visionMode) = (GVAR(visionMode) + 1) % 3; + + switch GVAR(visionMode) do { + //--- Normal + case 0: { + camusenvg false; + false setCamUseTi 0; + }; + //--- NVG + case 1: { + camusenvg true; + false setCamUseTi 0; + }; + //--- TI + default { + camusenvg false; + true setCamUseTi 0; + }; + }; + + playsound ["RscDisplayCurator_visionMode",true]; + }; + }; + } else { + switch true do { + case (_keyPressed == DIK_ESCAPE): { + _display closeDisplay 2; + }; + case (_keyPressed == DIK_BACKSPACE): { + _return = false; + }; + case (_keyPressed == DIK_NUMPADENTER); + case (_keyPressed == DIK_RETURN): { + if (GVAR(leftSearchbarFocus)) then { + [_display, _display displayCtrl IDC_leftSearchbar] call FUNC(handleSearchBar); + }; + if (GVAR(rightSearchbarFocus)) then { + [_display, _display displayCtrl IDC_rightSearchbar] call FUNC(handleSearchBar); + }; + }; + case (_keyPressed in [DIK_LEFT, DIK_RIGHT]): { + _return = false; + }; + case (_keyPressed == DIK_C && {_ctrlState}): { + _return = false; + }; + case (_keyPressed == DIK_V && {_ctrlState}): { + _return = false; + }; + case (_keyPressed == DIK_A && {_ctrlState}): { + _return = false; + }; + case (_keyPressed == DIK_X && {_ctrlState}): { + _return = false; + }; + // Search fields + case (_keyPressed == DIK_F && {_ctrlState}): { + if (GVAR(rightSearchbarFocus)) then { + ctrlSetFocus (_display displayCtrl IDC_leftSearchbar); + } else { + ctrlSetFocus (_display displayCtrl IDC_rightSearchbar); + }; }; }; }; -}; -if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { - _return = false; -}; + if (GVAR(leftTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { + _return = false; + }; -if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { - _return = false; -}; + if (GVAR(rightTabFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { + _return = false; + }; -if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { - _return = false; -}; + if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_UP, DIK_DOWN]}) then { + _return = false; + }; -if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then { - [_display, [1, 0] select (_keyPressed == DIK_LEFT)] call FUNC(buttonCargo); + if (GVAR(rightTabLnBFocus) && {_keyPressed in [DIK_LEFT, DIK_RIGHT]}) then { + [_display, [1, 0] select (_keyPressed == DIK_LEFT)] call FUNC(buttonCargo); + }; }; _return diff --git a/addons/arsenal/functions/fnc_onLoadoutsClose.sqf b/addons/arsenal/functions/fnc_onLoadoutsClose.sqf index 8318b4d409..777af3aed1 100644 --- a/addons/arsenal/functions/fnc_onLoadoutsClose.sqf +++ b/addons/arsenal/functions/fnc_onLoadoutsClose.sqf @@ -20,6 +20,8 @@ private _mouseBlockCtrl = _arsenalDisplay displayCtrl IDC_mouseBlock; GVAR(cameraPosition) = GVAR(previousCameraPos); GVAR(previousCameraPos) = nil; +GVAR(loadoutsSearchbarFocus) = nil; +GVAR(loadoutsPanelFocus) = nil; _mouseBlockCtrl ctrlEnable false; _mouseBlockCtrl ctrlCommit 0; diff --git a/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf b/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf index 6d6dd4bb76..ec025b0bc1 100644 --- a/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf +++ b/addons/arsenal/functions/fnc_onLoadoutsOpen.sqf @@ -27,6 +27,8 @@ _mouseBlockCtrl ctrlCommit 0; [_arsenalDisplay] call FUNC(buttonHide); GVAR(currentLoadoutsTab) = -1; +GVAR(loadoutsSearchbarFocus) = false; +GVAR(loadoutsPanelFocus) = false; GVAR(previousCameraPos) = GVAR(cameraPosition); GVAR(cameraPosition) = [5,0,20,[-0.85,0,0.85]]; diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index 44fab0515e..33564b7010 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -775,6 +775,8 @@ class GVAR(loadoutsDisplay) { columns[]={0, 0.05, 0.40, 0.50, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90}; drawSideArrows=0; disableOverflow=1; + onSetFocus = QUOTE(GVAR(loadoutsPanelFocus) = true); + onKillFocus = QUOTE(GVAR(loadoutsPanelFocus) = false); onLBSelChanged = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(onSelChangedLoadouts)); onLBDblClick = QUOTE([ARR_2(ctrlparent (_this select 0), (ctrlParent (_this select 0)) displayCtrl IDC_buttonLoad)] call FUNC(buttonLoadoutsLoad)); x = QUOTE(0); @@ -786,7 +788,7 @@ class GVAR(loadoutsDisplay) { class textTitle: RscText { idc= -1; text="$STR_DISP_GAME_NAME"; - x = QUOTE(1 * GRID_W); + x = QUOTE(0 * GRID_W); y = QUOTE(safezoneH - (51 * GRID_H)); w = QUOTE(15 * GRID_W); h = QUOTE(5 * GRID_H); @@ -795,9 +797,29 @@ class GVAR(loadoutsDisplay) { }; class textEditBox: ctrlEdit { idc= IDC_textEditBox; - x = QUOTE(16 * GRID_W); + x = QUOTE(15 * GRID_W); y = QUOTE(safezoneH - (51 * GRID_H)); - w = QUOTE(80 * GRID_W); + w = QUOTE(65 * GRID_W); + h = QUOTE(5 * GRID_H); + }; + class loadoutsSearchbar: ctrlEdit { + idc = IDC_loadoutsSearchbar; + onSetFocus = QUOTE(GVAR(loadoutsSearchbarFocus) = true); + onKillFocus = QUOTE(GVAR(loadoutsSearchbarFocus) = false); + onMouseButtonClick = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(clearSearchbar)); + x = QUOTE(83 * GRID_W); + y = QUOTE(safezoneH - (51 * GRID_H)); + w = QUOTE(72 * GRID_W); + h = QUOTE(5 * GRID_H); + }; + class loadoutsSearchbarButton: ctrlButtonPicture { + idc = -1; + text = "\a3\Ui_f\data\GUI\RscCommon\RscButtonSearch\search_start_ca.paa"; + colorBackground[]={0,0,0,0.5}; + onButtonClick = QUOTE([ARR_2(ctrlparent (_this select 0), ctrlparent (_this select 0) displayCtrl IDC_loadoutsSearchbar)] call FUNC(handleLoadoutsSearchbar)); + x = QUOTE(155 * GRID_W); + y = QUOTE(safezoneH - (51 * GRID_H)); + w = QUOTE(5 * GRID_W); h = QUOTE(5 * GRID_H); }; class buttonSave: ctrlButton {