1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-03 09:18:59 -09:00

[UI] Exile dialog

This commit is contained in:
magenoxx 2014-08-07 15:30:44 +04:00
parent 10840840ac
commit 53453243dc
5 changed files with 161 additions and 61 deletions
Mage.Client/src/main
java/mage/client
resources/info
Mage.Common/src/mage/view

View file

@ -97,6 +97,16 @@ public class DialogContainer extends JPanel {
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.ExileDialog) {
backgroundColor = new Color(250, 250, 250, 50);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.EmblemsDialog) {
backgroundColor = new Color(0, 0, 50, 110);

View file

@ -1,7 +1,11 @@
package mage.client.components.ext.dlg;
import java.awt.Component;
import java.awt.Rectangle;
import mage.client.cards.BigCard;
import mage.client.game.FeedbackPanel;
import mage.view.CardsView;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
@ -9,10 +13,6 @@ import java.awt.event.MouseWheelEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.client.cards.BigCard;
import mage.client.game.FeedbackPanel;
import mage.view.CardsView;
/**
* @author mw, noxx
@ -40,7 +40,7 @@ public class DialogManager extends JComponent implements MouseListener,
public enum MTGDialogs {
none, AboutDialog, MessageDialog, StackDialog, AssignDamageDialog, ManaChoiceDialog, ChoiceDialog, EmblemsDialog, GraveDialog, DialogContainer, CombatDialog,
ChooseDeckDialog, ChooseCommonDialog, RevealDialog
ChooseDeckDialog, ChooseCommonDialog, RevealDialog, ExileDialog
}
/**
@ -176,6 +176,35 @@ public class DialogManager extends JComponent implements MouseListener,
setVisible(true);
}
public void showExileDialog(CardsView cards, BigCard bigCard, UUID gameId) {
int w = 720;
int h = 550;
int height = getHeight();
int width = getWidth();
int x = ((width - w) / 2);
int y = ((height - h) / 2);
DlgParams params = new DlgParams();
params.rect = new Rectangle(x, y, w, h);
params.bigCard = bigCard;
params.gameId = gameId;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.ExileDialog, params);
dialogContainer.setVisible(true);
add(dialogContainer);
this.currentDialog = MTGDialogs.DialogContainer;
setDlgBounds(new Rectangle(x, y, w, h));
dialogContainer.showDialog(true);
setVisible(true);
}
public void showEmblemsDialog(CardsView cards, BigCard bigCard, UUID gameId) {
int w = 720;

View file

@ -34,28 +34,6 @@
package mage.client.game;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;
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;
@ -82,6 +60,19 @@ import mage.view.ManaPoolView;
import mage.view.PlayerView;
import org.mage.card.arcane.ManaSymbols;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* Enhanced player pane.
*
@ -94,7 +85,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private Session session;
private PlayerView player;
//private ShowCardsDialog graveyard;
private BigCard bigCard;
private static final int AVATAR_COUNT = 77;
@ -193,10 +183,12 @@ public class PlayerPanelExt extends javax.swing.JPanel {
int graveCards = player.getGraveyard().size();
if (graveCards > 99) {
Font font = graveLabel.getFont();
font = font.deriveFont(9f);
graveLabel.setFont(font);
changedFontGrave = true;
if (!changedFontGrave) {
Font font = graveLabel.getFont();
font = font.deriveFont(9f);
graveLabel.setFont(font);
changedFontGrave = true;
}
} else if (changedFontGrave) {
Font font = lifeLabel.getFont();
font = font.deriveFont(12f);
@ -205,6 +197,22 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
graveLabel.setText(Integer.toString(graveCards));
int exileCards = player.getExile().size();
if (exileCards > 99) {
if (!changedFontExile) {
Font font = exileLabel.getFont();
font = font.deriveFont(9f);
exileLabel.setFont(font);
changedFontExile = true;
}
} else if (changedFontExile) {
Font font = lifeLabel.getFont();
font = font.deriveFont(12f);
exileLabel.setFont(font);
changedFontExile = false;
}
exileLabel.setText(Integer.toString(exileCards));
if (!MageFrame.isLite()) {
int id = player.getUserData().getAvatarId();
if (id <= 0) {
@ -395,6 +403,22 @@ public class PlayerPanelExt extends javax.swing.JPanel {
}
});
exileLabel = new JLabel();
exileLabel.setToolTipText("Exile");
image = ImageHelper.getImageFromResources("/info/exile.png");
r = new Rectangle(21, 21);
resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
exileZone = new HoverButton(null, resized, resized, resized, r);
exileZone.setToolTipText("Exile");
exileZone.setOpaque(false);
exileZone.setObserver(new Command() {
@Override
public void execute() {
btnExileZoneActionPerformed(null);
}
});
exileZone.setBounds(25, 0, 21, 21);
// Cheat button
r = new Rectangle(25, 21);
image = ImageHelper.getImageFromResources("/info/cheat.png");
@ -426,9 +450,12 @@ public class PlayerPanelExt extends javax.swing.JPanel {
btnCommandZoneActionPerformed(null);
}
});
commandZone.setBounds(0, 0, 21, 21);
commandZone.setBounds(5, 0, 21, 21);
zonesPanel.add(commandZone);
cheat.setBounds(28, 0, 25, 21);
zonesPanel.add(cheat);
btnPlayer = new JButton();
btnPlayer.setText("Player");
btnPlayer.setVisible(false);
@ -554,19 +581,19 @@ public class PlayerPanelExt extends javax.swing.JPanel {
.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.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()
@ -601,12 +628,19 @@ public class PlayerPanelExt extends javax.swing.JPanel {
.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(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.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, 30, GroupLayout.PREFERRED_SIZE))))
@ -644,16 +678,16 @@ public class PlayerPanelExt extends javax.swing.JPanel {
.addGap(1)
.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)
.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)
@ -685,12 +719,19 @@ public class PlayerPanelExt extends javax.swing.JPanel {
.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(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
.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)
@ -749,6 +790,10 @@ public class PlayerPanelExt extends javax.swing.JPanel {
DialogManager.getManager(gameId).showEmblemsDialog(CardsViewUtil.convertCommandObject(player.getCommadObjectList()), bigCard, gameId);
}
private void btnExileZoneActionPerformed(java.awt.event.ActionEvent evt) {
DialogManager.getManager(gameId).showExileDialog(CardsViewUtil.convertSimple(player.getExile(), MageFrame.getGame(gameId).getLoadedCards()), bigCard, gameId);
}
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
DckDeckImporter deckImporter = new DckDeckImporter();
session.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
@ -776,9 +821,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private JLabel libraryLabel;
private JLabel poisonLabel;
private JLabel graveLabel;
private JLabel exileLabel;
private boolean changedFontLibrary;
private boolean changedFontLife;
private boolean changedFontGrave;
private boolean changedFontExile;
private JPanel zonesPanel;
private HoverButton exileZone;

Binary file not shown.

After

(image error) Size: 19 KiB

View file

@ -30,16 +30,17 @@ package mage.view;
import mage.cards.Card;
import mage.counters.CounterType;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.GameState;
import mage.game.command.CommandObject;
import mage.game.command.Commander;
import mage.game.command.Emblem;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.io.Serializable;
import java.util.*;
import mage.game.command.Commander;
/**
*
@ -59,6 +60,7 @@ public class PlayerView implements Serializable {
private final boolean hasLeft;
private final ManaPoolView manaPool;
private final SimpleCardsView graveyard = new SimpleCardsView();
private final SimpleCardsView exile = new SimpleCardsView();
private final Map<UUID, PermanentView> battlefield = new LinkedHashMap<>();
private final CardView topCard;
private final UserDataView userDataView;
@ -81,6 +83,14 @@ public class PlayerView implements Serializable {
for (Card card: player.getGraveyard().getCards(game)) {
graveyard.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.isFaceDown(), card.getTokenSetCode()));
}
for (ExileZone exileZone : game.getExile().getExileZones()) {
for (Card card : exileZone.getCards(game)) {
if (!player.getId().equals(card.getOwnerId())) {
break;
}
exile.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.isFaceDown(), card.getTokenSetCode()));
}
}
for (Permanent permanent: state.getBattlefield().getAllPermanents()) {
if (showInBattlefield(permanent, state)) {
PermanentView view = new PermanentView(permanent, game.getCard(permanent.getId()), createdForPlayerId, game);
@ -165,6 +175,10 @@ public class PlayerView implements Serializable {
return this.graveyard;
}
public SimpleCardsView getExile() {
return exile;
}
public Map<UUID, PermanentView> getBattlefield() {
return this.battlefield;
}