[GUI] Visible path finding

I am trying to figure out how to do path-finding in my Test Mission Grid mod. I want the path to be visible and updated in real-time as you move the mouse around. There are plenty of path-finding routines on the Internet. That is not the problem.

The problem is, how do I show the path to the user in the GUI? Can I use the onUpdate field in the GUI screen? How do I determine the coordinates of the mouse on the screen?

Here is what the map grid looks like currently. There are only 16 cells.

Here is kind of what I want the visible path to look like.

Thanks!

1 Like

You could perhaps use the onMouseEnter/onMouseExit fields of the different cells to show/hide other (empty) elements, which in turn would have their visibilty statuses tested in the onUpdate field of the GUI screen ?

1 Like

I will have to try that, thanks!

Right now I have over twenty 256x256px TGA images per map cell. When a mouse hovers over a cell, some images are made visible and others are not. It works, but my map is only 4x4 cells. Will this scale well to large maps? How much memory is consumed?

Why do you over 20 images per cell ? Different background for different maps ?
(edit : you were talking about the arrow and path perhaps ?)

How have you done it ? You have only one tga file for one global maps I hope (no need to have them in separate files)

Yes, I mean the arrows and paths. How would I put them all in one huge TGA?

You can define where you take your image in your tga/dds file, by adding an uvRect param, as seen below :

BackgroundGraphic = {
	texture = "DATA:UI\\NewUI\\example.tga",
	--uvRect= {top-left corner x / width, top-left corner y / height, bottom-right corner x +1 / width, bottom-right corner y +1 / height},
	--{0,0} being the top left corner
	uvRect = { 0/128, 64/256, 64/128, 128/256},
},

example

In my example, the full image has a size of 128 by 256 but the code will only use the red square, from the pixel of coordinates 0,64 to the pixel of coordinates 63/127.

1 Like