Skip to content

Commit

Permalink
Sort addons, credits and keybindings alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Aug 16, 2024
1 parent 6454723 commit b0c35e2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 45 deletions.
47 changes: 41 additions & 6 deletions addons/help/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,40 @@ if (!hasInterface) exitWith {};
private _unit = player;
_unit createDiarySubject [QGVAR(docs), "CBA"];

// add diary for scripted keybinds
private _keys = GVAR(keys);
// add diary for config & scripted keybinds
private _keys = [];

private _config = configFile >> "CfgSettings" >> "CBA" >> "events";

{
private _addon = configName _x;

private _addonKeys = [format ["%1:", _addon]];

{
private _action = configName _x;

private _keybind = if (isNumber _x) then {
[getNumber _x, false, false, false]
} else {
[
getNumber (_x >> "key"),
getNumber (_x >> "shift") > 0,
getNumber (_x >> "ctrl") > 0,
getNumber (_x >> "alt") > 0
]
};

private _keyName = _keybind call CBA_fnc_localizeKey;

_addonKeys pushBack format [" %1: <font color='#c48214'>%2</font>", _action, _keyName];
} forEach configProperties [_x, "isNumber _x || isClass _x"];

_addonKeys pushBack "<br/>";
_keys pushBack (_addonKeys joinString "<br/>");
} forEach ("true" configClasses _config);

private _addons = allVariables EGVAR(keybinding,addons);
_addons sort true;

{
(EGVAR(keybinding,addons) getVariable _x) params ["_addon", "_addonActions"];
Expand All @@ -22,7 +51,7 @@ if (!hasInterface) exitWith {};
_name = localize _name;
};

_keys = _keys + format ["%1:<br/>", _name];
private _addonKeys = [format ["%1:", _name]];

{
(EGVAR(keybinding,actions) getVariable (_addon + "$" + _x)) params ["_displayName", "", "_keybinds"];
Expand All @@ -33,12 +62,18 @@ if (!hasInterface) exitWith {};

private _keyName = (_keybinds select {_x select 0 > DIK_ESCAPE} apply {_x call CBA_fnc_localizeKey}) joinString " ";

_keys = _keys + format [" %1: <font color='#c48214'>%2</font><br/>", _displayName, _keyName];
_addonKeys pushBack format [" %1: <font color='#c48214'>%2</font>", _displayName, _keyName];
} forEach _addonActions;

_keys = _keys + "<br/>";
_addonKeys pushBack "<br/>";
_keys pushBack (_addonKeys joinString "<br/>");
} forEach _addons;

// Get localized categories first, then sort
_keys sort true;

_keys = _keys joinString "";

// delete last line breaks
_keys = _keys select [0, count _keys - 10];

Expand Down
34 changes: 0 additions & 34 deletions addons/help/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,4 @@ if (!hasInterface) exitWith {
// bwc
FUNC(help) = BIS_fnc_help;

// keys
private _keys = "";

private _config = configFile >> "CfgSettings" >> "CBA" >> "events";

{
private _addon = configName _x;

_keys = _keys + format ["%1:<br/>", _addon];

{
private _action = configName _x;

private _keybind = if (isNumber _x) then {
[getNumber _x, false, false, false]
} else {
[
getNumber (_x >> "key"),
getNumber (_x >> "shift") > 0,
getNumber (_x >> "ctrl") > 0,
getNumber (_x >> "alt") > 0
]
};

private _keyName = _keybind call CBA_fnc_localizeKey;

_keys = _keys + format [" %1: <font color='#c48214'>%2</font><br/>", _action, _keyName];
} forEach configProperties [_x, "isNumber _x || isClass _x"];

_keys = _keys + "<br/>";
} forEach ("true" configClasses _config);

GVAR(keys) = _keys;

ADDON = true;
16 changes: 11 additions & 5 deletions addons/help/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,38 @@ private _credits = [];
_credits pushBack format ["<font color='#bdcc9c'>%1%2 by %3</font>", _name, _version, _author];
} forEach _addons;

_credits = (_credits arrayIntersect _credits) joinString "<br/>";
_credits = _credits arrayIntersect _credits;

_credits sort true;

_credits = _credits joinString "<br/>";

uiNamespace setVariable [QGVAR(credits), compileFinal str _credits];

// mods
private _mods = "true" configClasses (configFile >> "CfgPatches") apply {configSourceMod _x};
_mods = (_mods arrayIntersect _mods select {!isNumber (configfile >> "CfgMods" >> _x >> "appId")}) - [""];
_mods = ((_mods arrayIntersect _mods) select {!isNumber (configfile >> "CfgMods" >> _x >> "appId")}) - [""];

_mods = _mods apply {
private _entry = configfile >> "CfgMods" >> _x;

private _name = getText (_entry >> "name") call CBA_fnc_sanitizeHTML;
private _name = getText (_entry >> "name");

if (isClass _entry) then {
_x = format [" <font color='#cc9cbd'>%1 - %2</font>", configName _entry, _name];

if (isText (_entry >> "description")) then {
private _description = getText (_entry >> "description") call CBA_fnc_sanitizeHTML;
private _description = getText (_entry >> "description");

_x = _x + format ["<br/>%1<br/>", _description];
};
};

_x
_x call CBA_fnc_sanitizeHTML
};

_mods sort true;

_mods = _mods joinString "<br/>";

uiNamespace setVariable [QGVAR(mods), compileFinal str _mods];

0 comments on commit b0c35e2

Please sign in to comment.