GUI - new card hints window features:

* new help window can be opened from a player panel;
* it collect and show all visible game hints from all players and all zones;
* it updates in real time on game update;
* allows to customize visible data;
* allows to open multiple windows (current limit is 5 windows, can be slow to render);
* allows to minimize opened windows;
* workable card popup on mouse move over card name or card id;
* filter modes:
  * all - show hints from all players;
  * player - show hints from single player;
* group mode:
  * by hints - show same hints as one with all used cards;
  * by cards - show full cards list with own hints;
* search mode:
  * allows to filter card hints by player name, card name, card id or card hint;
  * allows to search multiple words (equals to "or")
* current limitation:
  * card popup shows a card instead a real object, e.g. miss card hints in it (relelated to game logs problem);
  * unsupport of emblems, dungeons and other non card objects from a command zone;
  * unsupport of revealed and library's top cards;

GUI - player's panel improves:
* added hints helper button;
* added player hithlight as possible target in choose dialogs;
* improved player name button in small mode;
* fixed wrong height in small mode;

Other fixes:
* game logs: added card popup support for logs with custom object name;
This commit is contained in:
Oleg Agafonov 2023-11-18 14:48:25 +04:00
parent ca80849249
commit 2bbe2b3c43
16 changed files with 1229 additions and 75 deletions

View file

@ -7,6 +7,7 @@ import mage.client.cards.VirtualCardInfo;
import mage.client.dialog.PreferencesDialog;
import mage.game.command.Plane;
import mage.util.CardUtil;
import mage.util.GameLog;
import mage.utils.ThreadUtils;
import mage.view.CardView;
import mage.view.PlaneView;
@ -87,6 +88,8 @@ public class ColorPane extends JEditorPane {
if (e.getEventType() == EventType.ENTERED) {
CardView cardView = null;
// TODO: add real game object first
// card
CardInfo card = CardRepository.instance.findCards(cardName).stream().findFirst().orElse(null);
if (card != null) {
@ -144,19 +147,20 @@ public class ColorPane extends JEditorPane {
}
@Override
public void setText(String string) {
super.setText(string);
public void setText(String text) {
// must use append to enable popup/hyperlinks support
super.setText("");
append(text);
}
public void append(String text) {
try {
if (hyperlinkEnabled) {
text = text.replaceAll("(<font color=[^>]*>([^<]*)) (\\[[0-9a-fA-F]*\\])</font>", "<a href=\"#$2\">$1</a> $3");
text = GameLog.injectPopupSupport(text);
}
kit.insertHTML(doc, doc.getLength(), text, 0, 0, null);
int len = getDocument().getLength();
setCaretPosition(len);
} catch (Exception e) {
e.printStackTrace();
}
@ -182,7 +186,7 @@ public class ColorPane extends JEditorPane {
super.paintChildren(g);
}
public void enableHyperlinks() {
public void enableHyperlinksAndCardPopups() {
hyperlinkEnabled = true;
addHyperlinkHandlers();
}

View file

@ -0,0 +1,17 @@
package mage.client.components;
/**
* GUI: support windows mimize (iconify) by double clicks
*
* @author JayDi85
*/
public interface MageDesktopIconifySupport {
/**
* Window's header width after minimized to icon
*/
default int getDesktopIconWidth() {
return 250;
}
}

View file

@ -3,31 +3,33 @@ package mage.client.components;
import java.awt.BorderLayout;
import javax.swing.*;
import mage.client.dialog.CardHintsHelperDialog;
import mage.client.dialog.CardInfoWindowDialog;
/**
* GUI: helper class to improve work with desktop frames
*
* @author LevelX2
*/
public class MageDesktopManager extends DefaultDesktopManager {
static final int DESKTOP_ICON_WIDTH = 250;
@Override
public void iconifyFrame(JInternalFrame f) {
super.iconifyFrame(f);
if (f instanceof CardInfoWindowDialog) {
if (f instanceof MageDesktopIconifySupport) {
int needIconWidth = ((MageDesktopIconifySupport) f).getDesktopIconWidth();
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
icon.setBounds(f.getX() + (f.getWidth() - DESKTOP_ICON_WIDTH), f.getY(), DESKTOP_ICON_WIDTH, icon.getHeight());
icon.setBounds(f.getX() + (f.getWidth() - needIconWidth), f.getY(), needIconWidth, icon.getHeight());
}
}
@Override
public void deiconifyFrame(JInternalFrame f) {
super.deiconifyFrame(f);
if (f instanceof CardInfoWindowDialog) {
if (f instanceof MageDesktopIconifySupport) {
int needIconWidth = ((MageDesktopIconifySupport) f).getDesktopIconWidth();
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
f.setBounds(icon.getX() + (DESKTOP_ICON_WIDTH - f.getWidth()), icon.getY(), f.getWidth(), f.getHeight());
f.setBounds(icon.getX() + (needIconWidth - f.getWidth()), icon.getY(), f.getWidth(), f.getHeight());
}
}