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

Refactor Help Component #1073

Merged
merged 21 commits into from
Feb 22, 2019
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
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))]];
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
_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