Compare commits

...

2 Commits

Author SHA1 Message Date
Martin Felis
f351939d61 Tiny cleanup. 2025-03-14 12:40:08 +01:00
Martin Felis
a977698336 Fixed crash when starting up and no proper application config was available. 2025-03-14 12:36:22 +01:00

View File

@ -117,6 +117,8 @@ struct Viewport {
sg_image depth_image = {};
int size[2] = {400, 400};
Viewport() { Resize(size[0], size[1]); }
void Resize(int width, int height) {
width = width < 1 ? 1 : width;
height = height < 1 ? 1 : height;
@ -191,7 +193,7 @@ struct ApplicationConfig {
AnimationPlayerWidget animation_player_widget;
struct ViewportWidget {
bool visible = false;
bool visible = true;
int position[2] = {20, 20};
int size[2] = {800, 500};
};
@ -203,7 +205,6 @@ struct ApplicationConfig {
};
void to_json(nlohmann::json& j, const ApplicationConfig& config) {
std::cerr << "converting to json" << std::endl;
j["type"] = "AnimTestbedConfig";
j["main_window"]["position"][0] = config.window_position[0];
@ -247,8 +248,6 @@ void to_json(nlohmann::json& j, const ApplicationConfig& config) {
}
void from_json(const nlohmann::json& j, ApplicationConfig& config) {
std::cerr << "converting from json" << std::endl;
if (j.contains("main_window")) {
if (j["main_window"].contains("position")
and j["main_window"]["position"].size() == 2) {