From 6cdd5c23dad220f4de1eb323f93f5edc5f1e1ca6 Mon Sep 17 00:00:00 2001 From: bubblobill Date: Tue, 23 Jun 2026 23:00:19 +0800 Subject: [PATCH 1/3] Added status message for initiative panel summary. --- .../client/ui/tokenpanel/InitiativePanel.java | 164 +++++++++++++----- .../rptools/maptool/model/InitiativeList.java | 4 + .../rptools/maptool/language/i18n.properties | 4 +- 3 files changed, 124 insertions(+), 48 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java b/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java index 5e5032b912..37611f7c38 100644 --- a/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java +++ b/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java @@ -14,17 +14,18 @@ */ package net.rptools.maptool.client.ui.tokenpanel; +import static net.rptools.maptool.client.ui.MapToolFrame.MTFrame.INITIATIVE; + import com.google.common.eventbus.Subscribe; +import com.jidesoft.docking.DockableFrame; +import com.jidesoft.docking.event.DockableFrameAdapter; +import com.jidesoft.docking.event.DockableFrameEvent; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.Collections; +import java.util.*; import java.util.List; -import java.util.Set; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -62,7 +63,7 @@ public class InitiativePanel extends JPanel * Instance Variables *-------------------------------------------------------------------------------------------*/ - /** Model containing all of the tokens in this initiative. */ + /** Model containing all the tokens in this initiative. */ private InitiativeList list; /** The model used to display a list in the panel; */ @@ -98,7 +99,7 @@ public class InitiativePanel extends JPanel /** The component that contains the initiative menu. */ private final JPopupMenu popupMenu; - /** The menu item that tells the GM if NPC's are visible. */ + /** The menu item that tells the GM if NPCs are visible. */ private JCheckBoxMenuItem hideNPCMenuItem; /** @@ -135,10 +136,13 @@ public class InitiativePanel extends JPanel */ private boolean initPanelButtonsDisabled; + /** Frame used in docking manager */ + private DockableFrame dockableFrame; + /*--------------------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------------------*/ - /** Setup the menu */ + /** Set up the menu */ public InitiativePanel() { // Build the form and add it's component @@ -178,7 +182,7 @@ public InitiativePanel() { // Set up the list with an empty model displayList = - new JList() { + new JList<>() { @Override public boolean getScrollableTracksViewportWidth() { // Make sure the width of the list always tracks with the width of the panel. Without @@ -243,9 +247,12 @@ public boolean getScrollableTracksViewportWidth() { "initPanel.warnWhenResettingRoundCounter", TOGGLE_WARN_WHEN_RESETTING_COUNTER_ACTION); I18N.setAction("initPanel.next", NEXT_ACTION); I18N.setAction("initPanel.prev", PREV_ACTION); + updateView(); new MapToolEventBus().getMainEventBus().register(this); + + SwingUtilities.invokeLater(() -> dockableFrame = getDockableFrame()); } private static class TextlessButton extends JButton { @@ -332,7 +339,7 @@ public void updateView() { valueChanged(null); } - /** Remove all of the tokens from the model and clear round and current */ + /** Remove all the tokens from the model and clear round and current */ public void clearTokens() { list.clearModel(); } @@ -410,7 +417,7 @@ public InitiativeListModel getModel() { } /** - * Set the zone that we are currently working on. + * Set the zone we are working on. * * @param aZone The new zone */ @@ -442,15 +449,14 @@ public void setZone(Zone aZone) { public boolean hasOwnerPermission(Token token) { if (token == null) return false; if (hasGMPermission()) return true; - if (ownerPermissions + return ownerPermissions && (!MapTool.getServerPolicy().useStrictTokenManagement() - || token.isOwner(MapTool.getPlayer().getName()))) return true; - return false; + || token.isOwner(MapTool.getPlayer().getName())); } /** * See if the current player has permission to execute GM restricted actions. This is not - * related to so-called trusted macros in MTscript. + * related to so-called trusted macros in MT Script. * * @return The value true if this player has permission for all actions. */ @@ -503,7 +509,7 @@ public boolean isInitPanelButtonsDisabled() { * Updates the "Disable Panel Buttons" setting, and tweaks the Next/Previous button tooltips * appropriately. Updates the view. * - * @param initPanelButtonsDisabled + * @param initPanelButtonsDisabled disable panel buttons */ public void setInitPanelButtonsDisabled(boolean initPanelButtonsDisabled) { this.initPanelButtonsDisabled = initPanelButtonsDisabled; @@ -526,8 +532,7 @@ public void setInitPanelButtonsDisabled(boolean initPanelButtonsDisabled) { public boolean isMovementLocked(Token token) { if (!movementLock || list == null || list.getSize() == 0) return false; if (model.getCurrentTokenInitiative() == null) return true; - if (model.getCurrentTokenInitiative().getToken() == token) return false; - return true; + return model.getCurrentTokenInitiative().getToken() != token; } /** @@ -553,7 +558,73 @@ private void onInitiativeListChanged(InitiativeListChanged event) { int oldSize = model.getSize(); setList(list); - if (oldSize != model.getSize()) displayList.getSelectionModel().clearSelection(); + if (oldSize != model.getSize()) { + displayList.getSelectionModel().clearSelection(); + } + } + + public DockableFrame getDockableFrame() { + if (dockableFrame == null) { + dockableFrame = MapTool.getFrame().getFrame(INITIATIVE); + dockableFrame.addDockableFrameListener( + new DockableFrameAdapter() { + private String oldStatusMessage; + + @Override + public void dockableFrameActivated(DockableFrameEvent dockableFrameEvent) { + oldStatusMessage = MapTool.getFrame().getStatusMessage(); + updateStatusBar(); + } + + @Override + public void dockableFrameDeactivated(DockableFrameEvent dockableFrameEvent) { + MapTool.getFrame().setStatusMessage(oldStatusMessage); + oldStatusMessage = null; + } + }); + } + return dockableFrame; + } + + private void updateStatusBar() { + if (!getDockableFrame().isActive()) { + return; + } + SwingUtilities.invokeLater( + () -> { + if (list != null && list.getSize() > 0 && MapTool.getPlayer().isGM()) { + // PCs/NPCs: {0}/{1}, Current: {2}, Round/Phase {3}/{4} + int pc = 0, npc = 0; + TokenInitiative last = null; + boolean sorted = true; + Comparator comparator = list.getComparator(); + for (TokenInitiative ti : list.getTokens()) { + if (last != null && sorted && !ti.isHolding()) { + int comp = comparator.compare(ti, last); + if ((initUseReverseSort && comp > 0) || (!initUseReverseSort && comp < 0)) { + sorted = false; + } + } + last = ti; + if (ti.getToken().getType().equals(Type.PC)) { + pc++; + } else { + npc++; + } + } + TokenInitiative current = list.getCurrentTokenInitiative(); + MapTool.getFrame() + .setStatusMessage( + I18N.getText( + "initiative.status.summary", + pc, + npc, + current == null ? "*" : current.getToken().getName(), + list.getRound(), + current == null ? -1 : current.getState(), + sorted)); + } + }); } @Subscribe @@ -612,28 +683,29 @@ public void valueChanged(ListSelectionEvent e) { */ @Override public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals(InitiativeList.ROUND_PROP)) { - updateRound(); - } else if (evt.getPropertyName().equals(InitiativeList.CURRENT_PROP)) { - Token t = list.getCurrentToken(); - if (t == null) return; - String s = I18N.getText("initPanel.displayMessage", t.getName()); - if (InitiativeListModel.isTokenVisible(t, list.isHideNPC()) - && t.getType() != Type.NPC - && AppPreferences.showInitiativeGainedMessage.get()) - MapTool.addMessage(TextMessage.say(null, s)); - displayList.ensureIndexIsVisible(model.getDisplayIndex(list.getCurrent())); - NEXT_ACTION.setEnabled( - !isInitPanelButtonsDisabled() && hasOwnerPermission(list.getCurrentToken())); - } else if (evt.getPropertyName().equals(InitiativeList.TOKENS_PROP)) { - if ((evt.getOldValue() == null && evt.getNewValue() instanceof TokenInitiative) - || (evt.getNewValue() == null & evt.getOldValue() instanceof TokenInitiative)) - displayList.getSelectionModel().clearSelection(); - } else if (evt.getPropertyName().equals(InitiativeList.HIDE_NPCS_PROP)) { - displayList.getSelectionModel().clearSelection(); - } else if (evt.getPropertyName().equals(InitiativeList.OWNER_PERMISSIONS_PROP)) { - updateView(); - } // endif + updateStatusBar(); + switch (evt.getPropertyName()) { + case InitiativeList.ROUND_PROP -> updateRound(); + case InitiativeList.CURRENT_PROP -> { + Token t = list.getCurrentToken(); + if (t == null) return; + String s = I18N.getText("initPanel.displayMessage", t.getName()); + if (InitiativeListModel.isTokenVisible(t, list.isHideNPC()) + && t.getType() != Type.NPC + && AppPreferences.showInitiativeGainedMessage.get()) + MapTool.addMessage(TextMessage.say(null, s)); + displayList.ensureIndexIsVisible(model.getDisplayIndex(list.getCurrent())); + NEXT_ACTION.setEnabled( + !isInitPanelButtonsDisabled() && hasOwnerPermission(list.getCurrentToken())); + } + case InitiativeList.TOKENS_PROP -> { + if ((evt.getOldValue() == null && evt.getNewValue() instanceof TokenInitiative) + || (evt.getNewValue() == null & evt.getOldValue() instanceof TokenInitiative)) + displayList.getSelectionModel().clearSelection(); + } + case InitiativeList.HIDE_NPCS_PROP -> displayList.getSelectionModel().clearSelection(); + case InitiativeList.OWNER_PERMISSIONS_PROP -> updateView(); + } } /*--------------------------------------------------------------------------------------------- @@ -776,7 +848,7 @@ public void actionPerformed(ActionEvent e) { } }; - /** This action will set the initiative state of the currently selected token. */ + /** This action will set the initiative state of the current selected token. */ public final Action SET_INIT_STATE_VALUE = new AbstractAction() { @Override @@ -788,7 +860,7 @@ public void actionPerformed(ActionEvent e) { if (hasGMPermission() && token != null && token.getGMName() != null - && token.getGMName().trim().length() != 0) + && !token.getGMName().trim().isEmpty()) sName += " (" + token.getGMName().trim() + ")"; String s = I18N.getText("initPanel.enterState", sName); String input = JOptionPane.showInputDialog(s, ti.getState()); @@ -797,7 +869,7 @@ public void actionPerformed(ActionEvent e) { } }; - /** This action will clear the initiative state of the currently selected token. */ + /** This action will clear the initiative state of the current selected token. */ public final Action CLEAR_INIT_STATE_VALUE = new AbstractAction() { @Override @@ -831,7 +903,7 @@ public void actionPerformed(ActionEvent e) { new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); for (Token token : list.getZone().getTokensForLayers(Zone.Layer::isTokenLayer)) { if (token.getType() == Type.PC) tokens.add(token); } // endfor diff --git a/src/main/java/net/rptools/maptool/model/InitiativeList.java b/src/main/java/net/rptools/maptool/model/InitiativeList.java index 2d4a79e966..047c006ef6 100644 --- a/src/main/java/net/rptools/maptool/model/InitiativeList.java +++ b/src/main/java/net/rptools/maptool/model/InitiativeList.java @@ -1023,4 +1023,8 @@ public int compare(TokenInitiative o1, TokenInitiative o2) { return comparison; } } + + public TokenInitiativeDescComparator getComparator() { + return new TokenInitiativeDescComparator(); + } } diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index d983aaf40f..5fabd1e0ad 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -1943,8 +1943,8 @@ initiative.menu.hold = Hold initiative.menu.remove = Remove initiative.menu.resume = Resume initiative.menu.setState = Set Initiative... - - +# Initiative summary message for display in GM status bar +initiative.status.summary = PC: {0}, NPC: {1}, Current: {2} ({4}), Round: {3}, Sorted: {5} layer.token = Token layer.gm = Hidden layer.object = Object From 3df556dff5467a311f18f4d16a9a4fee77b3e278 Mon Sep 17 00:00:00 2001 From: bubblobill Date: Wed, 8 Jul 2026 17:32:28 +0800 Subject: [PATCH 2/3] Changed from status bar message to title bar component text. --- .../client/ui/tokenpanel/InitiativePanel.java | 101 ++++++++++-------- .../rptools/maptool/language/i18n.properties | 3 +- 2 files changed, 59 insertions(+), 45 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java b/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java index 37611f7c38..ee60fd8072 100644 --- a/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java +++ b/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java @@ -33,6 +33,7 @@ import net.rptools.maptool.client.AppUtil; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.swing.SwingUtil; +import net.rptools.maptool.client.ui.MapToolFrame; import net.rptools.maptool.client.ui.theme.Icons; import net.rptools.maptool.client.ui.theme.RessourceManager; import net.rptools.maptool.client.ui.zone.renderer.ZoneRenderer; @@ -137,7 +138,17 @@ public class InitiativePanel extends JPanel private boolean initPanelButtonsDisabled; /** Frame used in docking manager */ - private DockableFrame dockableFrame; + private DockableFrame dockableFrame = null; + + /** Custom title component for {@link #dockableFrame} */ + private final JLabel dockableFrameTitleComponent = new JLabel(); + + /** Display text used in {@link #dockableFrameTitleComponent} & {@link #dockableFrame} titles */ + private static final String TITLE_LABEL_TEXT = "%s (%d, %d)"; + + /** Tooltip text used in {@link #dockableFrameTitleComponent} */ + private static final String TITLE_LABEL_TOOLTIP_TEXT = + "%s: %d
%s: %d"; /*--------------------------------------------------------------------------------------------- * Constructor @@ -273,6 +284,7 @@ private static class TextlessButton extends JButton { * GM's and Player's properly */ public void updateView() { + updateFrameTitle(); displayList.setDragEnabled(hasGMPermission()); // Set up the buttons @@ -565,65 +577,68 @@ private void onInitiativeListChanged(InitiativeListChanged event) { public DockableFrame getDockableFrame() { if (dockableFrame == null) { - dockableFrame = MapTool.getFrame().getFrame(INITIATIVE); - dockableFrame.addDockableFrameListener( - new DockableFrameAdapter() { - private String oldStatusMessage; - - @Override - public void dockableFrameActivated(DockableFrameEvent dockableFrameEvent) { - oldStatusMessage = MapTool.getFrame().getStatusMessage(); - updateStatusBar(); - } + MapToolFrame mapToolFrame = MapTool.getFrame(); + if (mapToolFrame == null) { // this happens on startup before everything gets loaded + return null; + } + dockableFrame = mapToolFrame.getFrame(INITIATIVE); + if (dockableFrame != null) { + dockableFrame.setTitleLabelComponent(dockableFrameTitleComponent); + + dockableFrame.addDockableFrameListener( + new DockableFrameAdapter() { + @Override + public void dockableFrameAdded(DockableFrameEvent dockableFrameEvent) { + super.dockableFrameAdded(dockableFrameEvent); + updateFrameTitle(); + } - @Override - public void dockableFrameDeactivated(DockableFrameEvent dockableFrameEvent) { - MapTool.getFrame().setStatusMessage(oldStatusMessage); - oldStatusMessage = null; - } - }); + @Override + public void dockableFrameShown(DockableFrameEvent dockableFrameEvent) { + super.dockableFrameShown(dockableFrameEvent); + updateFrameTitle(); + } + + @Override + public void dockableFrameTabShown(DockableFrameEvent dockableFrameEvent) { + super.dockableFrameTabShown(dockableFrameEvent); + updateFrameTitle(); + } + }); + } } return dockableFrame; } - private void updateStatusBar() { - if (!getDockableFrame().isActive()) { + private void updateFrameTitle() { + if (!MapTool.getPlayer().isGM() || getDockableFrame() == null) { return; } SwingUtilities.invokeLater( () -> { + int pc = 0, npc = 0; if (list != null && list.getSize() > 0 && MapTool.getPlayer().isGM()) { - // PCs/NPCs: {0}/{1}, Current: {2}, Round/Phase {3}/{4} - int pc = 0, npc = 0; - TokenInitiative last = null; - boolean sorted = true; - Comparator comparator = list.getComparator(); for (TokenInitiative ti : list.getTokens()) { - if (last != null && sorted && !ti.isHolding()) { - int comp = comparator.compare(ti, last); - if ((initUseReverseSort && comp > 0) || (!initUseReverseSort && comp < 0)) { - sorted = false; - } - } - last = ti; if (ti.getToken().getType().equals(Type.PC)) { pc++; } else { npc++; } } - TokenInitiative current = list.getCurrentTokenInitiative(); - MapTool.getFrame() - .setStatusMessage( - I18N.getText( - "initiative.status.summary", - pc, - npc, - current == null ? "*" : current.getToken().getName(), - list.getRound(), - current == null ? -1 : current.getState(), - sorted)); } + + String text = String.format(TITLE_LABEL_TEXT, I18N.getText("panel.Initiative"), pc, npc); + String tooltip = + String.format( + TITLE_LABEL_TOOLTIP_TEXT, + I18N.getText("Token.Type.PC"), + pc, + I18N.getText("Token.Type.NPC"), + npc); + dockableFrameTitleComponent.setText(text); + dockableFrameTitleComponent.setToolTipText(tooltip); + dockableFrame.setSideTitle(text); + dockableFrame.setTabTitle(text); }); } @@ -683,7 +698,7 @@ public void valueChanged(ListSelectionEvent e) { */ @Override public void propertyChange(PropertyChangeEvent evt) { - updateStatusBar(); + updateFrameTitle(); switch (evt.getPropertyName()) { case InitiativeList.ROUND_PROP -> updateRound(); case InitiativeList.CURRENT_PROP -> { diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index 748218e3bd..710d631125 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -1945,8 +1945,7 @@ initiative.menu.hold = Hold initiative.menu.remove = Remove initiative.menu.resume = Resume initiative.menu.setState = Set Initiative... -# Initiative summary message for display in GM status bar -initiative.status.summary = PC: {0}, NPC: {1}, Current: {2} ({4}), Round: {3}, Sorted: {5} + layer.token = Token layer.gm = Hidden layer.object = Object From 4a9be57e6af8ec00b89cbd8aa16494bc8e1cd1c4 Mon Sep 17 00:00:00 2001 From: bubblobill Date: Thu, 9 Jul 2026 12:48:19 +0800 Subject: [PATCH 3/3] Added preference for display of info in title bar. Added associated menu option to toggle info display. --- .../maptool/client/AppPreferences.java | 3 + .../client/ui/tokenpanel/InitiativePanel.java | 85 ++++++++++++++----- .../rptools/maptool/language/i18n.properties | 1 + 3 files changed, 68 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppPreferences.java b/src/main/java/net/rptools/maptool/client/AppPreferences.java index 1dbfece17d..21624d84fa 100644 --- a/src/main/java/net/rptools/maptool/client/AppPreferences.java +++ b/src/main/java/net/rptools/maptool/client/AppPreferences.java @@ -745,6 +745,9 @@ public static PreferenceStore getAppPreferenceStore() { "Preferences.label.loadMRU.tooltip", false); + public static final Preference initiativePanelShowsInfoInTitle = + store.defineBoolean("initShowTitleInfo", true); + public static final Preference initiativePanelShowsTokenImage = store.defineBoolean("initShowTokens", true); diff --git a/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java b/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java index ee60fd8072..9a5f53e6e1 100644 --- a/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java +++ b/src/main/java/net/rptools/maptool/client/ui/tokenpanel/InitiativePanel.java @@ -137,6 +137,12 @@ public class InitiativePanel extends JPanel */ private boolean initPanelButtonsDisabled; + /** Flag indicating that additional information should be shown in the title bar. */ + private boolean showTitleInfo = AppPreferences.initiativePanelShowsInfoInTitle.get(); + + /** Flag indicating that title bar change needs action. */ + private boolean showTitleInfoPending = true; + /** Frame used in docking manager */ private DockableFrame dockableFrame = null; @@ -258,6 +264,7 @@ public boolean getScrollableTracksViewportWidth() { "initPanel.warnWhenResettingRoundCounter", TOGGLE_WARN_WHEN_RESETTING_COUNTER_ACTION); I18N.setAction("initPanel.next", NEXT_ACTION); I18N.setAction("initPanel.prev", PREV_ACTION); + I18N.setAction("initPanel.showTokenCountInTitle", SHOW_TOKEN_COUNT_IN_TITLE); updateView(); @@ -348,6 +355,12 @@ public void updateView() { popupMenu.addSeparator(); popupMenu.add(new JMenuItem(REMOVE_TOKEN_ACTION)); } // endif + if (MapTool.getPlayer().isGM()) { + popupMenu.addSeparator(); + JCheckBoxMenuItem showTitleInfoCB = new JCheckBoxMenuItem(SHOW_TOKEN_COUNT_IN_TITLE); + showTitleInfoCB.setSelected(AppPreferences.initiativePanelShowsInfoInTitle.get()); + popupMenu.add(showTitleInfoCB); + } valueChanged(null); } @@ -421,6 +434,13 @@ public boolean isShowInitState() { return showInitState; } + /** + * @return Getter for showTitleInfo + */ + public boolean isShowTitleInfo() { + return showTitleInfo; + } + /** * @return Getter for model */ @@ -611,34 +631,45 @@ public void dockableFrameTabShown(DockableFrameEvent dockableFrameEvent) { } private void updateFrameTitle() { - if (!MapTool.getPlayer().isGM() || getDockableFrame() == null) { + if (!MapTool.getPlayer().isGM() || getDockableFrame() == null && !showTitleInfoPending) { return; } SwingUtilities.invokeLater( () -> { - int pc = 0, npc = 0; - if (list != null && list.getSize() > 0 && MapTool.getPlayer().isGM()) { - for (TokenInitiative ti : list.getTokens()) { - if (ti.getToken().getType().equals(Type.PC)) { - pc++; - } else { - npc++; + String tooltip, text; + if (isShowTitleInfo()) { + int pc = 0, npc = 0; + if (list != null && list.getSize() > 0 && MapTool.getPlayer().isGM()) { + for (TokenInitiative ti : list.getTokens()) { + if (ti.getToken().getType().equals(Type.PC)) { + pc++; + } else { + npc++; + } } } - } - String text = String.format(TITLE_LABEL_TEXT, I18N.getText("panel.Initiative"), pc, npc); - String tooltip = - String.format( - TITLE_LABEL_TOOLTIP_TEXT, - I18N.getText("Token.Type.PC"), - pc, - I18N.getText("Token.Type.NPC"), - npc); - dockableFrameTitleComponent.setText(text); - dockableFrameTitleComponent.setToolTipText(tooltip); - dockableFrame.setSideTitle(text); - dockableFrame.setTabTitle(text); + text = String.format(TITLE_LABEL_TEXT, I18N.getText("panel.Initiative"), pc, npc); + tooltip = + String.format( + TITLE_LABEL_TOOLTIP_TEXT, + I18N.getText("Token.Type.PC"), + pc, + I18N.getText("Token.Type.NPC"), + npc); + dockableFrameTitleComponent.setText(text); + dockableFrameTitleComponent.setToolTipText(tooltip); + dockableFrame.setSideTitle(text); + dockableFrame.setTabTitle(text); + } else { + text = I18N.getText("panel.Initiative"); + tooltip = I18N.getText("panel.Initiative.description"); + dockableFrameTitleComponent.setText(text); + dockableFrameTitleComponent.setToolTipText(tooltip); + dockableFrame.setSideTitle(text); + dockableFrame.setTabTitle(text); + showTitleInfoPending = false; + } }); } @@ -792,6 +823,18 @@ public void actionPerformed(ActionEvent e) { } }; + /** This action toggles the display of token counts in the title bar. */ + public final Action SHOW_TOKEN_COUNT_IN_TITLE = + new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + showTitleInfo = ((JCheckBoxMenuItem) e.getSource()).isSelected(); + showTitleInfoPending = true; + AppPreferences.initiativePanelShowsInfoInTitle.set(showTitleInfo); + updateFrameTitle(); + } + }; + /** This action toggles the display of token images. */ public final Action SHOW_TOKEN_STATES_ACTION = new AbstractAction() { diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index 710d631125..a60be730d2 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -1916,6 +1916,7 @@ initPanel.setInitState = Set Initiative... initPanel.showInitStates = Show Initiative initPanel.showTokenStates = Show Token States initPanel.showTokens = Show Tokens +initPanel.showTokenCountInTitle = Show Token Count in Title Bar initPanel.sort = Sort initPanel.sort.description = Sort the list by initiative values. Uses Descending order by default, with any non-numeric values coming after any numbers, and any blank values coming last. initPanel.toggleHideNPCs = Hide NPCs