From b0c35e294997d75084e26b6da34561e98e2dfdcd Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:30:39 +0200 Subject: [PATCH 1/3] Sort addons, credits and keybindings alphabetically --- addons/help/XEH_postInit.sqf | 47 +++++++++++++++++++++++++++++++----- addons/help/XEH_preInit.sqf | 34 -------------------------- addons/help/XEH_preStart.sqf | 16 ++++++++---- 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/addons/help/XEH_postInit.sqf b/addons/help/XEH_postInit.sqf index 7b222be201..7f5d144574 100644 --- a/addons/help/XEH_postInit.sqf +++ b/addons/help/XEH_postInit.sqf @@ -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: %2", _action, _keyName]; + } forEach configProperties [_x, "isNumber _x || isClass _x"]; + + _addonKeys pushBack "
"; + _keys pushBack (_addonKeys joinString "
"); + } forEach ("true" configClasses _config); private _addons = allVariables EGVAR(keybinding,addons); - _addons sort true; { (EGVAR(keybinding,addons) getVariable _x) params ["_addon", "_addonActions"]; @@ -22,7 +51,7 @@ if (!hasInterface) exitWith {}; _name = localize _name; }; - _keys = _keys + format ["%1:
", _name]; + private _addonKeys = [format ["%1:", _name]]; { (EGVAR(keybinding,actions) getVariable (_addon + "$" + _x)) params ["_displayName", "", "_keybinds"]; @@ -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: %2
", _displayName, _keyName]; + _addonKeys pushBack format [" %1: %2", _displayName, _keyName]; } forEach _addonActions; - _keys = _keys + "
"; + _addonKeys pushBack "
"; + _keys pushBack (_addonKeys joinString "
"); } 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]; diff --git a/addons/help/XEH_preInit.sqf b/addons/help/XEH_preInit.sqf index 1e4c3a98c4..470af19c45 100644 --- a/addons/help/XEH_preInit.sqf +++ b/addons/help/XEH_preInit.sqf @@ -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:
", _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: %2
", _action, _keyName]; - } forEach configProperties [_x, "isNumber _x || isClass _x"]; - - _keys = _keys + "
"; -} forEach ("true" configClasses _config); - -GVAR(keys) = _keys; - ADDON = true; diff --git a/addons/help/XEH_preStart.sqf b/addons/help/XEH_preStart.sqf index db43220402..1b706da38a 100644 --- a/addons/help/XEH_preStart.sqf +++ b/addons/help/XEH_preStart.sqf @@ -38,32 +38,38 @@ private _credits = []; _credits pushBack format ["%1%2 by %3", _name, _version, _author]; } forEach _addons; -_credits = (_credits arrayIntersect _credits) joinString "
"; +_credits = _credits arrayIntersect _credits; + +_credits sort true; + +_credits = _credits joinString "
"; 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 [" %1 - %2", 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 ["
%1
", _description]; }; }; - _x + _x call CBA_fnc_sanitizeHTML }; +_mods sort true; + _mods = _mods joinString "
"; uiNamespace setVariable [QGVAR(mods), compileFinal str _mods]; From 627ccdec8f5dc58fe2a3aac40cddee62495a6f36 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:14:05 +0200 Subject: [PATCH 2/3] Don't sanitise everything --- addons/help/XEH_preStart.sqf | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/help/XEH_preStart.sqf b/addons/help/XEH_preStart.sqf index 1b706da38a..61277e7e3a 100644 --- a/addons/help/XEH_preStart.sqf +++ b/addons/help/XEH_preStart.sqf @@ -47,25 +47,27 @@ _credits = _credits joinString "
"; uiNamespace setVariable [QGVAR(credits), compileFinal str _credits]; // mods -private _mods = "true" configClasses (configFile >> "CfgPatches") apply {configSourceMod _x}; +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; - private _name = getText (_entry >> "name"); - if (isClass _entry) then { - _x = format [" %1 - %2", configName _entry, _name]; + private _name = getText (_entry >> "name") call CBA_fnc_sanitizeHTML; + + _name = format [" %1 - %2", configName _entry, _name]; if (isText (_entry >> "description")) then { - private _description = getText (_entry >> "description"); + private _description = getText (_entry >> "description") call CBA_fnc_sanitizeHTML; - _x = _x + format ["
%1
", _description]; + _name = _name + format ["
%1
", _description]; }; - }; - _x call CBA_fnc_sanitizeHTML + _name + } else { + _x call CBA_fnc_sanitizeHTML + }; }; _mods sort true; From 45b54dc8b3f324c47cfb39849e3c787128fdee3b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 20 Aug 2024 12:03:43 -0500 Subject: [PATCH 3/3] Use `modParams` to get name --- addons/help/XEH_preStart.sqf | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/addons/help/XEH_preStart.sqf b/addons/help/XEH_preStart.sqf index 61277e7e3a..1d53b0c3a2 100644 --- a/addons/help/XEH_preStart.sqf +++ b/addons/help/XEH_preStart.sqf @@ -51,23 +51,22 @@ private _mods = ("true" configClasses (configFile >> "CfgPatches")) apply {confi _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 }; - if (isClass _entry) then { - private _name = getText (_entry >> "name") call CBA_fnc_sanitizeHTML; - - _name = format [" %1 - %2", configName _entry, _name]; + private _mod = _x call CBA_fnc_sanitizeHTML; + _name = _name call CBA_fnc_sanitizeHTML; + _name = format [" %1 - %2", _mod, _name]; + private _entry = configfile >> "CfgMods" >> _x; // _x may be "@CBA_A3" + if (isClass _entry) then { if (isText (_entry >> "description")) then { private _description = getText (_entry >> "description") call CBA_fnc_sanitizeHTML; - _name = _name + format ["
%1
", _description]; }; - - _name - } else { - _x call CBA_fnc_sanitizeHTML }; + + _name }; _mods sort true;