GUI: added card hint popup support in pick choice dialogs (dialogs with searchable list, related to #12420)

This commit is contained in:
Oleg Agafonov 2024-07-07 11:39:17 +04:00
parent fad0271dbf
commit f3db9cb8af
3 changed files with 95 additions and 77 deletions

View file

@ -25,6 +25,14 @@ import java.util.*;
/**
* GUI: improved editor pane with html, hyperlinks/popup support
* <p>
* Can be used as:
* - read only text panel (example: chats and game logs)
* - read only text label (example: header messages in choice dialogs)
* <p>
* Call in form's constructor or show dialog:
* - xxx.enableTextLabelMode to enable text label mode
* - xxx.enableHyperlinksAndCardPopups + xxx.setGameData to enable card popup support
*
* @author JayDi85
*/
@ -36,7 +44,6 @@ public class MageEditorPane extends JEditorPane {
final HTMLEditorKit kit = new HTMLEditorKit();
final HTMLDocument doc;
public MageEditorPane() {
super();
// merge with UI.setHTMLEditorKit
@ -47,6 +54,17 @@ public class MageEditorPane extends JEditorPane {
kit.getStyleSheet().addRule(" a { text-decoration: none; } ");
}
/**
* Simulate JLabel (non-editable and transparent background)
*/
public void enableTextLabelMode() {
this.setOpaque(false);
this.setFocusable(false);
this.setBorder(null);
this.setAutoscrolls(false);
this.setBackground(new Color(0, 0, 0, 0)); // transparent background
}
// cards popup info
private boolean hyperlinkEnabled = false;
VirtualCardInfo cardInfo = new VirtualCardInfo();