From 2d6fbcfcefbdee34f777521fbae7a41ac787712c Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Thu, 1 Feb 2024 01:23:21 -0800 Subject: [PATCH 1/3] defines battalion info, integrates FBCB2 freqs and callsigns --- description.ext | 1 + functions/CfgFunctions.hpp | 3 + functions/definitions/BattalionInfo.hpp | 243 ++++++++++++++++++ functions/fbcb2/fn_processFBCB2Callsigns.sqf | 16 ++ .../fbcb2/fn_processFBCB2RadioFrequencies.sqf | 139 +++++++--- functions/util/fn_getBattalionCfg.sqf | 1 + functions/util/fn_padString.sqf | 20 ++ functions/util/fn_recurseSubclasses.sqf | 14 + 8 files changed, 404 insertions(+), 33 deletions(-) create mode 100644 functions/definitions/BattalionInfo.hpp create mode 100644 functions/util/fn_getBattalionCfg.sqf create mode 100644 functions/util/fn_padString.sqf create mode 100644 functions/util/fn_recurseSubclasses.sqf diff --git a/description.ext b/description.ext index 5bc6cb1..f319951 100644 --- a/description.ext +++ b/description.ext @@ -17,6 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "mission_settings.hpp" +#include "functions\definitions\BattalionInfo.hpp" //-------------------------------------------MISSION INFO-------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index 7e8f088..fcb9e91 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -75,6 +75,9 @@ class milsim class logMissionInfo { postInit = 1; }; class addPlayerInfoToArray {}; class log {}; + class padString {}; + class recurseSubclasses {}; + class getBattalionCfg {}; }; }; diff --git a/functions/definitions/BattalionInfo.hpp b/functions/definitions/BattalionInfo.hpp new file mode 100644 index 0000000..b4a3bff --- /dev/null +++ b/functions/definitions/BattalionInfo.hpp @@ -0,0 +1,243 @@ +// BattalionInfo.hpp +// Defines the structure of the Battalion, allowing properties to be easily changed and updated +// This file is included in description.ext + + +// Define the callsigns for the Battalion +#define COMMAND_CALLSIGN SPARTAN +#define RRC_CALLSIGN TIGER +#define MEDIC_CALLSIGN LIFELINE +#define ALPHA_CALLSIGN BLACKJACK +#define ECHO_CALLSIGN ZOOMER +#define WPN_CALLSIGN BLACKFOOT + +// Define the frequencies for the Battalion +#define FREQ_BATTALION 45 +#define FREQ_BATTALION_MEDICAL_INTERCOM 91.1 +#define FREQ_ALL_MEDICAL_SR 121.5 + +#define FREQ_ALPHA_COMPANY 40 + +#define FREQ_PLATOON1_SR 100 +#define FREQ_PLATOON1_LR 41 +#define FREQ_PLATOON1_RTO 101 + +#define FREQ_PLATOON2_SR 200 +#define FREQ_PLATOON2_LR 42 +#define FREQ_PLATOON2_RTO 201 + +#define FREQ_ECHO_FLIGHT_INTERCOM 30 +#define FREQ_ECHO_FLIGHT_CAS 35 +#define FREQ_ECHO_FLIGHT_LOGISTICS 35.1 + +#define FREQ_ECHO_GROUND 80 +#define FREQ_ECHO_GROUND_LOGISTICS 81 +#define FREQ_ECHO_ARTY 82 +#define FREQ_ECHO_ARTY_INTERCOM 155 + +#define FREQ_CONVOY 50 + +// Define the text colors to appear in diary entries +#define LVL1_TEXT_COLOR "#7c887e" +#define LVL2_TEXT_COLOR "#bab79f" +#define LVL3_TEXT_COLOR "#91967f" +#define LVL4_TEXT_COLOR "#d3d2cd" + + +// All elements and subclasses should have the following properties: +// callsign: the callsign of the element +// textColor: the color of the text for the element +// frequencies: an array of frequencies for the element in the format: +// {roleWithinElement, {primarySR, additionalSR}, {primaryLR, additionalLR}} + +// Battalion-level elements under Command should have the following additional properties: +// shortDescription: a short description of the element's place in the Battalion + + +// System macros +#define CALLSIGN_ELEMENT(callsign,element) callsign##element + + + +class BattalionInfo { + class Command { + callsign = COMMAND_CALLSIGN; + shortDescription = "Battalion Command"; + textColor = LVL1_TEXT_COLOR; + // frequencies are in format: + // {roleWithinElement, {primarySR, additionalSR}, {primaryLR, additionalLR}} + frequencies[] = { + {"Actual", {}, {FREQ_BATTALION}}, + {"Romeo", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} + }; + + + class RRC { // WIP + callsign = RRC_CALLSIGN; + shortDescription = "RRC"; + textColor = LVL2_TEXT_COLOR; + frequencies[] = { + {"Actual", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} + }; + }; + + class BattalionMedical { // WIP + callsign = MEDIC_CALLSIGN; + shortDescription = "Battalion Medical"; + textColor = LVL2_TEXT_COLOR; + frequencies[] = { + {"Actual", {FREQ_BATTALION_MEDICAL_INTERCOM, FREQ_ALL_MEDICAL_SR}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_LOGISTICS}}, + {"General", {FREQ_BATTALION_MEDICAL_INTERCOM, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + + // class WeaponsPlatoon { // WIP + // callsign = WPN_CALLSIGN; + // textColor = LVL2_TEXT_COLOR; + // frequencies[] = { + // {"Actual", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} + // }; + // }; + + + class AlphaCompany { + callsign = ALPHA_CALLSIGN; + shortDescription = "Alpha Company"; + textColor = LVL2_TEXT_COLOR; + frequencies[] = { + {"Actual", {}, {FREQ_COMPANY, FREQ_BATTALION}}, + {"Romeo", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS, FREQ_ECHO_FLIGHT_LOGISTICS}} + }; + + class Platoon1 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 1-6); + textColor = LVL3_TEXT_COLOR; + frequencies[] = { + {"Actual", {FREQ_PLATOON1_SR, FREQ_PLATOON1_RTO}, {FREQ_PLATOON1_LR, FREQ_COMPANY}} + }; + class Squad1 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 1-1); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {110, FREQ_PLATOON1_SR}, {FREQ_PLATOON1_LR}}, + {"Alpha Team", {111, 110}, {}}, + {"Bravo Team", {112, 110}, {}}, + {"Medic", {110, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + class Squad2 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 1-2); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {120, FREQ_PLATOON1_SR}, {FREQ_PLATOON1_LR}}, + {"Alpha Team", {121, 120}, {}}, + {"Bravo Team", {122, 120}, {}}, + {"Medic", {120, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + class Squad3 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 1-3); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {130, FREQ_PLATOON1_SR}, {FREQ_PLATOON1_LR}}, + {"Alpha Team", {131, 130}, {}}, + {"Bravo Team", {132, 130}, {}}, + {"Medic", {130, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + }; + + class Platoon2 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 2-6); + textColor = LVL3_TEXT_COLOR; + frequencies[] = { + {"Actual", {FREQ_PLATOON2_SR, FREQ_PLATOON2_RTO}, {FREQ_PLATOON2, FREQ_COMPANY}} + }; + class Squad1 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 2-1); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {210, FREQ_PLATOON2_SR}, {FREQ_PLATOON2_LR}}, + {"Alpha Team", {211, 210}, {}}, + {"Bravo Team", {212, 210}, {}}, + {"Medic", {210, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + class Squad2 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 2-2); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {220, FREQ_PLATOON2_SR}, {FREQ_PLATOON2_LR}}, + {"Alpha Team", {221, 220}, {}}, + {"Bravo Team", {222, 220}, {}}, + {"Medic", {220, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + class Squad3 { + callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 2-3); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {230, FREQ_PLATOON2_SR}, {FREQ_PLATOON2_LR}}, + {"Alpha Team", {231, 230}, {}}, + {"Bravo Team", {232, 230}, {}}, + {"Medic", {230, FREQ_ALL_MEDICAL_SR}, {}} + }; + }; + }; + }; + + class EchoCompany { + callsign = ECHO_CALLSIGN; + shortDescription = "Echo Company"; + textColor = LVL2_TEXT_COLOR; + frequencies[] = { + {"Actual", {}, {FREQ_BATTALION}} + }; + + class Flight { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, FLIGHT); + textColor = LVL3_TEXT_COLOR; + frequencies[] = { + {"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}} + }; + }; + + class Ground { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, GROUND); + textColor = LVL3_TEXT_COLOR; + frequencies[] = { + {"Actual", {}, {FREQ_ECHO_GROUND, FREQ_BATTALION}} + }; + + class Logistics { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, LOGISTICS); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"Actual", {}, {FREQ_ECHO_GROUND_LOGISTICS, FREQ_ECHO_GROUND}}, + {"General", {}, {FREQ_ECHO_GROUND_LOGISTICS}}, + {"Convoy", {}, {FREQ_CONVOY}} + }; + }; + + class Attack { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ATTACK); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"General", {}, {FREQ_ECHO_GROUND}}, + {"Convoy", {}, {FREQ_CONVOY}} + }; + }; + + class Artillery { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ARTILLERY); + textColor = LVL4_TEXT_COLOR; + frequencies[] = { + {"General", {FREQ_ECHO_ARTY_INTERCOM}, {FREQ_ECHO_GROUND, FREQ_ECHO_ARTY}} + }; + }; + }; + }; + }; +}; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2Callsigns.sqf b/functions/fbcb2/fn_processFBCB2Callsigns.sqf index 0c1083b..545511c 100644 --- a/functions/fbcb2/fn_processFBCB2Callsigns.sqf +++ b/functions/fbcb2/fn_processFBCB2Callsigns.sqf @@ -19,4 +19,20 @@ Weapons Squad

