move local diary mgmt to common module, clarify clientInit complete msg

This commit is contained in:
2024-02-08 15:04:22 -08:00
parent fba423e38d
commit 2db018103c
15 changed files with 56 additions and 23 deletions

View File

@@ -109,4 +109,4 @@ _text = _text joinString "<br/>";
GVAR(subjectIntelID),
_recordTitle,
_text
] call FUNC(createOrUpdateDiaryRecord);
] call EFUNC(common,createOrUpdateDiaryRecord);

View File

@@ -62,7 +62,7 @@ reverse _battalionElementCfgs;
GVAR(subjectFrequenciesID),
_diaryTitleText#0,
_diaryTitleText#1
] call FUNC(createOrUpdateDiaryRecord);
] call EFUNC(common,createOrUpdateDiaryRecord);
} forEach _battalionElementCfgs;
// add the battalion command to the top of the list
@@ -72,6 +72,6 @@ private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call FUNC(gene
GVAR(subjectFrequenciesID),
_diaryTitleText#0,
_diaryTitleText#1
] call FUNC(createOrUpdateDiaryRecord);
] call EFUNC(common,createOrUpdateDiaryRecord);
true;

View File

@@ -56,4 +56,4 @@ _text = _text joinString "<br/><br/>";
GVAR(subjectIntelID),
_recordTitle,
_text
] call FUNC(createOrUpdateDiaryRecord);
] call EFUNC(common,createOrUpdateDiaryRecord);

View File

@@ -25,12 +25,6 @@ player createDiarySubject[GVAR(subjectAssetsFixedWingID), "FBCB2 Planes"];
player createDiarySubject[GVAR(subjectAssetsRotaryID), "FBCB2 Helicopters"];
player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"];
// store records in format:
// [subject, [
// [title, diaryRecord]
// ]]
GVAR(diaryRecords) = createHashMap;
// run main inits
[] call FUNC(addFrequenciesRecord);
[] call FUNC(addSignalColorsRecord);
@@ -47,7 +41,7 @@ GVAR(diaryRecords) = createHashMap;
[
LEVEL_DEBUG,
QUOTE(COMPONENT),
"postInit complete",
"initClient complete",
[]
] call EFUNC(common,log);

View File

@@ -1,49 +0,0 @@
#include "../script_component.hpp"
if (!hasInterface) exitWith {};
params [
["_subjectID", GVAR(subjectStatusID), [""]],
["_recordTitle", "", [""]],
["_recordText", "", [""]],
["_recordIcon", "", [""]]
];
// Check if already created
private _subjectRecords = GVAR(diaryRecords) getOrDefault [_subjectID, createHashMap, true];
private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true];
if (!isNull _existingRecord) then {
player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]];
[
LEVEL_DEBUG,
QUOTE(COMPONENT),
format ["Updated diary record: %1", _recordTitle],
[
["subjectID", _subjectID],
["recordTitle", _recordTitle]
]
] call EFUNC(common,log);
} else {
private _new = player createDiaryRecord [
_subjectID,
[
_recordTitle,
_recordText,
_recordIcon
]
];
_subjectRecords set [_recordTitle, _new];
GVAR(diaryRecords) set [_subjectID, _subjectRecords];
[
LEVEL_DEBUG,
QUOTE(COMPONENT),
format ["Created diary record: %1", _recordTitle],
[
["subjectID", _subjectID],
["recordTitle", _recordTitle]
]
] call EFUNC(common,log);
};