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

@@ -0,0 +1,58 @@
#include "../script_component.hpp"
if (!hasInterface) exitWith {};
params [
["_subjectID", "", [""]],
["_recordTitle", "", [""]],
["_recordText", "", [""]],
["_recordIcon", "", [""]]
];
// Check if all parameters are provided
if (
count _subjectID isEqualTo 0 ||
count _recordTitle isEqualTo 0 ||
count _recordText isEqualTo 0
) exitWith {
[LEVEL_ERROR, QUOTE(COMPONENT), "Not all parameters provided"] call EFUNC(common,log);
};
// 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);
};