Jump to content
Sign in to follow this  
austin_medic

[CODE SNIPPET] Marker Color Names to Arrays

Recommended Posts

I'm not quite sure why the getMarkerColor command returns a string instead of an array of RGBA values that make up the color. Though it's a bit annoying when you need the RGBA values but only have a string, which is why I made up this little function to convert the color strings to arrays:

[spoiler]AUSMD_markerColorToArray =
{
_color = _this select 0;
_ret = [0,0,0,1]; //default value
switch(_color) do
{
	case "Default": {_ret = [0,0,0,1];};
	case "ColorBlack": {_ret = [0,0,0,1];};
	case "ColorBlue": {_ret = [0,0,1,1];};
	case "ColorGreen": {_ret = [0,1,0,1];};
	case "ColorWhite": {_ret = [1,1,1,1];};
	case "ColorPink": {_ret = [0.980,0.196,0.784,1];};
	case "colorBlue": {_ret = [0,0,1,1];};
	case "ColorGrey": {_ret = [0.5,0.5,1];};
	case "ColorYellow": {_ret = [1,1,0.0588,1];};
	case "ColorRed": {_ret = [1,0,0,1];};
	case "ColorRedAlpha": {_ret = [1,0,0,1];};
	case "ColorGreenAlpha": {_ret = [0,1,0,1];};
	case "colorBLUFOR": {_ret = [0,0,1,1];};
	case "ColorCIV": {_ret = [0.72549,0,1,1];};
	case "ColorCivilian": {_ret = [0.72549,0,1,1];};
	case "ColorEast": {_ret = [1,0,0,1];};
	case "ColorGUER": {_ret = [0,1,0,1];};
	case "ColorUNKNOWN": {_ret = [0,0,0,1];};
	case "Color1_FD_F": {_ret = [0.694,0.2,0.223,1];};
	case "Color2_FD_F": {_ret = [0.678,0.749,0.513,1];};
	case "Color3_FD_F": {_ret = [0.941176,0.509804,0.192157,1];};
	case "Color4_FD_F": {_ret = [0.403922,0.545098,0.607843,1];};
	};
_ret
};[/spoiler]

Share this post


Link to post
Share on other sites

You could have just looked it up in the config CFGMarkerColors.

_color = _this select 0;
_colorArrayRGBA = getArray ( configfile >> "CfgMarkerColors" >> _color >> "color" );
if ( _colorArrayRGBA isEqualTo [] ) then {
_colorArrayRGBA = [ 0, 0, 0, 1 ];
};

Share this post


Link to post
Share on other sites
You could have just looked it up in the config CFGMarkerColors.

_color = _this select 0;
_colorArrayRGBA = getArray ( configfile >> "CfgMarkerColors" >> _color >> "color" );
if ( _colorArrayRGBA isEqualTo [] ) then {
_colorArrayRGBA = [ 0, 0, 0, 1 ];
};

That doesnt work for all colors. For some of them it returns some weird GUI variable string that the player sets for the faction colors.

Share this post


Link to post
Share on other sites

There's a function for that ;)

_colorRGBA = (configfile >> "CfgMarkerColors" >> _color >> "color") call BIS_fnc_colorConfigToRGBA;

Share this post


Link to post
Share on other sites
For some of them it returns some weird GUI variable string that the player sets for the faction colors.

They are code as a string, these only need to be call compiled to retrieve the profileNamespace variables contents...

_color = _this select 0;
_colorRGBA = getArray ( configfile >> "CfgMarkerColors" >> _color >> "color" );
if ( _colorRGBA isEqualTo  [] ) then {
_colorRGBA = [ 0, 0, 0, 1 ];	
}else{
if ( typeName ( _colorRGBA select 0 ) == typeName "" ) then {
	{
		_colorRGBA set [ _forEachIndex, call compile _x ];
	}forEach _colorRGBA;
}; 
};
_colorRGBA

or as Moricky shows, use his helper function thats already available.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×