Merge branch 'master' into migrate-google-collections-to-guava

This commit is contained in:
John Hitchings 2019-02-22 22:43:23 -08:00
commit f76efb2b65
483 changed files with 2270 additions and 1997 deletions

View file

@ -27,7 +27,6 @@ public class MageRoundPane extends JPanel {
private int Y_OFFSET = 30;
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
private Color backgroundColor = defaultBackgroundColor;
private static final int alpha = 0;
private static final SoftValuesLoadingCache<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final SoftValuesLoadingCache<Key, BufferedImage> IMAGE_CACHE;
@ -36,7 +35,7 @@ public class MageRoundPane extends JPanel {
IMAGE_CACHE = ImageCaches.register(SoftValuesLoadingCache.from(MageRoundPane::createImage));
}
private final static class ShadowKey {
private static final class ShadowKey {
final int width;
final int height;
@ -76,7 +75,7 @@ public class MageRoundPane extends JPanel {
}
}
private final static class Key {
private static final class Key {
final int width;
final int height;
@ -163,8 +162,8 @@ public class MageRoundPane extends JPanel {
/**
* Add white translucent substrate
*/
/*if (alpha != 0) {
g2.setColor(new Color(255, 255, 255, alpha));
/*if (ALPHA != 0) {
g2.setColor(new Color(255, 255, 255, ALPHA));
g2.fillRoundRect(x, y, w, h, arc, arc);
}*/
g2.setColor(key.backgroundColor);

View file

@ -16,7 +16,7 @@ public class BackgroundPainter extends AbstractPainter {
private final Color bgColor = Color.black;
static final float bgalpha = 0.6f;
static final float BACKGROUND_ALPHA = 0.6f;
public BackgroundPainter() {
super();
@ -25,7 +25,7 @@ public class BackgroundPainter extends AbstractPainter {
@Override
protected void doPaint(Graphics2D g2, Object o, int i, int i1) {
float alpha = bgalpha;
float alpha = BACKGROUND_ALPHA;
Component c = (Component)o;
Composite composite = g2.getComposite();
if (composite instanceof AlphaComposite) {

View file

@ -0,0 +1,8 @@
package mage.client.components.ext;
public enum MessageDialogType {
INFO,
WARNING,
ERROR,
FLASH_INFO
}

View file

@ -1,13 +0,0 @@
package mage.client.components.ext;
/**
* @author mw, noxx
*/
public class MessageDlg {
MessageDlg() {}
public enum Types {
Info, Warning, Error, FlashInfo
}
}

View file

@ -1,6 +1,6 @@
package mage.client.components.ext.dlg;
import mage.client.components.ext.MessageDlg;
import mage.client.components.ext.MessageDialogType;
import mage.client.components.ext.dlg.impl.ChoiceDialog;
import mage.client.components.ext.dlg.impl.StackDialog;
@ -37,146 +37,99 @@ public class DialogContainer extends JPanel {
setLayout(null);
drawContainer = true;
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
//backgroundColor = new Color(0, 255, 255, 60);
if (params.type == MessageDlg.Types.Warning) {
backgroundColor = new Color(255, 0, 0, 90);
} else {
backgroundColor = new Color(0, 0, 0, 90);
switch (dialogType) {
case MESSAGE:
//backgroundColor = new Color(0, 255, 255, 60);
if (params.type == MessageDialogType.WARNING) {
backgroundColor = new Color(255, 0, 0, 90);
} else {
backgroundColor = new Color(0, 0, 0, 90);
}
alpha = 0;
//MessageDlg dlg = new MessageDlg(params);
//add(dlg);
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
//dlg.updateSize(params.rect.width, params.rect.height);
break;
case STACK: {
//backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(0, 0, 0, 50);
alpha = 0;
StackDialog dlg = new StackDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
//int width = Math.min(params.rect.width - 80, 600);
int width = params.rect.width;
int height = params.rect.height - 80;
dlg.updateSize(width, height);
break;
}
alpha = 0;
//MessageDlg dlg = new MessageDlg(params);
//add(dlg);
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
//dlg.updateSize(params.rect.width, params.rect.height);
} else if (dialogType == DialogManager.MTGDialogs.StackDialog) {
//backgroundColor = new Color(0, 255, 255, 60);
backgroundColor = new Color(0, 0, 0, 50);
alpha = 0;
StackDialog dlg = new StackDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
//int width = Math.min(params.rect.width - 80, 600);
int width = params.rect.width;
int height = params.rect.height - 80;
dlg.updateSize(width, height);
}
/*
else if (dialogType == DialogManager.MTGDialogs.CombatDialog) {
else if (dialogType == DialogManager.MTGDialogs.COMBAT) {
backgroundColor = new Color(0, 0, 0, 60);
alpha = 0;
CombatDialog dlg = new CombatDialog(params);
COMBAT dlg = new COMBAT(params);
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.ChoiceDialog) {
}*/
case CHOICE: {
//backgroundColor = new Color(200, 200, 172, 120);
//backgroundColor = new Color(180, 150, 200, 120);
//backgroundColor = new Color(0, 255, 0, 60);
//backgroundColor = new Color(200, 200, 172, 120);
//backgroundColor = new Color(180, 150, 200, 120);
//backgroundColor = new Color(0, 255, 0, 60);
//backgroundColor = new Color(139, 46, 173, 20);
backgroundColor = new Color(0, 0, 0, 110);
//backgroundColor = new Color(139, 46, 173, 0);
//backgroundColor = new Color(139, 46, 173, 20);
backgroundColor = new Color(0, 0, 0, 110);
//backgroundColor = new Color(139, 46, 173, 0);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
add(dlg);
//GameManager.getManager().setCurrentChoiceDlg(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
add(dlg);
//GameManager.getManager().setCurrentChoiceDlg(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
} else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
backgroundColor = new Color(0, 0, 0, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
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.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);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
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.GraveDialog) {
backgroundColor = new Color(20, 20, 20, 120);
alpha = 0;
GraveDialog dlg = new GraveDialog(params);
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.RevealDialog) {
backgroundColor = new Color(90, 135, 190, 80);
alpha = 0;
RevealDialog dlg = new RevealDialog(params);
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.AssignDamageDialog) {
backgroundColor = new Color(255, 255, 255, 130);
alpha = 0;
AssignDamageDialog dlg = new AssignDamageDialog(params);
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.ManaChoiceDialog) {
backgroundColor = new Color(0, 255, 255, 60);
alpha = 20;
ManaChoiceDialog dlg = new ManaChoiceDialog(params);
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
//isGradient = true;
gradient = ImageManager.getGradientImage();
if (gradient != null) {
b = ImageToBufferedImage.toBufferedImage(gradient);
b = Transparency.makeImageTranslucent(b, 0.35);
Rectangle2D tr = new Rectangle2D.Double(0, 0, params.rect.width, params.rect.height);
//gradient = gradient.getScaledInstance(w, h, Image.SCALE_SMOOTH);
tp = new TexturePaint(b, tr);
break;
}
case GRAVEYARD: {
backgroundColor = new Color(0, 0, 0, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
break;
}
case EXILE: {
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);
break;
}
case EMBLEMS: {
backgroundColor = new Color(0, 0, 50, 110);
alpha = 0;
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
break;
}
} else if (dialogType == DialogManager.MTGDialogs.ChooseDeckDialog) {
MWDeckPanel deckPanel = new MWDeckPanel(params.getDeckList(), params.isAI);
deckPanel.setVisible(true);
deckPanel.setBounds(0,0,480,320);
add(deckPanel);
drawContainer = false;
} else if (dialogType == DialogManager.MTGDialogs.ChooseCommonDialog) {
MWChoosePanel choosePanel = new MWChoosePanel(params.getObjectList(), params.getTitle());
choosePanel.setVisible(true);
choosePanel.setBounds(0,0,440,240);
add(choosePanel);
drawContainer = false;
} else if (dialogType == DialogManager.MTGDialogs.AboutDialog) {
backgroundColor = new Color(255, 255, 255, 120);
alpha = 0;
AboutDialog dlg = new AboutDialog();
add(dlg);
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
}
*/
}
public void cleanUp() {

View file

@ -20,7 +20,7 @@ import java.util.UUID;
public class DialogManager extends JComponent implements MouseListener,
MouseMotionListener {
private final static Map<UUID, DialogManager> dialogManagers = new HashMap<>();
private static final Map<UUID, DialogManager> dialogManagers = new HashMap<>();
public static DialogManager getManager(UUID gameId) {
if (!dialogManagers.containsKey(gameId)) {
@ -39,8 +39,8 @@ public class DialogManager extends JComponent implements MouseListener,
}
public enum MTGDialogs {
none, AboutDialog, MessageDialog, StackDialog, AssignDamageDialog, ManaChoiceDialog, ChoiceDialog, EmblemsDialog, GraveDialog, DialogContainer, CombatDialog,
ChooseDeckDialog, ChooseCommonDialog, RevealDialog, ExileDialog
NONE, ABOUT, MESSAGE, STACK, ASSIGN_DAMAGE, MANA_CHOICE, CHOICE, EMBLEMS, GRAVEYARD, DialogContainer, COMBAT,
CHOOSE_DECK, CHOOSE_COMMON, REVEAL, EXILE
}
/**
@ -58,7 +58,7 @@ public class DialogManager extends JComponent implements MouseListener,
}
}
private MTGDialogs currentDialog = MTGDialogs.none;
private MTGDialogs currentDialog = MTGDialogs.NONE;
private DialogContainer dialogContainer = null;
@ -133,7 +133,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId;
params.feedbackPanel = feedbackPanel;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.StackDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.STACK, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -163,7 +163,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId;
//params.feedbackPanel = feedbackPanel;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.GraveDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.GRAVEYARD, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -192,7 +192,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.bigCard = bigCard;
params.gameId = gameId;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.ExileDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.EXILE, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -222,7 +222,7 @@ public class DialogManager extends JComponent implements MouseListener,
params.gameId = gameId;
//params.feedbackPanel = feedbackPanel;
params.setCards(cards);
dialogContainer = new DialogContainer(MTGDialogs.EmblemsDialog, params);
dialogContainer = new DialogContainer(MTGDialogs.EMBLEMS, params);
dialogContainer.setVisible(true);
add(dialogContainer);
@ -248,7 +248,7 @@ public class DialogManager extends JComponent implements MouseListener,
removeAll();
}
this.currentDialog = MTGDialogs.none;
this.currentDialog = MTGDialogs.NONE;
setVisible(false);
@ -312,6 +312,7 @@ public class DialogManager extends JComponent implements MouseListener,
@Override
public void mouseExited(MouseEvent e) {
}
@Override
@ -360,7 +361,7 @@ public class DialogManager extends JComponent implements MouseListener,
public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
// System.out.println("outx:"+notches);
// if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) {
// if (currentDialog != null && currentDialog.equals(MTGDialogs.CHOOSE_COMMON)) {
// System.out.println("out:"+1);
// }
}

View file

@ -1,13 +1,14 @@
package mage.client.components.ext.dlg;
import mage.client.cards.BigCard;
import mage.client.components.ext.MessageDlg;
import mage.client.components.ext.MessageDialogType;
import mage.client.game.FeedbackPanel;
import mage.view.CardsView;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
@ -18,7 +19,7 @@ import java.util.UUID;
public class DlgParams {
public Rectangle rect;
public MessageDlg.Types type;
public MessageDialogType type;
public BigCard bigCard;
public FeedbackPanel feedbackPanel;
public UUID gameId;
@ -26,19 +27,19 @@ public class DlgParams {
private int playerID;
private CardsView cards;
private ArrayList<String> stringList;
private java.util.List<String> stringList;
//private ArrayList<DeckInfo> deckList;
private ArrayList<Object> objectList;
private java.util.List<Object> objectList;
private String title;
private int opponentID;
boolean isOptional = false;
boolean isChooseAbility = false;
boolean isCancelStopsPlaying = true;
private boolean isOptional = false;
private boolean isChooseAbility = false;
private boolean isCancelStopsPlaying = true;
boolean isAI = false;
private boolean isAI = false;
public HashSet<String> manaChoices = new HashSet<>();
private Set<String> manaChoices = new HashSet<>();
public int getPlayerID() {
return playerID;
@ -74,11 +75,11 @@ public class DlgParams {
this.message = message;
}
public HashSet<String> getManaChoices() {
public Set<String> getManaChoices() {
return manaChoices;
}
public void setManaChoices(HashSet<String> manaChoices) {
public void setManaChoices(Set<String> manaChoices) {
this.manaChoices = manaChoices;
}
@ -98,7 +99,7 @@ public class DlgParams {
this.isChooseAbility = isChooseAbility;
}
public ArrayList<String> getStringList() {
public java.util.List<String> getStringList() {
return stringList;
}
@ -114,7 +115,7 @@ public class DlgParams {
this.deckList = deckList;
}*/
public ArrayList<Object> getObjectList() {
public java.util.List<Object> getObjectList() {
return objectList;
}

View file

@ -10,7 +10,7 @@ import java.awt.*;
/**
* @author mw, noxx
*/
abstract public class IDialogPanel extends JXPanel {
public abstract class IDialogPanel extends JXPanel {
private DlgParams params;
private Dimension cardDimension;

View file

@ -50,11 +50,12 @@ public class ChoiceDialog extends IDialogPanel {
private boolean isCancelStopsPlaying = true;
private final DlgParams params;
private final String title;
/**
* This is the default constructor
*
* @param params
* @param title
*/
@ -130,18 +131,18 @@ public class ChoiceDialog extends IDialogPanel {
return;
}
ArrayList<Component> toRemove = new ArrayList<>();
java.util.List<Component> toRemove = new ArrayList<>();
for (int i = getComponentCount() - 1; i > 0; i--) {
Component o = getComponent(i);
if (o instanceof MageCard) {
toRemove.add(o);
}
}
for (int i = 0; i < toRemove.size(); i++) {
remove(toRemove.get(i));
for (Component aToRemove : toRemove) {
remove(aToRemove);
}
ArrayList<CardView> cardList = new ArrayList<>(cards.values());
java.util.List<CardView> cardList = new ArrayList<>(cards.values());
int width = SettingsManager.instance.getCardSize().width;
int height = SettingsManager.instance.getCardSize().height;
@ -163,7 +164,7 @@ public class ChoiceDialog extends IDialogPanel {
CardView card = cardList.get(i);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
cardImg.setLocation(dx, dy + j*(height + 30));
cardImg.setLocation(dx, dy + j * (height + 30));
add(cardImg);
dx += (width + 20);
@ -237,11 +238,8 @@ public class ChoiceDialog extends IDialogPanel {
int h = getDlgParams().rect.height - 90;
jButtonNextPage.setBounds(new Rectangle(w / 2 + 45, h - 50, 60, 60));
if (maxPages > 1) {
jButtonNextPage.setVisible(true);
} else {
jButtonNextPage.setVisible(false);
}
jButtonNextPage.setVisible(maxPages > 1);
jButtonNextPage.setObserver(new Command() {
private static final long serialVersionUID = -3174360416099554104L;

View file

@ -78,7 +78,6 @@ public enum MageTray {
tray.add(trayIcon);
} catch (AWTException e) {
log.error("TrayIcon could not be added: ", e);
return;
}
} catch (Exception e) {