* Revealing the top card of the library is now also shown by an extra window (no longer hiding life). Now Iconyfying and deiconifying does not change the postion of the reveal window. Iconifyed window width was a bit raised to be able to read more of the title in that state.

This commit is contained in:
LevelX2 2015-06-25 01:07:34 +02:00
parent 76f989a7f0
commit 81934e32e3
7 changed files with 833 additions and 738 deletions

View file

@ -1,30 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
package mage.client;
import java.awt.AlphaComposite;
@ -85,6 +85,7 @@ import mage.cards.repository.CardRepository;
import mage.client.cards.BigCard;
import mage.client.chat.ChatPanel;
import mage.client.components.MageComponents;
import mage.client.components.MageDesktopManager;
import mage.client.components.MageJDesktop;
import mage.client.components.MageRoundPane;
import mage.client.components.MageUI;
@ -156,7 +157,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static final Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title;
private Rectangle titleRectangle;
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private static final MageVersion version = new MageVersion(MageVersion.MAGE_VERSION_MAJOR, MageVersion.MAGE_VERSION_MINOR, MageVersion.MAGE_VERSION_PATCH, MageVersion.MAGE_VERSION_MINOR_PATCH, MageVersion.MAGE_VERSION_INFO);
private UUID clientId;
private static MagePane activeFrame;
private static boolean liteMode = false;
@ -211,7 +212,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
*/
public MageFrame() {
setWindowTitle();
clientId = UUID.randomUUID();
EDTExceptionHandler.registerExceptionHandler();
addWindowListener(new WindowAdapter() {
@ -236,6 +237,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
Plugins.getInstance().loadPlugins();
initComponents();
desktopPane.setDesktopManager(new MageDesktopManager());
setSize(1024, 768);
SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768);
DialogManager.updateParams(768, 1024, false);
@ -366,9 +370,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
public void setWindowTitle() {
setTitle(TITLE_NAME + " Client: "
setTitle(TITLE_NAME + " Client: "
+ version == null ? "<not available>" : version.toString() + " Server: "
+ ((session != null && session.isConnected()) ? session.getVersionInfo():"<not connected>"));
+ ((session != null && session.isConnected()) ? session.getVersionInfo() : "<not connected>"));
}
private void addTooltipContainer() {
@ -585,7 +589,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (frame instanceof GamePane) {
ArrowBuilder.getBuilder().showPanel(((GamePane) frame).getGameId());
MusicPlayer.playBGM();
}else{
} else {
MusicPlayer.stopBGM();
}
}
@ -596,7 +600,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (activeFrame != frame) {
frame.deactivated();
}
}
private static MagePane getTopMost(MagePane exclude) {
@ -618,11 +622,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
return topmost;
}
/**
/**
* Shows a game for a player of the game
*
*
* @param gameId
* @param playerId
* @param playerId
*/
public void showGame(UUID gameId, UUID playerId) {
try {
@ -638,7 +642,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void watchGame(UUID gameId) {
try {
for(Component component :desktopPane.getComponents()) {
for (Component component : desktopPane.getComponents()) {
if (component instanceof GamePane
&& ((GamePane) component).getGameId().equals(gameId)) {
setActive((GamePane) component);
@ -678,7 +682,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} catch (PropertyVetoException ex) {
}
}
public void endDraft(UUID draftId) {
// inform all open draft panes about
for (JInternalFrame window : desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER)) {
@ -688,12 +692,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
}
public void showTournament(UUID tournamentId) {
try {
for(Component component :desktopPane.getComponents()) {
if (component instanceof TournamentPane &&
((TournamentPane) component).getTournamentId().equals(tournamentId)) {
for (Component component : desktopPane.getComponents()) {
if (component instanceof TournamentPane
&& ((TournamentPane) component).getTournamentId().equals(tournamentId)) {
setActive((TournamentPane) component);
return;
}
@ -759,12 +763,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
connection.setProxyPort(proxyPort);
connection.setProxyUsername(proxyUsername);
connection.setProxyPassword(proxyPassword);
setUserPrefsToConnection(connection);
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
if (MageFrame.connect(connection)) {
showGames(false);
if (MageFrame.connect(connection)) {
showGames(false);
return true;
} else {
showMessage("Unable to connect to server");
@ -778,12 +782,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void setUserPrefsToConnection(Connection connection) {
connection.setUserData(PreferencesDialog.getUserData());
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -957,7 +960,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
session.disconnect(false);
tablesPane.clearChat();
setWindowTitle();
showMessage("You have disconnected");
showMessage("You have disconnected");
}
} else {
connectDialog.showDialog();
@ -1005,7 +1008,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
CardRepository.instance.closeDB();
tablesPane.cleanUp();
tablesPane.cleanUp();
Plugins.getInstance().shutdown();
dispose();
System.exit(0);
@ -1029,7 +1032,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
this.tablesPane.hideTables();
}
public void showGames(boolean setActive) {
public void showGames(boolean setActive) {
MagePane topPanebefore = getTopMost(tablesPane);
if (!tablesPane.isVisible()) {
this.tablesPane.setVisible(true);
@ -1042,9 +1045,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (topPanebefore != null) {
setActive(topPanebefore);
}
}
}
}
public void hideGames() {
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
@ -1063,8 +1066,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
// close & remove sideboarding or construction pane if open
if (window instanceof DeckEditorPane) {
DeckEditorPane deckEditorPane = (DeckEditorPane) window;
if (deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.LIMITED_BUILDING)
|| deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.SIDEBOARDING)){
if (deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.LIMITED_BUILDING)
|| deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.SIDEBOARDING)) {
deckEditorPane.removeFrame();
}
}
@ -1091,7 +1094,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
}
try {
DeckEditorPane deckEditorPane = new DeckEditorPane();
desktopPane.add(deckEditorPane, JLayeredPane.DEFAULT_LAYER);
@ -1167,7 +1170,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
* @param args the command line arguments
*/
public static void main(final String args[]) {
// Workaround for #451
// Workaround for #451
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
logger.info("Starting MAGE client version " + version);
logger.info("Logging level: " + logger.getEffectiveLevel());
@ -1205,7 +1208,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
instance = new MageFrame();
instance.setVisible(true);
}
});
}
@ -1269,7 +1272,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public static void removeGame(UUID gameId) {
games.remove(gameId);
}
public static DraftPanel getDraft(UUID draftId) {
return drafts.get(draftId);
@ -1280,7 +1282,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (draftPanel != null) {
drafts.remove(draftId);
draftPanel.hideDraft();
}
}
}
public static void addDraft(UUID draftId, DraftPanel draftPanel) {
@ -1368,6 +1370,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
class MagePaneMenuItem extends JCheckBoxMenuItem {
private final MagePane frame;
public MagePaneMenuItem(MagePane frame) {

View file

@ -1,37 +1,36 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
/*
* Cards.java
*
* Created on Dec 18, 2009, 10:40:12 AM
*/
package mage.client.cards;
import java.awt.Color;
@ -72,19 +71,21 @@ public class Cards extends javax.swing.JPanel {
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
private String zone;
private static final Border emptyBorder = new EmptyBorder(0,0,0,0);
private static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);
private int minOffsetY = 0;
/**
* Defines whether component should be visible whenever there is no objects within.
* True by default.
* Defines whether component should be visible whenever there is no objects
* within. True by default.
*/
private boolean isVisibleIfEmpty = true;
private Dimension cardDimension;
/** Creates new form Cards */
/**
* Creates new form Cards
*/
public Cards() {
this(false);
}
@ -93,7 +94,7 @@ public class Cards extends javax.swing.JPanel {
initComponents(skipAddingScrollPane);
setOpaque(false);
//cardArea.setOpaque(false);
setBackgroundColor(new Color(0,0,0,100));
setBackgroundColor(new Color(0, 0, 0, 100));
if (!skipAddingScrollPane) {
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
@ -105,10 +106,12 @@ public class Cards extends javax.swing.JPanel {
cardArea.setBorder(emptyBorder);
}
public void cleanUp() {}
public void cleanUp() {
}
/**
* Sets components background color
*
* @param color
*/
public void setBackgroundColor(Color color) {
@ -151,14 +154,14 @@ public class Cards extends javax.swing.JPanel {
if (cardsView.size() == 0 && countCards() > 0) {
// problem happens with transformable cards
logger.fatal("Card object on the cards panel was not removed");
for (Component comp: cardArea.getComponents()) {
for (Component comp : cardArea.getComponents()) {
if (comp instanceof Card) {
Card card = (Card)comp;
Card card = (Card) comp;
logger.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
} else if (comp instanceof MageCard) {
MageCard mageCard = (MageCard)comp;
MageCard mageCard = (MageCard) comp;
logger.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
} else {
} else {
logger.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
}
cardArea.remove(comp);
@ -167,24 +170,24 @@ public class Cards extends javax.swing.JPanel {
// order objects for display
java.util.List<CardView> orderedList = new ArrayList<>();
for (CardView card: cardsView.values()) {
for (CardView card : cardsView.values()) {
orderedList.add(0, card);
}
// add objects to the panel
for (CardView card: orderedList) {
for (CardView card : orderedList) {
if (dontDisplayTapped) {
if (card instanceof PermanentView) {
((PermanentView)card).overrideTapped(false);
((PermanentView) card).overrideTapped(false);
}
}
if (card instanceof StackAbilityView) {
CardView tmp = ((StackAbilityView)card).getSourceCard();
CardView tmp = ((StackAbilityView) card).getSourceCard();
tmp.overrideRules(card.getRules());
tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets());
tmp.overrideId(card.getId());
tmp.setAbilityType(((StackAbilityView)card).getAbilityType());
tmp.setAbilityType(((StackAbilityView) card).getAbilityType());
card = tmp;
} else {
card.setAbilityType(null);
@ -212,11 +215,15 @@ public class Cards extends javax.swing.JPanel {
}
public void sizeCards(Dimension cardDimension) {
cardArea.setPreferredSize(new Dimension((int)((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int)(cardDimension.getHeight()) + 20));
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
cardArea.revalidate();
cardArea.repaint();
}
public int getNumberOfCards() {
return cards.size();
}
private Dimension getCardDimension() {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
@ -237,23 +244,23 @@ public class Cards extends javax.swing.JPanel {
private void definePosition(MageCard card) {
int dx = 0;
for (Component comp: cardArea.getComponents()) {
for (Component comp : cardArea.getComponents()) {
if (!comp.equals(card)) {
dx = Math.max(dx, (int)comp.getLocation().getX());
dx = Math.max(dx, (int) comp.getLocation().getX());
}
}
dx += ((CardPanel)card).getCardWidth() + GAP_X;
card.setLocation(dx, (int)card.getLocation().getY());
dx += ((CardPanel) card).getCardWidth() + GAP_X;
card.setLocation(dx, (int) card.getLocation().getY());
}
private void removeCard(UUID cardId) {
for (Component comp: cardArea.getComponents()) {
for (Component comp : cardArea.getComponents()) {
if (comp instanceof Card) {
if (((Card)comp).getCardId().equals(cardId)) {
if (((Card) comp).getCardId().equals(cardId)) {
cardArea.remove(comp);
}
} else if (comp instanceof MageCard) {
if (((MageCard)comp).getOriginal().getId().equals(cardId)) {
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
cardArea.remove(comp);
}
}
@ -264,10 +271,10 @@ public class Cards extends javax.swing.JPanel {
return cardArea.getComponentCount();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -288,7 +295,6 @@ public class Cards extends javax.swing.JPanel {
}
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel cardArea;
private javax.swing.JScrollPane jScrollPane1;
@ -320,7 +326,7 @@ public class Cards extends javax.swing.JPanel {
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
cards.add((CardPanel)component);
cards.add((CardPanel) component);
}
}
Collections.sort(cards, new Comparator<CardPanel>() {

View file

@ -0,0 +1,64 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.client.components;
import java.awt.BorderLayout;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import mage.client.dialog.CardInfoWindowDialog;
/**
*
* @author LevelX2
*/
public class MageDesktopManager extends DefaultDesktopManager {
static final int DESKTOP_ICON_WIDTH = 250;
@Override
public void iconifyFrame(JInternalFrame f) {
super.iconifyFrame(f);
if (f instanceof CardInfoWindowDialog) {
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
icon.setBounds(f.getX() + (f.getWidth() - DESKTOP_ICON_WIDTH), f.getY(), DESKTOP_ICON_WIDTH, icon.getHeight());
}
}
@Override
public void deiconifyFrame(JInternalFrame f) {
super.deiconifyFrame(f);
if (f instanceof CardInfoWindowDialog) {
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
f.setBounds(icon.getX() + (DESKTOP_ICON_WIDTH - f.getWidth()), icon.getY(), f.getWidth(), f.getHeight());
}
}
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JDesktopPane desktopPane = new JDesktopPane();
DesktopManager dm = new MageDesktopManager();
desktopPane.setDesktopManager(dm);
JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
internalFrame.setSize(200, 150);
internalFrame.setVisible(true);
desktopPane.add(internalFrame);
frame.add(desktopPane, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setVisible(true);
}
});
}
}

View file

@ -1,42 +1,39 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
/*
* CardInfoWindowDialog.java
*
* Created on Feb 1, 2010, 3:00:35 PM
*/
package mage.client.dialog;
import java.awt.Point;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyVetoException;
import java.util.UUID;
import java.util.logging.Level;
@ -61,7 +58,10 @@ import org.mage.plugins.card.utils.impl.ImageManagerImpl;
*/
public class CardInfoWindowDialog extends MageDialog {
public static enum ShowType { REVEAL, LOOKED_AT, EXILE, GRAVEYARD, OTHER };
public static enum ShowType {
REVEAL, REVEAL_TOP_LIBRARY, LOOKED_AT, EXILE, GRAVEYARD, OTHER
};
private ShowType showType;
private boolean positioned;
@ -75,7 +75,7 @@ public class CardInfoWindowDialog extends MageDialog {
initComponents();
this.setModal(false);
switch(this.showType) {
switch (this.showType) {
case LOOKED_AT:
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getLookedAtImage()));
this.setClosable(true);
@ -84,9 +84,12 @@ public class CardInfoWindowDialog extends MageDialog {
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getRevealedImage()));
this.setClosable(true);
break;
case REVEAL_TOP_LIBRARY:
this.setFrameIcon(new ImageIcon(ImageHelper.getImageFromResources("/info/library.png")));
this.setClosable(true);
break;
case GRAVEYARD:
this.setFrameIcon(new ImageIcon(ImageHelper.getImageFromResources("/info/grave.png")));
this.setIconifiable(false);
this.setClosable(true);
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
addInternalFrameListener(new InternalFrameAdapter() {
@ -100,7 +103,7 @@ public class CardInfoWindowDialog extends MageDialog {
this.setFrameIcon(new ImageIcon(ImageManagerImpl.getInstance().getExileImage()));
break;
default:
// no icon yet
// no icon yet
}
this.setTitelBarToolTip(name);
}
@ -123,6 +126,19 @@ public class CardInfoWindowDialog extends MageDialog {
showAndPositionWindow();
}
@Override
public void show() {
if (showType.equals(ShowType.EXILE)) {
if (cards == null || cards.getNumberOfCards() == 0) {
return;
}
}
super.show();
if (positioned) { // check if in frame rectangle
showAndPositionWindow();
}
}
private void showAndPositionWindow() {
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -132,13 +148,13 @@ public class CardInfoWindowDialog extends MageDialog {
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
if (!positioned) {
positioned = true;
int xPos = centered.x / 2;
int yPos = centered.y / 2;
CardInfoWindowDialog.this.setLocation(xPos, yPos);
show();
positioned = true;
}
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, CardInfoWindowDialog.this);
GuiDisplayUtil.keepComponentInsideFrame(centered.x, centered.y, CardInfoWindowDialog.this);
}
}
});
@ -155,16 +171,15 @@ public class CardInfoWindowDialog extends MageDialog {
Logger.getLogger(CardInfoWindowDialog.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
else {
} else {
this.hideDialog();
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -191,7 +206,6 @@ public class CardInfoWindowDialog extends MageDialog {
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.cards.Cards cards;
// End of variables declaration//GEN-END:variables

File diff suppressed because it is too large Load diff

View file

@ -1,37 +1,36 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.
*/
/*
* PlayerPanel.java
*
* Created on Nov 18, 2009, 3:01:31 PM
*/
package mage.client.game;
import java.awt.Color;
@ -57,18 +56,13 @@ import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import mage.MageException;
import mage.cards.MageCard;
import mage.cards.action.ActionCallback;
import mage.cards.decks.importer.DckDeckImporter;
import mage.cards.repository.CardRepository;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.components.HoverButton;
import mage.client.components.MageRoundPane;
import mage.client.components.ext.dlg.DialogManager;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Command;
import mage.client.util.ImageHelper;
@ -77,7 +71,6 @@ import mage.components.ImagePanel;
import mage.constants.ManaType;
import mage.remote.Session;
import mage.utils.timer.PriorityTimer;
import mage.view.CardView;
import mage.view.ManaPoolView;
import mage.view.PlayerView;
import org.mage.card.arcane.ManaSymbols;
@ -97,26 +90,25 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private BigCard bigCard;
private static final int AVATAR_COUNT = 77;
private static final String DEFAULT_AVATAR_PATH = "/avatars/51.jpg";
private static final int PANEL_WIDTH = 94;
private static final int PANEL_HEIGHT = 242;
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 emptyBorder = BorderFactory.createEmptyBorder(0, 0, 0, 0);
private static final Dimension topCardDimension = new Dimension(40, 56);
private int avatarId = -1;
private PriorityTimer timer;
/** Creates new form PlayerPanel */
/**
* Creates new form PlayerPanel
*/
public PlayerPanelExt() {
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
initComponents();
@ -158,7 +150,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
if (timer != null) {
this.timer.cancel();
}
topCardPanel.updateCallback(null, gameId);
}
public void update(PlayerView player) {
@ -271,26 +262,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
this.avatar.setBorder(emptyBorder);
this.btnPlayer.setBorder(emptyBorder);
}
synchronized (this) {
if (player.getTopCard() != null) {
if (topCard == null || !topCard.getId().equals(player.getTopCard().getId())) {
if (topCard == null) {
topCardPanel.setVisible(true);
}
topCard = player.getTopCard();
topCardPanel.update(topCard);
topCardPanel.updateImage();
ActionCallback callback = Plugins.getInstance().getActionCallback();
((MageActionCallback)callback).refreshSession();
topCardPanel.updateCallback(callback, gameId);
}
} else if (topCard != null) {
topCard = null;
topCardPanel.setVisible(false);
}
}
update(player.getManaPool());
}
@ -304,7 +275,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
int h = priorityTimeLeft / 3600;
int m = (priorityTimeLeft % 3600) / 60;
int s = priorityTimeLeft % 60;
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
}
protected void update(ManaPoolView pool) {
@ -316,10 +287,10 @@ public class PlayerPanelExt extends javax.swing.JPanel {
manaLabels.get("X").setText(Integer.toString(pool.getColorless()));
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
private void initComponents() {
@ -331,6 +302,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
lifeLabel = new JLabel();
handLabel = new JLabel();
poisonLabel = new JLabel();
graveLabel = new JLabel();
libraryLabel = new JLabel();
setOpaque(false);
@ -341,10 +313,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
// Avatar
Image image = ImageHelper.getImageFromResources(DEFAULT_AVATAR_PATH);
topCardPanel = Plugins.getInstance().getMageCard(new CardView(CardRepository.instance.findCard("Forest").getMockCard()), bigCard, topCardDimension, gameId, true);
topCardPanel.setVisible(false);
panelBackground.add(topCardPanel);
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
avatar = new HoverButton("player", resized, resized, resized, r);
String showPlayerNamePermanently = MageFrame.getPreferences().get(PreferencesDialog.KEY_SHOW_PLAYER_NAMES_PERMANENTLY, "true");
@ -360,7 +328,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
});
// timer area /small layout)
timerLabel.setToolTipText("Time left");
timerLabel.setSize(80,12);
timerLabel.setSize(80, 12);
timerLabel.setHorizontalAlignment(SwingConstants.CENTER);
// life area
@ -389,22 +357,29 @@ public class PlayerPanelExt extends javax.swing.JPanel {
poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL);
poison.setToolTipText("Poison");
poison.setOpaque(false);
// Library
r = new Rectangle(19, 19);
libraryLabel.setToolTipText("Library");
Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png");
BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r);
library = new ImagePanel(resizedLibrary, ImagePanel.ACTUAL);
library = new HoverButton(null, resizedLibrary, resizedLibrary, resizedLibrary, r);
library.setToolTipText("Library");
library.setOpaque(false);
library.setObserver(new Command() {
@Override
public void execute() {
btnLibraryActionPerformed(null);
}
});
// Grave count and open graveyard button
graveLabel = new JLabel();
r = new Rectangle(21, 21);
graveLabel.setToolTipText("Graveyard");
Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r);
grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r);
grave.setToolTipText("Graveyard");
grave.setOpaque(false);
@ -579,195 +554,192 @@ public class PlayerPanelExt extends javax.swing.JPanel {
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
gl_panelBackground.setHorizontalGroup(
gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(9)
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
.addGap(3)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGap(4)
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(9)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(3)
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(20)
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)))
.addGap(3)
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(19)
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
.addGap(5)
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(20)
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
/*.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))*/
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(5)
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
.addGap(14))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addComponent(zonesPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(14))
);
gl_panelBackground.setVerticalGroup(
gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btnPlayer)
.addComponent(timerLabel)
.addGap(1)
// Life & Hand
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(1)
// Poison
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(4)
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
.addGap(4)
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(5)
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(2)
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(14)
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(14)
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGap(4)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(8)
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(39)
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(31)
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
/*.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))*/
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(31)
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(zonesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(9)
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
.addGap(3)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGap(4)
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(9)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(3)
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(2)
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(20)
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)))
.addGap(3)
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(19)
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
.addGap(5)
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(20)
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
/*.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))*/
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(18)
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(5)
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(40)
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, MANA_LABEL_SIZE_HORIZONTAL, GroupLayout.PREFERRED_SIZE))))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(timerLabel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
.addGap(14))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addComponent(zonesPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(14))
);
gl_panelBackground.setVerticalGroup(
gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(6)
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btnPlayer)
.addComponent(timerLabel)
.addGap(1)
// Life & Hand
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(1)
// Poison
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(4)
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
.addGap(4)
.addComponent(btnWhiteMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(btnBlueMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(2)
.addComponent(btnBlackMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
.addGap(5)
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(1)
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
.addGap(2)
.addComponent(btnRedMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(14)
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(14)
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGap(4)
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(8)
.addComponent(btnColorlessMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(39)
.addComponent(btnGreenMana, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(31)
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
/*.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))*/
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(exileZone, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
)
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(76)
.addComponent(exileLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panelBackground.createSequentialGroup()
.addGap(31)
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
)
)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(zonesPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
)
);
panelBackground.setLayout(gl_panelBackground);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
);
setLayout(groupLayout);
@ -780,8 +752,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
timerLabel.setVisible(true);
panelBackground.setPreferredSize(new Dimension(PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL));
panelBackground.setBounds(0, 0, PANEL_WIDTH - 2, PANEL_HEIGHT_SMALL);
}
else {
} else {
avatar.setVisible(true);
btnPlayer.setVisible(false);
timerLabel.setVisible(false);
@ -794,13 +765,12 @@ public class PlayerPanelExt extends javax.swing.JPanel {
session.sendPlayerManaType(gameId, player.getPlayerId(), manaType);
}
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {
MageFrame.getGame(gameId).openGraveyardWindow(player.getName());
/*if (graveyard == null) {
graveyard = new ShowCardsDialog();
}*/
//graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
// DialogManager.getManager(gameId).showGraveyardDialog(player.getGraveyard(), bigCard, gameId);
}
private void btnLibraryActionPerformed(java.awt.event.ActionEvent evt) {
MageFrame.getGame(gameId).openTopLibraryWindow(player.getName());
}
private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) {
@ -826,9 +796,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private ImagePanel poison;
private ImagePanel hand;
private HoverButton grave;
private ImagePanel library;
private CardView topCard;
private MageCard topCardPanel;
private HoverButton library;
private JButton cheat;
private MageRoundPane panelBackground;

View file

@ -1,7 +1,21 @@
package mage.client.util.gui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsConfiguration;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import mage.client.MageFrame;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.Rarity;
import mage.utils.CardUtil;
import mage.view.CardView;
import mage.view.CounterView;
@ -10,39 +24,34 @@ import org.jdesktop.swingx.JXPanel;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.UI;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import mage.constants.Rarity;
public class GuiDisplayUtil {
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
private static final Insets DEFAULT_INSETS = new Insets(0, 0, 70, 25);
private static final Insets COMPONENT_INSETS = new Insets(0, 0, 40, 40);
public static class TextLines {
public int basicTextLength;
public ArrayList<String> lines;
}
public static JXPanel getDescription(CardView card, int width, int height) {
JXPanel descriptionPanel = new JXPanel();
//descriptionPanel.setAlpha(.8f);
descriptionPanel.setBounds(0, 0, width, height);
descriptionPanel.setBounds(0, 0, width, height);
descriptionPanel.setVisible(false);
descriptionPanel.setLayout(null);
//descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
JButton j = new JButton("");
j.setBounds(0, 0, width, height);
j.setBounds(0, 0, width, height);
j.setBackground(Color.black);
j.setLayout(null);
JLabel cardText = new JLabel();
cardText.setBounds(5, 5, width - 10, height - 10);
cardText.setBounds(5, 5, width - 10, height - 10);
cardText.setForeground(Color.white);
cardText.setFont(cardNameFont);
cardText.setVerticalAlignment(SwingConstants.TOP);
@ -70,36 +79,52 @@ public class GuiDisplayUtil {
return out.toString().toLowerCase();
}
public static void keepComponentInsideScreen(int centerX, int centerY, Component component) {
Dimension screenDim = component.getToolkit().getScreenSize();
GraphicsConfiguration g = component.getGraphicsConfiguration();
public static void keepComponentInsideScreen(int x, int y, Component c) {
Dimension screenDim = c.getToolkit().getScreenSize();
GraphicsConfiguration g = c.getGraphicsConfiguration();
if (g != null) {
Insets insets = c.getToolkit().getScreenInsets(g);
Insets insets = component.getToolkit().getScreenInsets(g); // no usable space like toolbar
boolean setLocation = false;
if (x + c.getWidth() > screenDim.width - insets.right) {
x = (screenDim.width - insets.right) - c.getWidth();
if (centerX + component.getWidth() > screenDim.width - insets.right) {
centerX = (screenDim.width - insets.right) - component.getWidth();
setLocation = true;
} else if (x < insets.left) {
x = insets.left;
} else if (centerX < insets.left) {
centerX = insets.left;
setLocation = true;
}
if (y + c.getHeight() > screenDim.height - insets.bottom) {
y = (screenDim.height - insets.bottom) - c.getHeight();
if (centerY + component.getHeight() > screenDim.height - insets.bottom) {
centerY = (screenDim.height - insets.bottom) - component.getHeight();
setLocation = true;
} else if (y < insets.top) {
y = insets.top;
} else if (centerY < insets.top) {
centerY = insets.top;
setLocation = true;
}
if (setLocation) {
c.setLocation(x, y);
component.setLocation(centerX, centerY);
}
} else {
System.out.println("GuiDisplayUtil::keepComponentInsideScreen -> no GraphicsConfiguration");
}
}
static final int OVERLAP_LIMIT = 10;
public static void keepComponentInsideFrame(int centerX, int centerY, Component component) {
Rectangle frameRec = MageFrame.getInstance().getBounds();
boolean setLocation = false;
if (component.getX() > (frameRec.width - OVERLAP_LIMIT)) {
setLocation = true;
}
if (component.getY() > (frameRec.height - OVERLAP_LIMIT)) {
setLocation = true;
}
if (setLocation) {
component.setLocation(centerX, centerY);
}
}
public static Point keepComponentInsideParent(Point l, Point parentPoint, Component c, Component parent) {
int dx = parentPoint.x + parent.getWidth() - DEFAULT_INSETS.right - COMPONENT_INSETS.right;
if (l.x + c.getWidth() > dx) {
@ -117,8 +142,8 @@ public class GuiDisplayUtil {
public static TextLines getTextLinesfromCardView(CardView card) {
TextLines textLines = new TextLines();
textLines.lines = new ArrayList<>(card.getRules());
for (String rule: card.getRules()) {
textLines.basicTextLength +=rule.length();
for (String rule : card.getRules()) {
textLines.basicTextLength += rule.length();
}
if (card.getMageObjectType().equals(MageObjectType.PERMANENT)) {
if (card.getPairedCard() != null) {
@ -156,7 +181,7 @@ public class GuiDisplayUtil {
}
}
if (card.getMageObjectType().isPermanent() && card instanceof PermanentView) {
int damage = ((PermanentView)card).getDamage();
int damage = ((PermanentView) card).getDamage();
if (damage > 0) {
textLines.lines.add("<span color='red'><b>Damage dealt:</b> " + damage + "</span>");
textLines.basicTextLength += 50;
@ -183,10 +208,10 @@ public class GuiDisplayUtil {
String fontFamily = "tahoma";
/*if (prefs.fontFamily == CardFontFamily.arial)
fontFamily = "arial";
else if (prefs.fontFamily == CardFontFamily.verdana) {
fontFamily = "verdana";
}*/
fontFamily = "arial";
else if (prefs.fontFamily == CardFontFamily.verdana) {
fontFamily = "verdana";
}*/
final StringBuilder buffer = new StringBuilder(512);
buffer.append("<html><body style='font-family:");
@ -198,7 +223,7 @@ public class GuiDisplayUtil {
buffer.append("<tr><td valign='top'><b>");
buffer.append(card.getDisplayName());
if (card.isGameObject()) {
buffer.append(" [").append(card.getId().toString().substring(0,3)).append("]");
buffer.append(" [").append(card.getId().toString().substring(0, 3)).append("]");
}
buffer.append("</b></td><td align='right' valign='top' style='width:");
buffer.append(symbolCount * 11 + 1);
@ -208,31 +233,31 @@ public class GuiDisplayUtil {
}
buffer.append("</td></tr></table>");
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td style='margin-left: 1px'>");
if(card.getColor().isWhite()) {
if (card.getColor().isWhite()) {
buffer.append("<img src='").append(getResourcePath("card/color_ind_white.png")).append("' alt='W'>");
}
if(card.getColor().isBlue()) {
if (card.getColor().isBlue()) {
buffer.append("<img src='").append(getResourcePath("card/color_ind_blue.png")).append("' alt='U'>");
}
if(card.getColor().isBlack()) {
if (card.getColor().isBlack()) {
buffer.append("<img src='").append(getResourcePath("card/color_ind_black.png")).append("' alt='B'>");
}
if(card.getColor().isRed()) {
if (card.getColor().isRed()) {
buffer.append("<img src='").append(getResourcePath("card/color_ind_red.png")).append("' alt='R'>");
}
if(card.getColor().isGreen()) {
if (card.getColor().isGreen()) {
buffer.append("<img src='").append(getResourcePath("card/color_ind_green.png")).append("' alt='G'>");
}
if(!card.getColor().isColorless()) {
if (!card.getColor().isColorless()) {
buffer.append("&nbsp;&nbsp;");
}
buffer.append(getTypes(card));
buffer.append("</td><td align='right'>");
String rarity ;
String rarity;
if (card.getRarity() == null) {
rarity = Rarity.COMMON.getCode();
buffer.append("<b color='black'>");
}else {
buffer.append("<b color='black'>");
} else {
switch (card.getRarity()) {
case RARE:
buffer.append("<b color='#FFBF00'>");
@ -310,7 +335,7 @@ public class GuiDisplayUtil {
if (textLine != null && !textLine.replace(".", "").trim().isEmpty()) {
rule.append("<p style='margin: 2px'>").append(textLine).append("</p>");
}
}
}
}
String legal = rule.toString();
@ -319,12 +344,12 @@ public class GuiDisplayUtil {
// legal = legal.replaceAll("#([^#]+)#", "<i>$1</i>");
// legal = legal.replaceAll("\\s*//\\s*", "<hr width='50%'>");
// legal = legal.replace("\r\n", "<div style='font-size:5pt'></div>");
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this":card.getName());
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this":card.getName());
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this" : card.getName());
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this" : card.getName());
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.CARD));
}
buffer.append("<br></body></html>");
buffer.append("<br></body></html>");
return buffer;
}
@ -347,5 +372,5 @@ public class GuiDisplayUtil {
types += subType + " ";
}
return types.trim();
}
}
}