fixing some additional singleton classes

This commit is contained in:
ingmargoudt 2017-03-16 09:46:22 +01:00
parent 894c575d34
commit 2b91b88551
41 changed files with 148 additions and 166 deletions

View file

@ -229,14 +229,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
ManaSymbols.loadImages();
Plugins.getInstance().loadPlugins();
Plugins.instance.loadPlugins();
initComponents();
desktopPane.setDesktopManager(new MageDesktopManager());
setSize(1024, 768);
SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768);
SettingsManager.instance.setScreenWidthAndHeight(1024, 768);
DialogManager.updateParams(768, 1024, false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
@ -265,7 +265,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setBackground();
addMageLabel();
setAppIcon();
MageTray.getInstance().install();
MageTray.instance.install();
desktopPane.add(ArrowBuilder.getBuilder().getArrowsManagerPanel(), JLayeredPane.DRAG_LAYER);
@ -274,7 +274,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void componentResized(ComponentEvent e) {
int width = ((JComponent) e.getSource()).getWidth();
int height = ((JComponent) e.getSource()).getHeight();
SettingsManager.getInstance().setScreenWidthAndHeight(width, height);
SettingsManager.instance.setScreenWidthAndHeight(width, height);
if (!liteMode && !grayMode) {
backgroundPane.setSize(width, height);
}
@ -295,8 +295,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
mageToolbar.add(createSwitchPanelsButton(), 0);
mageToolbar.add(new javax.swing.JToolBar.Separator(), 1);
if (Plugins.getInstance().isCounterPluginLoaded()) {
int i = Plugins.getInstance().getGamesPlayed();
if (Plugins.instance.isCounterPluginLoaded()) {
int i = Plugins.instance.getGamesPlayed();
JLabel label = new JLabel(" Games played: " + String.valueOf(i));
desktopPane.add(label, JLayeredPane.DEFAULT_LAYER + 1);
label.setVisible(true);
@ -338,7 +338,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
private void addTooltipContainer() {
final JEditorPane cardInfoPane = (JEditorPane) Plugins.getInstance().getCardInfoPane();
final JEditorPane cardInfoPane = (JEditorPane) Plugins.instance.getCardInfoPane();
if (cardInfoPane == null) {
return;
}
@ -422,8 +422,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
String filename = "/background.jpg";
try {
if (Plugins.getInstance().isThemePluginLoaded()) {
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<>());
if (Plugins.instance.isThemePluginLoaded()) {
backgroundPane = (ImagePanel) Plugins.instance.updateTablePanel(new HashMap<>());
} else {
InputStream is = this.getClass().getResourceAsStream(filename);
BufferedImage background = ImageIO.read(is);
@ -460,7 +460,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
private void setAppIcon() {
Image image = ImageManagerImpl.getInstance().getAppImage();
Image image = ImageManagerImpl.instance.getAppImage();
setIconImage(image);
}
@ -1323,7 +1323,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void sendUserReplay(PlayerAction playerAction, UserRequestMessage userRequestMessage) {
switch (playerAction) {
case CLIENT_DOWNLOAD_SYMBOLS:
Plugins.getInstance().downloadSymbols();
Plugins.instance.downloadSymbols();
break;
case CLIENT_DOWNLOAD_CARD_IMAGES:
DownloadPictures.startDownload(null, missingCards);
@ -1361,7 +1361,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
CardRepository.instance.closeDB();
tablesPane.cleanUp();
Plugins.getInstance().shutdown();
Plugins.instance.shutdown();
dispose();
System.exit(0);
break;
@ -1390,7 +1390,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setGUISizeTooltipContainer();
Plugins.getInstance().changeGUISize();
Plugins.instance.changeGUISize();
CountryUtil.changeGUISize();
for (Component component : desktopPane.getComponents()) {
if (component instanceof MageDialog) {
@ -1410,7 +1410,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
} catch (Exception ex) {
ex.printStackTrace();
}
this.revalidate();

View file

@ -81,7 +81,7 @@ public class BigCard extends JComponent {
public BigCard(boolean rotated) {
initComponents();
if (!Plugins.getInstance().isCardPluginLoaded()) {
if (!Plugins.instance.isCardPluginLoaded()) {
initBounds(rotated);
}
setDoubleBuffered(true);

View file

@ -148,7 +148,7 @@ public class CardArea extends JPanel implements MouseListener {
tmp.setAbility(card); // cross-reference, required for ability picker
card = tmp;
}
MageCard cardPanel = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true, true);
MageCard cardPanel = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
cardPanel.setBounds(rectangle);
cardPanel.addMouseListener(this);

View file

@ -57,7 +57,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
currentCards = new ArrayList<>(source.dragCardList());
// Make a view for the first one and add it to us
dragView = Plugins.getInstance().getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false);
dragView = Plugins.instance.getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false);
for (MouseListener l: dragView.getMouseListeners()) {
dragView.removeMouseListener(l);
}

View file

@ -133,7 +133,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
}
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, drawImage, true);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true);
cards.put(card.getId(), cardImg);
cardImg.addMouseListener(this);
add(cardImg);

View file

@ -98,7 +98,7 @@ public class Cards extends javax.swing.JPanel {
jScrollPane1.getViewport().setOpaque(false);
jScrollPane1.setBorder(EMPTY_BORDER);
}
if (Plugins.getInstance().isCardPluginLoaded()) {
if (Plugins.instance.isCardPluginLoaded()) {
cardArea.setLayout(null);
}
cardArea.setBorder(EMPTY_BORDER);
@ -263,7 +263,7 @@ public class Cards extends javax.swing.JPanel {
}
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
MageCard mageCard = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
if (zone != null) {
mageCard.setZone(zone);
}

View file

@ -425,7 +425,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
}
private MageCard addCard(CardView card, BigCard bigCard, UUID gameId) {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true, true);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
cardArea.add(cardImg);
cardImg.update(card);
cardImg.addMouseListener(this);

View file

@ -127,7 +127,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
List<CardView> sortedCards = new ArrayList<>(booster.values());
sortedCards.sort(new CardViewRarityComparator());
for (CardView card: sortedCards) {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, true, true);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true);
cardImg.addMouseListener(this);
add(cardImg);
cardImg.update(card);
@ -156,7 +156,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
}
private void hidePopup() {
Plugins.getInstance().getActionCallback().mouseExited(null, null);
Plugins.instance.getActionCallback().mouseExited(null, null);
}
/** This method is called from within the constructor to

View file

@ -1767,7 +1767,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
updateCounts();
// Create the card view
final MageCard cardPanel = Plugins.getInstance().getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true);
final MageCard cardPanel = Plugins.instance.getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true);
cardPanel.update(card);
cardPanel.setTextOffset(0);

View file

@ -118,10 +118,10 @@ public class CombatManager {
blockerPoint.translate(-parentPoint.x, -parentPoint.y);
Point attackerPoint = attackerCard.getLocationOnScreen();
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
double yRateA = (attackerCard.getSize().height / SettingsManager.getInstance().getCardSize().height);
double xRateA = (attackerCard.getSize().width / SettingsManager.getInstance().getCardSize().width);
double yRateB = (blockerCard.getSize().height / SettingsManager.getInstance().getCardSize().height);
double xRateB = (blockerCard.getSize().width / SettingsManager.getInstance().getCardSize().width);
double yRateA = (attackerCard.getSize().height / SettingsManager.instance.getCardSize().height);
double xRateA = (attackerCard.getSize().width / SettingsManager.instance.getCardSize().width);
double yRateB = (blockerCard.getSize().height / SettingsManager.instance.getCardSize().height);
double xRateB = (blockerCard.getSize().width / SettingsManager.instance.getCardSize().width);
ArrowBuilder.getBuilder().addArrow(gameId, (int) blockerPoint.getX() + (int) (55 * xRateB), (int) blockerPoint.getY() + (int) (25 * xRateB),
(int) attackerPoint.getX() + (int) (70 * xRateA), (int) attackerPoint.getY() + (int) (25 * yRateA), Color.blue, ArrowBuilder.Type.COMBAT);
globalBlockersCount++;

View file

@ -112,7 +112,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
this.selected = false; // back to false - waiting for selection
setVisible(true);
Point centered = SettingsManager.getInstance().getComponentPosition(DIALOG_WIDTH, DIALOG_HEIGHT);
Point centered = SettingsManager.instance.getComponentPosition(DIALOG_WIDTH, DIALOG_HEIGHT);
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);

View file

@ -130,7 +130,7 @@ public class ChoiceDialog extends IDialogPanel {
return;
}
java.util.List<Component> toRemove = new ArrayList<>();
ArrayList<Component> toRemove = new ArrayList<>();
for (int i = getComponentCount() - 1; i > 0; i--) {
Component o = getComponent(i);
if (o instanceof MageCard) {
@ -141,10 +141,10 @@ public class ChoiceDialog extends IDialogPanel {
remove(toRemove.get(i));
}
java.util.List<CardView> cardList = new ArrayList<>(cards.values());
ArrayList<CardView> cardList = new ArrayList<>(cards.values());
int width = SettingsManager.getInstance().getCardSize().width;
int height = SettingsManager.getInstance().getCardSize().height;
int width = SettingsManager.instance.getCardSize().width;
int height = SettingsManager.instance.getCardSize().height;
int dx = 0;
int dy = 30;
@ -161,7 +161,7 @@ public class ChoiceDialog extends IDialogPanel {
}
CardView card = cardList.get(i);
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
cardImg.setLocation(dx, dy + j*(height + 30));
add(cardImg);
@ -174,9 +174,9 @@ public class ChoiceDialog extends IDialogPanel {
private HoverButton getJButtonOK() {
if (jButtonOK == null) {
jButtonOK = new HoverButton("", ImageManagerImpl.getInstance().getDlgAcceptButtonImage(),
ImageManagerImpl.getInstance().getDlgActiveAcceptButtonImage(),
ImageManagerImpl.getInstance().getDlgAcceptButtonImage(),
jButtonOK = new HoverButton("", ImageManagerImpl.instance.getDlgAcceptButtonImage(),
ImageManagerImpl.instance.getDlgActiveAcceptButtonImage(),
ImageManagerImpl.instance.getDlgAcceptButtonImage(),
new Rectangle(60, 60));
int w = getDlgParams().rect.width - 75;
int h = getDlgParams().rect.height - 90;
@ -190,9 +190,9 @@ public class ChoiceDialog extends IDialogPanel {
private HoverButton getJButtonPrevPage() {
if (jButtonPrevPage == null) {
jButtonPrevPage = new HoverButton("", ImageManagerImpl.getInstance().getDlgPrevButtonImage(),
ImageManagerImpl.getInstance().getDlgActivePrevButtonImage(),
ImageManagerImpl.getInstance().getDlgPrevButtonImage(),
jButtonPrevPage = new HoverButton("", ImageManagerImpl.instance.getDlgPrevButtonImage(),
ImageManagerImpl.instance.getDlgActivePrevButtonImage(),
ImageManagerImpl.instance.getDlgPrevButtonImage(),
new Rectangle(60, 60));
int w = getDlgParams().rect.width - 75;
int h = getDlgParams().rect.height - 90;
@ -229,9 +229,9 @@ public class ChoiceDialog extends IDialogPanel {
*/
private HoverButton getJButtonNextPage() {
if (jButtonNextPage == null) {
jButtonNextPage = new HoverButton("", ImageManagerImpl.getInstance().getDlgNextButtonImage(),
ImageManagerImpl.getInstance().getDlgActiveNextButtonImage(),
ImageManagerImpl.getInstance().getDlgNextButtonImage(),
jButtonNextPage = new HoverButton("", ImageManagerImpl.instance.getDlgNextButtonImage(),
ImageManagerImpl.instance.getDlgActiveNextButtonImage(),
ImageManagerImpl.instance.getDlgNextButtonImage(),
new Rectangle(60, 60));
int w = getDlgParams().rect.width - 75;
int h = getDlgParams().rect.height - 90;
@ -317,9 +317,9 @@ public class ChoiceDialog extends IDialogPanel {
*/
private HoverButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new HoverButton("", ImageManagerImpl.getInstance().getDlgCancelButtonImage(),
ImageManagerImpl.getInstance().getDlgActiveCancelButtonImage(),
ImageManagerImpl.getInstance().getDlgCancelButtonImage(),
jButtonCancel = new HoverButton("", ImageManagerImpl.instance.getDlgCancelButtonImage(),
ImageManagerImpl.instance.getDlgActiveCancelButtonImage(),
ImageManagerImpl.instance.getDlgCancelButtonImage(),
new Rectangle(60, 60));
int w = getDlgParams().rect.width - 75;
int h = getDlgParams().rect.height - 90;

View file

@ -110,7 +110,7 @@ public class StackDialog extends IDialogPanel {
/**
* Display spells and theis targets above them
*/
int dx = (SettingsManager.getInstance().getCardSize().width + 15) * (cards.size() - 1);
int dx = (SettingsManager.instance.getCardSize().width + 15) * (cards.size() - 1);
int dy = 30;
for (CardView card : cards.values()) {
@ -124,21 +124,21 @@ public class StackDialog extends IDialogPanel {
card = tmp;
}
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
//cardImg.setBorder(BorderFactory.createLineBorder(Color.red));
cardImg.setLocation(dx, dy);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 1);
dx -= (SettingsManager.getInstance().getCardSize().width + 15);
dx -= (SettingsManager.instance.getCardSize().width + 15);
}
}
private HoverButton getJButtonAccept() {
if (jButtonAccept == null) {
jButtonAccept = new HoverButton("", ImageManagerImpl.getInstance().getDlgAcceptButtonImage(),
ImageManagerImpl.getInstance().getDlgActiveAcceptButtonImage(),
ImageManagerImpl.getInstance().getDlgAcceptButtonImage(),
jButtonAccept = new HoverButton("", ImageManagerImpl.instance.getDlgAcceptButtonImage(),
ImageManagerImpl.instance.getDlgActiveAcceptButtonImage(),
ImageManagerImpl.instance.getDlgAcceptButtonImage(),
new Rectangle(60, 60));
int w = getDlgParams().rect.width - 90;
int h = getDlgParams().rect.height - 90;
@ -160,9 +160,9 @@ public class StackDialog extends IDialogPanel {
private HoverButton getJButtonResponse() {
if (jButtonResponse == null) {
jButtonResponse = new HoverButton("", ImageManagerImpl.getInstance().getDlgCancelButtonImage(),
ImageManagerImpl.getInstance().getDlgActiveCancelButtonImage(),
ImageManagerImpl.getInstance().getDlgCancelButtonImage(),
jButtonResponse = new HoverButton("", ImageManagerImpl.instance.getDlgCancelButtonImage(),
ImageManagerImpl.instance.getDlgActiveCancelButtonImage(),
ImageManagerImpl.instance.getDlgCancelButtonImage(),
new Rectangle(60, 60));
int w = getDlgParams().rect.width - 90;
int h = getDlgParams().rect.height - 90;

View file

@ -9,9 +9,9 @@ import org.mage.plugins.card.utils.impl.ImageManagerImpl;
/**
* @author noxx
*/
public class MageTray {
public enum MageTray {
private static final MageTray instance = new MageTray();
instance;
private static final Logger log = Logger.getLogger(MageTray.class);
@ -19,11 +19,8 @@ public class MageTray {
private Image flashedImage;
private TrayIcon trayIcon;
private static int state = 0;
private int state = 0;
public static MageTray getInstance() {
return instance;
}
public void install() {
if (!SystemTray.isSupported()) {
@ -32,8 +29,8 @@ public class MageTray {
}
try {
mainImage = ImageManagerImpl.getInstance().getAppSmallImage();
flashedImage = ImageManagerImpl.getInstance().getAppFlashedImage();
mainImage = ImageManagerImpl.instance.getAppSmallImage();
flashedImage = ImageManagerImpl.instance.getAppFlashedImage();
trayIcon = new TrayIcon(mainImage);
trayIcon.setImageAutoSize(true);

View file

@ -55,9 +55,9 @@ public class DeckEditorPane extends MagePane {
public DeckEditorPane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
boolean initialized = false;
if (Plugins.getInstance().isThemePluginLoaded()) {
if (Plugins.instance.isThemePluginLoaded()) {
Map<String, JComponent> uiMap = new HashMap<>();
JComponent container = Plugins.getInstance().updateTablePanel(uiMap);
JComponent container = Plugins.instance.updateTablePanel(uiMap);
if (container != null) {
deckEditorPanel1 = new mage.client.deckeditor.DeckEditorPanel();
initComponents(container);

View file

@ -541,7 +541,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
private void hidePopup() {
Plugins.getInstance().getActionCallback().mouseExited(null, null);
Plugins.instance.getActionCallback().mouseExited(null, null);
}
public void removeDeckEditor() {
@ -631,7 +631,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
cardInfoPane = Plugins.getInstance().getCardInfoPane();
cardInfoPane = Plugins.instance.getCardInfoPane();
if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
cardInfoPane.setPreferredSize(new Dimension(170, 150));
cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(200, 0, 0)));

View file

@ -46,9 +46,9 @@ public class CollectionViewerPane extends MagePane {
public CollectionViewerPane() {
boolean initialized = false;
this.setTitle("Collection Viewer");
if (Plugins.getInstance().isThemePluginLoaded()) {
if (Plugins.instance.isThemePluginLoaded()) {
Map<String, JComponent> uiComponents = new HashMap<>();
JComponent container = Plugins.getInstance().updateTablePanel(uiComponents);
JComponent container = Plugins.instance.updateTablePanel(uiComponents);
if (container != null) {
collectionViewerPanel = new CollectionViewerPanel();
initComponents(container);

View file

@ -185,7 +185,7 @@ public final class CollectionViewerPanel extends JPanel {
}
private void hidePopup() {
Plugins.getInstance().getActionCallback().mouseExited(null, null);
Plugins.instance.getActionCallback().mouseExited(null, null);
}
public void removeCollectionViewer() {

View file

@ -236,7 +236,7 @@ public class MageBook extends JComponent {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
}
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true, true);
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true);
cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(card);

View file

@ -11,7 +11,7 @@ import org.mage.card.arcane.ManaSymbols;
*/
public class TestMageBook extends JFrame {
public static void main(String[] args) {
Plugins.getInstance().loadPlugins();
Plugins.instance.loadPlugins();
ManaSymbols.loadImages();
CardScanner.scan();
JFrame frame = new TestMageBook();

View file

@ -406,7 +406,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
CardView card = view.get(row);
if (!card.getId().equals(bigCard.getCardId())) {
if (!MageFrame.isLite()) {
Image image = Plugins.getInstance().getOriginalImage(card);
Image image = Plugins.instance.getOriginalImage(card);
if (image != null && image instanceof BufferedImage) {
// XXX: scaled to fit width
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<>(), false);

View file

@ -83,11 +83,11 @@ public class CardInfoWindowDialog extends MageDialog {
this.setModal(false);
switch (this.showType) {
case LOOKED_AT:
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getLookedAtImage()));
this.setFrameIcon(new ImageIcon(ImageManagerImpl.instance.getLookedAtImage()));
this.setClosable(true);
break;
case REVEAL:
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getRevealedImage()));
this.setFrameIcon(new ImageIcon(ImageManagerImpl.instance.getRevealedImage()));
this.setClosable(true);
break;
case REVEAL_TOP_LIBRARY:
@ -106,7 +106,7 @@ public class CardInfoWindowDialog extends MageDialog {
});
break;
case EXILE:
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getExileImage()));
this.setFrameIcon(new ImageIcon(ImageManagerImpl.instance.getExileImage()));
break;
default:
// no icon yet
@ -189,7 +189,7 @@ public class CardInfoWindowDialog extends MageDialog {
int width = CardInfoWindowDialog.this.getWidth();
int height = CardInfoWindowDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
Point centered = SettingsManager.instance.getComponentPosition(width, height);
if (!positioned) {
int xPos = centered.x / 2;
int yPos = centered.y / 2;

View file

@ -82,7 +82,7 @@ public class PickChoiceDialog extends MageDialog {
mageDialogState.setStateToDialog(this);
} else {
Point centered = SettingsManager.getInstance().getComponentPosition(getWidth(), getHeight());
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight());
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
}

View file

@ -60,7 +60,7 @@ public class PickNumberDialog extends MageDialog {
this.btnCancel.setVisible(false);
this.pack();
Point centered = SettingsManager.getInstance().getComponentPosition(getWidth(), getHeight());
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight());
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);

View file

@ -107,7 +107,7 @@ public class PickPileDialog extends MageDialog {
}
pack();
Point centered = SettingsManager.getInstance().getComponentPosition(getWidth(), getHeight());
Point centered = SettingsManager.instance.getComponentPosition(getWidth(), getHeight());
this.setLocation(centered.x, centered.y);
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);

View file

@ -134,7 +134,7 @@ public class ShowCardsDialog extends MageDialog {
int width = ShowCardsDialog.this.getWidth();
int height = ShowCardsDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
Point centered = SettingsManager.instance.getComponentPosition(width, height);
ShowCardsDialog.this.setLocation(centered.x, centered.y);
positioned = true;
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);

View file

@ -432,12 +432,12 @@ class UpdateSeatsTask extends SwingWorker<Void, TableView> {
if (current != count) {
if (count > 0) {
if (current > count) {
MageTray.getInstance().displayMessage("New player joined your game.");
MageTray.instance.displayMessage("New player joined your game.");
AudioManager.playPlayerJoinedTable();
} else {
MageTray.getInstance().displayMessage("A player left your game.");
MageTray.instance.displayMessage("A player left your game.");
}
MageTray.getInstance().blink();
MageTray.instance.blink();
}
count = current;
}

View file

@ -52,9 +52,9 @@ public class DraftPane extends MagePane {
*/
public DraftPane() {
boolean initialized = false;
if (Plugins.getInstance().isThemePluginLoaded()) {
if (Plugins.instance.isThemePluginLoaded()) {
Map<String, JComponent> uiComponents = new HashMap<>();
JComponent container = Plugins.getInstance().updateTablePanel(uiComponents);
JComponent container = Plugins.instance.updateTablePanel(uiComponents);
if (container != null) {
draftPanel1 = new mage.client.draft.DraftPanel();
initComponents(container);

View file

@ -328,7 +328,7 @@ public class DraftPanel extends javax.swing.JPanel {
if (view != null) {
loadCardsToPickedCardsArea(view.getPicks());
draftBooster.loadBooster(EMPTY_VIEW, bigCard);
Plugins.getInstance().getActionCallback().hideOpenComponents();
Plugins.instance.getActionCallback().hideOpenComponents();
setMessage("Waiting for other players");
}
}
@ -340,8 +340,8 @@ public class DraftPanel extends javax.swing.JPanel {
);
setMessage("Pick a card");
if (!MageFrame.getInstance().isActive()) {
MageTray.getInstance().displayMessage("Pick the next card.");
MageTray.getInstance().blink();
MageTray.instance.displayMessage("Pick the next card.");
MageTray.instance.blink();
}
countdown.stop();
this.timeout = draftPickView.getTimeout();

View file

@ -252,8 +252,8 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
}
final MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
if (!Plugins.getInstance().isCardPluginLoaded()) {
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
if (!Plugins.instance.isCardPluginLoaded()) {
//perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)));
} else {
//perm.setAlpha(0);
@ -262,12 +262,12 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
BattlefieldPanel.this.jPanel.add(perm, 10);
//this.jPanel.add(perm);
if (!Plugins.getInstance().isCardPluginLoaded()) {
if (!Plugins.instance.isCardPluginLoaded()) {
moveToFront(perm);
perm.update(permanent);
} else {
moveToFront(jPanel);
Plugins.getInstance().onAddCard(perm, 1);
Plugins.instance.onAddCard(perm, 1);
/*Thread t = new Thread(new Runnable() {
@Override
public void run() {
@ -299,7 +299,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
} else if (comp instanceof MagePermanent) {
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
Thread t = new Thread(() -> {
Plugins.getInstance().onRemoveCard((MagePermanent) comp, count);
Plugins.instance.onRemoveCard((MagePermanent) comp, count);
comp.setVisible(false);
BattlefieldPanel.this.jPanel.remove(comp);
});

View file

@ -219,7 +219,7 @@ public final class GamePanel extends javax.swing.JPanel {
jLayeredBackgroundPane.add(jSplitPane0, JLayeredPane.DEFAULT_LAYER);
Map<String, JComponent> myUi = getUIComponents(jLayeredBackgroundPane);
Plugins.getInstance().updateGamePanel(myUi);
Plugins.instance.updateGamePanel(myUi);
// Enlarge jlayeredpane on resize of game panel
addComponentListener(new ComponentAdapter() {
@ -332,7 +332,7 @@ public final class GamePanel extends javax.swing.JPanel {
pickTargetDialog.cleanUp();
pickTargetDialog.removeDialog();
}
Plugins.getInstance().getActionCallback().hideOpenComponents();
Plugins.instance.getActionCallback().hideOpenComponents();
try {
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
popupContainer.setVisible(false);
@ -839,7 +839,7 @@ public final class GamePanel extends javax.swing.JPanel {
gamePane.setTitle(sb.toString());
}
GameManager.getInstance().setStackSize(game.getStack().size());
GameManager.instance.setStackSize(game.getStack().size());
displayStack(game, bigCard, feedbackPanel, gameId);
for (ExileView exile : game.getExile()) {
@ -902,7 +902,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.repaint();
}
static final int BORDER_SIZE = 2;
private static final int BORDER_SIZE = 2;
private void updateSkipButtons(boolean turn, boolean endOfTurn, boolean nextMain, boolean allTurns, boolean stack, boolean endStepBeforeYourStep) {
if (turn) { //F4
@ -1249,7 +1249,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
private void hideAll() {
ActionCallback callback = Plugins.getInstance().getActionCallback();
ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).hideGameUpdate(gameId);
}
@ -1442,7 +1442,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnCancelSkip.setContentAreaFilled(false);
btnCancelSkip.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnCancelSkip.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getCancelSkipButtonImage()));
btnCancelSkip.setIcon(new ImageIcon(ImageManagerImpl.instance.getCancelSkipButtonImage()));
btnCancelSkip.setToolTipText("Cancel all skip actions ("
+ getCachedKeyText(KEY_CONTROL_CANCEL_SKIP) + ").");
btnCancelSkip.setFocusable(false);
@ -1457,7 +1457,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToNextTurn.setContentAreaFilled(false);
btnSkipToNextTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToNextTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipNextTurnButtonImage()));
btnSkipToNextTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipNextTurnButtonImage()));
btnSkipToNextTurn.setToolTipText("Skip to next turn ("
+ getCachedKeyText(KEY_CONTROL_NEXT_TURN) + ").");
btnSkipToNextTurn.setFocusable(false);
@ -1481,7 +1481,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToEndTurn.setContentAreaFilled(false);
btnSkipToEndTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToEndTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipEndTurnButtonImage()));
btnSkipToEndTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipEndTurnButtonImage()));
btnSkipToEndTurn.setToolTipText("Skip to (opponents/next) end of turn step ("
+ getCachedKeyText(KEY_CONTROL_END_STEP) + ") - adjust using preferences.");
btnSkipToEndTurn.setFocusable(false);
@ -1514,7 +1514,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToNextMain.setContentAreaFilled(false);
btnSkipToNextMain.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipMainButtonImage()));
btnSkipToNextMain.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipMainButtonImage()));
btnSkipToNextMain.setToolTipText("Skip to (your) next main phase ("
+ getCachedKeyText(KEY_CONTROL_MAIN_STEP) + ") - adjust using preferences.");
btnSkipToNextMain.setFocusable(false);
@ -1538,7 +1538,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToYourTurn.setContentAreaFilled(false);
btnSkipToYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToYourTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipYourNextTurnButtonImage()));
btnSkipToYourTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipYourNextTurnButtonImage()));
btnSkipToYourTurn.setToolTipText("Skip to your next turn ("
+ getCachedKeyText(KEY_CONTROL_YOUR_TURN) + ").");
btnSkipToYourTurn.setFocusable(false);
@ -1562,7 +1562,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipToEndStepBeforeYourTurn.setContentAreaFilled(false);
btnSkipToEndStepBeforeYourTurn.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipToEndStepBeforeYourTurn.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipEndStepBeforeYourTurnButtonImage()));
btnSkipToEndStepBeforeYourTurn.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipEndStepBeforeYourTurnButtonImage()));
btnSkipToEndStepBeforeYourTurn.setToolTipText("Skip to the end step before your turn ("
+ getCachedKeyText(KEY_CONTROL_PRIOR_END) + ") - adjust using preferences.");
btnSkipToEndStepBeforeYourTurn.setFocusable(false);
@ -1586,7 +1586,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSkipStack.setContentAreaFilled(false);
btnSkipStack.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSkipStackButtonImage()));
btnSkipStack.setIcon(new ImageIcon(ImageManagerImpl.instance.getSkipStackButtonImage()));
btnSkipStack.setToolTipText("Skip until stack is resolved ("
+ getCachedKeyText(KEY_CONTROL_SKIP_STACK) + ").");
btnSkipStack.setFocusable(false);
@ -1610,7 +1610,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnConcede.setContentAreaFilled(false);
btnConcede.setBorder(new EmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
btnConcede.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getConcedeButtonImage()));
btnConcede.setIcon(new ImageIcon(ImageManagerImpl.instance.getConcedeButtonImage()));
btnConcede.setToolTipText("Concede the current game.");
btnConcede.setFocusable(false);
btnConcede.addMouseListener(new MouseAdapter() {
@ -1638,7 +1638,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("ENLARGE", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).enlargeCard(EnlargeMode.NORMAL);
}
});
@ -1648,7 +1648,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("ENLARGE_SOURCE", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).enlargeCard(EnlargeMode.ALTERNATE);
}
});
@ -1697,7 +1697,7 @@ public final class GamePanel extends javax.swing.JPanel {
this.getActionMap().put("ENLARGE_RELEASE", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
ActionCallback callback = Plugins.instance.getActionCallback();
((MageActionCallback) callback).hideEnlargedCard();
}
});
@ -1718,7 +1718,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnSwitchHands.setContentAreaFilled(false);
btnSwitchHands.setBorder(new EmptyBorder(0, 0, 0, 0));
btnSwitchHands.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getSwitchHandsButtonImage()));
btnSwitchHands.setIcon(new ImageIcon(ImageManagerImpl.instance.getSwitchHandsButtonImage()));
btnSwitchHands.setFocusable(false);
btnSwitchHands.setToolTipText("Switch between your hand cards and hand cards of controlled players.");
btnSwitchHands.addMouseListener(new MouseAdapter() {
@ -1732,7 +1732,7 @@ public final class GamePanel extends javax.swing.JPanel {
btnStopWatching.setContentAreaFilled(false);
btnStopWatching.setBorder(new EmptyBorder(0, 0, 0, 0));
btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getStopWatchButtonImage()));
btnStopWatching.setIcon(new ImageIcon(ImageManagerImpl.instance.getStopWatchButtonImage()));
btnStopWatching.setFocusable(false);
btnStopWatching.setToolTipText("Stop watching this game.");
btnStopWatching.addMouseListener(new MouseAdapter() {
@ -2192,7 +2192,7 @@ public final class GamePanel extends javax.swing.JPanel {
hoverButtons = new LinkedHashMap<>();
}
Rectangle rect = new Rectangle(36, 36);
HoverButton button = new HoverButton("", ImageManagerImpl.getInstance().getPhaseImage(name), rect);
HoverButton button = new HoverButton("", ImageManagerImpl.instance.getPhaseImage(name), rect);
button.setToolTipText(name.replaceAll("_", " "));
button.setPreferredSize(new Dimension(36, 36));
button.addMouseListener(mouseAdapter);

View file

@ -106,7 +106,7 @@ public class MageActionCallback implements ActionCallback {
public synchronized void refreshSession() {
if (cardInfoPane == null) {
cardInfoPane = Plugins.getInstance().getCardInfoPane();
cardInfoPane = Plugins.instance.getCardInfoPane();
}
}
@ -268,7 +268,7 @@ public class MageActionCallback implements ActionCallback {
@Override
public void mouseMoved(MouseEvent e, TransferData transferData) {
if (!Plugins.getInstance().isCardPluginLoaded()) {
if (!Plugins.instance.isCardPluginLoaded()) {
return;
}
if (!popupData.card.equals(transferData.card)) {

View file

@ -8,6 +8,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.cards.MageCard;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
@ -31,11 +32,10 @@ import org.apache.log4j.Logger;
import org.mage.plugins.card.CardPluginImpl;
import org.mage.plugins.theme.ThemePluginImpl;
public class Plugins implements MagePlugins {
public enum Plugins implements MagePlugins {
instance;
public static final String PLUGINS_DIRECTORY = "plugins/";
private static final MagePlugins instance = new Plugins();
private static final Logger LOGGER = Logger.getLogger(Plugins.class);
private static PluginManager pm;
@ -45,9 +45,6 @@ public class Plugins implements MagePlugins {
private static final MageActionCallback mageActionCallback = new MageActionCallback();
private final Map<String, String> sortingOptions = new HashMap<>();
public static MagePlugins getInstance() {
return instance;
}
@Override
public void loadPlugins() {

View file

@ -87,7 +87,7 @@ public class CallbackClientImpl implements CallbackClient {
switch (callback.getMethod()) {
case "startGame": {
TableClientMessage message = (TableClientMessage) callback.getData();
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
GameManager.instance.setCurrentPlayerUUID(message.getPlayerId());
gameStarted(message.getGameId(), message.getPlayerId());
break;
}
@ -457,8 +457,8 @@ public class CallbackClientImpl implements CallbackClient {
handleException(ex);
}
if (Plugins.getInstance().isCounterPluginLoaded()) {
Plugins.getInstance().addGamesPlayed();
if (Plugins.instance.isCounterPluginLoaded()) {
Plugins.instance.addGamesPlayed();
}
}

View file

@ -45,9 +45,9 @@ public class TablesPane extends MagePane {
*/
public TablesPane() {
boolean initialized = false;
if (Plugins.getInstance().isThemePluginLoaded()) {
if (Plugins.instance.isThemePluginLoaded()) {
tablesPanel = new mage.client.table.TablesPanel();
JComponent container = Plugins.getInstance().updateTablePanel(tablesPanel.getUIComponents());
JComponent container = Plugins.instance.updateTablePanel(tablesPanel.getUIComponents());
if (container != null) {
initComponents(container);
container.add(tablesPanel);

View file

@ -7,12 +7,8 @@ import java.util.UUID;
*
* @author nantuko
*/
public class GameManager {
private static final GameManager instance = new GameManager();
public static GameManager getInstance() {
return instance;
}
public enum GameManager {
instance;
public void setStackSize(int stackSize) {
this.stackSize = stackSize;

View file

@ -9,12 +9,8 @@ import org.mage.card.arcane.CardPanel;
*
* @author nantuko
*/
public class SettingsManager {
private static final SettingsManager instance = new SettingsManager();
public static SettingsManager getInstance() {
return instance;
}
public enum SettingsManager {
instance;
public int getScreenWidth() {
return screenWidth;

View file

@ -35,7 +35,7 @@ public class OldCardLayoutStrategy implements CardLayoutStrategy {
Map<UUID, MagePermanent> permanents = battlefieldPanel.getPermanents();
JLayeredPane jPanel = battlefieldPanel.getMainPanel();
int height = Plugins.getInstance().sortPermanents(battlefieldPanel.getUiComponentsList(), permanents.values(), battlefieldPanel.isTopPanelBattlefield());
int height = Plugins.instance.sortPermanents(battlefieldPanel.getUiComponentsList(), permanents.values(), battlefieldPanel.isTopPanelBattlefield());
jPanel.setPreferredSize(new Dimension(width - 30, height));
for (PermanentView permanent : battlefieldPanel.getBattlefield().values()) {
@ -54,7 +54,7 @@ public class OldCardLayoutStrategy implements CardLayoutStrategy {
int position = jLayeredPane.getPosition(perm);
perm.getLinks().clear();
Rectangle rectangleBaseCard = perm.getBounds();
if (!Plugins.getInstance().isCardPluginLoaded()) {
if (!Plugins.instance.isCardPluginLoaded()) {
for (UUID attachmentId : permanent.getAttachments()) {
MagePermanent link = permanents.get(attachmentId);
if (link != null) {

View file

@ -136,7 +136,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
dayNightButton = new JButton("");
dayNightButton.setSize(32, 32);
dayNightButton.setToolTipText("This permanent is a double faced card. To see the back face card, push this button or turn mouse wheel down while hovering with the mouse pointer over the permanent.");
BufferedImage day = ImageManagerImpl.getInstance().getDayImage();
BufferedImage day = ImageManagerImpl.instance.getDayImage();
dayNightButton.setIcon(new ImageIcon(day));
dayNightButton.addActionListener(e -> {
// if card is being rotated, ignore action performed
@ -159,9 +159,9 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
showCopySourceButton.setSize(32, 32);
showCopySourceButton.setToolTipText("This permanent is copying a target. To see original card, push this button or turn mouse wheel down while hovering with the mouse pointer over the permanent.");
showCopySourceButton.setVisible(((PermanentView) this.gameCard).isCopy());
showCopySourceButton.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getCopyInformIconImage()));
showCopySourceButton.setIcon(new ImageIcon(ImageManagerImpl.instance.getCopyInformIconImage()));
showCopySourceButton.addActionListener(e -> {
ActionCallback callback1 = Plugins.getInstance().getActionCallback();
ActionCallback callback1 = Plugins.instance.getActionCallback();
((MageActionCallback) callback1).enlargeCard(EnlargeMode.COPY);
});
@ -553,9 +553,9 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
if (card.canTransform()) {
BufferedImage transformIcon;
if (isTransformed() || card.isTransformed()) {
transformIcon = ImageManagerImpl.getInstance().getNightImage();
transformIcon = ImageManagerImpl.instance.getNightImage();
} else {
transformIcon = ImageManagerImpl.getInstance().getDayImage();
transformIcon = ImageManagerImpl.instance.getDayImage();
}
if (dayNightButton != null) {
dayNightButton.setVisible(!isPermanent);
@ -763,7 +763,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
this.transformed = !this.transformed;
if (transformed) {
if (dayNightButton != null) { // if transformbable card is copied, button can be null
BufferedImage night = ImageManagerImpl.getInstance().getNightImage();
BufferedImage night = ImageManagerImpl.instance.getNightImage();
dayNightButton.setIcon(new ImageIcon(night));
}
if (this.gameCard.getSecondCardFace() == null) {
@ -776,7 +776,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
}
} else {
if (dayNightButton != null) { // if transformbable card is copied, button can be null
BufferedImage day = ImageManagerImpl.getInstance().getDayImage();
BufferedImage day = ImageManagerImpl.instance.getDayImage();
dayNightButton.setIcon(new ImageIcon(day));
}
if (!isPermanent) { // use only for custom transformation (when pressing day-night button)

View file

@ -207,15 +207,15 @@ public class CardPanelComponentImpl extends CardPanel {
// Ability icon
if (newGameCard.isAbility()) {
if (newGameCard.getAbilityType() == AbilityType.TRIGGERED) {
setTypeIcon(ImageManagerImpl.getInstance().getTriggeredAbilityImage(), "Triggered Ability");
setTypeIcon(ImageManagerImpl.instance.getTriggeredAbilityImage(), "Triggered Ability");
} else if (newGameCard.getAbilityType() == AbilityType.ACTIVATED) {
setTypeIcon(ImageManagerImpl.getInstance().getActivatedAbilityImage(), "Activated Ability");
setTypeIcon(ImageManagerImpl.instance.getActivatedAbilityImage(), "Activated Ability");
}
}
// Token icon
if (this.gameCard.isToken()) {
setTypeIcon(ImageManagerImpl.getInstance().getTokenIconImage(), "Token Permanent");
setTypeIcon(ImageManagerImpl.instance.getTokenIconImage(), "Token Permanent");
}
displayTitleAnyway = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_CARD_NAMES, "true").equals("true");
@ -243,7 +243,7 @@ public class CardPanelComponentImpl extends CardPanel {
add(ptText);
// Sickness overlay
BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage();
BufferedImage sickness = ImageManagerImpl.instance.getSicknessImage();
overlayPanel = new ImagePanel(sickness, ImagePanelStyle.SCALED);
overlayPanel.setOpaque(false);
add(overlayPanel);
@ -620,21 +620,21 @@ public class CardPanelComponentImpl extends CardPanel {
case "+1/+1":
if (counterView.getCount() != plusCounter) {
plusCounter = counterView.getCount();
plusCounterLabel.setIcon(getCounterImageWithAmount(plusCounter, ImageManagerImpl.getInstance().getCounterImageGreen(), getCardWidth()));
plusCounterLabel.setIcon(getCounterImageWithAmount(plusCounter, ImageManagerImpl.instance.getCounterImageGreen(), getCardWidth()));
}
plusCounterLabel.setVisible(true);
break;
case "-1/-1":
if (counterView.getCount() != minusCounter) {
minusCounter = counterView.getCount();
minusCounterLabel.setIcon(getCounterImageWithAmount(minusCounter, ImageManagerImpl.getInstance().getCounterImageRed(), getCardWidth()));
minusCounterLabel.setIcon(getCounterImageWithAmount(minusCounter, ImageManagerImpl.instance.getCounterImageRed(), getCardWidth()));
}
minusCounterLabel.setVisible(true);
break;
case "loyalty":
if (counterView.getCount() != loyaltyCounter) {
loyaltyCounter = counterView.getCount();
loyaltyCounterLabel.setIcon(getCounterImageWithAmount(loyaltyCounter, ImageManagerImpl.getInstance().getCounterImageViolet(), getCardWidth()));
loyaltyCounterLabel.setIcon(getCounterImageWithAmount(loyaltyCounter, ImageManagerImpl.instance.getCounterImageViolet(), getCardWidth()));
}
loyaltyCounterLabel.setVisible(true);
break;
@ -643,7 +643,7 @@ public class CardPanelComponentImpl extends CardPanel {
name = counterView.getName();
otherCounter = counterView.getCount();
otherCounterLabel.setToolTipText(name);
otherCounterLabel.setIcon(getCounterImageWithAmount(otherCounter, ImageManagerImpl.getInstance().getCounterImageGrey(), getCardWidth()));
otherCounterLabel.setIcon(getCounterImageWithAmount(otherCounter, ImageManagerImpl.instance.getCounterImageGrey(), getCardWidth()));
otherCounterLabel.setVisible(true);
}
}

View file

@ -17,15 +17,11 @@ import mage.client.util.gui.BufferedImageBuilder;
import org.mage.plugins.card.utils.ImageManager;
import org.mage.plugins.card.utils.Transparency;
public class ImageManagerImpl implements ImageManager {
public enum ImageManagerImpl implements ImageManager {
instance;
private static final ImageManagerImpl instance = new ImageManagerImpl();
public static ImageManagerImpl getInstance() {
return instance;
}
public ImageManagerImpl() {
ImageManagerImpl() {
init();
}