Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong value in UI (Chapter 52) #219

Open
PierreGuyot opened this issue Dec 27, 2024 · 0 comments
Open

Wrong value in UI (Chapter 52) #219

PierreGuyot opened this issue Dec 27, 2024 · 0 comments

Comments

@PierreGuyot
Copy link

PierreGuyot commented Dec 27, 2024

So we fetch the map from the ECS `World`, calculate the name's length (plus two for the wrapping characters). Then we figure out the centered position (over the map pane; so 22, half the pane width, *minus* half the length of the name). Then we draw the endcaps and the name. You can `cargo run` to see the improvement:

From what I understand, the half width is 24, and not 22 (that would be the half height of the pane).
The title doesn't seem to be centered on the matching screen.

What about extracting size constants to make the UI code easier to read? Something like this:

const STATUS_BOX_HEIGHT: i32 = 8; // Top-right panel
pub const CAMERA_WIDTH: i32 = 48;
pub const CAMERA_HEIGHT: i32 = 44;
pub const SCREEN_WIDTH: i32 = 80;
pub const SCREEN_HEIGHT: i32 = 60;

(The screen constants are already needed in main.rs for example, so it might help to have a single source of truth for these.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant