Skip to content

Commit

Permalink
Merge pull request #3978 from kwvanderlinde/bugfix/3977-repeated-macr…
Browse files Browse the repository at this point in the history
…os-in-selection-panel
  • Loading branch information
cwisniew authored Apr 19, 2023
2 parents 3b597dc + 847014f commit 63185e8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ public void mouseExited(MouseEvent event) {}

@Subscribe
void onZoneActivated(ZoneActivated event) {
reset();
SwingUtilities.invokeLater(
() -> {
reset();
});
}

public static void clearHotkeys(AbstractMacroPanel panel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,42 @@ public void resetIfNotImpersonating() {

@Subscribe
private void onSelectionChanged(SelectionModel.SelectionChanged event) {
reset();
SwingUtilities.invokeLater(
() -> {
reset();
});
}

@Subscribe
private void onTokenMacroChanged(TokenMacroChanged event) {
resetIfAnyImpersonated(Collections.singletonList(event.token()));
SwingUtilities.invokeLater(
() -> {
resetIfAnyImpersonated(Collections.singletonList(event.token()));
});
}

@Subscribe
private void onTokenPanelChanged(TokenPanelChanged event) {
resetIfAnyImpersonated(Collections.singletonList(event.token()));
SwingUtilities.invokeLater(
() -> {
resetIfAnyImpersonated(Collections.singletonList(event.token()));
});
}

@Subscribe
private void onTokensRemoved(TokensRemoved event) {
resetIfAnyImpersonated(event.tokens());
SwingUtilities.invokeLater(
() -> {
resetIfAnyImpersonated(event.tokens());
});
}

@Subscribe
private void onTokensEdited(TokenEdited event) {
resetIfAnyImpersonated(Collections.singletonList(event.token()));
SwingUtilities.invokeLater(
() -> {
resetIfAnyImpersonated(Collections.singletonList(event.token()));
});
}

private void resetIfAnyImpersonated(List<Token> tokens) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.common.eventbus.Subscribe;
import com.jidesoft.docking.DockableFrame;
import java.util.*;
import javax.swing.SwingUtilities;
import net.rptools.lib.CodeTimer;
import net.rptools.maptool.client.AppState;
import net.rptools.maptool.client.AppUtil;
Expand Down Expand Up @@ -112,32 +113,46 @@ public void init(List<Token> selectedTokenList) {
MapTool.getProfilingNoteFrame().addText(results);
if (log.isDebugEnabled()) log.debug(results);
}
new MapToolEventBus().getMainEventBus().register(this);
}

@Subscribe
private void onSelectionChanged(SelectionModel.SelectionChanged event) {
reset();
SwingUtilities.invokeLater(
() -> {
reset();
});
}

@Subscribe
private void onTokenMacroChanged(TokenMacroChanged event) {
resetIfSelected(Collections.singletonList(event.token()));
SwingUtilities.invokeLater(
() -> {
resetIfSelected(Collections.singletonList(event.token()));
});
}

@Subscribe
private void onTokenPanelChanged(TokenPanelChanged event) {
resetIfSelected(Collections.singletonList(event.token()));
SwingUtilities.invokeLater(
() -> {
resetIfSelected(Collections.singletonList(event.token()));
});
}

@Subscribe
private void onTokensRemoved(TokensRemoved event) {
resetIfSelected(event.tokens());
SwingUtilities.invokeLater(
() -> {
resetIfSelected(event.tokens());
});
}

@Subscribe
private void onTokenEdited(TokenEdited event) {
resetIfSelected(Collections.singletonList(event.token()));
SwingUtilities.invokeLater(
() -> {
resetIfSelected(Collections.singletonList(event.token()));
});
}

private void resetIfSelected(List<Token> tokenList) {
Expand Down

0 comments on commit 63185e8

Please sign in to comment.