diff --git a/addons/arsenal/XEH_PREP.hpp b/addons/arsenal/XEH_PREP.hpp index 1a25968682..ca34487c97 100644 --- a/addons/arsenal/XEH_PREP.hpp +++ b/addons/arsenal/XEH_PREP.hpp @@ -45,6 +45,8 @@ PREP(handleLoadoutsSearchbar); PREP(handleMouse); PREP(handleScrollWheel); PREP(handleSearchbar); +PREP(handleSearchInputChanged); +PREP(handleSearchModeToggle); PREP(handleStats); PREP(initBox); PREP(itemInfo); diff --git a/addons/arsenal/functions/fnc_fillRightPanel.sqf b/addons/arsenal/functions/fnc_fillRightPanel.sqf index db56bd35f9..d01991f924 100644 --- a/addons/arsenal/functions/fnc_fillRightPanel.sqf +++ b/addons/arsenal/functions/fnc_fillRightPanel.sqf @@ -7,7 +7,7 @@ * Arguments: * 0: Arsenal display * 1: Tab control - * 2: Animate panel refresh + * 2: Animate panel refresh (default: true) * * Return Value: * None diff --git a/addons/arsenal/functions/fnc_handleSearchInputChanged.sqf b/addons/arsenal/functions/fnc_handleSearchInputChanged.sqf new file mode 100644 index 0000000000..2c7364c6ef --- /dev/null +++ b/addons/arsenal/functions/fnc_handleSearchInputChanged.sqf @@ -0,0 +1,28 @@ +#include "..\script_component.hpp" +#include "..\defines.hpp" +/* + * Author: PabstMirror + * Handles user input in the search text boxes + * + * Arguments: + * 0: Search text input (left or right) + * 1: Text + * + * Return Value: + * None + * + * Public: No +*/ + +params ["_ctrl", "_newText"]; + +if (!GVAR(liveUpdateSearch)) exitWith {}; + +private _display = ctrlParent _ctrl; + +if (GVAR(leftSearchbarFocus)) then { + [_display, _display displayCtrl IDC_leftSearchbar, false] call FUNC(handleSearchBar); +}; +if (GVAR(rightSearchbarFocus)) then { + [_display, _display displayCtrl IDC_rightSearchbar, false] call FUNC(handleSearchBar); +}; diff --git a/addons/arsenal/functions/fnc_handleSearchModeToggle.sqf b/addons/arsenal/functions/fnc_handleSearchModeToggle.sqf new file mode 100644 index 0000000000..b5c35b59a5 --- /dev/null +++ b/addons/arsenal/functions/fnc_handleSearchModeToggle.sqf @@ -0,0 +1,30 @@ +#include "..\script_component.hpp" +#include "..\defines.hpp" +/* + * Author: PabstMirror + * Handles mouse clicks on search button to toggle live results + * + * Arguments: + * 0: Search button (left or right) + * 1: Mouse Button + * 2: Not used + * 3: Not used + * 4: Not used + * 5: Ctrl Button + * + * Return Value: + * None + * + * Public: No +*/ + +params ["_ctrl", "_mouseButton", "", "", "", "_keyCtrl"]; + +if ((!_keyCtrl)) exitWith {}; // Ignore if not CTRL + Click + +GVAR(liveUpdateSearch) = !GVAR(liveUpdateSearch); + +private _display = ctrlParent _ctrl; +private _color = if (GVAR(liveUpdateSearch)) then { [0,1,0,0.5] } else { [0,0,0,0.5] }; +(_display displayCtrl IDC_leftSearchbarButton) ctrlSetBackgroundColor _color; +(_display displayCtrl IDC_rightSearchbarButton) ctrlSetBackgroundColor _color; diff --git a/addons/arsenal/functions/fnc_handleSearchbar.sqf b/addons/arsenal/functions/fnc_handleSearchbar.sqf index 77f681ce1b..592096b640 100644 --- a/addons/arsenal/functions/fnc_handleSearchbar.sqf +++ b/addons/arsenal/functions/fnc_handleSearchbar.sqf @@ -7,6 +7,7 @@ * Arguments: * 0: Arsenal display * 1: Searchbar control + * 2: Animate panel refresh (default: true) * * Return Value: * None @@ -14,7 +15,7 @@ * Public: No */ -params ["_display", "_control"]; +params ["_display", "_control", ["_animate", true]]; // Have to use toLower here and displayName to handle non-ANSI characters private _searchString = toLower ctrlText _control; @@ -28,7 +29,7 @@ if (_searchString != "") then { if ((ctrlIDC _control) == IDC_rightSearchbar) then { // Don't refill if there is no need if (GVAR(lastSearchTextRight) != "" && {(_searchString find GVAR(lastSearchTextRight)) != 0}) then { - [_display, _display displayCtrl GVAR(currentRightPanel)] call FUNC(fillRightPanel); + [_display, _display displayCtrl GVAR(currentRightPanel), _animate] call FUNC(fillRightPanel); }; GVAR(lastSearchTextRight) = _searchString; @@ -127,7 +128,7 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then { // Left panel search bar // Don't refill if there is no need if (GVAR(lastSearchTextLeft) != "" && {(_searchString find GVAR(lastSearchTextLeft)) != 0}) then { - [_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel); + [_display, _display displayCtrl GVAR(currentLeftPanel), _animate] call FUNC(fillLeftPanel); }; GVAR(lastSearchTextLeft) = _searchString; diff --git a/addons/arsenal/functions/fnc_onArsenalClose.sqf b/addons/arsenal/functions/fnc_onArsenalClose.sqf index d4ebc90792..2cac9fd0d9 100644 --- a/addons/arsenal/functions/fnc_onArsenalClose.sqf +++ b/addons/arsenal/functions/fnc_onArsenalClose.sqf @@ -104,6 +104,7 @@ GVAR(currentLeftPanel) = nil; GVAR(currentRightPanel) = nil; GVAR(leftSearchbarFocus) = nil; GVAR(rightSearchbarFocus) = nil; +GVAR(liveUpdateSearch) = nil; GVAR(shiftState) = nil; GVAR(leftTabFocus) = nil; GVAR(rightTabFocus) = nil; diff --git a/addons/arsenal/functions/fnc_onArsenalOpen.sqf b/addons/arsenal/functions/fnc_onArsenalOpen.sqf index e693e8206b..5e35500248 100644 --- a/addons/arsenal/functions/fnc_onArsenalOpen.sqf +++ b/addons/arsenal/functions/fnc_onArsenalOpen.sqf @@ -230,6 +230,7 @@ GVAR(currentLeftPanel) = nil; GVAR(currentRightPanel) = nil; GVAR(leftSearchbarFocus) = false; GVAR(rightSearchbarFocus) = false; +GVAR(liveUpdateSearch) = false; GVAR(leftTabFocus) = false; GVAR(rightTabFocus) = false; GVAR(rightTabLnBFocus) = false; diff --git a/addons/arsenal/stringtable.xml b/addons/arsenal/stringtable.xml index af880054af..64066d2554 100644 --- a/addons/arsenal/stringtable.xml +++ b/addons/arsenal/stringtable.xml @@ -1644,5 +1644,8 @@ 모든 아이템을 표시하거나 즐겨찾기를 표시할 때 전환합니다\nShift 키를 누른 상태에서 두 번 클릭하여 아이템을 추가하거나 제거합니다. Change entre l'affichage de tous les éléments ou de vos favoris.\nDouble-cliquez en maintenant la touche Maj enfoncée pour ajouter ou supprimer un élément. + + Search\nCTRL + Click to enable live results + diff --git a/addons/arsenal/ui/RscAttributes.hpp b/addons/arsenal/ui/RscAttributes.hpp index e1e6da5da8..23f26e2eb9 100644 --- a/addons/arsenal/ui/RscAttributes.hpp +++ b/addons/arsenal/ui/RscAttributes.hpp @@ -638,6 +638,7 @@ class GVAR(display) { onSetFocus = QUOTE(GVAR(leftSearchbarFocus) = true); onKillFocus = QUOTE(GVAR(leftSearchbarFocus) = false); onMouseButtonClick = QUOTE([ARR_3(ctrlParent (_this select 0), _this select 0, _this select 1)] call FUNC(clearSearchbar)); + onEditChanged = QUOTE(call FUNC(handleSearchInputChanged)); x = QUOTE(safezoneX + 13 * GRID_W); y = QUOTE(safezoneY + 1.8 * GRID_H); w = QUOTE(74 * GRID_W); @@ -647,8 +648,10 @@ class GVAR(display) { class leftSearchbarButton: ctrlButtonPicture { idc = IDC_leftSearchbarButton; text = "\a3\Ui_f\data\GUI\RscCommon\RscButtonSearch\search_start_ca.paa"; + tooltip = CSTRING(buttonSearchTooltip); colorBackground[] = {0,0,0,0.5}; onButtonClick = QUOTE([ARR_2(ctrlParent (_this select 0), ctrlParent (_this select 0) displayCtrl IDC_leftSearchbar)] call FUNC(handleSearchbar)); + onMouseButtonDown = QUOTE(call FUNC(handleSearchModeToggle)); x = QUOTE(safezoneX + 87 * GRID_W); y = QUOTE(safezoneY + 1.8 * GRID_H); w = QUOTE(6 * GRID_W);