"; + +private _text = []; + +private _battalionCfg = call milsim_fnc_getBattalionCfg; +private _commandCfg = _battalionCfg >> "Command"; +private _battalionLevelElements = [_commandCfg] call BIS_fnc_returnChildren; + +{ + private _cfg = _x; + private _callsign = getText (_cfg >> "callsign"); + private _desc = getText (_cfg >> "shortDescription"); + _text pushBack format ["%1
%2", _callsign, _desc]; +} forEach _battalionLevelElements; + +_text = _text joinString "

"; + player createDiaryRecord ["Status", ["MDS - COMMAND - CALLSIGNS", _text]]; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf b/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf index 7e58dcf..8902d03 100644 --- a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf +++ b/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf @@ -1,35 +1,108 @@ +// updated 2024-02-01 by IndigoFox +// now reads from the battalion config structure -_text = " -=======------ Mission Data Set ------======= -

-EXODUS -
-6 - 45 -
-RTO - 45 / 35 -

-RIPTIDE -
-Actual - 45 / 100 -
-Romeo - 45 / 35 -
-1 - 110 / 100 -
-2 - 120 / 100 -
-3 - 130 / 110 -
-Blackfoot - 150 / 100 -

-ECHO -
-Impaler - 45 / 35 -
-JTAC - 35 / 82 -
-IDF - 82 / 100 -

