Skip to content

Commit ee88aac

Browse files
authored
Refactor Help Component (#1073)
* cleanup help * cleanup help * help docs * delete help docs * cleanup help * cleanup help * cleanup help * travis * fix a script error * addons diary * mods help * remove bugtracker, wiki diary entries * formatting * display addons, cba CfgMods * rewrite part about config key handlers * html sanitize * html sanitize * html sanitize * CBA_fnc_sanitizeHTML
1 parent 1b62207 commit ee88aac

18 files changed

Lines changed: 256 additions & 543 deletions

addons/events/config.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,32 @@ class CfgWeapons {
4646
};
4747
};
4848
#endif
49+
50+
//["testcomponent1", "test1", {systemChat str 11}] call CBA_fnc_addKeyHandlerFromConfig;
51+
//["testcomponent1", "test2", {systemChat str 12}] call CBA_fnc_addKeyHandlerFromConfig;
52+
//["testcomponent2", "test1", {systemChat str 21}] call CBA_fnc_addKeyHandlerFromConfig;
53+
//["testcomponent2", "test2", {systemChat str 22}] call CBA_fnc_addKeyHandlerFromConfig;
54+
55+
/*class CfgSettings {
56+
class CBA {
57+
class events {
58+
class testcomponent1 {
59+
test1 = 15;
60+
61+
class test2 {
62+
key = 15;
63+
shift = 1;
64+
};
65+
};
66+
67+
class testcomponent2 {
68+
test1 = 19;
69+
70+
class test2 {
71+
key = 19;
72+
ctrl = 1;
73+
};
74+
};
75+
};
76+
};
77+
};*/

addons/help/CfgEventhandlers.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class Extended_PreStart_EventHandlers {
66

77
class Extended_PreInit_EventHandlers {
88
class ADDON {
9-
clientInit = QUOTE(call COMPILE_FILE(XEH_preClientInit));
9+
init = QUOTE(call COMPILE_FILE(XEH_preInit));
1010
};
1111
};
1212

1313
class Extended_PostInit_EventHandlers {
1414
class ADDON {
15-
clientInit = QUOTE(call COMPILE_FILE(XEH_postClientInit));
15+
init = QUOTE(call COMPILE_FILE(XEH_postInit));
1616
};
1717
};

addons/help/XEH_postClientInit.sqf

Lines changed: 0 additions & 56 deletions
This file was deleted.

addons/help/XEH_postInit.sqf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//#define DEBUG_MODE_FULL
2+
#include "script_component.hpp"
3+
4+
if (!hasInterface) exitWith {};
5+
6+
{
7+
// create diary, entries added in reverse order
8+
private _unit = player;
9+
_unit createDiarySubject [QGVAR(docs), "CBA"];
10+
11+
// add diary for scripted keybinds
12+
private _keys = GVAR(keys);
13+
14+
private _addons = allVariables EGVAR(keybinding,addons);
15+
_addons sort true;
16+
17+
{
18+
(EGVAR(keybinding,addons) getVariable _x) params ["_addon", "_addonActions"];
19+
20+
_keys = _keys + format ["%1:<br/>", _addon];
21+
22+
{
23+
(EGVAR(keybinding,actions) getVariable (_addon + "$" + _x)) params ["_displayName", "", "_keybinds"];
24+
25+
if (isLocalized _displayName) then {
26+
_displayName = localize _displayName;
27+
};
28+
29+
private _keyName = (_keybinds select {_x select 0 > DIK_ESCAPE} apply {_x call CBA_fnc_localizeKey}) joinString " ";
30+
31+
_keys = _keys + format [" %1: <font color='#c48214'>%2</font><br/>", _displayName, _keyName];
32+
} forEach _addonActions;
33+
34+
_keys = _keys + "<br/>";
35+
} forEach _addons;
36+
37+
// delete last line breaks
38+
_keys = _keys select [0, count _keys - 10];
39+
40+
_unit createDiaryRecord [QGVAR(docs), [localize "STR_CBA_Help_Keys", _keys]];
41+
_unit createDiaryRecord [QGVAR(docs), [localize "STR_CBA_Credits", call (uiNamespace getVariable QGVAR(credits))]];
42+
_unit createDiaryRecord [QGVAR(docs), [localize "STR_CBA_Addons", call (uiNamespace getVariable QGVAR(mods))]];
43+
} call CBA_fnc_execNextFrame;

addons/help/XEH_preClientInit.sqf

Lines changed: 0 additions & 147 deletions
This file was deleted.

addons/help/XEH_preInit.sqf

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//#define DEBUG_MODE_FULL
2+
#include "script_component.hpp"
3+
4+
if (!hasInterface) exitWith {};
5+
6+
ADDON = false;
7+
8+
// bwc
9+
FUNC(help) = BIS_fnc_help;
10+
11+
// keys
12+
private _keys = "";
13+
14+
private _config = configFile >> "CfgSettings" >> "CBA" >> "events";
15+
16+
{
17+
private _addon = configName _x;
18+
19+
_keys = _keys + format ["%1:<br/>", _addon];
20+
21+
{
22+
private _action = configName _x;
23+
24+
private _keybind = if (isNumber _x) then {
25+
[getNumber _x, false, false, false]
26+
} else {
27+
[
28+
getNumber (_x >> "key"),
29+
getNumber (_x >> "shift") > 0,
30+
getNumber (_x >> "ctrl") > 0,
31+
getNumber (_x >> "alt") > 0
32+
]
33+
};
34+
35+
private _keyName = _keybind call CBA_fnc_localizeKey;
36+
37+
_keys = _keys + format [" %1: <font color='#c48214'>%2</font><br/>", _action, _keyName];
38+
} forEach configProperties [_x, "isNumber _x || isClass _x"];
39+
40+
_keys = _keys + "<br/>";
41+
} forEach ("true" configClasses _config);
42+
43+
GVAR(keys) = _keys;
44+
45+
ADDON = true;

0 commit comments

Comments
 (0)