From ec3755f29344d53e6b26c60b441bd2184fd2ea80 Mon Sep 17 00:00:00 2001 From: Vhati Date: Mon, 15 Oct 2012 16:17:10 -0400 Subject: [PATCH 1/4] Added an informative error for bad ship ids --- src/main/java/net/blerf/ftl/parser/DataManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/blerf/ftl/parser/DataManager.java b/src/main/java/net/blerf/ftl/parser/DataManager.java index 4b72b9f2..3d68a44a 100644 --- a/src/main/java/net/blerf/ftl/parser/DataManager.java +++ b/src/main/java/net/blerf/ftl/parser/DataManager.java @@ -124,7 +124,10 @@ public List getAchievements() { } public ShipBlueprint getShip(String id) { - return ships.get(id); + ShipBlueprint result = ships.get(id); + if ( result == null ) + log.error( "No ShipBlueprint found for id: "+ id ); + return result; } public List getPlayerShips() { From a01f89e9573ac0cbdefd9ae7ca68f562076053b6 Mon Sep 17 00:00:00 2001 From: Vhati Date: Mon, 15 Oct 2012 17:03:33 -0400 Subject: [PATCH 2/4] Cleaned invalid xml for PLAYER_SHIP_CRYSTAL_2 blueprint --- src/main/java/net/blerf/ftl/parser/MappedDatParser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/blerf/ftl/parser/MappedDatParser.java b/src/main/java/net/blerf/ftl/parser/MappedDatParser.java index 804297c6..3b26752f 100644 --- a/src/main/java/net/blerf/ftl/parser/MappedDatParser.java +++ b/src/main/java/net/blerf/ftl/parser/MappedDatParser.java @@ -113,6 +113,7 @@ public Blueprints readBlueprints(InputStream stream) throws IOException, JAXBExc sb.append("").append("\n"); // XML has multiple root nodes so need to wrap boolean comment = false, inShipShields = false, inSlot = false; while( (line = in.readLine()) != null ) { + line = line.replaceAll(""); // Error above one shipBlueprint line = line.replaceAll("", ""); line = line.replaceAll("<\\?xml[^>]*>", ""); line = line.replaceAll("([^<]*)</[^>]*>", "<title>$1"); // Error present in systemBlueprint and itemBlueprint From c52fa39dea16762779bf8e062c5b1eab4e82b5be Mon Sep 17 00:00:00 2001 From: Vhati Date: Mon, 15 Oct 2012 17:38:22 -0400 Subject: [PATCH 3/4] Made the PLAYER_SHIP_CRYSTAL_2 xml regex safer --- src/main/java/net/blerf/ftl/parser/MappedDatParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/blerf/ftl/parser/MappedDatParser.java b/src/main/java/net/blerf/ftl/parser/MappedDatParser.java index 3b26752f..3788db9a 100644 --- a/src/main/java/net/blerf/ftl/parser/MappedDatParser.java +++ b/src/main/java/net/blerf/ftl/parser/MappedDatParser.java @@ -113,7 +113,7 @@ public Blueprints readBlueprints(InputStream stream) throws IOException, JAXBExc sb.append("").append("\n"); // XML has multiple root nodes so need to wrap boolean comment = false, inShipShields = false, inSlot = false; while( (line = in.readLine()) != null ) { - line = line.replaceAll(""); // Error above one shipBlueprint + line = line.replaceAll("^"); // Error above one shipBlueprint line = line.replaceAll("", ""); line = line.replaceAll("<\\?xml[^>]*>", ""); line = line.replaceAll("([^<]*)</[^>]*>", "<title>$1"); // Error present in systemBlueprint and itemBlueprint From 6f4204211da2f3c9dc942aea4443a002f7488344 Mon Sep 17 00:00:00 2001 From: Vhati Date: Tue, 16 Oct 2012 16:23:23 -0400 Subject: [PATCH 4/4] Moved LaF setup to before GUI construction --- src/main/java/net/blerf/ftl/FTLProfileEditor.java | 14 +++++++++++++- src/main/java/net/blerf/ftl/ui/FTLFrame.java | 7 ------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/blerf/ftl/FTLProfileEditor.java b/src/main/java/net/blerf/ftl/FTLProfileEditor.java index 4498885b..caace5dd 100644 --- a/src/main/java/net/blerf/ftl/FTLProfileEditor.java +++ b/src/main/java/net/blerf/ftl/FTLProfileEditor.java @@ -1,10 +1,12 @@ package net.blerf.ftl; -import net.blerf.ftl.ui.FTLFrame; +import javax.swing.UIManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import net.blerf.ftl.ui.FTLFrame; + public class FTLProfileEditor { @@ -14,6 +16,16 @@ public class FTLProfileEditor { public static void main(String[] args) { + // Set look and feel before the GUI. + // Otherwise, some existing components might not notice without this. + // SwingUtilities.updateComponentTreeUI(someComponent); + // Maybe risks NPE if present in a JFrame constructor? + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + log.error("Failed to set a native look and feel", e); + } + try { FTLFrame frame = new FTLFrame(VERSION); frame.setVisible(true); diff --git a/src/main/java/net/blerf/ftl/ui/FTLFrame.java b/src/main/java/net/blerf/ftl/ui/FTLFrame.java index c1748922..803e97e5 100644 --- a/src/main/java/net/blerf/ftl/ui/FTLFrame.java +++ b/src/main/java/net/blerf/ftl/ui/FTLFrame.java @@ -55,7 +55,6 @@ import javax.swing.JTabbedPane; import javax.swing.JToolBar; import javax.swing.SwingConstants; -import javax.swing.UIManager; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.filechooser.FileFilter; @@ -119,12 +118,6 @@ public class FTLFrame extends JFrame { public FTLFrame(int version) { this.version = version; - - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Exception e) { - e.printStackTrace(); - } // Read config file and locate FTL install File propFile = new File("ftl-editor.cfg");