-"; +private _formatElementForDiary = { + params ["_cfg", "_indentCount"]; -player createDiaryRecord ["Status", ["MDS - INTEL - RADIO FREQS", _text]]; \ No newline at end of file + private _leadingSpace = [ + format["| ", _ELEMENT_NAME_SIZE] + ]; + for "_i" from 1 to _indentCount do { + _leadingSpace pushBack "-"; + }; + _leadingSpace pushBack " | "; + + // make header line + private _lines = [ + format[ + "%3%4", + _ELEMENT_NAME_SIZE, + getText(_cfg >> "textColor"), + _leadingSpace joinString "", + getText (_cfg >> "callsign") + ] + ]; + + // make frequency lines + private _freqLeadingSpace = [ + format["| ", _ELEMENT_NAME_SIZE] + ]; + for "_i" from 1 to _indentCount + 4 do { + _freqLeadingSpace pushBack " "; + }; + _freqLeadingSpace pushBack ""; + _freqLeadingSpace = _freqLeadingSpace joinString ""; + + { + _x params ["_role", "_sr", "_lr"]; + + + private ["_srStr", "_lrStr"]; + if (count _sr > 0) then { + _srStr = format["SR [%1]", _sr joinString "/"]; + } else { + _srStr = "----"; + }; + if (count _lr > 0) then { + _lrStr = format["LR [%1]", _lr joinString "/"]; + } else { + _lrStr = "----"; + }; + + + _lines pushBack format[ + "%1- %4%5%6 -", + _freqLeadingSpace, + _ELEMENT_FREQ_SIZE, + _FREQ_TEXT_COLOR, + [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + [_lrStr, "right", " ", 8] call milsim_fnc_padString + ]; + } forEach (getArray (_cfg >> "frequencies")); + + _lines; +}; + +private _addToAllText = { + params [["_lines", []]]; + + _allText = format[ + "%1%2
", + _allText, + _lines joinString "
" + ]; +}; + +private _recurseAddElements = { + params ["_cfg", ["_indentCount", 1]]; + + // add config + private _lines = [_cfg, _indentCount] call _formatElementForDiary; + [_lines] call _addToAllText; + + // get children and recurse + _childCfgs = _cfg call BIS_fnc_returnChildren; + { + [_x, _indentCount+1] call _recurseAddElements; + } forEach _childCfgs; +}; + +//////////////////////////////////////// +_allText = " +=======------ Mission Data Set ------======= +

