malachid

malachid

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!

Marked As Solved

malachid

malachid

I figured it out.

ctx.mouse_pos vs ctx.mouse_pos()

Need to be careful about the auto-complete.

Popular Pragmatic Bookshelf topics Top

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
raul
Page 28: It implements io.ReaderAt on the store type. Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt? ...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
jwandekoken
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: d...
New

Other popular topics Top

siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New

Latest in Hands-on Rust

Hands-on Rust Portal