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

Help - Sort addons, credits and keybindings alphabetically #1684

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
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
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;
27 changes: 17 additions & 10 deletions addons/help/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,39 @@ 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")}) - [""];
private _mods = ("true" configClasses (configFile >> "CfgPatches")) apply {configSourceMod _x};
_mods = ((_mods arrayIntersect _mods) select {!isNumber (configfile >> "CfgMods" >> _x >> "appId")}) - [""];

_mods = _mods apply {
private _entry = configfile >> "CfgMods" >> _x;
(modParams [_x, ["name"]]) params ["_name"];
if (_name == "") then { _name = _x };

private _name = getText (_entry >> "name") call CBA_fnc_sanitizeHTML;
private _mod = _x call CBA_fnc_sanitizeHTML;
_name = _name call CBA_fnc_sanitizeHTML;
_name = format [" <font color='#cc9cbd'>%1 - %2</font>", _mod, _name];

private _entry = configfile >> "CfgMods" >> _x; // _x may be "@CBA_A3"
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;

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

_x
_name
};

_mods sort true;

_mods = _mods joinString "<br/>";

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