"; + +private _battalionInfoCfgs = [call milsim_fnc_getBattalionCfg] call BIS_fnc_returnChildren; +private _ELEMENT_NAME_SIZE = 10; +private _ELEMENT_FREQ_SIZE = 8; +private _FREQ_PAD_LENGTH = 14; +private _FREQ_TEXT_COLOR = "#CCCCCC"; + +{ + _x call _recurseAddElements; +} forEach _battalionInfoCfgs; + +_allText = format["%1
", _allText]; + +player createDiaryRecord ["Status", ["MDS - INTEL - RADIO FREQS", _allText]]; \ No newline at end of file diff --git a/functions/util/fn_getBattalionCfg.sqf b/functions/util/fn_getBattalionCfg.sqf new file mode 100644 index 0000000..b239a24 --- /dev/null +++ b/functions/util/fn_getBattalionCfg.sqf @@ -0,0 +1 @@ +(missionConfigFile >> "BattalionInfo") \ No newline at end of file diff --git a/functions/util/fn_padString.sqf b/functions/util/fn_padString.sqf new file mode 100644 index 0000000..e5d3faf --- /dev/null +++ b/functions/util/fn_padString.sqf @@ -0,0 +1,20 @@ +params [ + ["_text", "", [""]], + ["_padSide", "left", ["left", "right"]], + ["_padChar", " ", [" "]], + ["_padLength", 4, [4]] +]; + +// pad a string with a character to a certain length +if (_padSide == "left") then { + for "_i" from 1 to _padLength - count _text do { + _text = _padChar + _text; + }; +}; +if (_padSide == "right") then { + for "_i" from 1 to _padLength - count _text do { + _text = _text + _padChar; + }; +}; + +_text diff --git a/functions/util/fn_recurseSubclasses.sqf b/functions/util/fn_recurseSubclasses.sqf new file mode 100644 index 0000000..6d483f5 --- /dev/null +++ b/functions/util/fn_recurseSubclasses.sqf @@ -0,0 +1,14 @@ +params [ + ["_cfg", configNull, [configNull]], + ["_code", {}, [{}]] +]; + +if (isNull _cfg) exitWith {["Provided config is null!"] call BIS_fnc_error}; + +[_cfg] call _code; + +// get children and recurse +private _childCfgs = _cfg call BIS_fnc_returnChildren; +{ + [_x, _code] call milsim_fnc_recurseSubclasses; +} forEach _childCfgs; \ No newline at end of file From a7550d374ec13cc51d18bb7f1aecbcdea9dd099d Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Thu, 1 Feb 2024 15:19:30 -0800 Subject: [PATCH 2/3] major updates to fbcb2 diary stuff --- functions/CfgFunctions.hpp | 11 +- functions/definitions/BattalionInfo.hpp | 27 ++-- functions/fbcb2/fn_addFBCB2DiaryEntries.sqf | 10 -- functions/fbcb2/fn_initFBCB2.sqf | 23 ++- functions/fbcb2/fn_processFBCB2Callsigns.sqf | 38 ----- .../fbcb2/fn_processFBCB2Environment.sqf | 24 +++- .../fbcb2/fn_processFBCB2RadioFrequencies.sqf | 131 +++++------------- .../fn_formatRadioElementForDiary.sqf | 62 +++++++++ .../fn_generateElementFrequencyRecordText.sqf | 60 ++++++++ .../util/fn_createOrUpdateDiaryRecord.sqf | 18 +++ functions/util/fn_recurseSubclasses.sqf | 23 ++- 11 files changed, 261 insertions(+), 166 deletions(-) delete mode 100644 functions/fbcb2/fn_addFBCB2DiaryEntries.sqf delete mode 100644 functions/fbcb2/fn_processFBCB2Callsigns.sqf create mode 100644 functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf create mode 100644 functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf create mode 100644 functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf diff --git a/functions/CfgFunctions.hpp b/functions/CfgFunctions.hpp index fcb9e91..6b24d26 100644 --- a/functions/CfgFunctions.hpp +++ b/functions/CfgFunctions.hpp @@ -15,9 +15,7 @@ class milsim }; class fbcb2 { - class addFBCB2DiaryEntries { postInit = 1; }; class initFBCB2 { postInit = 1; }; - class processFBCB2Callsigns {}; class processFBCB2FixedWingAssets {}; class processFBCB2RotaryAssets {}; class processFBCB2RadioFrequencies {}; @@ -25,6 +23,15 @@ class milsim class processFBCB2Environment {}; class messageFBCB2AssetStatus {}; }; + class fbcb2_util { + file = "functions\fbcb2\util"; + class createOrUpdateDiaryRecord {}; + }; + class fbcb2_radioFrequencies { + file = "functions\fbcb2\radioFrequencies"; + class formatRadioElementForDiary {}; + class generateElementFrequencyRecordText {}; + }; class client { class addZenModules { postInit = 1; }; diff --git a/functions/definitions/BattalionInfo.hpp b/functions/definitions/BattalionInfo.hpp index b4a3bff..e2313f0 100644 --- a/functions/definitions/BattalionInfo.hpp +++ b/functions/definitions/BattalionInfo.hpp @@ -67,6 +67,7 @@ class BattalionInfo { // frequencies are in format: // {roleWithinElement, {primarySR, additionalSR}, {primaryLR, additionalLR}} frequencies[] = { + {"Contact", {}, {FREQ_BATTALION}}, {"Actual", {}, {FREQ_BATTALION}}, {"Romeo", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} }; @@ -77,6 +78,7 @@ class BattalionInfo { shortDescription = "RRC"; textColor = LVL2_TEXT_COLOR; frequencies[] = { + {"Contact", {}, {FREQ_BATTALION}}, {"Actual", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} }; }; @@ -86,18 +88,20 @@ class BattalionInfo { shortDescription = "Battalion Medical"; textColor = LVL2_TEXT_COLOR; frequencies[] = { + {"Contact", {FREQ_ALL_MEDICAL_SR}, {FREQ_BATTALION}}, {"Actual", {FREQ_BATTALION_MEDICAL_INTERCOM, FREQ_ALL_MEDICAL_SR}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_LOGISTICS}}, {"General", {FREQ_BATTALION_MEDICAL_INTERCOM, FREQ_ALL_MEDICAL_SR}, {}} }; }; - // class WeaponsPlatoon { // WIP - // callsign = WPN_CALLSIGN; - // textColor = LVL2_TEXT_COLOR; - // frequencies[] = { - // {"Actual", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} - // }; - // }; + class WeaponsSquad { // WIP + callsign = WPN_CALLSIGN; + shortDescription = "Special Weapons Squad"; + textColor = LVL2_TEXT_COLOR; + frequencies[] = { + {"Contact", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS}} + }; + }; class AlphaCompany { @@ -105,15 +109,15 @@ class BattalionInfo { shortDescription = "Alpha Company"; textColor = LVL2_TEXT_COLOR; frequencies[] = { - {"Actual", {}, {FREQ_COMPANY, FREQ_BATTALION}}, - {"Romeo", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS, FREQ_ECHO_FLIGHT_LOGISTICS}} + {"Contact", {}, {FREQ_ALPHA_COMPANY, FREQ_BATTALION}} }; class Platoon1 { callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 1-6); textColor = LVL3_TEXT_COLOR; frequencies[] = { - {"Actual", {FREQ_PLATOON1_SR, FREQ_PLATOON1_RTO}, {FREQ_PLATOON1_LR, FREQ_COMPANY}} + {"Actual", {FREQ_PLATOON1_SR, FREQ_PLATOON1_RTO}, {FREQ_PLATOON1_LR, FREQ_ALPHA_COMPANY}}, + {"Romeo", {}, {FREQ_BATTALION, FREQ_ECHO_FLIGHT_CAS, FREQ_ECHO_FLIGHT_LOGISTICS}} }; class Squad1 { callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 1-1); @@ -151,7 +155,7 @@ class BattalionInfo { callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 2-6); textColor = LVL3_TEXT_COLOR; frequencies[] = { - {"Actual", {FREQ_PLATOON2_SR, FREQ_PLATOON2_RTO}, {FREQ_PLATOON2, FREQ_COMPANY}} + {"Actual", {FREQ_PLATOON2_SR, FREQ_PLATOON2_RTO}, {FREQ_PLATOON2_LR, FREQ_ALPHA_COMPANY}} }; class Squad1 { callsign = CALLSIGN_ELEMENT(ALPHA_CALLSIGN, 2-1); @@ -191,6 +195,7 @@ class BattalionInfo { shortDescription = "Echo Company"; textColor = LVL2_TEXT_COLOR; frequencies[] = { + {"Contact", {}, {FREQ_BATTALION}}, {"Actual", {}, {FREQ_BATTALION}} }; diff --git a/functions/fbcb2/fn_addFBCB2DiaryEntries.sqf b/functions/fbcb2/fn_addFBCB2DiaryEntries.sqf deleted file mode 100644 index 10936a4..0000000 --- a/functions/fbcb2/fn_addFBCB2DiaryEntries.sqf +++ /dev/null @@ -1,10 +0,0 @@ -if ( !hasInterface ) exitWith {}; - -player createDiarySubject["Status","FBCB2 - Status"]; -player createDiarySubject["Intel","FBCB2 - Combat Msgs"]; -player createDiarySubject["Messages","FBCB2 - Messages"]; - - -diag_log text "[MILSIM] (fbcb2) diary entries added"; - -nil; \ No newline at end of file diff --git a/functions/fbcb2/fn_initFBCB2.sqf b/functions/fbcb2/fn_initFBCB2.sqf index 4a4d3f4..f906fd1 100644 --- a/functions/fbcb2/fn_initFBCB2.sqf +++ b/functions/fbcb2/fn_initFBCB2.sqf @@ -1,8 +1,29 @@ + if ( !hasInterface ) exitWith {}; waitUntil { !isNil "milsim_complete" }; -[] call milsim_fnc_processFBCB2Callsigns; +milsim_fbcb2_recordTitleColor = "#ff6666"; +milsim_fbcb2_recordTitleFont = "PuristaMedium"; +milsim_fbcb2_recordTitleSize = 20; + +milsim_fbcb2_subjectStatusID = "FBCB2_Status"; +milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; +milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; +milsim_fbcb2_subjectFrequenciesID = "FBCB2_Frequencies"; + +player createDiarySubject[milsim_fbcb2_subjectStatusID, "FBCB2 - Status"]; +player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"]; +player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"]; +player createDiarySubject[milsim_fbcb2_subjectFrequenciesID, "FBCB2 - Frequencies"]; + +// store records in format: +// [subject, [ +// [title, diaryRecord] +// ]] +milsim_fbcb2_diaryRecords = createHashMap; + +// populate diary [] call milsim_fnc_processFBCB2FixedWingAssets; [] call milsim_fnc_processFBCB2RotaryAssets; [] call milsim_fnc_processFBCB2RadioFrequencies; diff --git a/functions/fbcb2/fn_processFBCB2Callsigns.sqf b/functions/fbcb2/fn_processFBCB2Callsigns.sqf deleted file mode 100644 index 545511c..0000000 --- a/functions/fbcb2/fn_processFBCB2Callsigns.sqf +++ /dev/null @@ -1,38 +0,0 @@ - -_text = " -=======------ Mission Data Set ------======= -

