Skip to content

Commit

Permalink
rewrite help preClientInit, fix #244
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed Feb 18, 2016
1 parent 191965f commit e2c736c
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 92 deletions.
23 changes: 17 additions & 6 deletions addons/help/XEH_postClientInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

GVAR(CREDITS_Info) = [GVAR(credits), "CfgPatches"] call (uiNamespace getVariable "CBA_fnc_hashGet");
GVAR(CREDITS_Info) = GVAR(credits) getVariable "CfgPatches";

GVAR(CREDITS_CfgPatches) = (GVAR(CREDITS_Info)) call FUNC(process);
TRACE_2("",GVAR(CREDITS_Info), GVAR(CREDITS_CfgPatches));

Expand Down Expand Up @@ -78,16 +79,26 @@ _h = _pkeynam spawn {
player createDiaryRecord ["CBA_docs", [(localize "STR_DN_CBA_HELP_KEYS"), _text]];
};

// create diary
player createDiarySubject ["CBA_docs", "CBA"];

//player createDiaryRecord ["CBA_docs", [(localize "STR_DN_CBA_WEBSITE_WIKI"), "http://dev-heaven.net/projects/cca"]];
if (!isNil QGVAR(CREDITS_CfgPatches)) then { player createDiaryRecord ["CBA_docs", [(localize "STR_DN_CBA_CREDITS_ADDONS"), GVAR(CREDITS_CfgPatches)]];};
if (!isNil QGVAR(docs)) then { player createDiaryRecord ["CBA_docs", ["Docs", GVAR(docs)]];};
if (!isNil QGVAR(keys)) then { player createDiaryRecord ["CBA_docs", [(localize "STR_DN_CBA_HELP_KEYS"), GVAR(keys)]];};

if (!isNil QGVAR(CREDITS_CfgPatches)) then {
player createDiaryRecord ["CBA_docs", [localize "STR_DN_CBA_CREDITS_ADDONS", GVAR(CREDITS_CfgPatches)]];
};

if (!isNil QGVAR(docs)) then {
player createDiaryRecord ["CBA_docs", ["Docs", GVAR(docs)]];
};

if (!isNil QGVAR(keys)) then {
player createDiaryRecord ["CBA_docs", [localize "STR_DN_CBA_HELP_KEYS", GVAR(keys)]];
};

//player createDiaryRecord ["CBA_docs", [(localize "STR_DN_CBA_CREDITS"), GVAR(credits_cba)]];
//player createDiaryRecord ["CBA_docs", ["Credits - Vehicles", ([GVAR(credits), "CfgVehicles"] call (uiNamespace getVariable "CBA_fnc_hashGet")) call FUNC(process)]];
//player createDiaryRecord ["CBA_docs", ["Credits - Weapons", ([GVAR(credits), "CfgWeapons"] call (uiNamespace getVariable "CBA_fnc_hashGet")) call FUNC(process)]];

//player createDiaryRecord ["CBA_docs", [(localize "STR_DN_CBA_WEBSITE"), "http://dev-heaven.net/projects/cca"]];


// [cba_help_credits, "CfgPatches"] call (uiNamespace getVariable "CBA_fnc_hashGet")
207 changes: 123 additions & 84 deletions addons/help/XEH_preClientInit.sqf
Original file line number Diff line number Diff line change
@@ -1,112 +1,151 @@
// Any registered functions used in the PreINIT phase must use the uiNamespace copies of the variable.
// So uiNamespace getVariable "CBA_fnc_hashCreate" instead of just CBA_fnc_hashCreate -VM

//#define DEBUG_MODE_FULL
#include "script_component.hpp"

LOG(MSG_INIT);

ADDON = false;

FUNC(help) = {
call BIS_fnc_help;
};
FUNC(help) = {call BIS_fnc_help};

FUNC(readConfig) = {
params ["_type"];
_config = configFile >> _type;
_hash = [[], []] call (uiNamespace getVariable "CBA_fnc_hashCreate");
_hash2 = [[], ""] call (uiNamespace getVariable "CBA_fnc_hashCreate");
_hash3 = [[], ""] call (uiNamespace getVariable "CBA_fnc_hashCreate");
for "_i" from 0 to (count _config) - 1 do {
_entry = _config select _i;
if (isClass _entry) then {
if (isArray (_entry >> "author")) then { [_hash, configName _entry, getArray(_entry >> "author")] call (uiNamespace getVariable "CBA_fnc_hashSet") };
if (isText (_entry >> "authorUrl")) then { [_hash2, configName _entry, getText(_entry >> "authorUrl")] call (uiNamespace getVariable "CBA_fnc_hashSet") };
if (isText (_entry >> "version")) then { [_hash3, configName _entry, getText(_entry >> "version")] call (uiNamespace getVariable "CBA_fnc_hashSet") };
};
};
[_hash, _hash2, _hash3];

private _config = configFile >> _type;

private _hash1 = call CBA_fnc_createNamespace;
private _hash2 = call CBA_fnc_createNamespace;
private _hash3 = call CBA_fnc_createNamespace;

{
private _entry = _x;

_hash1 setVariable [configName _entry, getArray (_entry >> "author")];
_hash2 setVariable [configName _entry, getText (_entry >> "authorUrl")];
_hash3 setVariable [configName _entry, getText (_entry >> "version")];
} forEach ("isArray (_x >> 'author')" configClasses _config);

[_hash1, _hash2, _hash3]
};

