Skip to content

Commit

Permalink
Refactor Help Component (#1073)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
commy2 committed Feb 22, 2019
1 parent 1b62207 commit ee88aac
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 543 deletions.
29 changes: 29 additions & 0 deletions addons/events/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,32 @@ class CfgWeapons {
};
};
#endif

//["testcomponent1", "test1", {systemChat str 11}] call CBA_fnc_addKeyHandlerFromConfig;
//["testcomponent1", "test2", {systemChat str 12}] call CBA_fnc_addKeyHandlerFromConfig;
//["testcomponent2", "test1", {systemChat str 21}] call CBA_fnc_addKeyHandlerFromConfig;
//["testcomponent2", "test2", {systemChat str 22}] call CBA_fnc_addKeyHandlerFromConfig;

/*class CfgSettings {
class CBA {
class events {
class testcomponent1 {
test1 = 15;
class test2 {
key = 15;
shift = 1;
};
};
class testcomponent2 {
test1 = 19;
class test2 {
key = 19;
ctrl = 1;
};
};
};
};
};*/
4 changes: 2 additions & 2 deletions addons/help/CfgEventhandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Extended_PreStart_EventHandlers {

class Extended_PreInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_preClientInit));
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postClientInit));
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
56 changes: 0 additions & 56 deletions addons/help/XEH_postClientInit.sqf

This file was deleted.

43 changes: 43 additions & 0 deletions addons/help/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

if (!hasInterface) exitWith {};

{
// create diary, entries added in reverse order
private _unit = player;
_unit createDiarySubject [QGVAR(docs), "CBA"];

// add diary for scripted keybinds
private _keys = GVAR(keys);

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

{
(EGVAR(keybinding,addons) getVariable _x) params ["_addon", "_addonActions"];

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

{
(EGVAR(keybinding,actions) getVariable (_addon + "$" + _x)) params ["_displayName", "", "_keybinds"];

if (isLocalized _displayName) then {
_displayName = localize _displayName;
};

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];
} forEach _addonActions;

_keys = _keys + "<br/>";
} forEach _addons;

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

_unit createDiaryRecord [QGVAR(docs), [localize "STR_CBA_Help_Keys", _keys]];
_unit createDiaryRecord [QGVAR(docs), [localize "STR_CBA_Credits", call (uiNamespace getVariable QGVAR(credits))]];
_unit createDiaryRecord [QGVAR(docs), [localize "STR_CBA_Addons", call (uiNamespace getVariable QGVAR(mods))]];
} call CBA_fnc_execNextFrame;
147 changes: 0 additions & 147 deletions addons/help/XEH_preClientInit.sqf

This file was deleted.

45 changes: 45 additions & 0 deletions addons/help/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

if (!hasInterface) exitWith {};

ADDON = false;

// 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;
Loading

0 comments on commit ee88aac

Please sign in to comment.