-SPARTAN
-Command -

-BLACKJACK
-Alpha Platoon -

-ZOOMER
-Echo -

-TIGER
-RRC -

-BLACKFOOT
-Weapons Squad -

-"; - - -private _text = []; - -private _battalionCfg = call milsim_fnc_getBattalionCfg; -private _commandCfg = _battalionCfg >> "Command"; -private _battalionLevelElements = [_commandCfg] call BIS_fnc_returnChildren; - -{ - private _cfg = _x; - private _callsign = getText (_cfg >> "callsign"); - private _desc = getText (_cfg >> "shortDescription"); - _text pushBack format ["%1
%2", _callsign, _desc]; -} forEach _battalionLevelElements; - -_text = _text joinString "

"; - -player createDiaryRecord ["Status", ["MDS - COMMAND - CALLSIGNS", _text]]; \ No newline at end of file diff --git a/functions/fbcb2/fn_processFBCB2Environment.sqf b/functions/fbcb2/fn_processFBCB2Environment.sqf index 5c700fa..4206098 100644 --- a/functions/fbcb2/fn_processFBCB2Environment.sqf +++ b/functions/fbcb2/fn_processFBCB2Environment.sqf @@ -1,8 +1,16 @@ -_sunTimes = date call BIS_fnc_sunriseSunsetTime; +private _recordTitle = "MDS - INTEL - ENVIRONMENT"; -_text = " -=======------ Mission Data Set ------======= -

+ +_sunTimes = date call BIS_fnc_sunriseSunsetTime; + +_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) + " @@ -13,4 +21,10 @@ _text = "

"; -player createDiaryRecord ["Status", ["MDS - INTEL - ENVIRONMENT", _text]]; \ No newline at end of file +player createDiaryRecord ["Status", ["MDS - INTEL - ENVIRONMENT", _text]]; + +[ + milsim_fbcb2_subjectIntelID, + _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 8902d03..8057b22 100644 --- a/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf +++ b/functions/fbcb2/fn_processFBCB2RadioFrequencies.sqf @@ -1,108 +1,53 @@ // updated 2024-02-01 by IndigoFox // now reads from the battalion config structure -private _formatElementForDiary = { - params ["_cfg", "_indentCount"]; - - private _leadingSpace = [ - format["| ", _ELEMENT_NAME_SIZE] - ]; - for "_i" from 1 to _indentCount do { - _leadingSpace pushBack "-"; - }; - _leadingSpace pushBack " | "; - - // make header line - private _lines = [ - format[ - "%3%4", - _ELEMENT_NAME_SIZE, - getText(_cfg >> "textColor"), - _leadingSpace joinString "", - getText (_cfg >> "callsign") - ] - ]; - - // make frequency lines - private _freqLeadingSpace = [ - format["| ", _ELEMENT_NAME_SIZE] - ]; - for "_i" from 1 to _indentCount + 4 do { - _freqLeadingSpace pushBack " "; - }; - _freqLeadingSpace pushBack ""; - _freqLeadingSpace = _freqLeadingSpace joinString ""; - - { - _x params ["_role", "_sr", "_lr"]; - - - private ["_srStr", "_lrStr"]; - if (count _sr > 0) then { - _srStr = format["SR [%1]", _sr joinString "/"]; - } else { - _srStr = "----"; - }; - if (count _lr > 0) then { - _lrStr = format["LR [%1]", _lr joinString "/"]; - } else { - _lrStr = "----"; - }; - - - _lines pushBack format[ - "%1- %4%5%6 -", - _freqLeadingSpace, - _ELEMENT_FREQ_SIZE, - _FREQ_TEXT_COLOR, - [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, - [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, - [_lrStr, "right", " ", 8] call milsim_fnc_padString - ]; - } forEach (getArray (_cfg >> "frequencies")); - - _lines; -}; - private _addToAllText = { params [["_lines", []]]; - _allText = format[ - "%1%2
", - _allText, - _lines joinString "
" - ]; -}; - -private _recurseAddElements = { - params ["_cfg", ["_indentCount", 1]]; - - // add config - private _lines = [_cfg, _indentCount] call _formatElementForDiary; - [_lines] call _addToAllText; - - // get children and recurse - _childCfgs = _cfg call BIS_fnc_returnChildren; - { - [_x, _indentCount+1] call _recurseAddElements; - } forEach _childCfgs; + _allText pushBack (_lines joinString "
"); }; //////////////////////////////////////// -_allText = " -=======------ Mission Data Set ------======= -

