From 1e4a5a79a8009c00f7e3d95317e6118d4e988771 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Thu, 1 Feb 2024 20:48:30 -0800 Subject: [PATCH] updates FBCB2, updates log fnc, adds comments --- functions/CfgFunctions.hpp | 2 +- functions/definitions/BattalionInfo.hpp | 7 +- ...Status.sqf => fn_hintFBCB2AssetStatus.sqf} | 0 functions/fbcb2/fn_initFBCB2.sqf | 3 + .../fbcb2/fn_processFBCB2Environment.sqf | 55 +++++++++------ .../fbcb2/fn_processFBCB2FixedWingAssets.sqf | 13 +++- .../fbcb2/fn_processFBCB2RadioFrequencies.sqf | 39 +++++------ .../fbcb2/fn_processFBCB2RotaryAssets.sqf | 13 +++- .../fbcb2/fn_processFBCB2SmokeColors.sqf | 67 +++++++++++-------- .../fn_formatRadioElementForDiary.sqf | 17 ++++- .../fn_generateElementFrequencyRecordText.sqf | 37 ++++++++-- functions/util/fn_log.sqf | 6 +- 12 files changed, 173 insertions(+), 86 deletions(-) rename functions/fbcb2/{fn_messageFBCB2AssetStatus.sqf => fn_hintFBCB2AssetStatus.sqf} (100%) diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 6b24d26..f7d3fb2 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -21,7 +21,7 @@ class milsim class processFBCB2RadioFrequencies {}; class processFBCB2SmokeColors {}; class processFBCB2Environment {}; - class messageFBCB2AssetStatus {}; + class hintFBCB2AssetStatus {}; }; class fbcb2_util { file = "functions\fbcb2\util"; diff --git a/functions/definitions/BattalionInfo.hpp b/functions/definitions/BattalionInfo.hpp index e2313f0..52ab77a 100644 --- a/functions/definitions/BattalionInfo.hpp +++ b/functions/definitions/BattalionInfo.hpp @@ -99,7 +99,7 @@ class BattalionInfo { shortDescription = "Special Weapons Squad"; textColor = LVL2_TEXT_COLOR; frequencies[] = { - {"Contact", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} + {"Contact", {}, {FREQ_BATTALION}} }; }; @@ -203,6 +203,7 @@ class BattalionInfo { callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, FLIGHT); textColor = LVL3_TEXT_COLOR; frequencies[] = { + {"Contact", {}, {FREQ_BATTALION}}, {"Actual", {}, {FREQ_ECHO_FLIGHT_INTERCOM, FREQ_BATTALION}}, {"CAS Support", {}, {FREQ_ECHO_FLIGHT_INTERCOM, FREQ_ECHO_FLIGHT_CAS}}, {"Logistics", {}, {FREQ_ECHO_FLIGHT_INTERCOM, FREQ_ECHO_FLIGHT_LOGISTICS}} @@ -213,6 +214,7 @@ class BattalionInfo { callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, GROUND); textColor = LVL3_TEXT_COLOR; frequencies[] = { + {"Contact", {}, {FREQ_BATTALION}}, {"Actual", {}, {FREQ_ECHO_GROUND, FREQ_BATTALION}} }; @@ -220,6 +222,7 @@ class BattalionInfo { callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, LOGISTICS); textColor = LVL4_TEXT_COLOR; frequencies[] = { + {"Contact", {}, {FREQ_ECHO_GROUND}}, {"Actual", {}, {FREQ_ECHO_GROUND_LOGISTICS, FREQ_ECHO_GROUND}}, {"General", {}, {FREQ_ECHO_GROUND_LOGISTICS}}, {"Convoy", {}, {FREQ_CONVOY}} @@ -230,6 +233,8 @@ class BattalionInfo { callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ATTACK); textColor = LVL4_TEXT_COLOR; frequencies[] = { + {"Contact", {}, {FREQ_ECHO_GROUND, FREQ_ECHO_FLIGHT_CAS}}, + {"Actual", {}, {FREQ_ECHO_GROUND}}, {"General", {}, {FREQ_ECHO_GROUND}}, {"Convoy", {}, {FREQ_CONVOY}} }; diff --git a/functions/fbcb2/fn_messageFBCB2AssetStatus.sqf b/functions/fbcb2/fn_hintFBCB2AssetStatus.sqf similarity index 100% rename from functions/fbcb2/fn_messageFBCB2AssetStatus.sqf rename to functions/fbcb2/fn_hintFBCB2AssetStatus.sqf diff --git a/functions/fbcb2/fn_initFBCB2.sqf b/functions/fbcb2/fn_initFBCB2.sqf index f906fd1..ba00b91 100644 --- a/functions/fbcb2/fn_initFBCB2.sqf +++ b/functions/fbcb2/fn_initFBCB2.sqf @@ -7,6 +7,9 @@ milsim_fbcb2_recordTitleColor = "#ff6666"; milsim_fbcb2_recordTitleFont = "PuristaMedium"; milsim_fbcb2_recordTitleSize = 20; +milsim_fbcb2_recordTextHeaderSize = 16; +milsim_fbcb2_recordTextBodySize = 14; + milsim_fbcb2_subjectStatusID = "FBCB2_Status"; milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; diff --git a/functions/fbcb2/fn_processFBCB2Environment.sqf b/functions/fbcb2/fn_processFBCB2Environment.sqf index 4206098..91c8bac 100644 --- a/functions/fbcb2/fn_processFBCB2Environment.sqf +++ b/functions/fbcb2/fn_processFBCB2Environment.sqf @@ -1,27 +1,42 @@ private _recordTitle = "MDS - INTEL - ENVIRONMENT"; - -_sunTimes = date call BIS_fnc_sunriseSunsetTime; - -_text = format[ - "%4

", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, - _recordTitle +private _text = [ + format[ + "%4

", + milsim_fbcb2_recordTitleSize, + milsim_fbcb2_recordTitleColor, + milsim_fbcb2_recordTitleFont, + _recordTitle + ] ]; -_text = _text + " -Local Sunrise -
-" + ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString) + " -

-Local Sunset -
-" + ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString) + " -

-"; -player createDiaryRecord ["Status", ["MDS - INTEL - ENVIRONMENT", _text]]; +private _sunriseColor = "#4A86E8"; +private _sunsetColor = "#6AA84F"; +private _whiteColor = "#FFFFFF"; + +private _sunTimes = date call BIS_fnc_sunriseSunsetTime; + +_text pushBack format[ + "Local Sunrise
+ %5

", + milsim_fbcb2_recordTextHeaderSize, + _sunriseColor, + milsim_fbcb2_recordTextBodySize, + _whiteColor, + ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString) +]; + +_text pushBack format[ + "Local Sunset
+ %5

", + milsim_fbcb2_recordTextHeaderSize, + _sunsetColor, + milsim_fbcb2_recordTextBodySize, + _whiteColor, + ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString) +]; + +_text = _text joinString ""; [ milsim_fbcb2_subjectIntelID, diff --git a/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf index 539beb2..773e0e1 100644 --- a/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf +++ b/functions/fbcb2/fn_processFBCB2FixedWingAssets.sqf @@ -1,4 +1,6 @@ - _assetList = missionNamespace getVariable "milsim_var_fixedAssets"; +private _recordTitle = "MDS - ASSETS - FIXED"; + +private _assetList = missionNamespace getVariable "milsim_var_fixedAssets"; _text = "=======------ Mission Data Set ------======="; @@ -14,6 +16,11 @@ _text = "=======------ Mission Data Set ---- } foreach _assetList; -_text = _text + "

Run Report on local node?"; +_text = _text + "

Run Report on local node?"; -player createDiaryRecord ["Status", ["MDS - ASSETS - FIXED", _text]]; \ No newline at end of file + +[ + milsim_fbcb2_subjectStatusID, + _recordTitle, + _text +] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf b/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf index 8057b22..69270a8 100644 --- a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf +++ b/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf @@ -1,16 +1,15 @@ // updated 2024-02-01 by IndigoFox -// now reads from the battalion config structure - -private _addToAllText = { - params [["_lines", []]]; - - _allText pushBack (_lines joinString "
"); -}; +// now reads from the battalion config structure to generate the diary entries //////////////////////////////////////// - +// Get info from missionConfigFile +//////////////////////////////////////// private _battalionInfoCfg = call milsim_fnc_getBattalionCfg; private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; + +//////////////////////////////////////// +// Define formatting constants +//////////////////////////////////////// private _ELEMENT_NAME_SIZE = 10; private _ELEMENT_NAME_FONT = "EtelkaMonospaceProBold"; private _ELEMENT_FREQ_SIZE = 9; @@ -18,21 +17,17 @@ private _ELEMENT_FREQ_FONT = "EtelkaMonospacePro"; private _FREQ_INDENT_CONSTANT = 6; private _FREQ_PAD_LENGTH = 17; private _FREQ_TEXT_COLOR = "#CCCCCC"; +// Note: Element colors are defined in the battalion config +//////////////////////////////////////// +// ADD DIARY ENTRIES +//////////////////////////////////////// -private _freqLeadingSpace = [ - format["| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT] -]; -for "_i" from 1 to _FREQ_INDENT_CONSTANT do { - _freqLeadingSpace pushBack " "; -}; -_freqLeadingSpace pushBack ""; -_freqLeadingSpace = _freqLeadingSpace joinString ""; - - - -// reverse the list so diary records are filed in the correct order +// First is all the battalion-level elements beneath command +// To have the records listed in the order they appear in the battalion config, we need to reverse the array +// Since each entry is added to the top of the list, this will result in the entries being added in the correct order reverse _battalionElementCfgs; + { // recursively generate diary text for all child elements of battalion-level elements private _diaryTitleText = [_x, true] call milsim_fnc_generateElementFrequencyRecordText; @@ -50,4 +45,6 @@ private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call milsim_fn milsim_fbcb2_subjectFrequenciesID, _diaryTitleText#0, _diaryTitleText#1 -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file +] call milsim_fnc_createOrUpdateDiaryRecord; + +true; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf b/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf index a9d40bf..95bdeda 100644 --- a/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf +++ b/functions/fbcb2/fn_processFBCB2RotaryAssets.sqf @@ -1,4 +1,6 @@ - _assetList = missionNamespace getVariable "milsim_var_rotaryAssets"; +private _recordTitle = "MDS - ASSETS - ROTARY"; + +_assetList = missionNamespace getVariable "milsim_var_rotaryAssets"; _text = "=======------ Mission Data Set ------======="; @@ -14,6 +16,11 @@ _text = "=======------ Mission Data Set ---- } foreach _assetList; -_text = _text + "

Run Report on local node?"; +_text = _text + "

Run Report on local node?"; -player createDiaryRecord ["Status", ["MDS - ASSETS - ROTARY", _text]]; \ No newline at end of file + +[ + milsim_fbcb2_subjectStatusID, + _recordTitle, + _text +] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2SmokeColors.sqf b/functions/fbcb2/fn_processFBCB2SmokeColors.sqf index 14a6212..1797d06 100644 --- a/functions/fbcb2/fn_processFBCB2SmokeColors.sqf +++ b/functions/fbcb2/fn_processFBCB2SmokeColors.sqf @@ -1,30 +1,41 @@ +private _recordTitle = "MDS - INTEL - SMOKES"; -_text = " -=======------ Mission Data Set ------======= -

-Smoke is a Guideline Not a Rule -

-WHITE
-Concealment -

-GREEN
-Friendly Forces -

-BLUE
-LZ Markers -

-RED
-Enemy Location -

-ORANGE
-Resupply Marker -

-YELLOW
-Medical Emergency -

-PURPLE
-Broken Arrow - 100m radius -

-"; +private _text = [ + // Title + format[ + "%4", + milsim_fbcb2_recordTitleSize, + milsim_fbcb2_recordTitleColor, + milsim_fbcb2_recordTitleFont, + _recordTitle + ] +]; -player createDiaryRecord ["Status", ["MDS - INTEL - SMOKES", _text]]; \ No newline at end of file +private _smokeColors = [ + ["#FFFFFF", "WHITE", "Concealment"], + ["#008800", "GREEN", "Friendly Forces"], + ["#0000FF", "BLUE", "LZ Markers"], + ["#FF0000", "RED", "Enemy Location"], + ["#FFA500", "ORANGE", "Resupply Marker"], + ["#FFFF00", "YELLOW", "Medical Emergency"], + ["#800080", "PURPLE", "Broken Arrow - 100m radius"] +]; + +{ + _x params ["_color", "_name", "_description"]; + _text pushBack format[ + "%3 - %4", + milsim_fbcb2_recordTextHeaderSize, + _color, + _name, + _description + ]; +} forEach _smokeColors; + +_text = _text joinString "

"; + +[ + milsim_fbcb2_subjectIntelID, + _recordTitle, + _text +] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file diff --git a/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf b/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf index 8b5210c..8a4bdc0 100644 --- a/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf +++ b/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf @@ -1,6 +1,9 @@ // called from milsim_fnc_processFBCB2RadioFrequencies params ["_cfg", ["_indentCount", 1, [5]]]; +////////////////////////////////////////////////////// +// Define leading space/hyphenation for element name +////////////////////////////////////////////////////// private _leadingSpace = [ format["| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT] ]; @@ -9,7 +12,9 @@ for "_i" from 1 to _indentCount do { }; _leadingSpace pushBack " | "; -// make header line +///////////////////////////////////////////////////////// +// Create the header line for the provided config entry +///////////////////////////////////////////////////////// private _lines = [ format[ "%2%3", @@ -19,7 +24,11 @@ private _lines = [ ] ]; -// make frequency lines +//////////////////////////////////////////////////////////// +// Create the frequency lines for the provided config entry +//////////////////////////////////////////////////////////// + +// Generate leading space private _freqLeadingSpace = [ format["| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT] ]; @@ -29,6 +38,7 @@ for "_i" from 1 to _FREQ_INDENT_CONSTANT do { _freqLeadingSpace pushBack ""; _freqLeadingSpace = _freqLeadingSpace joinString ""; +// Process config values for frequencies { _x params ["_role", "_sr", "_lr"]; @@ -45,7 +55,7 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; _lrStr = "----"; }; - + // Add formatted line to the array _lines pushBack format[ "%1- %5%6%7", _freqLeadingSpace, @@ -59,4 +69,5 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; } forEach (getArray (_cfg >> "frequencies")); // diag_log text (_lines joinString endl); +// Return the formatted lines in ARRAY format _lines; \ No newline at end of file diff --git a/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf b/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf index d66f07a..113ede7 100644 --- a/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf +++ b/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf @@ -1,4 +1,5 @@ -// called from milsim_fnc_processFBCB2RadioFrequencies +// called from milsim_fnc_processFBCB2RadioFrequencies ONLY +// this function is called recursively to process all child elements of a battalion element in missionConfigFile params [ ["_elementCfg", configNull, [configNull]], ["_shouldProcessChildCfgs", true] @@ -8,8 +9,10 @@ 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"), @@ -17,16 +20,33 @@ private _recordTitle = format[ ]; // systemChat _recordTitle; + +////////////////////////////////////////////////////////// +// Generate frequency table header line's leading space +////////////////////////////////////////////////////////// +private _freqLeadingSpace = [ + format["| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT] +]; +for "_i" from 1 to _FREQ_INDENT_CONSTANT do { + _freqLeadingSpace pushBack " "; +}; +_freqLeadingSpace pushBack ""; +_freqLeadingSpace = _freqLeadingSpace joinString ""; + +////////////////////////////////////////////////////////// +// Generate header line and frequency table header line +////////////////////////////////////////////////////////// + private _headers = [ format[ - "%4

", + "%4", milsim_fbcb2_recordTitleSize, milsim_fbcb2_recordTitleColor, milsim_fbcb2_recordTitleFont, _recordTitle ], format[ - "%1- %5%6%7

", + "%1- %5%6%7", _freqLeadingSpace, _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, @@ -37,6 +57,10 @@ private _headers = [ ] ]; + +////////////////////////////////////////////////////////// +// Generate the list of element headers and frequencies +////////////////////////////////////////////////////////// private _allText = []; // get all child elements recursively and format them @@ -49,12 +73,15 @@ if (_shouldProcessChildCfgs) then { _allText pushBack (_lines joinString "
"); }] call milsim_fnc_recurseSubclasses; } else { + // or if the param was false, just add the battalion element private _lines = [_battalionElement, 1] call milsim_fnc_formatRadioElementForDiary; // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); }; +// add headers, add all other lines and format them as monospace +_allText = format[ + "%1

%2", _headers joinString "
", _allText joinString "

"]; -_allText = format["%1%2", _headers joinString "
", _allText joinString "
"]; - +// return the title and all text [_recordTitle, _allText]; \ No newline at end of file diff --git a/functions/util/fn_log.sqf b/functions/util/fn_log.sqf index 5b780b4..d80dbc2 100644 --- a/functions/util/fn_log.sqf +++ b/functions/util/fn_log.sqf @@ -18,7 +18,11 @@ params [ private _hash = createHashMapFromArray _data; +// Replace square brackets with round brackets to avoid parsing issues. +_message regexReplace ["\[", "("]; +_message regexReplace ["\]", ")"]; + private _json = [_hash] call CBA_fnc_encodeJSON; -_log = format ["[milsim] (%1) (%2) (%3) :: %4", _component, _fnc_scriptNameParent, _message, _json]; +_log = format ["[milsim] [%1] [%2] [%3] :: %4", _component, _fnc_scriptNameParent, _message, _json]; diag_log text _log; \ No newline at end of file