mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-08 19:50:23 -04:00
parent
7aa35798be
commit
df0af7afbc
@ -217,7 +217,18 @@ pub fn save() void { // MARK: save()
|
|||||||
guiZon.put(window.id, windowZon);
|
guiZon.put(window.id, windowZon);
|
||||||
}
|
}
|
||||||
|
|
||||||
main.files.cubyzDir().writeZon("gui_layout.zig.zon", guiZon) catch |err| {
|
// Merge with the old settings file to preserve unknown settings.
|
||||||
|
const oldZon: ZonElement = main.files.cubyzDir().readToZon(main.stackAllocator, "gui_layout.zig.zon") catch |err| blk: {
|
||||||
|
if(err != error.FileNotFound) {
|
||||||
|
std.log.err("Could not read gui_layout.zig.zon: {s}", .{@errorName(err)});
|
||||||
|
}
|
||||||
|
break :blk .null;
|
||||||
|
};
|
||||||
|
defer oldZon.deinit(main.stackAllocator);
|
||||||
|
|
||||||
|
oldZon.join(guiZon);
|
||||||
|
|
||||||
|
main.files.cubyzDir().writeZon("gui_layout.zig.zon", oldZon) catch |err| {
|
||||||
std.log.err("Could not write gui_layout.zig.zon: {s}", .{@errorName(err)});
|
std.log.err("Could not write gui_layout.zig.zon: {s}", .{@errorName(err)});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,18 @@ pub fn save() void {
|
|||||||
}
|
}
|
||||||
zonObject.put("keyboard", keyboard);
|
zonObject.put("keyboard", keyboard);
|
||||||
|
|
||||||
// Write to file:
|
// Merge with the old settings file to preserve unknown settings.
|
||||||
main.files.cubyzDir().writeZon(settingsFile, zonObject) catch |err| {
|
const oldZonObject: ZonElement = main.files.cubyzDir().readToZon(main.stackAllocator, settingsFile) catch |err| blk: {
|
||||||
|
if(err != error.FileNotFound) {
|
||||||
|
std.log.err("Could not read settings file: {s}", .{@errorName(err)});
|
||||||
|
}
|
||||||
|
break :blk .null;
|
||||||
|
};
|
||||||
|
defer oldZonObject.deinit(main.stackAllocator);
|
||||||
|
|
||||||
|
oldZonObject.join(zonObject);
|
||||||
|
|
||||||
|
main.files.cubyzDir().writeZon(settingsFile, oldZonObject) catch |err| {
|
||||||
std.log.err("Couldn't write settings to file: {s}", .{@errorName(err)});
|
std.log.err("Couldn't write settings to file: {s}", .{@errorName(err)});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user