#1171 - Safe get variables if settings not defined

This commit is contained in:
PabstMirror 2015-05-14 15:29:09 -05:00
parent 03130ab3c9
commit 2158f467f4

View File

@ -12,7 +12,7 @@
*/
#include "script_component.hpp"
private ["_menuDepth", "_mixColor", "_pathCount", "_row", "_shadowColor", "_textColor", "_textSize"];
private ["_menuDepth", "_mixColor", "_pathCount", "_row", "_shadowColor", "_textColor", "_textSize", "_colorShadowMax", "_colorShadowMin", "_colorTextMax", "_colorTextMin", "_shadowSetting"];
//Mixes 2 colors (number arrays) and makes a color string "#AARRGGBB" for structured text
_mixColor = {
@ -30,9 +30,16 @@ _mixColor = {
_return
};
_textColor = [GVAR(colorTextMin), GVAR(colorTextMax), 1] call _mixColor;
_shadowColor = [GVAR(colorShadowMin), GVAR(colorShadowMax), 1] call _mixColor;
_textSize = switch (GVAR(textSize)) do {
_colorTextMin = missionNamespace getVariable [QGVAR(colorTextMin), [1,1,1,0.25]];
_colorTextMax = missionNamespace getVariable [QGVAR(colorTextMax), [1,1,1,1]];
_colorShadowMin = missionNamespace getVariable [QGVAR(colorShadowMin), [0,0,0,0.25]];
_colorShadowMax = missionNamespace getVariable [QGVAR(colorShadowMax), [0,0,0,1]];
_shadowSetting = missionNamespace getVariable [QGVAR(shadowSetting), 2];
_textSize = missionNamespace getVariable [QGVAR(textSize), 2];
_textColor = [_colorTextMin, _colorTextMax, 1] call _mixColor;
_shadowColor = [_colorShadowMin, _colorShadowMax, 1] call _mixColor;
_textSize = switch (_textSize) do {
case (0): {0.4};
case (1): {0.6};
case (2): {0.8};
@ -40,20 +47,20 @@ _textSize = switch (GVAR(textSize)) do {
case (4): {1.2};
};
GVAR(colorSelectedSettings) = format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, GVAR(shadowSetting), _shadowColor];
GVAR(colorSelectedSettings) = format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, _shadowSetting, _shadowColor];
GVAR(textSettingsMatrix) = [];
for "_pathCount" from 0 to 15 do {
_row = [];
for "_menuDepth" from 0 to 15 do {
if (_menuDepth > 0) then {
_textColor = [GVAR(colorTextMin), GVAR(colorTextMax), (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor;
_shadowColor = [GVAR(colorShadowMin), GVAR(colorShadowMax), (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor;
_textColor = [_colorTextMin, _colorTextMax, (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor;
_shadowColor = [_colorShadowMin, _colorShadowMax, (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor;
} else {
_textColor = [GVAR(colorTextMin), GVAR(colorTextMax), 0] call _mixColor;
_shadowColor = [GVAR(colorShadowMin), GVAR(colorShadowMax), 0] call _mixColor;
_textColor = [_colorTextMin, _colorTextMax, 0] call _mixColor;
_shadowColor = [_colorShadowMin, _colorShadowMax, 0] call _mixColor;
};
_row pushBack format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, GVAR(shadowSetting), _shadowColor];
_row pushBack format ["color='%1' size='%2' shadow='%3' shadowColor='%4' shadowOffset='0.06'", _textColor, _textSize, _shadowSetting, _shadowColor];
};
GVAR(textSettingsMatrix) pushBack _row;
};