Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556// Numeric layout checks for the framebuffer developer HUD.#include "../app/debug_ui.hpp"#include "sc2k/render/asset_loader.hpp"
#include <cstdio>
#include "test_harness.hpp"#include "test_paths.hpp"
using namespace sc2k;
int main() { const std::string fontPath = render::assets_dir() + "/fonts/NotoSans-Regular.ttf"; if (!exists(fontPath)) { std::printf("debug_ui: SKIP (no font at %s)\n", fontPath.c_str()); return 0; }
const std::vector<debug::DbgRow> rows = { {"field min/avg/max active cells", "", debug::kHdr}, {"Crime", "0/3/92 89"}, {"displayed-period commute routes", "", debug::kHdr}, {"success / attempts", "2258 / 2341"}, {"cost-limit / work-limit", "83 / 0"}, {"car / bus / rail / subway", "1672 / 0 / 0 / 586"}, }; ui::Font normal(fontPath, 15); ui::Font dense(fontPath, 30); const debug::DbgPanelGeometry normalGeometry = debug::debug_panel_geometry( normal, "DEBUG Fields [4/7] 79 fps", rows, 580, 8); const debug::DbgPanelGeometry denseGeometry = debug::debug_panel_geometry( dense, "DEBUG Fields [4/7] 79 fps", rows, 1160, 16);
CHECK(normalGeometry.x >= 8); CHECK(normalGeometry.x + normalGeometry.width <= 580); CHECK(denseGeometry.x >= 8); CHECK(denseGeometry.x + denseGeometry.width <= 1160); CHECK(denseGeometry.width >= normalGeometry.width * 19 / 10); CHECK(denseGeometry.rowHeight >= normalGeometry.rowHeight * 19 / 10);
render::Framebuffer framebuffer(1280, 800); framebuffer.clear({0, 0, 0, 0xFF}); debug::draw_panel(framebuffer, normal, "DEBUG Fields [4/7] 79 fps", rows, normalGeometry.x, normalGeometry.y, normalGeometry.width); for (int y = 0; y < framebuffer.height(); ++y) for (int x = 580; x < framebuffer.width(); ++x) CHECK(framebuffer.at(x, y).r == 0 && framebuffer.at(x, y).g == 0 && framebuffer.at(x, y).b == 0);
if (failures == 0) { std::puts("debug_ui: density scaling and toolbar-safe placement passed"); return 0; } std::printf("debug_ui: %d failure(s)\n", failures); return 1;}