From 90599bce02669b1c901317e663c1aef4c181d5a6 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Fri, 16 Feb 2024 00:57:55 +0100 Subject: [PATCH] [#2456] Save warning priority in .ork --- .../file/openrocket/OpenRocketSaver.java | 25 ++++++------------- .../openrocket/importt/DocumentConfig.java | 2 +- .../openrocket/importt/FlightDataHandler.java | 5 +++- fileformat.txt | 7 ++++-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java index cdb3f499f..e3bf4b8bc 100644 --- a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java @@ -216,23 +216,8 @@ public class OpenRocketSaver extends RocketSaver { private int calculateNecessaryFileVersion(OpenRocketDocument document, StorageOptions opts) { /* * NOTE: Remember to update the supported versions in DocumentConfig as well! - * - * File version 1.9 is required for: - * - new-style positioning - * - external/parallel booster stages - * - external pods - * - Rail Buttons - * - Flight event source saving - * - * Otherwise use version 1.9. */ - - ///////////////// - // Version 1.9 // - ///////////////// - // for any new-style positioning: 'axialoffset', 'angleoffset', 'radiusoffset' tags - // these tags are used for any RocketComponent child classes positioning... so... ALL the classes. - return FILE_VERSION_DIVISOR + 9; + return FILE_VERSION_DIVISOR + 10; } @@ -409,7 +394,7 @@ public class OpenRocketSaver extends RocketSaver { indent++; for (Warning w : data.getWarningSet()) { - writeElement("warning", TextUtil.escapeXML(w.toString())); + writeElementWithAttribute("warning", "priority", w.getPriority().getExportLabel(), TextUtil.escapeXML(w.toString())); } // Check whether to store data @@ -606,6 +591,12 @@ public class OpenRocketSaver extends RocketSaver { content = ""; writeln("<" + element + ">" + TextUtil.escapeXML(content) + ""); } + + private void writeElementWithAttribute(String element, String attributeName, String attribute, Object content) throws IOException { + content = content == null ? "" : content; + + writeln("<" + element + " " + attributeName + " = \"" + attribute + "\">" + TextUtil.escapeXML(content) + ""); + } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java index 489fec875..781461e01 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java @@ -52,7 +52,7 @@ import net.sf.openrocket.util.Reflection; class DocumentConfig { /* Remember to update OpenRocketSaver as well! */ - public static final String[] SUPPORTED_VERSIONS = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" }; + public static final String[] SUPPORTED_VERSIONS = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10" }; /** * Divisor used in converting an integer version to the point-represented version. diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java index d23537401..369e0d235 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import net.sf.openrocket.logging.MessagePriority; import net.sf.openrocket.logging.Warning; import net.sf.openrocket.logging.WarningSet; import net.sf.openrocket.file.DocumentLoadingContext; @@ -83,7 +84,9 @@ class FlightDataHandler extends AbstractElementHandler { branches.add(branch); } } else if (element.equals("warning")) { - warningSet.add(Warning.fromString(content)); + String priorityStr = attributes.get("priority"); + MessagePriority priority = MessagePriority.fromExportLabel(priorityStr); + warningSet.add(Warning.fromString(content, priority)); } } diff --git a/fileformat.txt b/fileformat.txt index aa3093182..ae33ec0b5 100644 --- a/fileformat.txt +++ b/fileformat.txt @@ -64,5 +64,8 @@ The following file format versions exist: Rename to ( remains for backward compatibility) Rename to ( remains for backward compatibility) -1.9: Introduced with OpenRocket 23.xx. - Added ID for each rocket component, to in turn add this ID as a source for flight events. \ No newline at end of file +1.9: Introduced with OpenRocket 23.09. + Added ID for each rocket component, to in turn add this ID as a source for flight events. + +1.10: Introduced with OpenRocket 24.XX. + Added a priority attribute to simulation warnings.