Fix Config File Generation

This commit is contained in:
Dark98
2026-01-21 22:45:55 +00:00
parent 76996225df
commit 6dbb3a8f1d
@@ -101,13 +101,26 @@ public class SliceBeam extends Application {
public static ConfigObject buildCurrentConfigObject() { public static ConfigObject buildCurrentConfigObject() {
ConfigObject singleObject = new ConfigObject(); ConfigObject singleObject = new ConfigObject();
singleObject.values.putAll(SliceBeam.CONFIG.findPrinter(SliceBeam.CONFIG.presets.get("printer")).values); ConfigObject printerConfig = SliceBeam.CONFIG.findPrinter(SliceBeam.CONFIG.presets.get("printer"));
if (SliceBeam.CONFIG.findPrint(SliceBeam.CONFIG.presets.get("print")) != null) { if (printerConfig != null) {
singleObject.values.putAll(SliceBeam.CONFIG.findPrint(SliceBeam.CONFIG.presets.get("print")).values); singleObject.values.putAll(printerConfig.values);
}
ConfigObject printConfig = SliceBeam.CONFIG.findPrint(SliceBeam.CONFIG.presets.get("print"));
if (printConfig != null) {
for (Map.Entry<String, String> en : printConfig.values.entrySet()) {
if (!Slic3rConfigWrapper.PRINTER_CONFIG_KEYS.contains(en.getKey())) {
singleObject.values.put(en.getKey(), en.getValue());
}
}
} }
// TODO: MMU. Detect by printerConfig#getExtruderCount() // TODO: MMU. Detect by printerConfig#getExtruderCount()
if (SliceBeam.CONFIG.findFilament(SliceBeam.CONFIG.presets.get("filament")) != null) { ConfigObject filamentConfig = SliceBeam.CONFIG.findFilament(SliceBeam.CONFIG.presets.get("filament"));
singleObject.values.putAll(SliceBeam.CONFIG.findFilament(SliceBeam.CONFIG.presets.get("filament")).values); if (filamentConfig != null) {
for (Map.Entry<String, String> en : filamentConfig.values.entrySet()) {
if (!Slic3rConfigWrapper.PRINTER_CONFIG_KEYS.contains(en.getKey())) {
singleObject.values.put(en.getKey(), en.getValue());
}
}
} }
PrintConfigDef def = PrintConfigDef.getInstance(); PrintConfigDef def = PrintConfigDef.getInstance();
@@ -121,12 +134,10 @@ public class SliceBeam extends Application {
public static void genCurrentConfig() throws IOException { public static void genCurrentConfig() throws IOException {
File cfg = getCurrentConfigFile(); File cfg = getCurrentConfigFile();
if (!cfg.exists()) { FileOutputStream fos = new FileOutputStream(cfg);
FileOutputStream fos = new FileOutputStream(cfg); ConfigObject singleObject = buildCurrentConfigObject();
ConfigObject singleObject = buildCurrentConfigObject(); fos.write(singleObject.serialize().getBytes(StandardCharsets.UTF_8));
fos.write(singleObject.serialize().getBytes(StandardCharsets.UTF_8)); fos.close();
fos.close();
}
} }
public static File getCurrentConfigFile() { public static File getCurrentConfigFile() {