diff --git a/src/main/java/net/rptools/maptool/client/MapTool.java b/src/main/java/net/rptools/maptool/client/MapTool.java index 579ee3da5c..80e2eaf95b 100644 --- a/src/main/java/net/rptools/maptool/client/MapTool.java +++ b/src/main/java/net/rptools/maptool/client/MapTool.java @@ -84,6 +84,7 @@ import net.rptools.maptool.model.TextMessage; import net.rptools.maptool.model.Zone; import net.rptools.maptool.model.ZoneFactory; +import net.rptools.maptool.model.library.LibraryManager; import net.rptools.maptool.model.library.url.LibraryURLStreamHandler; import net.rptools.maptool.model.player.LocalPlayer; import net.rptools.maptool.model.player.Player; @@ -639,6 +640,7 @@ private static void moveToMonitor(JFrame frame, int monitor, boolean maximize) { private static void initialize() { // First time AppSetup.install(); + LibraryManager.init(); // Clean up after ourselves FileUtil.delete(AppUtil.getAppHome("tmp"), 2); @@ -657,10 +659,12 @@ private static void initialize() { assetTransferManager.addConsumerListener(new AssetTransferHandler()); setClientFrame(new MapToolFrame(menuBar)); + taskbarFlasher = new TaskBarFlasher(clientFrame); try { playerZoneListener = new PlayerZoneListener(); zoneLoadedListener = new ZoneLoadedListener(); + Campaign cmpgn = CampaignFactory.createBasicCampaign(); startPersonalServer(cmpgn); } catch (Exception e) { @@ -1279,8 +1283,6 @@ private static void postInitialize() { // fire up autosaves getAutoSaveManager().start(); - taskbarFlasher = new TaskBarFlasher(clientFrame); - // Jamz: After preferences are loaded, Asset Tree and ImagePanel are out of sync, // so after frame is all done loading we sync them back up. MapTool.getFrame().getAssetPanel().getAssetTree().initialize(); @@ -1750,6 +1752,7 @@ public static void main(String[] args) { EventQueue.invokeLater( () -> { initialize(); + EventQueue.invokeLater( () -> { clientFrame.setVisible(true); diff --git a/src/main/java/net/rptools/maptool/client/ui/MapToolFrame.java b/src/main/java/net/rptools/maptool/client/ui/MapToolFrame.java index 4a122f2fb3..ae95b3f2dc 100644 --- a/src/main/java/net/rptools/maptool/client/ui/MapToolFrame.java +++ b/src/main/java/net/rptools/maptool/client/ui/MapToolFrame.java @@ -228,6 +228,8 @@ public class MapToolFrame extends DefaultDockableHolder implements WindowListene private final DragImageGlassPane dragImageGlassPane = new DragImageGlassPane(); + private boolean dockingConfigured = false; + private final class KeyListenerDeleteDraw implements KeyListener { private final JTree tree; @@ -455,8 +457,7 @@ public MapToolFrame(JMenuBar menuBar) { restorePreferences(); updateKeyStrokes(); - // This will cause the frame to be set to visible (BAD jide, BAD! No cookie for you!) - configureDocking(); + initializeFrames(); new WindowPreferences(AppConstants.APP_NAME, "mainFrame", this); chatTyperTimers = new ChatNotificationTimers(); @@ -545,8 +546,6 @@ public String getPropertyName() { } private void configureDocking() { - initializeFrames(); - getDockingManager().setProfileKey(DOCKING_PROFILE_NAME); getDockingManager().setOutlineMode(com.jidesoft.docking.DockingManager.PARTIAL_OUTLINE_MODE); getDockingManager().setUsePref(false); @@ -619,6 +618,16 @@ private void configureDocking() { /* /Issue #2485 */ } + @Override + public void setVisible(boolean b) { + if (!dockingConfigured) { + dockingConfigured = true; + configureDocking(); + } + + super.setVisible(b); + } + public DockableFrame getFrame(MTFrame frame) { return frameMap.get(frame); } diff --git a/src/main/java/net/rptools/maptool/model/library/LibraryManager.java b/src/main/java/net/rptools/maptool/model/library/LibraryManager.java index 3bd991ecdc..f5507f78d3 100644 --- a/src/main/java/net/rptools/maptool/model/library/LibraryManager.java +++ b/src/main/java/net/rptools/maptool/model/library/LibraryManager.java @@ -74,7 +74,7 @@ public class LibraryManager { private static final AddOnSlashCommandManager addOnSlashCommandManager = new AddOnSlashCommandManager(); - static { + public static void init() { libraryTokenManager.init(); builtInLibraryManager.loadBuiltIns(); new MapToolEventBus().getMainEventBus().register(addOnSlashCommandManager); diff --git a/src/main/java/net/rptools/maptool/model/sheet/stats/StatSheet.java b/src/main/java/net/rptools/maptool/model/sheet/stats/StatSheet.java index 733a6eb6e6..6f043dc0e7 100644 --- a/src/main/java/net/rptools/maptool/model/sheet/stats/StatSheet.java +++ b/src/main/java/net/rptools/maptool/model/sheet/stats/StatSheet.java @@ -15,6 +15,7 @@ package net.rptools.maptool.model.sheet.stats; import java.net.URL; +import java.util.Objects; import java.util.Set; /** @@ -28,4 +29,36 @@ * @param namespace The namespace of the add-on that provides the spreadsheet. */ public record StatSheet( - String name, String description, URL entry, Set propertyTypes, String namespace) {} + String name, String description, URL entry, Set propertyTypes, String namespace) { + @Override + public boolean equals(Object obj) { + if (!(obj instanceof StatSheet other)) { + return false; + } + if (!Objects.equals(name, other.name)) { + return false; + } + if (!Objects.equals(description, other.description)) { + return false; + } + if (!Objects.equals(propertyTypes, other.propertyTypes)) { + return false; + } + if (!Objects.equals(namespace, other.namespace)) { + return false; + } + + // Finally the URLs + var thisUrl = entry == null ? null : entry.toString(); + var otherUrl = other.entry == null ? null : other.entry.toString(); + + return Objects.equals(thisUrl, otherUrl); + } + + @Override + public int hashCode() { + // Hash the URL as a string. E.g., we don't need hostname resolution just for a hashcode. + return Objects.hash( + name, description, entry == null ? null : entry.toString(), propertyTypes, namespace); + } +}