FUNC(process) = {
params ["_h1","_h2","_h3"];
_ar = [];
[_h1, {_entry = format["%1, v%2, (%3)<br/>Author: %4", _key, [_h3, _key] call (uiNamespace getVariable "CBA_fnc_hashGet"), [_h2, _key] call (uiNamespace getVariable "CBA_fnc_hashGet"), _value joinString ", "]; PUSH(_ar,_entry) }] call (uiNamespace getVariable "CBA_fnc_hashEachPair");
_ar joinString "<br/><br/>";
params ["_hash1", "_hash2", "_hash3"];

private _result = [];

{
private _entry = format [
"%1, v%2, (%3)<br/>Author: %4",
_x,
_hash3 getVariable _x,
_hash2 getVariable _x,
(_hash1 getVariable _x) joinString ", "
];

_result pushBack _entry;
} forEach allVariables _hash1;

_result joinString "<br/><br/>";
};

private ["_pkeynam", "_shift", "_ctrl", "_alt", "_keys", "_key", "_keystrg", "_mod", "_knaml", "_knam", "_k", "_text", "_cEvents", "_i", "_cSys", "_tSys", "_aSys", "_tS", "_j", "_c", "_tC", "_keyn", "_credits"];
_pkeynam = { //local function
_shift = if(_shift > 0) then {42} else {0};
_ctrl = if(_ctrl > 0) then {56} else {0};
_alt = if(_alt > 0) then {29} else {0};
_keys = [_shift,_ctrl,_alt,_key];
_keystrg = "^";
// keys
private _fnc_getKeyName = {
private _shift = [0, DIK_LSHIFT] select (_shift > 0);
private _ctrl = [0, DIK_LCONTROL] select (_ctrl > 0);
private _alt = [0, DIK_LMENU] select (_alt > 0);

private _keys = [_shift, _ctrl, _alt, _key];

private _result = "^";

{
_mod = _x in [42,56,29]; // ???
_knaml = call compile format["format['%2',%1]",(keyName _x),"%1"];
_knaml = [_knaml, " "] call (uiNamespace getVariable "CBA_fnc_split");
_knam = "^";
{_k = _x; _knam = _knam + " " + _k} forEach _knaml;
// if(!(_mod) || ( (_k != (localize "STR_ACE_KN_LEFT")) && (_k != (localize "STR_ACE_KN_RIGHT")) )) then { // ?????
_knam = [_knam, "^ ", ""] call (uiNamespace getVariable "CBA_fnc_replace");
_keystrg = _keystrg + "-" + _knam;
private _keyname1 = call compile format ["format ['%1', %2]", "%1", keyName _x];

_keyname1 = [_keyname1, " "] call CBA_fnc_split;

private _keyname2 = "^";

{
_keyname2 = _keyname2 + " " + _x;
} forEach _keyname1;

_keyname2 = [_keyname2, "^ ", ""] call CBA_fnc_replace;
_result = _result + "-" + _keyname2;
} forEach _keys;
_keystrg = [_keystrg, "^ ", ""] call (uiNamespace getVariable "CBA_fnc_replace");
_keystrg = [_keystrg, "^-", ""] call (uiNamespace getVariable "CBA_fnc_replace");
_keystrg = [_keystrg, "^", "None"] call (uiNamespace getVariable "CBA_fnc_replace");
_keystrg

_result = [_result, "^ ", ""] call CBA_fnc_replace;
_result = [_result, "^-", ""] call CBA_fnc_replace;
_result = [_result, "^", "None"] call CBA_fnc_replace;
_result
};

_text="";
_cEvents = configFile/"CfgSettings"/"CBA"/"events";
for "_i" from 0 to (count _cEvents)-1 do {
_cSys = _cEvents select _i;
_tSys = configName _cSys;
if (isNumber((_cSys select 0)/"key")) then {
//format system name
_aSys = [_tSys, "_"] call (uiNamespace getVariable "CBA_fnc_split");
_tS = "^";
{if((_x != "sys")) then {_tS = _tS + " " + _x;}} forEach _aSys;
// (_x != "ace") &&
_tS = [_tS, "^ ", ""] call (uiNamespace getVariable "CBA_fnc_replace");
_tS = format["%1:",_tS];
_text = _text + _tS + "<br/>";
for "_j" from 0 to (count _cSys)-1 do {
_c = _cSys select _j;
_tC = configName _c;
_tC = [_tC, "_", " "] call (uiNamespace getVariable "CBA_fnc_replace");
//key
_key = getNumber (_c/"key");
_shift = getNumber (_c/"shift");
_ctrl = getNumber (_c/"ctrl");
_alt = getNumber (_c/"alt");
_keyn = [_key,_shift,_ctrl,_alt] call _pkeynam;
_tC = format[" %1: %2",_tC,_keyn];
_text = _text + _tC + "<br/>";
private _text = "";

private _config = configFile >> "CfgSettings" >> "CBA" >> "events";

{
private _addonConfig = _x;
private _addonName = configName _addonConfig;

private _addonNameArr = [_addonName, "_"] call CBA_fnc_split;
private _addonText = "^";

{
if (_x != "sys") then {
_addonText = format ["%1 %2", _addonText, _x];
};
_text = _text + "<br/>";
};
};
} forEach _addonNameArr;

_addonText = [_addonText, "^ ", ""] call CBA_fnc_replace;
_addonText = format ["%1:", _addonText];

GVAR(credits) = [[], []] call (uiNamespace getVariable "CBA_fnc_hashCreate");
{ [GVAR(credits), _x, [_x] call FUNC(readConfig)] call (uiNamespace getVariable "CBA_fnc_hashSet") } forEach ["CfgPatches"]; //, "CfgVehicles", "CfgWeapons"];
{
private _entry = _x;
private _actionName = configName _entry;

GVAR(docs) = "";
_cfg = configFile >> "CfgMods";
_c = count _cfg;
if (_c > 0) then {
for "_i" from 0 to (_c - 1) do {
_mod = _cfg select _i;
if (isClass _mod && {isText(_mod >> "description")}) then {
_e = format["* %1 - %2<br />%3<br /><br />", configName _mod, getText(_mod >> "name"), getText(_mod >> "description")];
ADD(GVAR(docs),_e);
_actionName = [_actionName, "_", " "] call CBA_fnc_replace;

private ["_key", "_shift", "_ctrl", "_alt"];

if (isNumber _entry) then {
_key = getNumber _entry;
_shift = 0;
_ctrl = 0;
_alt = 0;
} else {
_key = getNumber (_entry >> "key");
_shift = getNumber (_entry >> "shift");
_ctrl = getNumber (_entry >> "ctrl");
_alt = getNumber (_entry >> "alt");
};
};
};

private _keyName = [_key, _shift, _ctrl, _alt] call _fnc_getKeyName;

_actionName = format [" %1: %2", _actionName, _keyName];

_text = _text + _actionName + "<br/>";
} forEach configProperties [_addonConfig, "isNumber _x || isClass _x", true];

_text = _text + "<br/>";
} forEach ("true" configClasses _config);

GVAR(keys) = _text;

// credits
GVAR(credits) = call CBA_fnc_createNamespace;

{
GVAR(credits) setVariable [_x, _x call FUNC(readConfig)];
} forEach ["CfgPatches"]; //, "CfgVehicles", "CfgWeapons"];

// docs
GVAR(docs) = "";

private _config = configFile >> "CfgMods";

{
private _entry = format ["* %1 - %2<br />%3<br /><br />", configName _x, getText (_x >> "name"), getText (_x >> "description")];

GVAR(docs) + _entry;
} forEach ("isText (_x >> 'description')" configClasses _config);

ADDON = true;
2 changes: 2 additions & 0 deletions addons/help/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ class CfgPatches {

#include "CfgEventhandlers.hpp"
#include "CfgRscStd.hpp"

//#include "test_key.hpp"
2 changes: 1 addition & 1 deletion addons/help/cred_line.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

disableSerialization;
Expand Down
1 change: 1 addition & 0 deletions addons/help/script_dialog_defines.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "\a3\ui_f\hpp\defineCommonGrids.inc"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
#include "\a3\ui_f\hpp\defineResincl.inc"

#define __X SafeZoneX
Expand Down
22 changes: 22 additions & 0 deletions addons/help/test_key.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

class CfgSettings {
class CBA {
class Events {
class TestAddon {
action1 = 15; // tab

class action2 { // ctrl T
key = 20;
shift = 0;
ctrl = 1;
alt = 0;
};
};
};
};
};

/*
a1 = ["TestAddon", "action1", { systemChat str _this }] call CBA_fnc_addKeyHandlerFromConfig;
a2 = ["TestAddon", "action2", { systemChat str _this }] call CBA_fnc_addKeyHandlerFromConfig;
*/
2 changes: 1 addition & 1 deletion addons/help/ver_line.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

disableSerialization;
Expand Down

0 comments on commit e2c736c

Please sign in to comment.