Full-screen translucent FBC-style menu with BRIEFING/OPTIONS tabs, resolution (720p/900p/1080p/4K), RAW/POST FX, unlocked FPS and hidden dev UI. Settings persist to cntrl.cfg, CLI overrides stay authoritative, render targets resize with resolution. Added a settings unit test and README docs.
65 lines
2.3 KiB
C++
65 lines
2.3 KiB
C++
// Title-screen options: defaults, cycling and config round-trip.
|
|
#include <cstdio>
|
|
#include <filesystem>
|
|
|
|
#include "render/settings.hpp"
|
|
|
|
namespace {
|
|
|
|
bool failed = false;
|
|
|
|
void check(bool ok, const char* what) {
|
|
if (!ok) {
|
|
std::printf("FAIL: %s\n", what);
|
|
failed = true;
|
|
}
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main() {
|
|
settings::RuntimeSettings s;
|
|
settings::reset(s);
|
|
check(s.resolution == settings::Resolution::P900, "default resolution is 900p");
|
|
check(s.render_mode == settings::RenderMode::Raw, "default rendering is raw");
|
|
check(!s.unlock_fps, "frame rate starts capped");
|
|
check(s.hide_dev_ui, "dev UI starts hidden");
|
|
|
|
int w = 0, h = 0;
|
|
settings::resolution_dimensions(settings::Resolution::P720, w, h);
|
|
check(w == 1280 && h == 720, "720p dimensions");
|
|
settings::resolution_dimensions(settings::Resolution::P4K, w, h);
|
|
check(w == 3840 && h == 2160, "4K dimensions");
|
|
|
|
settings::cycle_resolution(s, +1);
|
|
check(s.resolution == settings::Resolution::P1080, "cycle forward to 1080p");
|
|
settings::cycle_resolution(s, -1);
|
|
check(s.resolution == settings::Resolution::P900, "cycle back to 900p");
|
|
s.resolution = settings::Resolution::P720;
|
|
settings::cycle_resolution(s, -1);
|
|
check(s.resolution == settings::Resolution::P4K, "resolution wraps backwards");
|
|
|
|
settings::cycle_render_mode(s, +1);
|
|
check(s.render_mode == settings::RenderMode::PostFx, "cycle into post FX");
|
|
settings::cycle_render_mode(s, +1);
|
|
check(s.render_mode == settings::RenderMode::Raw, "render mode wraps to raw");
|
|
|
|
const auto path = std::filesystem::temp_directory_path() / "cntrl_settings_test.cfg";
|
|
s.resolution = settings::Resolution::P1080;
|
|
s.render_mode = settings::RenderMode::PostFx;
|
|
s.unlock_fps = true;
|
|
s.hide_dev_ui = false;
|
|
check(settings::save(s, path.c_str()), "config file written");
|
|
|
|
settings::RuntimeSettings loaded;
|
|
check(settings::load(loaded, path.c_str()), "config file read");
|
|
check(loaded.resolution == settings::Resolution::P1080, "resolution persisted");
|
|
check(loaded.render_mode == settings::RenderMode::PostFx, "render mode persisted");
|
|
check(loaded.unlock_fps, "unlocked FPS persisted");
|
|
check(!loaded.hide_dev_ui, "dev UI visibility persisted");
|
|
std::filesystem::remove(path);
|
|
|
|
if (failed) return 1;
|
|
std::printf("settings: OK\n");
|
|
return 0;
|
|
}
|