Skip to content

Commit c7894e1

Browse files
committed
fix: end sequence panel layout and logic
1 parent 2870556 commit c7894e1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/supertux/statistics.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <algorithm>
2222
#include <iomanip>
2323
#include <limits>
24+
#include <numeric>
2425

2526
#include <simplesquirrel/table.hpp>
2627

@@ -264,10 +265,22 @@ Statistics::draw_endseq_panel(DrawingContext& context, Statistics* best_stats, c
264265

265266
int layer = LAYER_GUI + 50;
266267

267-
int box_w = 220+110+110;
268-
int box_h = 30+20+20+20;
269-
int box_x = static_cast<int>((static_cast<int>(context.get_width()) - box_w) / 2);
270-
int box_y = static_cast<int>(SCREEN_HEIGHT / 2) - box_h;
268+
const std::vector<int> column_widths = {220, 110, 110};
269+
const int box_w = std::accumulate(column_widths.begin(), column_widths.end(), 0);
270+
271+
constexpr int row_height = 20;
272+
constexpr int padding_top = 30;
273+
constexpr int padding_bottom = 10;
274+
275+
int visible_rows = 1;
276+
if (m_preferences.enable_coins) ++visible_rows;
277+
if (m_preferences.enable_badguys) ++visible_rows;
278+
if (m_preferences.enable_secrets) ++visible_rows;
279+
280+
const int box_h = padding_top + (visible_rows * row_height) + padding_bottom;
281+
282+
const int box_x = ((static_cast<int>(context.get_width()) - box_w) / 2) - 10;
283+
const int box_y = static_cast<int>(SCREEN_HEIGHT / 2) - box_h;
271284

272285
int bd_w = static_cast<int>(backdrop->get_width());
273286
int bd_h = static_cast<int>(backdrop->get_height());
@@ -278,13 +291,13 @@ Statistics::draw_endseq_panel(DrawingContext& context, Statistics* best_stats, c
278291
float col2_x = col1_x + 200.0f;
279292
float col3_x = col2_x + 130.0f;
280293

281-
float y_offset = 47.f;
294+
float y_offset = 35.f;
282295
if (m_preferences.enable_coins)
283-
y_offset -= 9.f;
296+
y_offset -= 7.f;
284297
if (m_preferences.enable_badguys)
285-
y_offset -= 9.f;
298+
y_offset -= 7.f;
286299
if (m_preferences.enable_secrets)
287-
y_offset -= 9.f;
300+
y_offset -= 7.f;
288301

289302
float y = static_cast<float>(box_y);
290303

0 commit comments

Comments
 (0)