From 5cb4682ad996727b098dd51981e64b6a12018372 Mon Sep 17 00:00:00 2001 From: CrushedPixel Date: Sun, 16 Aug 2015 14:52:25 +0200 Subject: [PATCH] Deep-Copies the CustomImageObjects from the original Object List in the GuiObjectManager to prevent the dirty check when closing the GUI from failing --- .../replaymod/assets/CustomImageObject.java | 14 ++++++++++++++ .../replaymod/gui/GuiObjectManager.java | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/crushedpixel/replaymod/assets/CustomImageObject.java b/src/main/java/eu/crushedpixel/replaymod/assets/CustomImageObject.java index 82f1f92d..5c9e7b92 100644 --- a/src/main/java/eu/crushedpixel/replaymod/assets/CustomImageObject.java +++ b/src/main/java/eu/crushedpixel/replaymod/assets/CustomImageObject.java @@ -24,6 +24,20 @@ public class CustomImageObject implements GuiEntryListEntry { setLinkedAsset(assetUUID); } + public CustomImageObject copy() throws IOException { + CustomImageObject copy = new CustomImageObject(this.name, this.getLinkedAsset()); + + copy.textureWidth = this.textureWidth; + copy.textureHeight = this.textureHeight; + + copy.width = width; + copy.height = height; + + copy.transformations = transformations; + + return copy; + } + @Getter @Setter private String name; @Getter private UUID linkedAsset; diff --git a/src/main/java/eu/crushedpixel/replaymod/gui/GuiObjectManager.java b/src/main/java/eu/crushedpixel/replaymod/gui/GuiObjectManager.java index 8832729a..7dc52609 100644 --- a/src/main/java/eu/crushedpixel/replaymod/gui/GuiObjectManager.java +++ b/src/main/java/eu/crushedpixel/replaymod/gui/GuiObjectManager.java @@ -175,7 +175,11 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv nameInput.hint = I18n.format("replaymod.gui.objects.properties.name"); for(CustomImageObject customImageObject : initialObjects) { - objectList.addElement(customImageObject); + try { + objectList.addElement(customImageObject.copy()); + } catch(IOException ioe) { + ioe.printStackTrace(); + } } objectList.addSelectionListener(new SelectionListener() {