Skip to content

Settings - Add Searchbar - #1825

Merged
PabstMirror merged 1 commit into
CBATeam:masterfrom
LinkIsGrim:settings-search
Aug 7, 2026
Merged

PabstMirror merged 1 commit into
CBATeam:masterfrom
LinkIsGrim:settings-search

Conversation

@LinkIsGrim

@LinkIsGrim LinkIsGrim commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

When merged this pull request will:

  • Add searchbar to settings.
image

also does fuzzy matching:

image

private _category = uiNamespace getVariable [QGVAR(addon), ""];
private _source = uiNamespace getVariable [QGVAR(source), ""];

if (_category isEqualTo "" || {_source isEqualTo ""}) exitWith {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_category isEqualTo "" || {_source isEqualTo ""}) exitWith {};
if (_category isEqualTo "" || _source isEqualTo "") exitWith {};

Not worth the lazy eval, isEqualTo is faster.


if (!isNil "_members") then {
// hide sub-category headers that have no settings left
private _show = (_members findIf {ctrlShown _x}) != -1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private _show = (_members findIf {ctrlShown _x}) != -1;
private _show = (_members findIf {ctrlShown _x}) isNotEqualTo -1;

_handled = true;
};
};
// ----- swallow enter in the search bar, it would close the dialog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ----- swallow enter in the search bar, it would close the dialog
// ----- swallow Enter in the search bar, it would close the dialog

// ----- adding to the search can only ever remove results, so only search through those again
private _searchScope = createHashMap;

if (_lastSearchText isNotEqualTo "" && {(_searchText find _lastSearchText) == 0}) then {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_lastSearchText isNotEqualTo "" && {(_searchText find _lastSearchText) == 0}) then {
if (_lastSearchText isNotEqualTo "" && {(_searchText find _lastSearchText) isEqualTo 0}) then {

I don't see why not use findIf instead of find, though.

private _fields = [_displayName, _setting, _tooltip, _category, _subCategory];

// list labels and their tooltips are searchable as well
if (toUpper _settingType == "LIST") then {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (toUpper _settingType == "LIST") then {
if (toUpper _settingType isEqualTo "LIST") then {

};

// ----- nothing matches at all, keep the category so it comes back when the search is cleared
if (_index == -1 && {lbSize _ctrlAddonList == 0}) exitWith {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_index == -1 && {lbSize _ctrlAddonList == 0}) exitWith {
if (_index isEqualTo -1 && {lbSize _ctrlAddonList isEqualTo 0}) exitWith {

I wonder if, combined with isEqualTo, lbSize would be faster than lazy eval.

};

// ----- the category is gone, show the first one that's left instead
if (_index == -1) exitWith {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (_index == -1) exitWith {
if (_index isEqualTo -1) exitWith {

Comment thread addons/settings/gui.hpp
onSetFocus = QUOTE((ctrlParent (_this select 0)) setVariable [ARR_2(QQGVAR(searchFocus),true)]);
onKillFocus = QUOTE((ctrlParent (_this select 0)) setVariable [ARR_2(QQGVAR(searchFocus),false)]);
// right click clears the search
onMouseButtonClick = QUOTE(if ((_this select 1) == 1) then {(_this select 0) ctrlSetText ''; [ctrlParent (_this select 0)] call FUNC(gui_search)});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onMouseButtonClick = QUOTE(if ((_this select 1) == 1) then {(_this select 0) ctrlSetText ''; [ctrlParent (_this select 0)] call FUNC(gui_search)});
onMouseButtonClick = QUOTE(if ((_this select 1) isEqualTo 1) then {(_this select 0) ctrlSetText ''; [ctrlParent (_this select 0)] call FUNC(gui_search)});

I ain't sure, but it probly would be better if _this select 0 wasn't called twice like this. I'm even less sure what that array element even is, so what I'd call the variable is very difficult to say.

@PabstMirror
PabstMirror merged commit 060ab6d into CBATeam:master Aug 7, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants