Skip to content

Commit

Permalink
add diary record with all addon versions (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fusselwurm authored Jun 16, 2021
1 parent e361921 commit bb456a9
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 12 deletions.
14 changes: 8 additions & 6 deletions addons/ui/XEH_postClientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ if (!hasInterface) exitWith {};

player createDiarySubject [QGVAR(helpSubject),"Gruppe Adler Mod"];

private _helpRecords = missionNamespace getVariable [QGVAR(helpRecords),[]];
_helpRecords sort true;
private _helpRecordsQueue = missionNamespace getVariable [QGVAR(helpRecordsQueue),[]];
_helpRecordsQueue sort true;

ISNILS(GVAR(helpRecords), createHashMap);

{
_x params ["_title","_text"];

player createDiaryRecord [QGVAR(helpSubject),[
private _record = player createDiaryRecord [QGVAR(helpSubject),[
_title,
format ["<img width='32' height='32' image='\x\grad\addons\ui\dialog\logo_128.paa'/><font size='32' color='#D18D1F' face='RobotoCondensedLight'> %1</font><br/><br/>%2",_title,_text]
]];
GVAR(helpRecords) set [_title, _record];

} forEach _helpRecords;
} forEach _helpRecordsQueue;

_helpRecords resize 0;
GVAR(helpRecords) = nil;
GVAR(helpRecordsQueue) = nil;
3 changes: 2 additions & 1 deletion addons/ui/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class CfgFunctions {
};
class help {
file = QPATHTOF(functions\help);
class addHelpRecord {};
class addHelpRecord {};
class getHelpRecord {};
};
};
};
6 changes: 2 additions & 4 deletions addons/ui/functions/help/fn_addHelpRecord.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

params [["_title","ERROR: NO TITLE"],["_text","ERROR: NO TEXT"]];

if (isNil QGVAR(helpRecords)) then {
GVAR(helpRecords) = [];
};
ISNILS(GVAR(helpRecordsQueue), []);

GVAR(helpRecords) pushBack [_title,_text];
GVAR(helpRecordsQueue) pushBack [_title,_text];
6 changes: 6 additions & 0 deletions addons/ui/functions/help/fn_getHelpRecord.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "script_component.hpp"

params ["_title"];

assert(!isNil QGVAR(helpRecords));
GVAR(helpRecords) getOrDefault [_title, diaryRecordNull];
3 changes: 3 additions & 0 deletions addons/versionCheck/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ private _settingsGroup = "GRAD Version Check";
false,
1
] call CBA_settings_fnc_init;

GVAR(addonVersionsTitle) = "Addon Versions";
[GVAR(addonVersionsTitle), "<execute expression=""call grad_versionCheck_fnc_createDiaryEntry"">Show</execute>"] call EFUNC(ui,addHelpRecord);
1 change: 1 addition & 0 deletions addons/versionCheck/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class cfgFunctions {
file = "x\grad\addons\versionCheck\functions";

class compileDialogText {};
class createDiaryEntry {};
class determineVersions {};
class getVersionNo {};
class logResult {};
Expand Down
2 changes: 1 addition & 1 deletion addons/versionCheck/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CfgPatches {
name = QUOTE(ADDON);
url = "$STR_grad_URL";
requiredVersion = 1.0;
requiredAddons[] = {"grad_main","ace_common"};
requiredAddons[] = {"ace_common", "grad_main", "grad_ui"};
units[] = {};
weapons[] = {};
VERSION_CONFIG;
Expand Down
38 changes: 38 additions & 0 deletions addons/versionCheck/functions/fn_createDiaryEntry.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "..\script_component.hpp"

private _pad = {
params ["_str", "_targetLen"];
private _strLen = count _str;
if (_strLen >= _targetLen) exitWith {_str};

private _a = [];
_a resize (_targetLen - _strLen);
(_str + ((_a apply {" "}) joinString ""));
};

private _description = [
" LOCAL | SERVER | ADDON <br/>",
"------------|------------|---------- <br/>"
];

private _addonNames = keys grad_versionCheck_versions;
_addonNames sort true;
{
private _name = _x;

private _myVersion = (grad_versionCheck_versions getOrDefault [_name, ["-", false]])#0;
if (_myVersion isEqualTo "") then {
_myVersion = "-";
};
_myVersion = [_myVersion, 10] call _pad;
private _serverVersion = (grad_versionCheck_versions_server getOrDefault [_name, ["-", false]])#0;
if (_serverVersion isEqualTo "") then {
_serverVersion = "-";
};
_serverVersion = [_serverVersion, 10] call _pad;

_description pushBack (format [" %1 | %2 | %3 <br/>", _myVersion, _serverVersion, _name]);

} forEach _addonNames;

player setDiaryRecordText [["grad_ui_helpSubject", [GVAR(addonVersionsTitle)] call EFUNC(ui,getHelpRecord)], [GVAR(addonVersionsTitle), "<font face=""EtelkaMonospacePro"" size=""8"">" + (_description joinString "") + "</font>"]]

0 comments on commit bb456a9

Please sign in to comment.