GUI: added changeable card popup mode for chats/logs by card name clicks (alternative to mouse wheel from game cards);

other: fixed duplicated chat popups in game, added miss error logs from popup related code, added additional checks for good code usage;
This commit is contained in:
Oleg Agafonov 2023-11-26 12:48:41 +04:00
parent 785f6973b9
commit 4500b79008
12 changed files with 129 additions and 70 deletions

View file

@ -21,10 +21,7 @@ import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.*;
/**
* GUI: chats with html and hints popup support for objects
@ -51,7 +48,10 @@ public class ColorPane extends JEditorPane {
}
private void addHyperlinkHandlers() {
addHyperlinkListener(e -> ThreadUtils.threadPool2.submit(() -> {
if (Arrays.stream(getHyperlinkListeners()).findAny().isPresent()) {
throw new IllegalStateException("Wrong code usage: popup links support enabled already");
}
addHyperlinkListener(e -> ThreadUtils.threadPoolPopups.submit(() -> {
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_DELAY, 300) == 0) {
// if disabled
return;
@ -111,13 +111,23 @@ public class ColorPane extends JEditorPane {
cardInfo.init(cardView, this.bigCard, this.gameId);
cardInfo.setTooltipDelay(CHAT_TOOLTIP_DELAY_MS);
cardInfo.setPopupAutoLocationMode(TransferData.PopupAutoLocationMode.PUT_NEAR_MOUSE_POSITION);
cardInfo.onMouseEntered(MouseInfo.getPointerInfo().getLocation());
cardInfo.onMouseMoved(MouseInfo.getPointerInfo().getLocation());
SwingUtilities.invokeLater(() -> {
cardInfo.onMouseEntered(MouseInfo.getPointerInfo().getLocation());
cardInfo.onMouseMoved(MouseInfo.getPointerInfo().getLocation());
});
}
}
if (e.getEventType() == EventType.ACTIVATED) {
SwingUtilities.invokeLater(() -> {
cardInfo.onMouseWheel(MouseInfo.getPointerInfo().getLocation());
});
}
if (e.getEventType() == EventType.EXITED) {
cardInfo.onMouseExited();
SwingUtilities.invokeLater(() -> {
cardInfo.onMouseExited();
});
}
}));