Arsenal - Add option to show live search results (#9354)

* Arsenal - Add option to show live search results

* use onEditChanged

* Update fnc_onKeyDown.sqf

* Update fnc_onKeyDown.sqf

* update script_components

* skip animate on live search
This commit is contained in:
PabstMirror 2023-10-27 19:55:14 -05:00 committed by GitHub
parent f452d6633e
commit 3c8cff75d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 73 additions and 4 deletions

View File

@ -45,6 +45,8 @@ PREP(handleLoadoutsSearchbar);
PREP(handleMouse);
PREP(handleScrollWheel);
PREP(handleSearchbar);
PREP(handleSearchInputChanged);
PREP(handleSearchModeToggle);
PREP(handleStats);
PREP(initBox);
PREP(itemInfo);

View File

@ -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

View File

@ -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);
};

View File

@ -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;

View File

@ -7,6 +7,7 @@
* Arguments:
* 0: Arsenal display <DISPLAY>
* 1: Searchbar control <CONTROL>
* 2: Animate panel refresh <BOOL> (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;

View File

@ -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;

View File

@ -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;

View File

@ -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>

View File

@ -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);