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!

0 619 1

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...
4 983 0
New
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
4 1231 1
New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
8 1923 7
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
2 1425 11
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
0 2667 2
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
17 1372 9
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
1 1265 2
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
0 1761 6
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
0 1127 1
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...
0 2059 6
New

Other popular topics Top

dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
177 8632 77
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
243 5922 95
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
37 2727 14
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
32 3916 9
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
4 4891 0
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
21 5598 9
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
72 3959 21
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
37 3237 14
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
0 2781 0
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
0 2183 2
New

Sub Categories: