Added condition hints with good/bad icons for cards

This commit is contained in:
Oleg Agafonov 2019-02-05 13:05:10 +04:00
parent 2a63314714
commit 043a7af086
8 changed files with 70 additions and 70 deletions

View file

@ -1,14 +1,9 @@
package mage.client.util.gui;
import java.awt.*;
import java.util.ArrayList;
import java.util.Locale;
import javax.swing.*;
import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE;
import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog;
import mage.client.table.PlayersChatPanel;
import mage.client.util.GUISizeHelper;
import mage.client.table.*;
import mage.constants.*;
import mage.view.CardView;
import mage.view.CounterView;
@ -17,6 +12,13 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Locale;
import static mage.client.dialog.PreferencesDialog.KEY_MAGE_PANEL_LAST_SIZE;
public final class GuiDisplayUtil {
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
@ -30,32 +32,32 @@ public final class GuiDisplayUtil {
}
public static void restoreDividerLocations(Rectangle bounds, String lastDividerLocation, JComponent component) {
String currentBounds = Double.toString(bounds.getWidth()) + 'x' + Double.toString(bounds.getHeight());
String savedBounds = PreferencesDialog.getCachedValue(KEY_MAGE_PANEL_LAST_SIZE, null);
// use divider positions only if screen size is the same as it was the time the settings were saved
if (savedBounds != null && savedBounds.equals(currentBounds)) {
if (lastDividerLocation != null && component != null) {
if (component instanceof JSplitPane) {
JSplitPane jSplitPane = (JSplitPane) component;
jSplitPane.setDividerLocation(Integer.parseInt(lastDividerLocation));
}
String currentBounds = Double.toString(bounds.getWidth()) + 'x' + bounds.getHeight();
String savedBounds = PreferencesDialog.getCachedValue(KEY_MAGE_PANEL_LAST_SIZE, null);
// use divider positions only if screen size is the same as it was the time the settings were saved
if (savedBounds != null && savedBounds.equals(currentBounds)) {
if (lastDividerLocation != null && component != null) {
if (component instanceof JSplitPane) {
JSplitPane jSplitPane = (JSplitPane) component;
jSplitPane.setDividerLocation(Integer.parseInt(lastDividerLocation));
}
if (component instanceof PlayersChatPanel) {
PlayersChatPanel playerChatPanel = (PlayersChatPanel) component;
playerChatPanel.setSplitDividerLocation(Integer.parseInt(lastDividerLocation));
}
if (component instanceof PlayersChatPanel) {
PlayersChatPanel playerChatPanel = (PlayersChatPanel) component;
playerChatPanel.setSplitDividerLocation(Integer.parseInt(lastDividerLocation));
}
}
}
}
}
public static void saveCurrentBoundsToPrefs() {
Rectangle rec = MageFrame.getDesktop().getBounds();
String currentBounds = Double.toString(rec.getWidth()) + 'x' + Double.toString(rec.getHeight());
PreferencesDialog.saveValue(KEY_MAGE_PANEL_LAST_SIZE, currentBounds);
Rectangle rec = MageFrame.getDesktop().getBounds();
String currentBounds = Double.toString(rec.getWidth()) + 'x' + rec.getHeight();
PreferencesDialog.saveValue(KEY_MAGE_PANEL_LAST_SIZE, currentBounds);
}
public static void saveDividerLocationToPrefs(String dividerPrefKey, int position) {
PreferencesDialog.saveValue(dividerPrefKey, Integer.toString(position));
PreferencesDialog.saveValue(dividerPrefKey, Integer.toString(position));
}
public static JXPanel getDescription(CardView card, int width, int height) {
@ -204,6 +206,10 @@ public final class GuiDisplayUtil {
return textLines;
}
public static String getHintIconHtml(String iconName, int symbolSize) {
return "<img src='" + getResourcePath("hint/" + iconName + ".png") + "' alt='" + iconName + "' width=" + symbolSize + " height=" + symbolSize + ">";
}
public static StringBuilder getRulefromCardView(CardView card, TextLines textLines) {
String manaCost = "";
for (String m : card.getManaCost()) {
@ -236,7 +242,7 @@ public final class GuiDisplayUtil {
buffer.append("<tr><td valign='top'><b>");
buffer.append(card.getDisplayName());
if (card.isGameObject()) {
buffer.append(" [").append(card.getId().toString().substring(0, 3)).append(']');
buffer.append(" [").append(card.getId().toString(), 0, 3).append(']');
}
buffer.append("</b></td><td align='right' valign='top' style='width:");
buffer.append(symbolCount * GUISizeHelper.cardTooltipFontSize);