mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Arsenal - Use regex matching for searchbars (multi-word searching) (#9348)
* use regex * remove extra brackets * add regex pattern, change refill condition * add missing quote * change pattern again * bleh, we'll just go with this * use pattern quote (thanks veteran) * remove comment * use escapeRegex function * add regex to 3DEN attribute
This commit is contained in:
parent
8b3b265d87
commit
8f24884f73
@ -19,13 +19,20 @@
|
||||
params ["_controlsGroup"];
|
||||
|
||||
private _category = lbCurSel (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_CATEGORY);
|
||||
private _filter = toLower ctrlText (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_SEARCHBAR);
|
||||
private _filter = ctrlText (_controlsGroup controlsGroupCtrl IDC_ATTRIBUTE_SEARCHBAR);
|
||||
private _configItems = uiNamespace getVariable QGVAR(configItems);
|
||||
private _magazineMiscItems = uiNamespace getVariable QGVAR(magazineMiscItems);
|
||||
private _attributeValue = uiNamespace getVariable [QGVAR(attributeValue), [[], 0]];
|
||||
_attributeValue params ["_attributeItems", "_attributeMode"];
|
||||
|
||||
TRACE_3("Populating list",_category,_filter,_attributeValue);
|
||||
if (_filter != "") then {
|
||||
_filter = _filter call EFUNC(common,escapeRegex);
|
||||
_filter = ".*?" + (_filter splitString " " joinString ".*?" + ".*?/io");
|
||||
} else {
|
||||
_filter = ".*?/io";
|
||||
};
|
||||
|
||||
|
||||
private _modeSymbol = [SYMBOL_ITEM_VIRTUAL, SYMBOL_ITEM_REMOVE] select _attributeMode;
|
||||
|
||||
@ -59,7 +66,7 @@ if (_category == IDX_CAT_ALL) exitWith {
|
||||
_displayName = getText (_config >> "displayName");
|
||||
|
||||
// Add item if not filtered
|
||||
if (_filter in (toLower _displayName) || {_filter in (toLower _x)}) then {
|
||||
if (_displayName regexMatch _filter || {_x regexMatch _filter}) then {
|
||||
_index = _listbox lnbAddRow ["", _displayName, _modeSymbol];
|
||||
_listbox lnbSetData [[_index, 1], _x];
|
||||
_listbox lnbSetPicture [[_index, 0], getText (_config >> "picture")];
|
||||
@ -111,7 +118,7 @@ private _config = _cfgClass;
|
||||
_displayName = getText (_config >> _x >> "displayName");
|
||||
|
||||
// Add item if not filtered
|
||||
if (_filter in (toLower _displayName) || {_filter in (toLower _x)}) then {
|
||||
if (_displayName regexMatch _filter || {_x regexMatch _filter}) then {
|
||||
// Change symbol and alpha if item already selected
|
||||
if (_x in _attributeItems) then {
|
||||
_symbol = _modeSymbol;
|
||||
|
@ -17,11 +17,15 @@
|
||||
params ["_display", "_control"];
|
||||
|
||||
private _searchString = ctrlText _control;
|
||||
if (_searchString != "") then {
|
||||
_searchString = _searchString call EFUNC(common,escapeRegex);
|
||||
_searchString = ".*?" + (_searchString splitString " " joinString ".*?") + ".*?/io";
|
||||
};
|
||||
|
||||
// Right panel search bar
|
||||
if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
// Don't refill if there is no need
|
||||
if (GVAR(lastSearchTextRight) != "" && {(_searchString find GVAR(lastSearchTextRight)) != 0}) then {
|
||||
if (GVAR(lastSearchTextRight) != "" && {GVAR(lastSearchTextRight) isNotEqualTo _searchString}) then {
|
||||
[_display, _display displayCtrl GVAR(currentRightPanel)] call FUNC(fillRightPanel);
|
||||
};
|
||||
|
||||
@ -33,8 +37,6 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
private _rightPanelState = GVAR(currentLeftPanel) in [IDC_buttonPrimaryWeapon, IDC_buttonHandgun, IDC_buttonSecondaryWeapon, IDC_buttonBinoculars];
|
||||
private _rightPanelCtrl = [_display displayCtrl IDC_rightTabContentListnBox, _display displayCtrl IDC_rightTabContent] select _rightPanelState;
|
||||
|
||||
_searchString = toLower _searchString;
|
||||
|
||||
// If right panel selection is weapons or binoculars
|
||||
if (_rightPanelState) then {
|
||||
// Get the currently selected item in panel
|
||||
@ -51,11 +53,11 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
|
||||
// Go through all items in panel and see if they need to be deleted or not
|
||||
for "_lbIndex" from (lbSize _rightPanelCtrl) - 1 to 0 step -1 do {
|
||||
_currentDisplayName = toLower (_rightPanelCtrl lbText _lbIndex);
|
||||
_currentClassname = toLower (_rightPanelCtrl lbData _lbIndex);
|
||||
_currentDisplayName = _rightPanelCtrl lbText _lbIndex;
|
||||
_currentClassname = _rightPanelCtrl lbData _lbIndex;
|
||||
|
||||
// Remove item in panel if it doesn't match search, skip otherwise
|
||||
if ((_currentDisplayName == "") || {!(_searchString in _currentDisplayName) && {!(_searchString in _currentClassname)}}) then {
|
||||
if ((_currentDisplayName == "") || {!(_currentDisplayName regexMatch _searchString) && {!(_currentClassname regexMatch _searchString)}}) then {
|
||||
_rightPanelCtrl lbDelete _lbIndex;
|
||||
};
|
||||
};
|
||||
@ -91,11 +93,11 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
|
||||
// Go through all items in panel and see if they need to be deleted or not
|
||||
for "_lbIndex" from (lnbSize _rightPanelCtrl select 0) - 1 to 0 step -1 do {
|
||||
_currentDisplayName = toLower (_rightPanelCtrl lnbText [_lbIndex, 1]);
|
||||
_currentClassname = toLower (_rightPanelCtrl lnbData [_lbIndex, 0]);
|
||||
_currentDisplayName = _rightPanelCtrl lnbText [_lbIndex, 1];
|
||||
_currentClassname = _rightPanelCtrl lnbData [_lbIndex, 0];
|
||||
|
||||
// Remove item in panel if it doesn't match search, skip otherwise
|
||||
if ((_currentDisplayName == "") || {!(_searchString in _currentDisplayName) && {!(_searchString in _currentClassname)}}) then {
|
||||
if ((_currentDisplayName == "") || {!(_currentDisplayName regexMatch _searchString) && {!(_currentClassname regexMatch _searchString)}}) then {
|
||||
_rightPanelCtrl lnbDeleteRow _lbIndex;
|
||||
};
|
||||
};
|
||||
@ -122,7 +124,7 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
} else {
|
||||
// Left panel search bar
|
||||
// Don't refill if there is no need
|
||||
if (GVAR(lastSearchTextLeft) != "" && {(_searchString find GVAR(lastSearchTextLeft)) != 0}) then {
|
||||
if (GVAR(lastSearchTextLeft) != "" && {GVAR(lastSearchTextLeft) isNotEqualTo _searchString}) then {
|
||||
[_display, _display displayCtrl GVAR(currentLeftPanel)] call FUNC(fillLeftPanel);
|
||||
};
|
||||
|
||||
@ -133,8 +135,6 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
|
||||
private _leftPanelCtrl = _display displayCtrl IDC_leftTabContent;
|
||||
|
||||
_searchString = toLower _searchString;
|
||||
|
||||
// Get the currently selected item in panel
|
||||
private _selectedItemIndex = lbCurSel _leftPanelCtrl;
|
||||
private _selectedItem = "";
|
||||
@ -149,11 +149,11 @@ if ((ctrlIDC _control) == IDC_rightSearchbar) then {
|
||||
|
||||
// Go through all items in panel and see if they need to be deleted or not
|
||||
for "_lbIndex" from (lbSize _leftPanelCtrl) - 1 to 0 step -1 do {
|
||||
_currentDisplayName = toLower (_leftPanelCtrl lbText _lbIndex);
|
||||
_currentClassname = toLower (_leftPanelCtrl lbData _lbIndex);
|
||||
_currentDisplayName = _leftPanelCtrl lbText _lbIndex;
|
||||
_currentClassname = _leftPanelCtrl lbData _lbIndex;
|
||||
|
||||
// Remove item in panel if it doesn't match search, skip otherwise
|
||||
if ((_currentDisplayName == "") || {!(_searchString in _currentDisplayName) && {!(_searchString in _currentClassname)}}) then {
|
||||
if ((_currentDisplayName == "") || {!(_currentDisplayName regexMatch _searchString) && {!(_currentClassname regexMatch _searchString)}}) then {
|
||||
_leftPanelCtrl lbDelete _lbIndex;
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user