Skip to content

Conversation

johannes-el
Copy link
Contributor

@johannes-el johannes-el commented Jul 4, 2025

Fixes #3081

supertux

Copy link
Member

@tobbi tobbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

Copy link
Member

@bruhmoent bruhmoent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please try calculating the position values instead of hardcoding them? Not the biggest fan of magic numbers, as having to alter them every single time the text changes is quite cumbersome.

@johannes-el
Copy link
Contributor Author

johannes-el commented Jul 4, 2025

@bruhmoent
Like this?

constexpr int box_x_offset = -10;

int box_w = 220+110+110;
int box_h = 30+20+20+20;
int box_x = static_cast<int>((static_cast<int>(context.get_width()) - box_w) / 2) - box_x_offset;
int box_y = static_cast<int>(SCREEN_HEIGHT / 2) - box_h;

int bd_w = static_cast<int>(backdrop->get_width());
int bd_h = static_cast<int>(backdrop->get_height());
int bd_x = static_cast<int>((static_cast<int>(context.get_width()) - bd_w) / 2);
int bd_y = box_y + (box_h / 2) - (bd_h / 2);

float col1_x = static_cast<float>(box_x);
float col2_x = col1_x + 200.0f;
float col3_x = col2_x + 130.0f;

float y_offset = 35.f;
if (m_preferences.enable_coins)
  y_offset -= 7.f;
if (m_preferences.enable_badguys)
  y_offset -= 7.f;
if (m_preferences.enable_secrets)
  y_offset -= 7.f;

I'm a bit confused. I'm aware that -10 is a bit magic, but what do you propose? How should I calculate this?
I can define a const for it, but I thought aligning it a bit more left looks better.

@bruhmoent
Copy link
Member

One way to do this is by defining a vector with the column widths - so when a change is made, the code will automatically update the appropriate values. You could then calculate a total width of all the columns, and with that the x column positions. After that, you could define clear and concise helper variables, responsible for things like the row's height, label's indent, etc; to allow for it to be easily changeable. Also, const correctness would be nice to include.

@Alasdairbugs Alasdairbugs added this to the 0.7.1 milestone Jul 15, 2025
Copy link
Member

@Frostwithasideofsalt Frostwithasideofsalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

twerks sooo hard

@bruhmoent bruhmoent merged commit 29a4bfe into SuperTux:master Jul 18, 2025
33 checks passed
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

Successfully merging this pull request may close these issues.

Level-complete statistics text is offset
5 participants