"; -private _battalionInfoCfgs = [call milsim_fnc_getBattalionCfg] call BIS_fnc_returnChildren; +private _battalionInfoCfg = call milsim_fnc_getBattalionCfg; +private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; private _ELEMENT_NAME_SIZE = 10; -private _ELEMENT_FREQ_SIZE = 8; -private _FREQ_PAD_LENGTH = 14; +private _ELEMENT_NAME_FONT = "EtelkaMonospaceProBold"; +private _ELEMENT_FREQ_SIZE = 9; +private _ELEMENT_FREQ_FONT = "EtelkaMonospacePro"; +private _FREQ_INDENT_CONSTANT = 6; +private _FREQ_PAD_LENGTH = 17; private _FREQ_TEXT_COLOR = "#CCCCCC"; + +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 +reverse _battalionElementCfgs; { - _x call _recurseAddElements; -} forEach _battalionInfoCfgs; + // recursively generate diary text for all child elements of battalion-level elements + private _diaryTitleText = [_x, true] call milsim_fnc_generateElementFrequencyRecordText; + [ + milsim_fbcb2_subjectFrequenciesID, + _diaryTitleText#0, + _diaryTitleText#1 + ] call milsim_fnc_createOrUpdateDiaryRecord; +} forEach _battalionElementCfgs; -_allText = format["%1
", _allText]; - -player createDiaryRecord ["Status", ["MDS - INTEL - RADIO FREQS", _allText]]; \ No newline at end of file +// add the battalion command to the top of the list +// don't process child elements +private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call milsim_fnc_generateElementFrequencyRecordText; +[ + milsim_fbcb2_subjectFrequenciesID, + _diaryTitleText#0, + _diaryTitleText#1 +] 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 new file mode 100644 index 0000000..8b5210c --- /dev/null +++ b/functions/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf @@ -0,0 +1,62 @@ +// called from milsim_fnc_processFBCB2RadioFrequencies +params ["_cfg", ["_indentCount", 1, [5]]]; + +private _leadingSpace = [ + format["| ", _ELEMENT_NAME_SIZE, _ELEMENT_NAME_FONT] +]; +for "_i" from 1 to _indentCount do { + _leadingSpace pushBack "-"; +}; +_leadingSpace pushBack " | "; + +// make header line +private _lines = [ + format[ + "%2%3", + getText(_cfg >> "textColor"), + _leadingSpace joinString "", + getText (_cfg >> "callsign") + ] +]; + +// make frequency lines +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 ""; + +{ + _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 = "----"; + }; + + + _lines pushBack format[ + "%1- %5%6%7", + _freqLeadingSpace, + _ELEMENT_FREQ_SIZE, + _ELEMENT_FREQ_FONT, + _FREQ_TEXT_COLOR, + [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + _lrStr + ]; +} forEach (getArray (_cfg >> "frequencies")); +// diag_log text (_lines joinString endl); + +_lines; \ No newline at end of file diff --git a/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf b/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf new file mode 100644 index 0000000..d66f07a --- /dev/null +++ b/functions/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf @@ -0,0 +1,60 @@ +// called from milsim_fnc_processFBCB2RadioFrequencies +params [ + ["_elementCfg", configNull, [configNull]], + ["_shouldProcessChildCfgs", true] +]; + +if (isNull _elementCfg) exitWith { + ["_elementCfg parameter is NULL"] call BIS_fnc_error; +}; + +private _battalionElement = _elementCfg; + +private _recordTitle = format[ + "%1 (%2)", + getText(_battalionElement >> "callsign"), + getText(_battalionElement >> "shortDescription") +]; +// systemChat _recordTitle; + +private _headers = [ + format[ + "%4

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

