Jump to content
JSD

Help with drawIcon map icons

Recommended Posts

I'm trying to learn some scripting and decided to try and create map markers that fade when you zoom in on your map, but I can't get it to work at all with how I'm trying to do it, and it seems to give no errors. It would be awesome if anyone is able to point me in the right direction. I'll copy my files down here:


init.sqf

JSD_Fnc_Drawmapicons = compile preprocessFileLineNumbers "JSD_Fnc_Drawmapicons.sqf";

execVM "JSD_Drawmapicons_Icons.sqf";
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {
  _this call JSD_Fnc_Drawmapicons_Test;
}];

 

JSD_Drawmapicons_icons.sqf

JSD_Drawmapicons_Icons =
[
	[	"TOP", 		"Saint Louis", 		JSD_Icon_Empty, 			[1,1,1], 		[7132.977,8963.188], 		0,		0,			0.1,			"PuristaBold", 	"center", 2],
	[	"TOP", 		"La Trinite", 		JSD_Icon_Empty, 			[1,1,1], 		[7240.061,7929.14], 		0,		0,			0.1,			"PuristaBold", 	"center", 2]
];

 

JSD_Fnc_Drawmapicons.sqf

//_map = _this select 0;
{
	_mapScale = ctrlMapScale (_this select 0);

	_layer			= _x select 0;
	_mrkTxt			= _x select 1;
	_mrkIcon 		= _x select 2;
	_mrkRGB			= + _x select 3;
	_mrkPos			= _x select 4;
	_mrkW			= _x select 5;
	_mrkH			= _x select 6;
	_mrkTxtSize		= _x select 7;
	_mrkFont		= _x select 8;
	_align 			= _x select 9;
	_shadow			= _x select 10;

	_mrkA = switch (_layer) do {
		case "NONE": 	{ 	1											};
		case "TOP": 	{	1 - (_mapScale				-1.45	)	^30 };
		case "MID": 	{	1 - (_mapScale	* 18				)	^10 };
		case "LOW": 	{	1 - (_mapScale	* 4		-115		)	^40 };
	};
	_mrkRGB pushBack _mrkA;

	_mrkRGB = [1,1,1,1];

	_mrkTxtSize2 = _mrkTxtSize/ctrlMapScale (_this select 0);

	if (_mrkA > 0) then
	{
		_this select 0 drawIcon [
			_mrkIcon,		// icon
			_mrkRGB,		// color: 			[RGBA]
			_mrkPos,		// position			[X, Y]
			_mrkW,			// width
			_mrkH,			// height
			0,				// angle
			_mrkTxt,		// text
			_shadow,		// shadow
			_mrkTxtSize,	// textSize
			_mrkFont,		// font
			_align			// align
		];
	};
} forEach JSD_Drawmapicons_Icons;

 

Thanks in advance!

Share this post


Link to post
Share on other sites

ah I copied the wrong one, init.sqf is meant to be:

JSD_Fnc_Drawmapicons = compile preprocessFileLineNumbers "JSD_Fnc_Drawmapicons.sqf";

execVM "JSD_Drawmapicons_Icons.sqf";
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {
  _this call JSD_Fnc_Drawmapicons;
}];

 

I made a new one to see if redoing it would work, it didn't . JSD_Fnc_Drawmapicons_Test and JSD_Fnc_Drawmapicons are the same thing.

Share this post


Link to post
Share on other sites

Did you try waitUntil {!isNull fiddisplay 12};  before doing anything with that display?

Share this post


Link to post
Share on other sites
9 hours ago, pierremgi said:

Did you try waitUntil {!isNull fiddisplay 12};  before doing anything with that display?

Nope, but I'll give it a shot, thanks. I did try a "waituntil {!isnull (finddisplay 46)};", but that didn't work.

 

I added "waituntil {!isnull (finddisplay 12)};" right before adding the EH, that didn't do it though.

I tried replacing all the variables in the drawIcon to regular ones which didn't work either.

 

After some more testing it shows the calculations I use for _mrkA are a bit off, fully zoomed out it's 0, and zooming in it goes down to -67927.4 rapidly. The calculations I used should look like this:
9rnUBiD.png

where X is the _mapScale (1 is zoomed out 0 is zoomed in) and y would be the _mrkA.

But even without calculating the _mrkA it won't work (that's also what I was trying a the time I copied over the files).

 

going back to the regular values (except _mrkA) and adding a hint:

hint format ["Text: %1 \nIcon: %2 \nRGB: %3 \nPos: %4 \nW,H: %5, %6 \nTxtSize: %7 \nFont: %8 \nalign: %9 \nshadow: %10", _mrkTxt, _mrkIcon, _mrkRGB, _mrkPos, _mrkW, _mrkH, _mrkTxtSize, _mrkFont, _align, _shadow];

shows that all values are what they're meant to be and that the EH does its thing on the map properly:
j26Gut8.png

Share this post


Link to post
Share on other sites

what exacly do you think should happen to marker colour after

 

_mrkRGB pushBack _mrkA;

	_mrkRGB = [1,1,1,1];

Share this post


Link to post
Share on other sites
1 minute ago, killzone_kid said:

what exacly do you think should happen to marker colour after

 


_mrkRGB pushBack _mrkA;

	_mrkRGB = [1,1,1,1];

I don't think I completely understand your question.

 

The idea with calculating the _mrkA that way is so that markers would fade in/out when you'd zoom in and out. But as it isn't working I decided to add "_mrkRGB = [1,1,1,1]" there so it'd just take that for the colour until I've fixed the calculations for _mrkA.

It might be a good one to mention I've also removed the following bit after copying it over here:

	if (_mrkA > 0) then { drawIcon etc.. };

As the _mrkA never seems to go above 0.
 

Share this post


Link to post
Share on other sites

I seem to have fixed it. I had: _mrkIcon = "";, changing that to a texture (I used "a3\ui_f\data\map\vehicleicons\iconman_ca.paa";) made the text show properly. It seems like it needs a texture to show anything. I should have probably gathered that from AgentRevolution's comment on the drawIcon wiki page: "If you want only text with no icon, you can use "#(argb,8,8,3)color(0,0,0,0)" as texture.".

Seems like I was just being a dummy as usual, apologies and thanks for the help!

Share this post


Link to post
Share on other sites
2 hours ago, JSD said:

I don't think I completely understand your question.

 

You change the _mrkRGB array value with pushBack and then immediately overwrite it with [1,1,1,1]. So my question why do you do it?

Share this post


Link to post
Share on other sites
4 minutes ago, killzone_kid said:

 

You change the _mrkRGB array value with pushBack and then immediately overwrite it with [1,1,1,1]. So my question why do you do it?

Ah yeah, well like I said the idea is to calculate the Alpha using the map zoom zo it fades away when you zoom in, but as the whole thing wasn't working I added the _mrkRGB = [1,1,1,1] bit to just make sure the colour wasn't messing it up, I removed the line now so it actually calculates the alpha properly. Too bad the zoom increments are a bit too big to notice a nice fade effect.

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

×