Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arsenal - Add option to show live search results #9354

Merged
merged 8 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/arsenal/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ PREP(handleLoadoutsSearchbar);
PREP(handleMouse);
PREP(handleScrollWheel);
PREP(handleSearchbar);
PREP(handleSearchInputChanged);
PREP(handleSearchModeToggle);
PREP(handleStats);
PREP(initBox);
PREP(itemInfo);
Expand Down
2 changes: 1 addition & 1 deletion addons/arsenal/functions/fnc_fillRightPanel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Tab control <CONTROL>
* 2: Animate panel refresh <BOOL>
* 2: Animate panel refresh <BOOL> (default: true)
*
* Return Value:
* None
Expand Down
28 changes: 28 additions & 0 deletions addons/arsenal/functions/fnc_handleSearchInputChanged.sqf
Original file line number Diff line number Diff line change
@@ -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) <CONTROL>
* 1: Text <STRING>
*
* 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);
};
30 changes: 30 additions & 0 deletions addons/arsenal/functions/fnc_handleSearchModeToggle.sqf
Original file line number Diff line number Diff line change
@@ -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) <CONTROL>
* 1: Mouse Button <NUMBER>
* 2: Not used
* 3: Not used
* 4: Not used
* 5: Ctrl Button <BOOL>
*
* 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;
7 changes: 4 additions & 3 deletions addons/arsenal/functions/fnc_handleSearchbar.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Searchbar control <CONTROL>
* 2: Animate panel refresh <BOOL> (default: true)
*
* Return Value:
* None
*
* 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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions addons/arsenal/functions/fnc_onArsenalClose.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions addons/arsenal/functions/fnc_onArsenalOpen.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions addons/arsenal/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1644,5 +1644,8 @@
<Korean>모든 아이템을 표시하거나 즐겨찾기를 표시할 때 전환합니다\nShift 키를 누른 상태에서 두 번 클릭하여 아이템을 추가하거나 제거합니다.</Korean>
<French>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.</French>
</Key>
<Key ID="STR_ACE_Arsenal_buttonSearchTooltip">
<English>Search\nCTRL + Click to enable live results</English>
</Key>
</Package>
</Project>
3 changes: 3 additions & 0 deletions addons/arsenal/ui/RscAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down