", + _freqLeadingSpace, + _ELEMENT_FREQ_SIZE, + _ELEMENT_FREQ_FONT, + _FREQ_TEXT_COLOR, + ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + ["SR", "right", " ", _FREQ_PAD_LENGTH] call milsim_fnc_padString, + "LR" + ] +]; + +private _allText = []; + +// get all child elements recursively and format them +if (_shouldProcessChildCfgs) then { + [_battalionElement, { + params ["_cfg", "_recurseCounter"]; + // add config + private _lines = [_cfg, _recurseCounter+1] call milsim_fnc_formatRadioElementForDiary; + // private _lines = [_cfg, _indentCount] call t; + _allText pushBack (_lines joinString "
"); + }] call milsim_fnc_recurseSubclasses; +} else { + private _lines = [_battalionElement, 1] call milsim_fnc_formatRadioElementForDiary; + // private _lines = [_cfg, _indentCount] call t; + _allText pushBack (_lines joinString "
"); +}; + + +_allText = format["%1%2", _headers joinString "
", _allText joinString "
"]; + +[_recordTitle, _allText]; \ No newline at end of file diff --git a/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf b/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf new file mode 100644 index 0000000..89380e8 --- /dev/null +++ b/functions/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf @@ -0,0 +1,18 @@ +params [ + ["_subjectID", milsim_fbcb2_subjectStatusID, [""]], + ["_recordTitle", "", [""]], + ["_recordText", "", [""]] +]; + +// Check if already created +private _subjectRecords = milsim_fbcb2_diaryRecords getOrDefault [_subjectID, createHashMap, true]; +private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true]; + +if (!isNull _existingRecord) then { + player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText]]; + systemChat format ["Updated diary record: %1", _recordTitle]; +} else { + private _new = player createDiaryRecord [_subjectID, [_recordTitle, _recordText]]; + _subjectRecords set [_recordTitle, _new]; + milsim_fbcb2_diaryRecords set [_subjectID, _subjectRecords]; +}; \ No newline at end of file diff --git a/functions/util/fn_recurseSubclasses.sqf b/functions/util/fn_recurseSubclasses.sqf index 6d483f5..b4ba431 100644 --- a/functions/util/fn_recurseSubclasses.sqf +++ b/functions/util/fn_recurseSubclasses.sqf @@ -5,10 +5,21 @@ params [ if (isNull _cfg) exitWith {["Provided config is null!"] call BIS_fnc_error}; -[_cfg] call _code; -// get children and recurse -private _childCfgs = _cfg call BIS_fnc_returnChildren; -{ - [_x, _code] call milsim_fnc_recurseSubclasses; -} forEach _childCfgs; \ No newline at end of file +private _recurseFnc = { + params ["_cfg", "_code", ["_recurseCounter", 0]]; + [_cfg, _recurseCounter] call _code; + // get children and recurse + private _childCfgs = _cfg call BIS_fnc_returnChildren; + if (count _childCfgs isEqualTo 0) exitWith {false}; + + { + [_x, _code, _recurseCounter + 1] call _recurseFnc; + } forEach _childCfgs; + false; +}; + +private _continue = true; +while {_continue} do { + _continue = [_cfg, _code] call _recurseFnc; +}; \ No newline at end of file From 1e4a5a79a8009c00f7e3d95317e6118d4e988771 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Thu, 1 Feb 2024 20:48:30 -0800 Subject: [PATCH 3/3] 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