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.

Where Next?

Popular Pragmatic Bookshelf topics Top

iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
New
nicoatridge
Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New

Sub Categories: