#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 EFUNC(common,createOrUpdateDiaryRecord);