Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repeated macro buttons in selection panel #3978

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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