big refactor, WIP!
This commit is contained in:
112
framework/fbcb2_main/functions/fn_addEnvironmentRecord.sqf
Normal file
112
framework/fbcb2_main/functions/fn_addEnvironmentRecord.sqf
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
private _recordTitle = "ENVIRONMENTAL CONDITIONS";
|
||||
|
||||
private _text = [
|
||||
format[
|
||||
"<font size='%1' color='%2' face='%3'>%4</font>",
|
||||
GVAR(recordTitleSize),
|
||||
GVAR(recordTitleColor),
|
||||
GVAR(recordTitleFont),
|
||||
_recordTitle
|
||||
]
|
||||
];
|
||||
|
||||
private _sunriseColor = "#4A86E8";
|
||||
private _sunsetColor = "#6AA84F";
|
||||
private _whiteColor = "#FFFFFF";
|
||||
|
||||
private _sunTimes = date call BIS_fnc_sunriseSunsetTime;
|
||||
private _nearestBase = [player] call EFUNC(common,getNearestBase);
|
||||
|
||||
if (isNull _nearestBase) exitWith {
|
||||
[
|
||||
LEVEL_WARNING,
|
||||
QUOTE(COMPONENT),
|
||||
"WARNING: No bases found nearby to report weather!",
|
||||
[player, [
|
||||
["position", getPos player]
|
||||
]] call EFUNC(common,addPlayerInfoToArray)
|
||||
] call EFUNC(common,log);
|
||||
["WARNING: No bases found nearby to report weather!"] call BIS_fnc_error;
|
||||
};
|
||||
|
||||
_text pushBack format[
|
||||
"<font size='%1'>Current conditions at nearest weather station: %2</font><br/>",
|
||||
GVAR(recordTextBodySize),
|
||||
[_nearestBase] call EFUNC(common,getNameOfBase)
|
||||
];
|
||||
|
||||
private _weatherData = [];
|
||||
|
||||
if (isClass (configFile >> "CfgPatches" >> "ace_weather")) then {
|
||||
// get ace_weather data
|
||||
private _barometricPressure = ((getPosASL _nearestBase)#2) call ace_weather_fnc_calculateBarometricPressure;
|
||||
private _relHumidity = missionNamespace getVariable ["ace_weather_currentHumidity", 0.5];
|
||||
private _temperature = ((getPosASL _nearestBase)#2) call ace_weather_fnc_calculateTemperatureAtHeight;
|
||||
private _dewPoint = [_temperature, _relHumidity] call ace_weather_fnc_calculateDewPoint;
|
||||
private _windSpeed = [getPosASL _nearestBase, false, false, false] call ace_weather_fnc_calculateWindSpeed;
|
||||
private _windChill = [_temperature, _windSpeed] call ace_weather_fnc_calculateWindChill;
|
||||
private _heatIndex = [_temperature, _relHumidity] call ace_weather_fnc_calculateHeatIndex;
|
||||
|
||||
toFixed 2;
|
||||
private _aceData = [
|
||||
["Temperature", format["%1°C / %2°F", _temperature, _temperature * (9/5) + 32]],
|
||||
["Wind Chill", format["%1°C / %2°F", _windChill, _windChill * (9/5) + 32]],
|
||||
["Heat Index", format["%1°C / %2°F", _heatIndex, _heatIndex * (9/5) + 32]],
|
||||
["Dew Point", format["%1°C / %2°F", _dewPoint, _dewPoint * (9/5) + 32]],
|
||||
["Wind Speed", format["%1mph / %2kph / %3kts", _windSpeed * 2.237, _windSpeed * 3.6, _windSpeed * 1.944]],
|
||||
["Wind Direction", ""],
|
||||
["Barometric Pressure", format["%1 hPA", _barometricPressure]],
|
||||
["Relative Humidity", format["%1%2", _relHumidity * 100, "%"]],
|
||||
["Fog Cover", ""],
|
||||
["Rain", ""],
|
||||
["Overcast", ""]
|
||||
];
|
||||
toFixed -1;
|
||||
|
||||
{
|
||||
_x params ["_name", "_value"];
|
||||
[_weatherData, _name, _value] call BIS_fnc_setToPairs;
|
||||
} forEach _aceData;
|
||||
};
|
||||
|
||||
// always add built-in weather
|
||||
toFixed 2;
|
||||
private _vanillaData = [
|
||||
["Temperature", format["%1°C", (ambientTemperature)#0]],
|
||||
["Fog Cover", format["%1%2", fog * 100, "%"]],
|
||||
["Overcast", format["%1%2", overcast * 100, "%"]],
|
||||
["Rain", format["%1%2", rain * 100, "%"]],
|
||||
["Wind Speed", format["%1m/s", windStr]],
|
||||
["Wind Direction", format["%1°", windDir]]
|
||||
];
|
||||
toFixed -1;
|
||||
|
||||
_vanillaData pushBack ["Sunrise", ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString)];
|
||||
_vanillaData pushBack ["Sunset", ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString)];
|
||||
|
||||
// override or set keys for vanilla data into weather data
|
||||
{
|
||||
_x params ["_name", "_value"];
|
||||
[_weatherData, _name, _value] call BIS_fnc_setToPairs;
|
||||
} forEach _vanillaData;
|
||||
|
||||
// write lines
|
||||
{
|
||||
_x params ["_name", "_value"];
|
||||
_text pushBack format[
|
||||
"<font size='%1' face='EtelkaMonospacePro'>%2%3</font>",
|
||||
GVAR(recordTextBodySize)-4,
|
||||
[_name, "right", " ", 23] call EFUNC(common,padString),
|
||||
_value
|
||||
];
|
||||
} forEach _weatherData;
|
||||
|
||||
_text = _text joinString "<br/>";
|
||||
|
||||
[
|
||||
GVAR(subjectIntelID),
|
||||
_recordTitle,
|
||||
_text
|
||||
] call FUNC(createOrUpdateDiaryRecord);
|
||||
@@ -6,22 +6,24 @@
|
||||
////////////////////////////////////////
|
||||
// Get info from missionConfigFile
|
||||
////////////////////////////////////////
|
||||
private _battalionInfoCfg = call EFUNC(util,getBattalionCfg);
|
||||
private _battalionInfoCfg = call EFUNC(common,getBattalionCfg);
|
||||
if (isNull _battalionInfoCfg) exitWith {
|
||||
[
|
||||
LEVEL_ERROR,
|
||||
QUOTE(COMPONENT),
|
||||
"Null Battalion Config",
|
||||
[]
|
||||
] call EFUNC(util,log);
|
||||
] call EFUNC(common,log);
|
||||
};
|
||||
|
||||
private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren;
|
||||
if (count _battalionElementCfgs == 0) exitWith {
|
||||
[
|
||||
LEVEL_ERROR,
|
||||
QUOTE(COMPONENT),
|
||||
"ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.",
|
||||
[]
|
||||
] call EFUNC(util,log);
|
||||
] call EFUNC(common,log);
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
59
framework/fbcb2_main/functions/fn_addSignalColorsRecord.sqf
Normal file
59
framework/fbcb2_main/functions/fn_addSignalColorsRecord.sqf
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "../script_component.hpp"
|
||||
|
||||
private _recordTitle = "SIGNAL COLORS";
|
||||
|
||||
private _text = [
|
||||
// Title
|
||||
format[
|
||||
"<font size='%1' color='%2' face='%3'>%4</font>",
|
||||
GVAR(recordTitleSize),
|
||||
GVAR(recordTitleColor),
|
||||
GVAR(recordTitleFont),
|
||||
_recordTitle
|
||||
]
|
||||
];
|
||||
|
||||
private _signalColorDefs = (missionConfigFile >> "SignalColors") call BIS_fnc_returnChildren;
|
||||
|
||||
{
|
||||
private _cfg = _x;
|
||||
private _color = getText(_cfg >> "hexCode");
|
||||
private _name = getText(_cfg >> "name");
|
||||
private _usage = getText(_cfg >> "usage");
|
||||
private _itemExamples = getArray(_cfg >> "itemExamples");
|
||||
|
||||
private _thisText = [];
|
||||
|
||||
_thisText pushBack format[
|
||||
"<font size='%1'><font color='%2'>%3</font> - %4</font>",
|
||||
GVAR(recordTextHeaderSize),
|
||||
_color,
|
||||
_name,
|
||||
_usage
|
||||
];
|
||||
|
||||
private _imagesLine = [];
|
||||
|
||||
{
|
||||
private _itemClassname = _x;
|
||||
private _itemCfg = [_itemClassname] call CBA_fnc_getItemConfig;
|
||||
private _itemName = getText(_itemCfg >> "displayName");
|
||||
private _itemImage = getText(_itemCfg >> "picture");
|
||||
_imagesLine pushBack format[
|
||||
"<img height='32' src='%1' title='%2'/>",
|
||||
_itemImage,
|
||||
_itemName
|
||||
];
|
||||
} forEach _itemExamples;
|
||||
|
||||
_thisText pushBack (_imagesLine joinString " ");
|
||||
_text pushBack (_thisText joinString "<br/>");
|
||||
} forEach _signalColorDefs;
|
||||
|
||||
_text = _text joinString "<br/><br/>";
|
||||
|
||||
[
|
||||
GVAR(subjectIntelID),
|
||||
_recordTitle,
|
||||
_text
|
||||
] call FUNC(createOrUpdateDiaryRecord);
|
||||
@@ -34,6 +34,21 @@ player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"];
|
||||
GVAR(diaryRecords) = createHashMap;
|
||||
|
||||
// run main inits - assets handled in that component
|
||||
[] call FUNC(processFBCB2RadioFrequencies);
|
||||
[] call FUNC(processFBCB2SmokeColors);
|
||||
[] call FUNC(processFBCB2Environment);
|
||||
[] call FUNC(addFrequenciesRecord);
|
||||
[] call FUNC(addSignalColorsRecord);
|
||||
[] call FUNC(addEnvironmentRecord);
|
||||
|
||||
// starting 5 minutes after postInit, update weather diary record every 5 minutes
|
||||
[{
|
||||
[
|
||||
{call FUNC(addEnvironmentRecord);},
|
||||
60*5
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
}, 60*5] call CBA_fnc_waitAndExecute;
|
||||
|
||||
[
|
||||
LEVEL_DEBUG,
|
||||
QUOTE(COMPONENT),
|
||||
"postInit complete",
|
||||
[]
|
||||
] call EFUNC(common,log);
|
||||
@@ -1,47 +0,0 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
private _recordTitle = "MDS - INTEL - ENVIRONMENT";
|
||||
|
||||
private _text = [
|
||||
format[
|
||||
"<font size='%1' color='%2' face='%3'>%4</font><br/><br/>",
|
||||
GVAR(recordTitleSize),
|
||||
GVAR(recordTitleColor),
|
||||
GVAR(recordTitleFont),
|
||||
_recordTitle
|
||||
]
|
||||
];
|
||||
|
||||
private _sunriseColor = "#4A86E8";
|
||||
private _sunsetColor = "#6AA84F";
|
||||
private _whiteColor = "#FFFFFF";
|
||||
|
||||
private _sunTimes = date call BIS_fnc_sunriseSunsetTime;
|
||||
|
||||
_text pushBack format[
|
||||
"<font size='%1' color='%2'>Local Sunrise</font><br/>
|
||||
<font size='%3' color='%4'>%5</font><br/><br/>",
|
||||
GVAR(recordTextHeaderSize),
|
||||
_sunriseColor,
|
||||
GVAR(recordTextBodySize),
|
||||
_whiteColor,
|
||||
([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString)
|
||||
];
|
||||
|
||||
_text pushBack format[
|
||||
"<font size='%1' color='%2'>Local Sunset</font><br/>
|
||||
<font size='%3' color='%4'>%5</font><br/><br/>",
|
||||
GVAR(recordTextHeaderSize),
|
||||
_sunsetColor,
|
||||
GVAR(recordTextBodySize),
|
||||
_whiteColor,
|
||||
([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString)
|
||||
];
|
||||
|
||||
_text = _text joinString "";
|
||||
|
||||
[
|
||||
GVAR(subjectIntelID),
|
||||
_recordTitle,
|
||||
_text
|
||||
] call FUNC(createOrUpdateDiaryRecord);
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "../script_component.hpp"
|
||||
|
||||
private _recordTitle = "MDS - INTEL - SMOKES";
|
||||
|
||||
private _text = [
|
||||
// Title
|
||||
format[
|
||||
"<font size='%1' color='%2' face='%3'>%4</font>",
|
||||
GVAR(recordTitleSize),
|
||||
GVAR(recordTitleColor),
|
||||
GVAR(recordTitleFont),
|
||||
_recordTitle
|
||||
]
|
||||
];
|
||||
|
||||
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[
|
||||
"<font size='%1'><font color='%2'>%3</font> - %4</font>",
|
||||
GVAR(recordTextHeaderSize),
|
||||
_color,
|
||||
_name,
|
||||
_description
|
||||
];
|
||||
} forEach _smokeColors;
|
||||
|
||||
_text = _text joinString "<br/><br/>";
|
||||
|
||||
[
|
||||
GVAR(subjectIntelID),
|
||||
_recordTitle,
|
||||
_text
|
||||
] call FUNC(createOrUpdateDiaryRecord);
|
||||
@@ -15,7 +15,9 @@ private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecor
|
||||
|
||||
if (!isNull _existingRecord) then {
|
||||
player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]];
|
||||
systemChat format ["Updated diary record: %1", _recordTitle];
|
||||
if (DEBUG_ENABLED) then {
|
||||
systemChat format ["Updated diary record: %1", _recordTitle];
|
||||
};
|
||||
} else {
|
||||
private _new = player createDiaryRecord [
|
||||
_subjectID,
|
||||
|
||||
@@ -64,8 +64,8 @@ _freqLeadingSpace = _freqLeadingSpace joinString "";
|
||||
_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),
|
||||
[_role, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString),
|
||||
[_srStr, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString),
|
||||
_lrStr
|
||||
];
|
||||
} forEach (getArray (_cfg >> "frequencies"));
|
||||
|
||||
@@ -54,8 +54,8 @@ private _headers = [
|
||||
_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),
|
||||
["ROLE", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString),
|
||||
["SR", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(common,padString),
|
||||
"LR"
|
||||
]
|
||||
];
|
||||
@@ -68,26 +68,27 @@ 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
|
||||
];
|
||||
[
|
||||
LEVEL_TRACE,
|
||||
QUOTE(COMPONENT),
|
||||
"Processing child elements for battalion element %1"
|
||||
] call EFUNC(common,log);
|
||||
|
||||
[_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);
|
||||
}] call EFUNC(common,recurseSubclasses);
|
||||
} else {
|
||||
diag_log text format[
|
||||
"[%1] <%2> Processing %3",
|
||||
QUOTE(PREFIX),
|
||||
_fnc_scriptName,
|
||||
configName _battalionElement
|
||||
];
|
||||
[
|
||||
LEVEL_TRACE,
|
||||
QUOTE(COMPONENT),
|
||||
"Skipping processing of child elements for battalion element %1",
|
||||
[]
|
||||
] call EFUNC(common,log);
|
||||
|
||||
// or if the param was false, just add the battalion element
|
||||
private _lines = [_battalionElement, 1] call FUNC(formatRadioElementForDiary);
|
||||
// private _lines = [_cfg, _indentCount] call t;
|
||||
|
||||
Reference in New Issue
Block a user