Hands-on Rust: Mouse not scaling for the tooltips (151)

The layers in general are working, with the map, entities and hud. The tooltips are not showing up though. It seems that it is due to the filter failing in tooltips.rs. I verified that the source available from the site does run correctly, so I started comparing my code to yours - but am not seeing anything obvious. I tried adding some logging to both sets of code to see where it might be breaking.

In src/main.rs I tried adding a log:

ctx.set_active_console(0);
println!("mouse({}): {:?}", ctx.active_console, Point::from_tuple(ctx.mouse_pos));
self.resources.insert(Point::from_tuple(ctx.mouse_pos()));

If I move the mouse to the bottom right corner of the map, on both versions of the code, it shows that it is on console #0 with coordinates around x:2229 y:1354.

So next was in src/systems/tooltips.rs. Based on your comments here, I tried adding a log just before submitting the batch (drawing the log didn’t work).

println!("batch mouse: {:?}", *mouse_pos);
draw_batch.submit(10100).expect("Batch error");

Here, it differs.
For my code, this shows the mouse_pos at the same coordinates as listed in main.rs (ie: 2229x1354). For your code, it shows the mouse_pos at x:39 y:24.

I added more logging at the top of the tooltips.rs and the #[resource] mouse_pos: &Point is being populated with a different value between our two versions. Since the insert in the tick is the same, I thought maybe I configured the system incorrectly in main, but it’s the same there as well.

Any thoughts on why yours shows a large number during self.resources.insert(Point::from_tuple(ctx.mouse_pos)); but a smaller number during #[resource] mouse_pos: &Point? Mine shows the same number in both places.

Thanks for your help!

I figured it out.

ctx.mouse_pos vs ctx.mouse_pos()

Need to be careful about the auto-complete.