many changes. includes rework of baselocation-asset storage format
This commit is contained in:
30
framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf
Normal file
30
framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf
Normal file
@@ -0,0 +1,30 @@
|
||||
#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]];
|
||||
systemChat format ["Updated diary record: %1", _recordTitle];
|
||||
} else {
|
||||
private _new = player createDiaryRecord [
|
||||
_subjectID,
|
||||
[
|
||||
_recordTitle,
|
||||
_recordText,
|
||||
_recordIcon
|
||||
]
|
||||
];
|
||||
_subjectRecords set [_recordTitle, _new];
|
||||
GVAR(diaryRecords) set [_subjectID, _subjectRecords];
|
||||
};
|
||||
75
framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf
Normal file
75
framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf
Normal file
@@ -0,0 +1,75 @@
|
||||
// called from milsim_fnc_processFBCB2RadioFrequencies
|
||||
#include "../script_component.hpp"
|
||||
|
||||
params ["_cfg", ["_indentCount", 1, [5]]];
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Define leading space/hyphenation for element name
|
||||
//////////////////////////////////////////////////////
|
||||
private _leadingSpace = [
|
||||
format["<font size='%1' face='%2'>| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT]
|
||||
];
|
||||
for "_i" from 1 to _indentCount do {
|
||||
_leadingSpace pushBack "-";
|
||||
};
|
||||
_leadingSpace pushBack " | </font>";
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Create the header line for the provided config entry
|
||||
/////////////////////////////////////////////////////////
|
||||
private _lines = [
|
||||
format[
|
||||
"<font color='%1'>%2%3</font>",
|
||||
getText(_cfg >> "textColor"),
|
||||
_leadingSpace joinString "",
|
||||
getText (_cfg >> "callsign")
|
||||
]
|
||||
];
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Create the frequency lines for the provided config entry
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
// Generate leading space
|
||||
private _freqLeadingSpace = [
|
||||
format["<font size='%1' face='%2'>| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT]
|
||||
];
|
||||
for "_i" from 1 to _FREQ_INDENT_CONSTANT do {
|
||||
_freqLeadingSpace pushBack " ";
|
||||
};
|
||||
_freqLeadingSpace pushBack "</font>";
|
||||
_freqLeadingSpace = _freqLeadingSpace joinString "";
|
||||
|
||||
// Process config values for frequencies
|
||||
{
|
||||
_x params ["_role", "_sr", "_lr"];
|
||||
|
||||
|
||||
private ["_srStr", "_lrStr"];
|
||||
if (count _sr > 0) then {
|
||||
_srStr = format["%1", _sr joinString " / "];
|
||||
} else {
|
||||
_srStr = "----";
|
||||
};
|
||||
if (count _lr > 0) then {
|
||||
_lrStr = format["%1", _lr joinString " / "];
|
||||
} else {
|
||||
_lrStr = "----";
|
||||
};
|
||||
|
||||
// Add formatted line to the array
|
||||
_lines pushBack format[
|
||||
"%1<font size='%2' face='%3' color='%4'>- %5%6%7</font>",
|
||||
_freqLeadingSpace,
|
||||
_ELEMENT_FREQ_SIZE,
|
||||
_ELEMENT_FREQ_FONT,
|
||||
_FREQ_TEXT_COLOR,
|
||||
[_role, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString),
|
||||
[_srStr, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString),
|
||||
_lrStr
|
||||
];
|
||||
} forEach (getArray (_cfg >> "frequencies"));
|
||||
// diag_log text (_lines joinString endl);
|
||||
|
||||
// Return the formatted lines in ARRAY format
|
||||
_lines;
|
||||
@@ -0,0 +1,102 @@
|
||||
// called from milsim_fnc_processFBCB2RadioFrequencies ONLY
|
||||
// this function is called recursively to process all child elements of a battalion element in missionConfigFile
|
||||
|
||||
#include "../script_component.hpp"
|
||||
|
||||
params [
|
||||
["_elementCfg", configNull, [configNull]],
|
||||
["_shouldProcessChildCfgs", true]
|
||||
];
|
||||
|
||||
if (isNull _elementCfg) exitWith {
|
||||
["_elementCfg parameter is NULL"] call BIS_fnc_error;
|
||||
};
|
||||
|
||||
// change reference variable for clarity
|
||||
private _battalionElement = _elementCfg;
|
||||
|
||||
// Generate title from callsign and shortDescription
|
||||
private _recordTitle = format[
|
||||
"%1 (%2)",
|
||||
getText(_battalionElement >> "callsign"),
|
||||
getText(_battalionElement >> "shortDescription")
|
||||
];
|
||||
// systemChat _recordTitle;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Generate frequency table header line's leading space
|
||||
//////////////////////////////////////////////////////////
|
||||
private _freqLeadingSpace = [
|
||||
format["<font size='%1' face='%2'>| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT]
|
||||
];
|
||||
for "_i" from 1 to _FREQ_INDENT_CONSTANT do {
|
||||
_freqLeadingSpace pushBack " ";
|
||||
};
|
||||
_freqLeadingSpace pushBack "</font>";
|
||||
_freqLeadingSpace = _freqLeadingSpace joinString "";
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Generate header line and frequency table header line
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
private _headers = [
|
||||
format[
|
||||
"<font size='%1' color='%2' face='%3'>%4</font>",
|
||||
GVAR(recordTitleSize),
|
||||
GVAR(recordTitleColor),
|
||||
GVAR(recordTitleFont),
|
||||
_recordTitle
|
||||
],
|
||||
format[
|
||||
"%1<font size='%2' face='%3' color='%4'>- %5%6%7</font>",
|
||||
_freqLeadingSpace,
|
||||
_ELEMENT_FREQ_SIZE,
|
||||
_ELEMENT_FREQ_FONT,
|
||||
_FREQ_TEXT_COLOR,
|
||||
["ROLE", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString),
|
||||
["SR", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString),
|
||||
"LR"
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Generate the list of element headers and frequencies
|
||||
//////////////////////////////////////////////////////////
|
||||
private _allText = [];
|
||||
|
||||
// get all child elements recursively and format them
|
||||
if (_shouldProcessChildCfgs) then {
|
||||
diag_log text format[
|
||||
"[%1] <%2> Processing %3",
|
||||
QUOTE(PREFIX),
|
||||
_fnc_scriptName,
|
||||
configName _battalionElement
|
||||
];
|
||||
[_battalionElement, {
|
||||
params ["_cfg", "_recurseCounter"];
|
||||
// add config
|
||||
private _lines = [_cfg, _recurseCounter+1] call FUNC(formatRadioElementForDiary);
|
||||
// private _lines = [_cfg, _indentCount] call t;
|
||||
_allText pushBack (_lines joinString "<br/>");
|
||||
}] call EFUNC(util,recurseSubclasses);
|
||||
} else {
|
||||
diag_log text format[
|
||||
"[%1] <%2> Processing %3",
|
||||
QUOTE(PREFIX),
|
||||
_fnc_scriptName,
|
||||
configName _battalionElement
|
||||
];
|
||||
// or if the param was false, just add the battalion element
|
||||
private _lines = [_battalionElement, 1] call FUNC(formatRadioElementForDiary);
|
||||
// private _lines = [_cfg, _indentCount] call t;
|
||||
_allText pushBack (_lines joinString "<br/>");
|
||||
};
|
||||
|
||||
// add headers, add all other lines and format them as monospace
|
||||
_allText = format[
|
||||
"%1<br/><br/><font face='EtelkaMonospaceProBold'>%2</font>", _headers joinString "<br/>", _allText joinString "<br/><br/>"];
|
||||
|
||||
// return the title and all text
|
||||
[_recordTitle, _allText];
|
||||
Reference in New Issue
Block a user