From 54b9a16acc7aa56378385eeeec987c2cd7561b40 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Sun, 10 Nov 2024 01:37:05 -0800 Subject: [PATCH] Apply ToolBox.updateTools() to all tools, not just class-based tools --- .../net/rptools/maptool/client/tool/Toolbox.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/tool/Toolbox.java b/src/main/java/net/rptools/maptool/client/tool/Toolbox.java index 9990fd65a9..0b27d0b4d5 100644 --- a/src/main/java/net/rptools/maptool/client/tool/Toolbox.java +++ b/src/main/java/net/rptools/maptool/client/tool/Toolbox.java @@ -17,7 +17,9 @@ import java.awt.EventQueue; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.swing.ButtonGroup; import net.rptools.maptool.client.MapTool; @@ -28,13 +30,21 @@ /** */ public class Toolbox { private ZoneRenderer currentRenderer; + + /** The selected tool, if any. Will be one of {@link #tools} or {@code null}. */ private Tool currentTool; + + /** Contains all tools in the toolbox regardless of how they were registered. */ + private final List tools = new ArrayList<>(); + + /** Remembers which tool was registered for which class. Values are members of {@link #tools}. */ private final Map, Tool> toolMap = new HashMap, Tool>(); + private final ButtonGroup buttonGroup = new ButtonGroup(); public void updateTools() { - for (Tool tool : toolMap.values()) { + for (Tool tool : tools) { tool.setEnabled(tool.isAvailable()); tool.updateButtonState(); } @@ -82,6 +92,7 @@ public T createTool(Class toolClass) { * @param tool The tool to add. */ public void addTool(Tool tool) { + tools.add(tool); if (tool.hasGroup()) { buttonGroup.add(tool); }