sonar 220219, criticals

This commit is contained in:
Ingmar Goudt 2019-02-22 12:05:44 +01:00
parent 4504ad5e6f
commit 3359c1f3f1
23 changed files with 153 additions and 280 deletions

View file

@ -805,7 +805,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
insertArrow = new JLabel();
insertArrow.setSize(20, 20);
insertArrow.setVisible(false);
cardContent.add(insertArrow, new Integer(1000));
cardContent.add(insertArrow, 1000);
// Selection panel
selectionPanel = new SelectionBox();

View file

@ -14,6 +14,9 @@ import java.util.UUID;
public final class LocalCommands {
private LocalCommands(){}
/**
* Handler for commands that do not require server interaction, i.e settings etc
* @param chatId

View file

@ -26,7 +26,7 @@ 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 int ALPHA = 0;
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final Map<Key, BufferedImage> IMAGE_CACHE;
@ -163,8 +163,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

@ -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,7 +1,7 @@
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;
@ -19,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;
@ -33,13 +33,13 @@ public class DlgParams {
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 Set<String> manaChoices = new HashSet<>();
private Set<String> manaChoices = new HashSet<>();
public int getPlayerID() {
return playerID;

View file

@ -1,7 +1,7 @@
/*
* CombatDialog.java
* COMBAT.java
*
* Created on Feb 10, 2010, 3:35:02 PM
*/
@ -33,7 +33,7 @@ public class CombatDialog extends MageDialog {
private int lastX = 500;
private int lastY = 300;
/** Creates new form CombatDialog */
/** Creates new form COMBAT */
public CombatDialog() {
JPanel contentPane = new JPanel() {