Skip to content

Commit fbf8f19

Browse files
authored
Sort pylon magazine combo boxes alphabetically (#532)
1 parent 6fa3460 commit fbf8f19

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

addons/pylons/functions/fnc_configure.sqf

+13-7
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,28 @@ private _controls = [];
6464
_ctrlCombo lbAdd localize LSTRING(Empty);
6565
_ctrlCombo lbSetCurSel 0;
6666

67-
// Add compatible magazines to the combo box
67+
// Get compatible magazines and sort them alphabetically by name
68+
private _magazines = _aircraft getCompatiblePylonMagazines configName _x apply {
69+
private _config = _cfgMagazines >> _x;
70+
[getText (_config >> "displayName"), getText (_config >> "descriptionShort"), _x]
71+
};
72+
73+
_magazines sort true;
74+
75+
// Add compatible magazines to the combo box and select the current one
6876
private _currentMagazine = _currentMagazines select _forEachIndex;
6977

7078
{
71-
private _config = _cfgMagazines >> _x;
72-
private _name = getText (_config >> "displayName");
73-
private _tooltip = getText (_config >> "descriptionShort");
79+
_x params ["_name", "_tooltip", "_magazine"];
7480

7581
private _index = _ctrlCombo lbAdd _name;
7682
_ctrlCombo lbSetTooltip [_index, _tooltip];
77-
_ctrlCombo lbSetData [_index, _x];
83+
_ctrlCombo lbSetData [_index, _magazine];
7884

79-
if (_x == _currentMagazine) then {
85+
if (_magazine == _currentMagazine) then {
8086
_ctrlCombo lbSetCurSel _index;
8187
};
82-
} forEach (_aircraft getCompatiblePylonMagazines configName _x);
88+
} forEach _magazines;
8389

8490
// Create turret button if aircraft has a gunner position
8591
private _ctrlTurret = controlNull;

0 commit comments

Comments
 (0)