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 - Tweaked sorting #9314

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
17 changes: 11 additions & 6 deletions addons/arsenal/functions/fnc_sortPanel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private _quantity = "";
private _itemCfg = configNull;
private _value = "";
private _name = "";
private _fillerChar = toString [1];

private _magazineMiscItems = uiNamespace getVariable QGVAR(magazineMiscItems);
private _sortCache = uiNamespace getVariable QGVAR(sortCache);
Expand Down Expand Up @@ -217,16 +218,20 @@ _for do {

// Save the current row's item's name in a cache and set text to it's sorting value
if (_right) then {
_originalNames set [_item, _panel lnbText [_i, 1]];
_name = _panel lnbText [_i, 1];
_originalNames set [_item, _name];

// Use tooltip to sort, as it also contains the classname, which means a fixed alphabetical order is guaranteed
_panel lnbSetText [[_i, 1], format ["%1%2", _value, _panel lbTooltip (_i * _countColumns)]];
// Use value, display name and classname to sort, which means a fixed alphabetical order is guaranteed
// Filler char has lowest lexicographical order possible
_panel lnbSetText [[_i, 1], format ["%1%2%4%3", _value, _name, _item, _fillerChar]];
} else {
if (_item != "") then {
_originalNames set [_item, _panel lbText _i];
_name = _panel lbText _i;
_originalNames set [_item, _name];

// Use tooltip to sort, as it also contains the classname, which means a fixed alphabetical order is guaranteed
_panel lbSetText [_i, format ["%1%2", _value, _panel lbTooltip _i]];
// Use value, display name and classname to sort, which means a fixed alphabetical order is guaranteed
// Filler char has lowest lexicographical order possible
_panel lbSetText [_i, format ["%1%2%4%3", _value, _name, _item, _fillerChar]];
};
};
};
Expand Down