mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Some more changes to GUI to better support high screen resolutions.
This commit is contained in:
parent
2ce5e00c6d
commit
706d319f81
25 changed files with 376 additions and 229 deletions
|
@ -101,6 +101,7 @@ import mage.client.dialog.ConnectDialog;
|
|||
import mage.client.dialog.ErrorDialog;
|
||||
import mage.client.dialog.FeedbackDialog;
|
||||
import mage.client.dialog.GameEndDialog;
|
||||
import mage.client.dialog.MageDialog;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.dialog.TableWaitingDialog;
|
||||
import mage.client.dialog.UserRequestDialog;
|
||||
|
@ -237,7 +238,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
try {
|
||||
UIManager.put("desktop", new Color(0, 0, 0, 0));
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
FontSizeHelper.setGUISize();
|
||||
FontSizeHelper.calculateGUISizes();
|
||||
// Change default font and row size for JTables
|
||||
Font font = FontSizeHelper.getTableFont();
|
||||
UIManager.put("Table.font", font);
|
||||
|
@ -1406,29 +1407,24 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
for (Component component : desktopPane.getComponents()) {
|
||||
if (component instanceof MageDialog) {
|
||||
((MageDialog) component).changeGUISize();
|
||||
}
|
||||
if (component instanceof MagePane) {
|
||||
((MagePane) component).changeGUISize();
|
||||
}
|
||||
}
|
||||
Font font = FontSizeHelper.getChatFont();
|
||||
for (ChatPanelBasic chatPanel : getChatPanels().values()) {
|
||||
chatPanel.changeGUISize(font);
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
Font font = FontSizeHelper.getToolbarFont();
|
||||
// Tables
|
||||
if (tablesPane != null) {
|
||||
tablesPane.changeGUISize();
|
||||
}
|
||||
// Deck editor
|
||||
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
|
||||
for (JInternalFrame window : windows) {
|
||||
if (window instanceof DeckEditorPane) {
|
||||
((DeckEditorPane) window).getPanel().changeGUISize();
|
||||
}
|
||||
}
|
||||
// Tournament panels
|
||||
for (Component component : desktopPane.getComponents()) {
|
||||
if (component instanceof TournamentPane) {
|
||||
((TournamentPane) component).changeGUISize();
|
||||
}
|
||||
}
|
||||
mageToolbar.setFont(font);
|
||||
int newHeight = font.getSize() + 6;
|
||||
Dimension mageToolbarDimension = mageToolbar.getPreferredSize();
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.awt.KeyboardFocusManager;
|
|||
import java.beans.PropertyVetoException;
|
||||
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||
import javax.swing.plaf.basic.BasicInternalFrameUI;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,8 +44,6 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public abstract class MagePane extends javax.swing.JInternalFrame {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(MagePane.class);
|
||||
|
||||
/**
|
||||
* Creates new form MagePane
|
||||
*/
|
||||
|
@ -62,6 +59,10 @@ public abstract class MagePane extends javax.swing.JInternalFrame {
|
|||
}
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
|
|
|
@ -72,6 +72,12 @@ public class DeckEditorPane extends MagePane {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeGUISize() {
|
||||
super.changeGUISize();
|
||||
deckEditorPanel1.changeGUISize();
|
||||
}
|
||||
|
||||
public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) {
|
||||
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
|
||||
this.setTitle("Deck Editor - " + tableId.toString());
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* MageDialog.java
|
||||
*
|
||||
* Created on 15-Dec-2009, 10:28:27 PM
|
||||
|
@ -56,7 +56,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class MageDialog extends javax.swing.JInternalFrame {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MageDialog.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(MageDialog.class);
|
||||
|
||||
protected boolean modal = false;
|
||||
|
||||
|
@ -67,6 +67,10 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
|
@ -89,22 +93,20 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
this.setClosable(false);
|
||||
if (value) {
|
||||
startModal();
|
||||
} else if (SwingUtilities.isEventDispatchThread()) {
|
||||
stopModal();
|
||||
} else {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
stopModal();
|
||||
} else {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stopModal();
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("MageDialog error", ex);
|
||||
} catch (InvocationTargetException ex) {
|
||||
logger.fatal("MageDialog error", ex);
|
||||
}
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stopModal();
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException ex) {
|
||||
LOGGER.fatal("MageDialog error", ex);
|
||||
} catch (InvocationTargetException ex) {
|
||||
LOGGER.fatal("MageDialog error", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
} else if (source instanceof MenuComponent) {
|
||||
((MenuComponent) source).dispatchEvent(event);
|
||||
} else {
|
||||
logger.warn("Unable to dispatch: " + event);
|
||||
LOGGER.warn("Unable to dispatch: " + event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -443,7 +443,7 @@
|
|||
</Component>
|
||||
<Component class="javax.swing.JSlider" name="sliderFontSize">
|
||||
<Properties>
|
||||
<Property name="majorTickSpacing" type="int" value="10"/>
|
||||
<Property name="majorTickSpacing" type="int" value="5"/>
|
||||
<Property name="maximum" type="int" value="50"/>
|
||||
<Property name="minimum" type="int" value="10"/>
|
||||
<Property name="minorTickSpacing" type="int" value="1"/>
|
||||
|
|
|
@ -724,9 +724,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
fontSizeLabel.setText("Size");
|
||||
fontSizeLabel.setToolTipText("<HTML>The size of the font used to display text.");
|
||||
guiSize_font.add(fontSizeLabel, java.awt.BorderLayout.CENTER);
|
||||
fontSizeLabel.getAccessibleContext().setAccessibleName("Size");
|
||||
|
||||
sliderFontSize.setMajorTickSpacing(10);
|
||||
sliderFontSize.setMajorTickSpacing(5);
|
||||
sliderFontSize.setMaximum(50);
|
||||
sliderFontSize.setMinimum(10);
|
||||
sliderFontSize.setMinorTickSpacing(1);
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
*/
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CancellationException;
|
||||
|
@ -46,6 +48,7 @@ import mage.client.components.MageComponents;
|
|||
import mage.client.components.tray.MageTray;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.gui.TableUtil;
|
||||
import mage.client.util.gui.countryBox.CountryCellRenderer;
|
||||
|
@ -90,10 +93,25 @@ public class TableWaitingDialog extends MageDialog {
|
|||
tableSeats.createDefaultColumnsFromModel();
|
||||
TableUtil.setColumnWidthAndOrder(tableSeats, DEFAULT_COLUMS_WIDTH, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER);
|
||||
tableSeats.setDefaultRenderer(Icon.class, new CountryCellRenderer());
|
||||
setGUISize();
|
||||
|
||||
MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
Font font = FontSizeHelper.getTableFont();
|
||||
tableSeats.getTableHeader().setFont(font);
|
||||
tableSeats.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
|
||||
|
||||
jSplitPane1.setDividerSize(FontSizeHelper.dividerBarSize);
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(FontSizeHelper.scrollBarSize, 0));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, FontSizeHelper.scrollBarSize));
|
||||
}
|
||||
|
||||
public void update(TableView table) {
|
||||
try {
|
||||
if (table != null) {
|
||||
|
|
|
@ -24,38 +24,37 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* BattlefieldPanel.java
|
||||
*
|
||||
* Created on 10-Jan-2010, 10:43:14 PM
|
||||
*/
|
||||
|
||||
package mage.client.game;
|
||||
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.Permanent;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.layout.CardLayoutStrategy;
|
||||
import mage.constants.CardType;
|
||||
import mage.utils.CardUtil;
|
||||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.Permanent;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.layout.CardLayoutStrategy;
|
||||
import mage.client.util.layout.impl.OldCardLayoutStrategy;
|
||||
import mage.constants.CardType;
|
||||
import mage.utils.CardUtil;
|
||||
import mage.view.CounterView;
|
||||
import mage.view.PermanentView;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -78,18 +77,20 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
private final CardLayoutStrategy layoutStrategy = new OldCardLayoutStrategy();
|
||||
|
||||
//private static int iCounter = 0;
|
||||
|
||||
private boolean addedPermanent;
|
||||
private boolean addedArtifact;
|
||||
private boolean addedCreature;
|
||||
|
||||
private boolean removedCreature;
|
||||
|
||||
/** Creates new form BattlefieldPanel */
|
||||
/**
|
||||
* Creates new form BattlefieldPanel
|
||||
*/
|
||||
public BattlefieldPanel() {
|
||||
uiComponentsList.put("battlefieldPanel", this);
|
||||
initComponents();
|
||||
uiComponentsList.put("jPanel", jPanel);
|
||||
setGUISize();
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
|
@ -109,7 +110,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
|
||||
public void cleanUp() {
|
||||
for (Component c: this.jPanel.getComponents()) {
|
||||
for (Component c : this.jPanel.getComponents()) {
|
||||
if (c instanceof Permanent || c instanceof MagePermanent) {
|
||||
this.jPanel.remove(c);
|
||||
}
|
||||
|
@ -119,11 +120,20 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
this.bigCard = null;
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
jScrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(FontSizeHelper.scrollBarSize, 0));
|
||||
jScrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(0, FontSizeHelper.scrollBarSize));
|
||||
}
|
||||
|
||||
public void update(Map<UUID, PermanentView> battlefield) {
|
||||
boolean changed = false;
|
||||
|
||||
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
||||
for (PermanentView permanent: battlefield.values()) {
|
||||
for (PermanentView permanent : battlefield.values()) {
|
||||
if (!permanent.isPhasedIn()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -131,7 +141,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
if (oldMagePermanent == null) {
|
||||
permanentsToAdd.add(permanent);
|
||||
changed = true;
|
||||
} else {
|
||||
} else {
|
||||
if (!changed) {
|
||||
changed = CardUtil.isCreature(oldMagePermanent.getOriginalPermanent()) != CardUtil.isCreature(permanent);
|
||||
if (!changed) {
|
||||
|
@ -158,7 +168,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
UUID u1 = oldMagePermanent.getOriginalPermanent().getAttachedTo();
|
||||
UUID u2 = permanent.getAttachedTo();
|
||||
if (u1 == null && u2 != null || u2 == null && u1 != null
|
||||
|| (u1 != null && !u1.equals(u2)) ) {
|
||||
|| (u1 != null && !u1.equals(u2))) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +224,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
|
||||
public void sortLayout() {
|
||||
if (battlefield == null) {return;}
|
||||
if (battlefield == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
layoutStrategy.doLayout(this, width);
|
||||
|
||||
|
@ -266,26 +278,26 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
|
||||
private void removePermanent(UUID permanentId, final int count) {
|
||||
for (Component c: this.jPanel.getComponents()) {
|
||||
for (Component c : this.jPanel.getComponents()) {
|
||||
final Component comp = c;
|
||||
if (comp instanceof Permanent) {
|
||||
if (((Permanent)comp).getPermanentId().equals(permanentId)) {
|
||||
if (((Permanent) comp).getPermanentId().equals(permanentId)) {
|
||||
comp.setVisible(false);
|
||||
this.jPanel.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MagePermanent) {
|
||||
if (((MagePermanent)comp).getOriginal().getId().equals(permanentId)) {
|
||||
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Plugins.getInstance().onRemoveCard((MagePermanent)comp, count);
|
||||
Plugins.getInstance().onRemoveCard((MagePermanent) comp, count);
|
||||
comp.setVisible(false);
|
||||
BattlefieldPanel.this.jPanel.remove(comp);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
if (((MagePermanent)comp).getOriginal().getCardTypes().contains(CardType.CREATURE)) {
|
||||
if (((MagePermanent) comp).getOriginal().getCardTypes().contains(CardType.CREATURE)) {
|
||||
removedCreature = true;
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +305,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isOptimizedDrawingEnabled () {
|
||||
public boolean isOptimizedDrawingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -309,7 +321,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
jPanel.setOpaque(false);
|
||||
jScrollPane = new JScrollPane(jPanel);
|
||||
|
||||
Border empty = new EmptyBorder(0,0,0,0);
|
||||
Border empty = new EmptyBorder(0, 0, 0, 0);
|
||||
jScrollPane.setBorder(empty);
|
||||
jScrollPane.setViewportBorder(empty);
|
||||
jScrollPane.setOpaque(false);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* FeedbackPanel.java
|
||||
*
|
||||
* Created on 23-Dec-2009, 9:54:01 PM
|
||||
|
@ -60,7 +60,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class FeedbackPanel extends javax.swing.JPanel {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FeedbackPanel.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(FeedbackPanel.class);
|
||||
|
||||
public enum FeedbackMode {
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private ChatPanelBasic connectedChatPanel;
|
||||
private int lastMessageId;
|
||||
|
||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||
private static final ScheduledExecutorService WORKER = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
/**
|
||||
* Creates new form FeedbackPanel
|
||||
|
@ -88,12 +88,21 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
this.gameId = gameId;
|
||||
session = MageFrame.getSession();
|
||||
helper.init(gameId);
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
helper.changeGUISize();
|
||||
}
|
||||
|
||||
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options, int messageId) {
|
||||
synchronized (this) {
|
||||
if (messageId < this.lastMessageId) {
|
||||
logger.warn("ignoring message from later source: " + messageId + ", text=" + message);
|
||||
LOGGER.warn("ignoring message from later source: " + messageId + ", text=" + message);
|
||||
return;
|
||||
}
|
||||
this.lastMessageId = messageId;
|
||||
|
@ -179,7 +188,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
Runnable task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("Ending game...");
|
||||
LOGGER.info("Ending game...");
|
||||
Component c = MageFrame.getGame(gameId);
|
||||
while (c != null && !(c instanceof GamePane)) {
|
||||
c = c.getParent();
|
||||
|
@ -189,7 +198,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
};
|
||||
worker.schedule(task, 8, TimeUnit.SECONDS);
|
||||
WORKER.schedule(task, 8, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void handleOptions(Map<String, Serializable> options) {
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* GamePane.java
|
||||
*
|
||||
* Created on Dec 17, 2009, 9:34:10 AM
|
||||
*/
|
||||
|
||||
package mage.client.game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -44,8 +43,10 @@ import mage.client.MagePane;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GamePane extends MagePane {
|
||||
|
||||
/** Creates new form GamePane */
|
||||
|
||||
/**
|
||||
* Creates new form GamePane
|
||||
*/
|
||||
public GamePane() {
|
||||
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
initComponents();
|
||||
|
@ -66,7 +67,13 @@ public class GamePane extends MagePane {
|
|||
}
|
||||
|
||||
public void cleanUp() {
|
||||
gamePanel.cleanUp();
|
||||
gamePanel.cleanUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeGUISize() {
|
||||
super.changeGUISize();
|
||||
gamePanel.changeGUISize();
|
||||
}
|
||||
|
||||
public void removeGame() {
|
||||
|
@ -97,14 +104,14 @@ public class GamePane extends MagePane {
|
|||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)
|
||||
.addGap(0, 600, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)
|
||||
.addGap(0, 600, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pack();
|
||||
|
@ -123,7 +130,7 @@ public class GamePane extends MagePane {
|
|||
public void activated() {
|
||||
gamePanel.activated();
|
||||
}
|
||||
|
||||
|
||||
private mage.client.game.GamePanel gamePanel;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private UUID gameId;
|
||||
|
|
|
@ -103,6 +103,7 @@ import mage.client.plugins.impl.Plugins;
|
|||
import mage.client.util.CardsViewUtil;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.Listener;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
|
@ -204,6 +205,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
public GamePanel() {
|
||||
initComponents();
|
||||
changeGUISize();
|
||||
|
||||
initPopupMenuTriggerOrder();
|
||||
//this.add(popupMenuTriggerOrder);
|
||||
|
@ -323,6 +325,21 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.bigCard = null;
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
handContainer.changeGUISize();
|
||||
for (PlayAreaPanel playAreaPanel : players.values()) {
|
||||
playAreaPanel.changeGUISize();
|
||||
}
|
||||
feedbackPanel.changeGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
jSplitPane0.setDividerSize(FontSizeHelper.dividerBarSize);
|
||||
jSplitPane1.setDividerSize(FontSizeHelper.dividerBarSize);
|
||||
jSplitPane2.setDividerSize(FontSizeHelper.dividerBarSize);
|
||||
}
|
||||
|
||||
private void saveDividerLocations() {
|
||||
// save panel sizes and divider locations.
|
||||
Rectangle rec = MageFrame.getDesktop().getBounds();
|
||||
|
@ -374,19 +391,17 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
p.sizePlayer(smallMode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (smallMode) {
|
||||
smallMode = false;
|
||||
Dimension bbDimension = new Dimension(256, 367);
|
||||
bigCard.setMaximumSize(bbDimension);
|
||||
bigCard.setMinimumSize(bbDimension);
|
||||
bigCard.setPreferredSize(bbDimension);
|
||||
pnlShortCuts.revalidate();
|
||||
pnlShortCuts.repaint();
|
||||
this.handContainer.sizeHand(1, smallMode);
|
||||
for (PlayAreaPanel p : players.values()) {
|
||||
p.sizePlayer(smallMode);
|
||||
}
|
||||
} else if (smallMode) {
|
||||
smallMode = false;
|
||||
Dimension bbDimension = new Dimension(256, 367);
|
||||
bigCard.setMaximumSize(bbDimension);
|
||||
bigCard.setMinimumSize(bbDimension);
|
||||
bigCard.setPreferredSize(bbDimension);
|
||||
pnlShortCuts.revalidate();
|
||||
pnlShortCuts.repaint();
|
||||
this.handContainer.sizeHand(1, smallMode);
|
||||
for (PlayAreaPanel p : players.values()) {
|
||||
p.sizePlayer(smallMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package mage.client.game;
|
||||
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.Config;
|
||||
import mage.constants.Zone;
|
||||
import mage.view.CardsView;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.UUID;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.util.UUID;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import mage.constants.Zone;
|
||||
import mage.view.CardsView;
|
||||
|
||||
public class HandPanel extends JPanel {
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class HandPanel extends JPanel {
|
|||
public HandPanel() {
|
||||
double factor = 1;
|
||||
initComponents();
|
||||
changeGUISize();
|
||||
sizeHand(factor, false);
|
||||
}
|
||||
|
||||
|
@ -65,6 +66,15 @@ public class HandPanel extends JPanel {
|
|||
hand.cleanUp();
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(FontSizeHelper.scrollBarSize, 0));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, FontSizeHelper.scrollBarSize));
|
||||
}
|
||||
|
||||
public void loadCards(CardsView cards, BigCard bigCard, UUID gameId) {
|
||||
hand.loadCards(cards, bigCard, gameId, true);
|
||||
hand.sizeCards(getHandCardDimension());
|
||||
|
|
|
@ -50,6 +50,7 @@ import mage.client.MageFrame;
|
|||
import mage.client.components.MageTextArea;
|
||||
import mage.client.game.FeedbackPanel.FeedbackMode;
|
||||
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_NO;
|
||||
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_YES;
|
||||
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
|
||||
|
@ -107,6 +108,23 @@ public class HelperPanel extends JPanel {
|
|||
session = MageFrame.getSession();
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
for (Component comp : popupMenuAskNo.getComponents()) {
|
||||
if (comp instanceof JMenuItem) {
|
||||
comp.setFont(FontSizeHelper.menuFont);
|
||||
}
|
||||
}
|
||||
for (Component comp : popupMenuAskYes.getComponents()) {
|
||||
if (comp instanceof JMenuItem) {
|
||||
comp.setFont(FontSizeHelper.menuFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
initPopupMenuTriggerOrder();
|
||||
setBackground(new Color(0, 0, 0, 100));
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.client.game;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
@ -55,6 +56,7 @@ import mage.client.dialog.PreferencesDialog;
|
|||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT;
|
||||
import static mage.client.dialog.PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE;
|
||||
import mage.client.util.FontSizeHelper;
|
||||
import mage.constants.PlayerAction;
|
||||
import mage.view.PlayerView;
|
||||
|
||||
|
@ -103,6 +105,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
addPopupMenuWatcher();
|
||||
}
|
||||
this.add(popupMenu);
|
||||
setGUISize();
|
||||
|
||||
init(player, bigCard, gameId, priorityTime);
|
||||
update(player);
|
||||
}
|
||||
|
@ -137,6 +141,26 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
battlefieldPanel.changeGUISize();
|
||||
playerPanel.changeGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
for (Component comp : popupMenu.getComponents()) {
|
||||
if (comp instanceof JMenuItem) {
|
||||
comp.setFont(FontSizeHelper.menuFont);
|
||||
if (comp instanceof JMenu) {
|
||||
comp.setFont(FontSizeHelper.menuFont);
|
||||
for (Component subComp : ((JMenu) comp).getMenuComponents()) {
|
||||
subComp.setFont(FontSizeHelper.menuFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPopupMenuPlayer(boolean allowRequestToShowHandCards) {
|
||||
|
||||
JMenuItem menuItem;
|
||||
|
@ -530,8 +554,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 0)));
|
||||
playerPanel = new PlayerPanelExt();
|
||||
btnCheat = new javax.swing.JButton();
|
||||
//jScrollPane1 = new javax.swing.JScrollPane();
|
||||
//battlefieldPanel = new mage.client.game.BattlefieldPanel(jScrollPane1);
|
||||
battlefieldPanel = new mage.client.game.BattlefieldPanel();
|
||||
|
||||
btnCheat.setText("Cheat");
|
||||
|
@ -542,10 +564,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
//jScrollPane1.setViewportView(battlefieldPanel);
|
||||
//Border empty = new EmptyBorder(0,0,0,0);
|
||||
//jScrollPane1.setBorder(empty);
|
||||
//jScrollPane1.setViewportBorder(empty);
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createSequentialGroup()
|
||||
|
|
|
@ -102,9 +102,9 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
private static final int PANEL_HEIGHT_SMALL = 212;
|
||||
private static final int MANA_LABEL_SIZE_HORIZONTAL = 20;
|
||||
|
||||
private static final Border greenBorder = new LineBorder(Color.green, 3);
|
||||
private static final Border redBorder = new LineBorder(Color.red, 2);
|
||||
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
||||
private static final Border GREEN_BORDER = new LineBorder(Color.green, 3);
|
||||
private static final Border RED_BORDER = new LineBorder(Color.red, 2);
|
||||
private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0);
|
||||
|
||||
private int avatarId = -1;
|
||||
private String flagName;
|
||||
|
@ -118,6 +118,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
public PlayerPanelExt() {
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
initComponents();
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard, int priorityTime) {
|
||||
|
@ -158,6 +159,14 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
public void changeGUISize() {
|
||||
setGUISize();
|
||||
}
|
||||
|
||||
private void setGUISize() {
|
||||
|
||||
}
|
||||
|
||||
public void update(PlayerView player) {
|
||||
this.player = player;
|
||||
updateAvatar();
|
||||
|
@ -257,14 +266,14 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
if (player.isActive()) {
|
||||
this.avatar.setBorder(greenBorder);
|
||||
this.btnPlayer.setBorder(greenBorder);
|
||||
this.avatar.setBorder(GREEN_BORDER);
|
||||
this.btnPlayer.setBorder(GREEN_BORDER);
|
||||
} else if (player.hasLeft()) {
|
||||
this.avatar.setBorder(redBorder);
|
||||
this.btnPlayer.setBorder(redBorder);
|
||||
this.avatar.setBorder(RED_BORDER);
|
||||
this.btnPlayer.setBorder(RED_BORDER);
|
||||
} else {
|
||||
this.avatar.setBorder(emptyBorder);
|
||||
this.btnPlayer.setBorder(emptyBorder);
|
||||
this.avatar.setBorder(EMPTY_BORDER);
|
||||
this.btnPlayer.setBorder(EMPTY_BORDER);
|
||||
}
|
||||
|
||||
update(player.getManaPool());
|
||||
|
@ -501,7 +510,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
manaCountLabelW.setText("0");
|
||||
manaLabels.put("W", manaCountLabelW);
|
||||
r = new Rectangle(12, 12);
|
||||
BufferedImage imageManaW = ManaSymbols.getManaSymbolImageSmall("W");
|
||||
BufferedImage imageManaW = ManaSymbols.getSizedManaSymbol("W");
|
||||
HoverButton btnWhiteMana = new HoverButton(null, imageManaW, imageManaW, imageManaW, r);
|
||||
btnWhiteMana.setToolTipText("White mana");
|
||||
btnWhiteMana.setOpaque(false);
|
||||
|
@ -517,7 +526,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
manaCountLabelU.setText("0");
|
||||
manaLabels.put("U", manaCountLabelU);
|
||||
r = new Rectangle(12, 12);
|
||||
BufferedImage imageManaU = ManaSymbols.getManaSymbolImageSmall("U");
|
||||
BufferedImage imageManaU = ManaSymbols.getSizedManaSymbol("U");
|
||||
HoverButton btnBlueMana = new HoverButton(null, imageManaU, imageManaU, imageManaU, r);
|
||||
btnBlueMana.setToolTipText("Blue mana");
|
||||
btnBlueMana.setOpaque(false);
|
||||
|
@ -533,7 +542,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
manaCountLabelB.setText("0");
|
||||
manaLabels.put("B", manaCountLabelB);
|
||||
r = new Rectangle(12, 12);
|
||||
BufferedImage imageManaB = ManaSymbols.getManaSymbolImageSmall("B");
|
||||
BufferedImage imageManaB = ManaSymbols.getSizedManaSymbol("B");
|
||||
HoverButton btnBlackMana = new HoverButton(null, imageManaB, imageManaB, imageManaB, r);
|
||||
btnBlackMana.setToolTipText("Black mana");
|
||||
btnBlackMana.setOpaque(false);
|
||||
|
@ -549,7 +558,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
manaCountLabelR.setText("0");
|
||||
manaLabels.put("R", manaCountLabelR);
|
||||
r = new Rectangle(12, 12);
|
||||
BufferedImage imageManaR = ManaSymbols.getManaSymbolImageSmall("R");
|
||||
BufferedImage imageManaR = ManaSymbols.getSizedManaSymbol("R");
|
||||
HoverButton btnRedMana = new HoverButton(null, imageManaR, imageManaR, imageManaR, r);
|
||||
btnRedMana.setToolTipText("Red mana");
|
||||
btnRedMana.setOpaque(false);
|
||||
|
@ -565,7 +574,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
manaCountLabelG.setText("0");
|
||||
manaLabels.put("G", manaCountLabelG);
|
||||
r = new Rectangle(12, 12);
|
||||
BufferedImage imageManaG = ManaSymbols.getManaSymbolImageSmall("G");
|
||||
BufferedImage imageManaG = ManaSymbols.getSizedManaSymbol("G");
|
||||
HoverButton btnGreenMana = new HoverButton(null, imageManaG, imageManaG, imageManaG, r);
|
||||
btnGreenMana.setToolTipText("Green mana");
|
||||
btnGreenMana.setOpaque(false);
|
||||
|
@ -581,7 +590,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
manaCountLabelX.setText("0");
|
||||
manaLabels.put("X", manaCountLabelX);
|
||||
r = new Rectangle(12, 12);
|
||||
BufferedImage imageManaX = ManaSymbols.getManaSymbolImageSmall("C");
|
||||
BufferedImage imageManaX = ManaSymbols.getSizedManaSymbol("C");
|
||||
HoverButton btnColorlessMana = new HoverButton(null, imageManaX, imageManaX, imageManaX, r);
|
||||
btnColorlessMana.setToolTipText("Colorless mana");
|
||||
btnColorlessMana.setOpaque(false);
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package mage.client.plugins;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.swing.*;
|
||||
import mage.cards.MageCard;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
|
@ -7,31 +13,41 @@ import mage.client.cards.BigCard;
|
|||
import mage.view.CardView;
|
||||
import mage.view.PermanentView;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface MagePlugins {
|
||||
|
||||
void loadPlugins();
|
||||
|
||||
void shutdown();
|
||||
|
||||
void updateGamePanel(Map<String, JComponent> ui);
|
||||
|
||||
JComponent updateTablePanel(Map<String, JComponent> ui);
|
||||
|
||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
||||
|
||||
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
||||
|
||||
boolean isThemePluginLoaded();
|
||||
|
||||
boolean isCardPluginLoaded();
|
||||
|
||||
boolean isCounterPluginLoaded();
|
||||
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
||||
|
||||
void downloadSymbols();
|
||||
|
||||
int getGamesPlayed();
|
||||
|
||||
void addGamesPlayed();
|
||||
Image getManaSymbolImage(String symbol);
|
||||
|
||||
void onAddCard(MagePermanent card, int count);
|
||||
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
|
||||
JComponent getCardInfoPane();
|
||||
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
|
||||
ActionCallback getActionCallback();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package mage.client.plugins.impl;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
@ -32,12 +31,11 @@ import org.apache.log4j.Logger;
|
|||
import org.mage.plugins.card.CardPluginImpl;
|
||||
import org.mage.plugins.theme.ThemePluginImpl;
|
||||
|
||||
|
||||
public class Plugins implements MagePlugins {
|
||||
|
||||
public static final String PLUGINS_DIRECTORY = "plugins/";
|
||||
|
||||
private static final MagePlugins fINSTANCE = new Plugins();
|
||||
private static final MagePlugins fINSTANCE = new Plugins();
|
||||
private static final Logger logger = Logger.getLogger(Plugins.class);
|
||||
private static PluginManager pm;
|
||||
|
||||
|
@ -107,8 +105,6 @@ public class Plugins implements MagePlugins {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCardPluginLoaded() {
|
||||
return this.cardPlugin != null;
|
||||
|
@ -135,7 +131,7 @@ public class Plugins implements MagePlugins {
|
|||
@Override
|
||||
public int getGamesPlayed() {
|
||||
if (this.counterPlugin != null) {
|
||||
synchronized(Plugins.class) {
|
||||
synchronized (Plugins.class) {
|
||||
try {
|
||||
return this.counterPlugin.getGamePlayed();
|
||||
} catch (PluginException e) {
|
||||
|
@ -150,7 +146,7 @@ public class Plugins implements MagePlugins {
|
|||
@Override
|
||||
public void addGamesPlayed() {
|
||||
if (this.counterPlugin != null) {
|
||||
synchronized(Plugins.class) {
|
||||
synchronized (Plugins.class) {
|
||||
try {
|
||||
this.counterPlugin.addGamePlayed();
|
||||
} catch (PluginException e) {
|
||||
|
@ -171,14 +167,6 @@ public class Plugins implements MagePlugins {
|
|||
return this.themePlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getManaSymbolImage(String symbol) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getManaSymbolImage(symbol);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCard(MagePermanent card, int count) {
|
||||
if (this.cardPlugin != null) {
|
||||
|
|
|
@ -63,7 +63,9 @@ public class TablesPane extends MagePane {
|
|||
tablesPanel.cleanUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeGUISize() {
|
||||
super.changeGUISize();
|
||||
tablesPanel.changeGUISize();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public class TournamentPane extends MagePane {
|
|||
removeFrame();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeGUISize() {
|
||||
tournamentPanel.changeGUISize();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ package mage.client.util;
|
|||
|
||||
import java.awt.Font;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanelBasic;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
|
||||
/**
|
||||
|
@ -17,9 +16,12 @@ import mage.client.dialog.PreferencesDialog;
|
|||
public class FontSizeHelper {
|
||||
|
||||
public static String basicSymbolSize = "small";
|
||||
|
||||
public static int symbolCardSize = 15;
|
||||
public static int symbolTooltipSize = 15;
|
||||
public static int symbolPaySize = 15;
|
||||
public static int symbolEditorSize = 15;
|
||||
|
||||
public static int tableHeaderHeight = 24;
|
||||
public static int tableRowHeight = 20;
|
||||
|
||||
|
@ -28,6 +30,11 @@ public class FontSizeHelper {
|
|||
|
||||
public static Font tooltipFont = new java.awt.Font("Arial", 0, 12);
|
||||
|
||||
public static Font menuFont = new java.awt.Font("Arial", 0, 12);
|
||||
|
||||
public static Font gameDialogAreaFontBig = new java.awt.Font("Arial", 0, 12);
|
||||
public static Font gameDialogAreaFontSmall = new java.awt.Font("Arial", 0, 12);
|
||||
|
||||
public static Font getChatFont() {
|
||||
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14);
|
||||
return new java.awt.Font("Arial", 0, fontSize);
|
||||
|
@ -54,14 +61,11 @@ public class FontSizeHelper {
|
|||
}
|
||||
|
||||
public static void changeGUISize() {
|
||||
setGUISize();
|
||||
for (ChatPanelBasic chatPanel : MageFrame.getChatPanels().values()) {
|
||||
chatPanel.changeGUISize(getChatFont());
|
||||
}
|
||||
calculateGUISizes();
|
||||
MageFrame.getInstance().changeGUISize();
|
||||
}
|
||||
|
||||
public static void setGUISize() {
|
||||
public static void calculateGUISizes() {
|
||||
// Set basic symbol size
|
||||
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14);
|
||||
if (fontSize < 25) {
|
||||
|
@ -73,18 +77,22 @@ public class FontSizeHelper {
|
|||
}
|
||||
if (fontSize > 15) {
|
||||
symbolTooltipSize = fontSize - 5;
|
||||
symbolEditorSize = fontSize - 5;
|
||||
symbolPaySize = fontSize - 5;
|
||||
symbolCardSize = fontSize - 5;
|
||||
symbolCardSize = 15;
|
||||
dividerBarSize = 10 + (fontSize / 4);
|
||||
scrollBarSize = 14 + (fontSize / 4);
|
||||
} else {
|
||||
symbolTooltipSize = fontSize;
|
||||
symbolEditorSize = fontSize;
|
||||
symbolPaySize = fontSize;
|
||||
symbolCardSize = fontSize;
|
||||
symbolCardSize = 15;
|
||||
dividerBarSize = 10;
|
||||
scrollBarSize = 14;
|
||||
}
|
||||
tooltipFont = new java.awt.Font("Arial", 0, fontSize - 2);
|
||||
// used for popup menus
|
||||
menuFont = new java.awt.Font("Arial", 0, fontSize);
|
||||
|
||||
tableRowHeight = fontSize + 4;
|
||||
tableHeaderHeight = fontSize + 10;
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.awt.FlowLayout;
|
|||
import java.awt.Image;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComboBox;
|
||||
|
@ -14,9 +13,8 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import mage.client.constants.Constants;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
||||
public class ColorsChooser extends JComboBox implements ListCellRenderer {
|
||||
|
||||
|
@ -82,7 +80,7 @@ public class ColorsChooser extends JComboBox implements ListCellRenderer {
|
|||
value = value.toUpperCase();
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char symbol = value.charAt(i);
|
||||
Image image = Plugins.getInstance().getManaSymbolImage(String.valueOf(symbol));
|
||||
Image image = ManaSymbols.getSizedManaSymbol(String.valueOf(symbol));
|
||||
if (image != null) {
|
||||
images.add(image);
|
||||
}
|
||||
|
@ -101,7 +99,7 @@ public class ColorsChooser extends JComboBox implements ListCellRenderer {
|
|||
}
|
||||
} else {
|
||||
String s = value.replace("B", "{B}").replace("R", "{R}").replace("G", "{G}").replace("W", "{W}").replace("U", "{U}").replace("X", "{X}");
|
||||
panel.add(new JLabel(s));
|
||||
panel.add(new JLabel(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ public class ManaSymbols {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
|
||||
private static final Map<String, BufferedImage> MANA_IMAGES = new HashMap<>();
|
||||
private static final Map<String, Image> MANA_IMAGES_ORIGINAL = new HashMap<>();
|
||||
private static final Map<String, Image> SET_IMAGES = new HashMap<>();
|
||||
private static final Map<String, Dimension> SET_IMAGES_EXIST = new HashMap<>();
|
||||
private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
|
||||
|
@ -35,23 +34,36 @@ public class ManaSymbols {
|
|||
"BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU",
|
||||
"WP", "UP", "BP", "RP", "GP", "X", "C" /*, "Y", "Z", "slash"*/};
|
||||
|
||||
MANA_IMAGES.clear();
|
||||
SET_IMAGES.clear();
|
||||
SET_IMAGES_EXIST.clear();
|
||||
|
||||
for (String symbol : symbols) {
|
||||
File file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg");
|
||||
Rectangle r = new Rectangle(11, 11);
|
||||
String resourcePath = Constants.RESOURCE_PATH_MANA_SMALL;
|
||||
switch (FontSizeHelper.basicSymbolSize) {
|
||||
case "medium":
|
||||
resourcePath = Constants.RESOURCE_PATH_MANA_SMALL;
|
||||
break;
|
||||
case "large":
|
||||
resourcePath = Constants.RESOURCE_PATH_MANA_LARGE;
|
||||
break;
|
||||
}
|
||||
File file = new File(getSymbolsPath() + resourcePath + "/" + symbol + ".jpg");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
MANA_IMAGES.put(symbol, resized);
|
||||
if (FontSizeHelper.symbolPaySize != 15) {
|
||||
BufferedImage notResized = ImageIO.read(file);
|
||||
MANA_IMAGES.put(symbol, notResized);
|
||||
} else {
|
||||
Rectangle r = new Rectangle(FontSizeHelper.symbolPaySize, FontSizeHelper.symbolPaySize);
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
MANA_IMAGES.put(symbol, resized);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error for symbol:" + symbol);
|
||||
}
|
||||
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
MANA_IMAGES_ORIGINAL.put(symbol, image);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> setCodes = ExpansionRepository.instance.getSetCodes();
|
||||
if (setCodes == null) {
|
||||
// the cards db file is probaly not included in the client. It will be created after the first connect to a server.
|
||||
|
@ -158,10 +170,6 @@ public class ManaSymbols {
|
|||
return path;
|
||||
}
|
||||
|
||||
public static Image getManaSymbolImage(String symbol) {
|
||||
return MANA_IMAGES_ORIGINAL.get(symbol);
|
||||
}
|
||||
|
||||
public static void draw(Graphics g, String manaCost, int x, int y) {
|
||||
if (manaCost.length() == 0) {
|
||||
return;
|
||||
|
@ -201,9 +209,9 @@ public class ManaSymbols {
|
|||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
CARD,
|
||||
TOOLTIP,
|
||||
EDITOR,
|
||||
PAY
|
||||
}
|
||||
|
||||
|
@ -213,28 +221,28 @@ public class ManaSymbols {
|
|||
String replaced = value;
|
||||
|
||||
if (!MANA_IMAGES.isEmpty()) {
|
||||
int symbolSize;
|
||||
switch (type) {
|
||||
case TOOLTIP:
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true) + "/symbols/small/$1$2.jpg' alt='$1$2' width=11 height=11>");
|
||||
// replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
// + "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
|
||||
// + FontSizeHelper.symbolTooltipSize + " height=" + FontSizeHelper.symbolTooltipSize + ">");
|
||||
symbolSize = FontSizeHelper.symbolTooltipSize;
|
||||
break;
|
||||
case CARD:
|
||||
value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
|
||||
+ FontSizeHelper.symbolCardSize + " height=" + FontSizeHelper.symbolCardSize + ">");
|
||||
symbolSize = FontSizeHelper.symbolCardSize;
|
||||
break;
|
||||
case PAY:
|
||||
value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' "
|
||||
+ "width=" + FontSizeHelper.symbolPaySize + " height=" + FontSizeHelper.symbolPaySize + ">");
|
||||
symbolSize = FontSizeHelper.symbolPaySize;
|
||||
break;
|
||||
case EDITOR:
|
||||
symbolSize = FontSizeHelper.symbolEditorSize;
|
||||
break;
|
||||
default:
|
||||
symbolSize = 11;
|
||||
break;
|
||||
}
|
||||
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
|
||||
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
|
||||
+ symbolSize + " height=" + symbolSize + ">");
|
||||
|
||||
}
|
||||
replaced = replaced.replace("|source|", "{source}");
|
||||
replaced = replaced.replace("|this|", "{this}");
|
||||
|
@ -256,7 +264,7 @@ public class ManaSymbols {
|
|||
return SET_IMAGES.get(set);
|
||||
}
|
||||
|
||||
public static BufferedImage getManaSymbolImageSmall(String symbol) {
|
||||
public static BufferedImage getSizedManaSymbol(String symbol) {
|
||||
return MANA_IMAGES.get(symbol);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.mage.plugins.card;
|
|||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
@ -31,7 +30,6 @@ import net.xeoh.plugins.base.annotations.meta.Author;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.Animation;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
import org.mage.plugins.card.constants.Constants;
|
||||
import org.mage.plugins.card.dl.DownloadGui;
|
||||
import org.mage.plugins.card.dl.DownloadJob;
|
||||
|
@ -48,14 +46,15 @@ import org.mage.plugins.card.info.CardInfoPaneImpl;
|
|||
*
|
||||
* @author nantuko
|
||||
* @version 0.1 01.11.2010 Mage permanents. Sorting card layout.
|
||||
* @version 0.6 17.07.2011 #sortPermanents got option to display non-land permanents in one pile
|
||||
* @version 0.6 17.07.2011 #sortPermanents got option to display non-land
|
||||
* permanents in one pile
|
||||
* @version 0.7 29.07.2011 face down cards support
|
||||
*/
|
||||
@PluginImplementation
|
||||
@Author(name = "nantuko")
|
||||
public class CardPluginImpl implements CardPlugin {
|
||||
|
||||
private static final Logger log = Logger.getLogger(CardPluginImpl.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(CardPluginImpl.class);
|
||||
|
||||
private static final int GUTTER_Y = 15;
|
||||
private static final int GUTTER_X = 5;
|
||||
|
@ -81,7 +80,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
|
||||
@PluginLoaded
|
||||
public void newPlugin(CardPlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
LOGGER.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -398,6 +397,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private class Row extends ArrayList<Stack> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Row() {
|
||||
|
@ -458,6 +458,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private class Stack extends ArrayList<MagePermanent> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
@ -474,7 +475,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
private int getHeight() {
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + attachmentSpacingY*maxAttachedCount;
|
||||
return cardHeight + (size() - 1) * stackSpacingY + cardSpacingY + attachmentSpacingY * maxAttachedCount;
|
||||
}
|
||||
|
||||
public int getMaxAttachedCount() {
|
||||
|
@ -489,7 +490,8 @@ public class CardPluginImpl implements CardPlugin {
|
|||
/**
|
||||
* Download various symbols (mana, tap, set).
|
||||
*
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in such case default path should be used.
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in
|
||||
* such case default path should be used.
|
||||
*/
|
||||
@Override
|
||||
public void downloadSymbols(String imagesPath) {
|
||||
|
@ -502,17 +504,17 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
|
||||
it = new GathererSets(imagesPath);
|
||||
for(DownloadJob job:it) {
|
||||
g.getDownloader().add(job);
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
|
||||
it = new CardFrames(imagesPath);
|
||||
for(DownloadJob job:it) {
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
|
||||
it = new DirectLinksForDownload(imagesPath);
|
||||
for(DownloadJob job:it) {
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
|
||||
|
@ -530,11 +532,6 @@ public class CardPluginImpl implements CardPlugin {
|
|||
d.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getManaSymbolImage(String symbol) {
|
||||
return ManaSymbols.getManaSymbolImage(symbol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCard(MagePermanent card, int count) {
|
||||
if (card != null) {
|
||||
|
|
|
@ -4,22 +4,26 @@ import java.awt.Rectangle;
|
|||
import java.io.File;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String RESOURCE_PATH_SET = File.separator + "sets" + File.separator;
|
||||
|
||||
public static final String RESOURCE_PATH_MANA_SMALL = File.separator + "symbols" + File.separator + "small";
|
||||
public static final String RESOURCE_PATH_MANA_LARGE = File.separator + "symbols" + File.separator + "large";
|
||||
public static final String RESOURCE_PATH_MANA_MEDIUM = File.separator + "symbols" + File.separator + "medium";
|
||||
|
||||
public static final String RESOURCE_PATH_SET = File.separator + "sets" + File.separator;
|
||||
public static final String RESOURCE_PATH_SET_SMALL = RESOURCE_PATH_SET + File.separator + "small" + File.separator;
|
||||
|
||||
public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149);
|
||||
public static final Rectangle THUMBNAIL_SIZE_FULL = new Rectangle(102, 146);
|
||||
|
||||
|
||||
public static final int TOOLTIP_WIDTH_MIN = 320;
|
||||
public static final int TOOLTIP_HEIGHT_MIN = 201;
|
||||
|
||||
public static final int TOOLTIP_HEIGHT_MAX = 401;
|
||||
public static final int TOOLTIP_BORDER_WIDTH = 80;
|
||||
|
||||
public interface IO {
|
||||
public interface IO {
|
||||
|
||||
String imageBaseDir = "plugins" + File.separator + "images";
|
||||
String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||
}
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
package mage.interfaces.plugin;
|
||||
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.view.CardView;
|
||||
import mage.view.PermanentView;
|
||||
import net.xeoh.plugins.base.Plugin;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.swing.*;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.view.CardView;
|
||||
import mage.view.PermanentView;
|
||||
import net.xeoh.plugins.base.Plugin;
|
||||
|
||||
/**
|
||||
* Interface for card plugins
|
||||
|
@ -23,20 +22,26 @@ import java.util.UUID;
|
|||
* @author nantuko
|
||||
*/
|
||||
public interface CardPlugin extends Plugin {
|
||||
|
||||
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
|
||||
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
|
||||
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, Map<String, String> options);
|
||||
|
||||
/**
|
||||
* Download various symbols (mana, tap, set).
|
||||
*
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in such case default path should be used.
|
||||
* @param imagesPath Path to check in and store symbols to. Can be null, in
|
||||
* such case default path should be used.
|
||||
*/
|
||||
void downloadSymbols(String imagesPath);
|
||||
|
||||
Image getManaSymbolImage(String symbol);
|
||||
void onAddCard(MagePermanent card, int count);
|
||||
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
|
||||
JComponent getCardInfoPane();
|
||||
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue