GUI enchancements (themes, sound notification, deck validation) (#6755)

GUI enchancements (themes, sound notification, deck validation)
This commit is contained in:
18ths 2020-07-17 19:15:02 +02:00 committed by GitHub
parent 8c4c2728d6
commit 99d5eafc8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
128 changed files with 1988 additions and 11320 deletions

View file

@ -161,6 +161,11 @@
<artifactId>prettytime</artifactId> <artifactId>prettytime</artifactId>
<version>4.0.2.Final</version> <version>4.0.2.Final</version>
</dependency> </dependency>
<dependency>
<groupId>org.unbescape</groupId>
<artifactId>unbescape</artifactId>
<version>1.1.6.RELEASE</version>
</dependency>
</dependencies> </dependencies>
<!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ --> <!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ -->

Binary file not shown.

View file

@ -200,9 +200,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
TConfig config = TConfig.current(); TConfig config = TConfig.current();
config.setArchiveDetector(new TArchiveDetector("zip")); config.setArchiveDetector(new TArchiveDetector("zip"));
config.setAccessPreference(FsAccessOption.STORE, true); config.setAccessPreference(FsAccessOption.STORE, true);
try { try {
UIManager.put("desktop", new Color(0, 0, 0, 0)); UIManager.put("desktop", new Color(0, 0, 0, 0));
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
UIManager.put("nimbusBlueGrey", PreferencesDialog.getCurrentTheme().getNimbusBlueGrey()); // buttons, scrollbar background, disabled inputs
UIManager.put("control", PreferencesDialog.getCurrentTheme().getControl()); // window bg
UIManager.put("nimbusLightBackground", PreferencesDialog.getCurrentTheme().getNimbusLightBackground()); // inputs, table rows
UIManager.put("info", PreferencesDialog.getCurrentTheme().getInfo()); // tooltips
UIManager.put("nimbusBase", PreferencesDialog.getCurrentTheme().getNimbusBase()); // title bars, scrollbar foreground
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// stop JSplitPane from eating F6 and F8 or any other function keys // stop JSplitPane from eating F6 and F8 or any other function keys
{ {
@ -445,16 +453,19 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
} }
// Sets background for login screen
private void setBackground() { private void setBackground() {
if (liteMode || grayMode) { if (liteMode || grayMode) {
return; return;
} }
String filename = "/background.jpg";
try { try {
if (Plugins.instance.isThemePluginLoaded()) { // If user has custom background, use that, otherwise, use theme background
if (Plugins.instance.isThemePluginLoaded() &&
!PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) {
backgroundPane = (ImagePanel) Plugins.instance.updateTablePanel(new HashMap<>()); backgroundPane = (ImagePanel) Plugins.instance.updateTablePanel(new HashMap<>());
} else { } else {
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(PreferencesDialog.getCurrentTheme().getLoginBackgroundPath());
BufferedImage background = ImageIO.read(is); BufferedImage background = ImageIO.read(is);
backgroundPane = new ImagePanel(background, ImagePanelStyle.SCALED); backgroundPane = new ImagePanel(background, ImagePanelStyle.SCALED);
} }
@ -1020,6 +1031,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)) .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
); );
if (PreferencesDialog.getCurrentTheme().getMageToolbar() != null) {
mageToolbar.getParent().setBackground(PreferencesDialog.getCurrentTheme().getMageToolbar());
}
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents

View file

@ -17,8 +17,12 @@ public class KeyboundButton extends JButton {
private boolean tinting = false; private boolean tinting = false;
public KeyboundButton(String key) { public KeyboundButton(String key, boolean drawText) {
if (drawText) {
text = PreferencesDialog.getCachedKeyText(key); text = PreferencesDialog.getCachedKeyText(key);
} else {
text = "";
}
} }
@Override @Override
@ -27,17 +31,21 @@ public class KeyboundButton extends JButton {
Graphics sg = g.create(); Graphics sg = g.create();
try { try {
ui.update(sg, this); ui.update(sg, this);
if (tinting) { if (tinting) {
sg.setColor(new Color(0, 0, 0, 32)); sg.setColor(new Color(0, 0, 0, 32));
sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6); sg.fillRoundRect(2, 2, getWidth() - 4 , getHeight() - 4, 6, 6);
} }
sg.setColor(tinting ? Color.lightGray : Color.white); sg.setColor(tinting ? Color.lightGray : Color.white);
if (!text.isEmpty()) {
sg.setFont(keyFont); sg.setFont(keyFont);
int textWidth = sg.getFontMetrics(keyFont).stringWidth(text); int textWidth = sg.getFontMetrics(keyFont).stringWidth(text);
int centerX = (getWidth() - textWidth) / 2; int centerX = (getWidth() - textWidth) / 2;
sg.drawString(text, centerX, 28); sg.drawString(text, centerX, 28);
}
} finally { } finally {
sg.dispose(); sg.dispose();
} }
@ -48,5 +56,4 @@ public class KeyboundButton extends JButton {
this.tinting = tinting; this.tinting = tinting;
repaint(); repaint();
} }
} }

View file

@ -0,0 +1,180 @@
package mage.client.components;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckValidator;
import mage.cards.decks.importer.DeckImporter;
import org.unbescape.html.HtmlEscape;
import org.unbescape.html.HtmlEscapeLevel;
import org.unbescape.html.HtmlEscapeType;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.util.Map;
/**
* @author Elandril
*/
public class LegalityLabel extends JLabel {
protected static final Color COLOR_UNKNOWN = new Color(174, 174, 174);
protected static final Color COLOR_LEGAL = new Color(117, 152, 110);
protected static final Color COLOR_NOT_LEGAL = new Color(191, 84, 74);
protected static final Color COLOR_TEXT = new Color(255, 255, 255);
protected static final Dimension DIM_MINIMUM = new Dimension(75, 25);
protected static final Dimension DIM_MAXIMUM = new Dimension(150, 75);
protected static final Dimension DIM_PREFERRED = new Dimension(75, 25);
protected Deck currentDeck;
protected String errorMessage;
protected DeckValidator validator;
/**
* Creates a <code>LegalityLabel</code> instance with the specified text
* and the given DeckValidator.
*
* @param text The text to be displayed by the label.
* @param validator The DeckValidator to check against.
*/
public LegalityLabel(String text, DeckValidator validator) {
super(text);
this.validator = validator;
setBackground(COLOR_UNKNOWN);
setForeground(COLOR_TEXT);
setHorizontalAlignment(SwingConstants.CENTER);
setMinimumSize(DIM_MINIMUM);
setMaximumSize(DIM_MAXIMUM);
setName(text); // NOI18N
setOpaque(true);
setPreferredSize(DIM_PREFERRED);
}
/**
* Creates a <code>LegalityLabel</code> instance with the given DeckValidator and uses its
* shortName as the text.
*
* @param validator The DeckValidator to check against.
*/
public LegalityLabel(DeckValidator validator) {
this(validator.getShortName(), validator);
}
/**
* Creates a <code>LegalityLabel</code> instance with no DeckValidator or text.
* This is used by the Netbeans GUI Editor.
*/
public LegalityLabel() {
super();
setBackground(COLOR_UNKNOWN);
setForeground(COLOR_TEXT);
setHorizontalAlignment(SwingConstants.CENTER);
setMinimumSize(DIM_MINIMUM);
setMaximumSize(DIM_MAXIMUM);
setOpaque(true);
setPreferredSize(DIM_PREFERRED);
}
public String getErrorMessage() {
return errorMessage;
}
public DeckValidator getValidator() {
return validator;
}
public void setValidator(DeckValidator validator) {
this.validator = validator;
revalidateDeck();
}
protected String escapeHtml(String string) {
return HtmlEscape.escapeHtml(string, HtmlEscapeType.HTML4_NAMED_REFERENCES_DEFAULT_TO_HEXA, HtmlEscapeLevel.LEVEL_0_ONLY_MARKUP_SIGNIFICANT_EXCEPT_APOS);
}
protected String formatInvalidTooltip(Map<String, String> invalid) {
return invalid.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.reduce("<html><body><p>Deck is <span style='color:#BF544A;font-weight:bold;'>INVALID</span></p><u>The following problems have been found:</u><br><table>",
(str, entry) -> String.format("%s<tr><td><b>%s</b></td><td>%s</td></tr>", str, escapeHtml(entry.getKey()), escapeHtml(entry.getValue())), String::concat)
+ "</table></body></html>";
}
private String appendErrorMessage(String string) {
if (errorMessage.isEmpty())
return string;
if (string.contains("<html>")) {
return string.replaceFirst("((</body>)?</html>)", String.format("<br><br>The following errors occurred while loading the deck:<br>%s$1", escapeHtml(errorMessage)));
}
return string.concat("\n\nThe following errors occurred while loading the deck:\n" + errorMessage);
}
public void showState(Color color) {
setBackground(color);
}
public void showState(Color color, String tooltip) {
setBackground(color);
setToolTipText(appendErrorMessage(tooltip));
}
public void showStateUnknown(String tooltip) {
showState(COLOR_UNKNOWN, tooltip);
}
public void showStateLegal(String tooltip) {
showState(COLOR_LEGAL, tooltip);
}
public void showStateNotLegal(String tooltip) {
showState(COLOR_NOT_LEGAL, tooltip);
}
public void validateDeck(Deck deck) {
errorMessage = "";
currentDeck = deck;
if (deck == null) {
showStateUnknown("<html><body><b>No deck loaded!</b></body></html>");
return;
}
if (validator == null) {
showStateUnknown("<html><body><b>No deck type selected!</b></body></html>");
return;
}
try {
if (validator.validate(deck)) {
showStateLegal("<html><body>Deck is <span style='color:green;font-weight:bold;'>VALID</span></body></html>");
} else {
showStateNotLegal(formatInvalidTooltip(validator.getInvalid()));
}
} catch (Exception e) {
showStateUnknown(String.format("<html><body><b>Deck could not be validated!</b><br>The following error occurred while validating this deck:<br>%s</body></html>", escapeHtml(e.getMessage())));
}
}
public void validateDeck(File deckFile) {
deckFile = deckFile.getAbsoluteFile();
if (!deckFile.exists()) {
errorMessage = String.format("Deck file '%s' does not exist.", deckFile.getAbsolutePath());
showStateUnknown("<html><body><b>No Deck loaded!</b></body></html>");
return;
}
try {
StringBuilder errorMessages = new StringBuilder();
Deck deck = Deck.load(DeckImporter.importDeckFromFile(deckFile.getAbsolutePath(), errorMessages), true, true);
errorMessage = errorMessages.toString();
validateDeck(deck);
} catch (Exception ex) {
errorMessage = String.format("Error importing deck from file '%s'!", deckFile.getAbsolutePath());
}
}
public void revalidateDeck() {
validateDeck(currentDeck);
}
public void validateDeck(String deckFile) {
validateDeck(new File(deckFile));
}
}

View file

@ -10,6 +10,7 @@ import mage.ObjectColor;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.cards.Sets; import mage.cards.Sets;
import mage.cards.decks.PennyDreadfulLegalityUtil;
import mage.cards.repository.*; import mage.cards.repository.*;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.*; import mage.client.cards.*;
@ -421,9 +422,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
try { try {
java.util.List<Card> filteredCards = new ArrayList<>(); java.util.List<Card> filteredCards = new ArrayList<>();
boolean chkPD = chkPennyDreadful.isSelected(); if (chkPennyDreadful.isSelected() && pdAllowed.isEmpty()) {
if (chkPD) { pdAllowed.putAll(PennyDreadfulLegalityUtil.getLegalCardList());
generatePennyDreadfulHash();
} }
if (limited) { if (limited) {
@ -437,7 +437,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
for (CardInfo cardInfo : foundCards) { for (CardInfo cardInfo : foundCards) {
Card card = cardInfo.getMockCard(); Card card = cardInfo.getMockCard();
if (filter.match(card, null)) { if (filter.match(card, null)) {
if (chkPD) { if (chkPennyDreadful.isSelected()) {
if (!pdAllowed.containsKey(card.getName())) { if (!pdAllowed.containsKey(card.getName())) {
continue; continue;
} }
@ -478,22 +478,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
} }
public void generatePennyDreadfulHash() {
if (pdAllowed.size() > 0) {
return;
}
Properties properties = new Properties();
try {
properties.load(CardSelector.class.getResourceAsStream("pennydreadful.properties"));
} catch (Exception e) {
e.printStackTrace();
}
for (final Entry<Object, Object> entry : properties.entrySet()) {
pdAllowed.put((String) entry.getKey(), 1);
}
}
private void reloadSetsCombobox() { private void reloadSetsCombobox() {
DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes()); DefaultComboBoxModel model = new DefaultComboBoxModel<>(ConstructedFormats.getTypes());
cbExpansionSet.setModel(model); cbExpansionSet.setModel(model);

View file

@ -18,7 +18,7 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="panelLeft" min="-2" max="-2" attributes="0"/> <Component id="panelLeft" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="panelRight" pref="890" max="32767" attributes="0"/> <Component id="panelRight" pref="890" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -26,7 +26,7 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="panelLeft" alignment="0" max="32767" attributes="0"/> <Component id="panelLeft" alignment="0" max="32767" attributes="0"/>
<Component id="panelRight" alignment="1" pref="808" max="32767" attributes="0"/> <Component id="panelRight" alignment="1" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
@ -59,13 +59,13 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="panelDeck" alignment="1" max="32767" attributes="0"/> <Component id="panelDeck" alignment="1" max="32767" attributes="0"/>
<Component id="bigCard" alignment="0" max="32767" attributes="0"/> <Component id="bigCard" alignment="0" max="32767" attributes="0"/>
</Group> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="deckLegalityDisplay" min="-2" pref="245" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -73,9 +73,11 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="panelDeck" min="-2" max="-2" attributes="0"/> <Component id="panelDeck" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace min="-2" pref="62" max="-2" attributes="0"/>
<Component id="deckLegalityDisplay" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="63" max="-2" attributes="0"/>
<Component id="bigCard" min="-2" max="-2" attributes="0"/> <Component id="bigCard" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -112,7 +114,7 @@
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="lblDeckName" min="-2" max="-2" attributes="0"/> <Component id="lblDeckName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtDeckName" pref="175" max="32767" attributes="0"/> <Component id="txtDeckName" pref="184" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -158,7 +160,7 @@
<Component id="btnNew" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnNew" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnGenDeck" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnGenDeck" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/> <EmptySpace pref="49" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -215,7 +217,7 @@
<Component id="btnLoad" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnLoad" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnImport" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnImport" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/> <EmptySpace pref="49" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -272,7 +274,7 @@
<Component id="btnSave" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnSave" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnExport" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnExport" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/> <EmptySpace pref="49" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -329,7 +331,7 @@
<Component id="btnSubmit" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnSubmit" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnSubmitTimer" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnSubmitTimer" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/> <EmptySpace pref="49" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -392,15 +394,20 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnAddLand" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnAddLand" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="146" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnLegality" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="49" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnAddLand" pref="30" max="32767" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<Component id="btnAddLand" max="32767" attributes="0"/>
<Component id="btnLegality" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/> <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -420,6 +427,16 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAddLandActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnLegality">
<Properties>
<Property name="text" type="java.lang.String" value="Validate"/>
<Property name="iconTextGap" type="int" value="2"/>
<Property name="name" type="java.lang.String" value="btnLegality" noResource="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLegalityActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="panelDeckExit"> <Container class="javax.swing.JPanel" name="panelDeckExit">
@ -435,7 +452,7 @@
<Component id="btnExit" min="-2" pref="100" max="-2" attributes="0"/> <Component id="btnExit" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtTimeRemaining" min="-2" pref="100" max="-2" attributes="0"/> <Component id="txtTimeRemaining" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/> <EmptySpace pref="49" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -470,6 +487,20 @@
</Container> </Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="mage.client.deckeditor.DeckLegalityPanel" name="deckLegalityDisplay">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[245, 155]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[85, 155]"/>
</Property>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="deckLegalityDisplay.setVisible(false);"/>
</AuxValues>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
</SubComponents> </SubComponents>

View file

@ -43,7 +43,7 @@ import static mage.cards.decks.DeckFormats.XMAGE;
import static mage.cards.decks.DeckFormats.XMAGE_INFO; import static mage.cards.decks.DeckFormats.XMAGE_INFO;
/** /**
* @author BetaSteward_at_googlemail.com, JayDi85 * @author BetaSteward_at_googlemail.com, JayDi85, Elandril
*/ */
public class DeckEditorPanel extends javax.swing.JPanel { public class DeckEditorPanel extends javax.swing.JPanel {
@ -858,9 +858,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
btnSubmitTimer = new javax.swing.JButton(); btnSubmitTimer = new javax.swing.JButton();
panelDeckLands = new javax.swing.JPanel(); panelDeckLands = new javax.swing.JPanel();
btnAddLand = new javax.swing.JButton(); btnAddLand = new javax.swing.JButton();
btnLegality = new javax.swing.JButton();
panelDeckExit = new javax.swing.JPanel(); panelDeckExit = new javax.swing.JPanel();
btnExit = new javax.swing.JButton(); btnExit = new javax.swing.JButton();
txtTimeRemaining = new javax.swing.JTextField(); txtTimeRemaining = new javax.swing.JTextField();
deckLegalityDisplay = new mage.client.deckeditor.DeckLegalityPanel();
panelRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); panelRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
panelRight.setResizeWeight(0.5); panelRight.setResizeWeight(0.5);
@ -884,7 +886,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addContainerGap() .addContainerGap()
.addComponent(lblDeckName) .addComponent(lblDeckName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE) .addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
.addContainerGap()) .addContainerGap())
); );
panelDeckNameLayout.setVerticalGroup( panelDeckNameLayout.setVerticalGroup(
@ -928,7 +930,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnNew, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnNew, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnGenDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnGenDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE)) .addContainerGap(49, Short.MAX_VALUE))
); );
panelDeckCreateLayout.setVerticalGroup( panelDeckCreateLayout.setVerticalGroup(
panelDeckCreateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelDeckCreateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -971,7 +973,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnLoad, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnLoad, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnImport, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnImport, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE)) .addContainerGap(49, Short.MAX_VALUE))
); );
panelDeckLoadLayout.setVerticalGroup( panelDeckLoadLayout.setVerticalGroup(
panelDeckLoadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelDeckLoadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1014,7 +1016,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExport, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnExport, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE)) .addContainerGap(49, Short.MAX_VALUE))
); );
panelDeckSaveLayout.setVerticalGroup( panelDeckSaveLayout.setVerticalGroup(
panelDeckSaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelDeckSaveLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1059,7 +1061,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnSubmit, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSubmit, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnSubmitTimer, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSubmitTimer, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE)) .addContainerGap(49, Short.MAX_VALUE))
); );
panelDeckDraftLayout.setVerticalGroup( panelDeckDraftLayout.setVerticalGroup(
panelDeckDraftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelDeckDraftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1087,6 +1089,15 @@ public class DeckEditorPanel extends javax.swing.JPanel {
} }
}); });
btnLegality.setText("Validate");
btnLegality.setIconTextGap(2);
btnLegality.setName("btnLegality"); // NOI18N
btnLegality.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLegalityActionPerformed(evt);
}
});
javax.swing.GroupLayout panelDeckLandsLayout = new javax.swing.GroupLayout(panelDeckLands); javax.swing.GroupLayout panelDeckLandsLayout = new javax.swing.GroupLayout(panelDeckLands);
panelDeckLands.setLayout(panelDeckLandsLayout); panelDeckLands.setLayout(panelDeckLandsLayout);
panelDeckLandsLayout.setHorizontalGroup( panelDeckLandsLayout.setHorizontalGroup(
@ -1094,13 +1105,17 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addGroup(panelDeckLandsLayout.createSequentialGroup() .addGroup(panelDeckLandsLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(btnAddLand, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnAddLand, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(146, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnLegality, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(49, Short.MAX_VALUE))
); );
panelDeckLandsLayout.setVerticalGroup( panelDeckLandsLayout.setVerticalGroup(
panelDeckLandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelDeckLandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelDeckLandsLayout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDeckLandsLayout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(btnAddLand, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE) .addGroup(panelDeckLandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnAddLand, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnLegality, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, 0)) .addGap(0, 0, 0))
); );
@ -1131,7 +1146,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtTimeRemaining, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtTimeRemaining, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(40, Short.MAX_VALUE)) .addContainerGap(49, Short.MAX_VALUE))
); );
panelDeckExitLayout.setVerticalGroup( panelDeckExitLayout.setVerticalGroup(
panelDeckExitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelDeckExitLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1144,21 +1159,29 @@ public class DeckEditorPanel extends javax.swing.JPanel {
panelDeck.add(panelDeckExit); panelDeck.add(panelDeckExit);
deckLegalityDisplay.setMaximumSize(new java.awt.Dimension(245, 155));
deckLegalityDisplay.setMinimumSize(new java.awt.Dimension(85, 155));
deckLegalityDisplay.setOpaque(false);
deckLegalityDisplay.setVisible(false);
javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft); javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
panelLeft.setLayout(panelLeftLayout); panelLeft.setLayout(panelLeftLayout);
panelLeftLayout.setHorizontalGroup( panelLeftLayout.setHorizontalGroup(
panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelDeck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelDeck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bigCard, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(bigCard, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(deckLegalityDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
); );
panelLeftLayout.setVerticalGroup( panelLeftLayout.setVerticalGroup(
panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLeftLayout.createSequentialGroup() .addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(panelDeck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelDeck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(62, 62, 62)
.addComponent(deckLegalityDisplay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(63, 63, 63)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap()) .addContainerGap())
); );
@ -1169,13 +1192,13 @@ public class DeckEditorPanel extends javax.swing.JPanel {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(panelLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(panelLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelRight, javax.swing.GroupLayout.DEFAULT_SIZE, 890, Short.MAX_VALUE)) .addComponent(panelRight, javax.swing.GroupLayout.PREFERRED_SIZE, 890, Short.MAX_VALUE))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelLeft, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panelLeft, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelRight, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 808, Short.MAX_VALUE) .addComponent(panelRight, javax.swing.GroupLayout.Alignment.TRAILING)
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -1368,6 +1391,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
exportChoose(evt); exportChoose(evt);
}//GEN-LAST:event_btnExportActionPerformed }//GEN-LAST:event_btnExportActionPerformed
private void btnLegalityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLegalityActionPerformed
this.deckLegalityDisplay.setVisible(true);
this.deckLegalityDisplay.validateDeck(deck);
}//GEN-LAST:event_btnLegalityActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.cards.BigCard bigCard; private mage.client.cards.BigCard bigCard;
@ -1376,6 +1404,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private javax.swing.JButton btnExport; private javax.swing.JButton btnExport;
private javax.swing.JButton btnGenDeck; private javax.swing.JButton btnGenDeck;
private javax.swing.JButton btnImport; private javax.swing.JButton btnImport;
private javax.swing.JButton btnLegality;
private javax.swing.JButton btnLoad; private javax.swing.JButton btnLoad;
private javax.swing.JButton btnNew; private javax.swing.JButton btnNew;
private javax.swing.JButton btnSave; private javax.swing.JButton btnSave;
@ -1387,6 +1416,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
*/ */
private mage.client.deckeditor.CardSelector cardSelector; private mage.client.deckeditor.CardSelector cardSelector;
private mage.client.deckeditor.DeckArea deckArea; private mage.client.deckeditor.DeckArea deckArea;
private mage.client.deckeditor.DeckLegalityPanel deckLegalityDisplay;
private javax.swing.JLabel lblDeckName; private javax.swing.JLabel lblDeckName;
private javax.swing.JPanel panelDeck; private javax.swing.JPanel panelDeck;
private javax.swing.JPanel panelDeckCreate; private javax.swing.JPanel panelDeckCreate;

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[85, 35]"/>
</Property>
<Property name="name" type="java.lang.String" value="DeckLegalityPanel" noResource="true"/>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,0,-11"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="3"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="previewUnknown">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ae" green="ae" red="ae" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Unknown"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 50]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[75, 25]"/>
</Property>
<Property name="name" type="java.lang.String" value="previewUnknown" noResource="true"/>
<Property name="opaque" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[75, 25]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="previewLegal">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="6e" green="98" red="75" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Legal"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 50]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[75, 25]"/>
</Property>
<Property name="name" type="java.lang.String" value="previewLegal" noResource="true"/>
<Property name="opaque" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[75, 25]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="previewNotLegal">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="4a" green="54" red="bf" type="rgb"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Not Legal"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 50]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[75, 25]"/>
</Property>
<Property name="name" type="java.lang.String" value="previewNotLegal" noResource="true"/>
<Property name="opaque" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[75, 25]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>

View file

@ -0,0 +1,111 @@
package mage.client.deckeditor;
import java.util.*;
import java.util.stream.Stream;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckValidator;
import mage.client.components.LegalityLabel;
import mage.deck.*;
/**
* @author Elandril
*/
public class DeckLegalityPanel extends javax.swing.JPanel {
/**
* Creates new form DeckLegalityPanel
*/
public DeckLegalityPanel() {
initComponents();
initDeckLabels();
}
/**
* 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
private void initComponents() {
previewUnknown = new javax.swing.JLabel();
previewLegal = new javax.swing.JLabel();
previewNotLegal = new javax.swing.JLabel();
setMinimumSize(new java.awt.Dimension(85, 35));
setName("DeckLegalityPanel"); // NOI18N
setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING));
previewUnknown.setBackground(new java.awt.Color(174, 174, 174));
previewUnknown.setForeground(new java.awt.Color(255, 255, 255));
previewUnknown.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
previewUnknown.setText("Unknown");
previewUnknown.setMaximumSize(new java.awt.Dimension(150, 50));
previewUnknown.setMinimumSize(new java.awt.Dimension(75, 25));
previewUnknown.setName("previewUnknown"); // NOI18N
previewUnknown.setOpaque(true);
previewUnknown.setPreferredSize(new java.awt.Dimension(75, 25));
add(previewUnknown);
previewLegal.setBackground(new java.awt.Color(117, 152, 110));
previewLegal.setForeground(new java.awt.Color(255, 255, 255));
previewLegal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
previewLegal.setText("Legal");
previewLegal.setMaximumSize(new java.awt.Dimension(150, 50));
previewLegal.setMinimumSize(new java.awt.Dimension(75, 25));
previewLegal.setName("previewLegal"); // NOI18N
previewLegal.setOpaque(true);
previewLegal.setPreferredSize(new java.awt.Dimension(75, 25));
add(previewLegal);
previewNotLegal.setBackground(new java.awt.Color(191, 84, 74));
previewNotLegal.setForeground(new java.awt.Color(255, 255, 255));
previewNotLegal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
previewNotLegal.setText("Not Legal");
previewNotLegal.setMaximumSize(new java.awt.Dimension(150, 50));
previewNotLegal.setMinimumSize(new java.awt.Dimension(75, 25));
previewNotLegal.setName("previewNotLegal"); // NOI18N
previewNotLegal.setOpaque(true);
previewNotLegal.setPreferredSize(new java.awt.Dimension(75, 25));
add(previewNotLegal);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel previewLegal;
private javax.swing.JLabel previewNotLegal;
private javax.swing.JLabel previewUnknown;
// End of variables declaration//GEN-END:variables
private void initDeckLabels() {
remove(previewUnknown);
remove(previewLegal);
remove(previewNotLegal);
Stream.of(
new Standard(), new Pioneer(), new Modern(), new Pauper(), new HistoricalType2(),
new Legacy(), new Vintage(), new Eternal(), new Frontier(), new Momir(),
new Commander(), new Brawl(), new Oathbreaker(), new PennyDreadfulCommander(), new TinyLeaders()
).forEach(this::addLegalityLabel);
revalidate();
repaint();
}
protected LegalityLabel addLegalityLabel(DeckValidator validator) {
LegalityLabel label = new LegalityLabel(validator);
add(label);
return label;
}
public void validateDeck(Deck deck) {
Arrays.stream(getComponents())
.filter(LegalityLabel.class::isInstance)
.map(LegalityLabel.class::cast)
.forEach(label -> label.validateDeck(deck));
}
}

View file

@ -31,15 +31,12 @@
*/ */
public class GameEndDialog extends MageDialog { public class GameEndDialog extends MageDialog {
private final DateFormat df = DateFormat.getDateTimeInstance();
/** /**
* Creates new form GameEndDialog * Creates new form GameEndDialog
* *
* @param gameEndView * @param gameEndView
*/ */
public GameEndDialog(GameEndView gameEndView) { public GameEndDialog(GameEndView gameEndView) {
initComponents(); initComponents();
this.modal = true; this.modal = true;
@ -47,7 +44,14 @@
pnlText.setBackground(new Color(240, 240, 240, 140)); pnlText.setBackground(new Color(240, 240, 240, 140));
Rectangle r = new Rectangle(610, 250); Rectangle r = new Rectangle(610, 250);
Image image = ImageHelper.getImageFromResources(gameEndView.hasWon() ? "/game_won.jpg" : "/game_lost.jpg");
Image image;
if (gameEndView.hasWon()) {
image = ImageHelper.getImageFromResources(PreferencesDialog.getCurrentTheme().getWinlossPath("game_won.jpg"));
} else {
image = ImageHelper.getImageFromResources(PreferencesDialog.getCurrentTheme().getWinlossPath("game_lost.jpg"));
}
BufferedImage imageResult = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); BufferedImage imageResult = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
ImageIcon icon = new ImageIcon(imageResult); ImageIcon icon = new ImageIcon(imageResult);
lblResultImage.setIcon(icon); lblResultImage.setIcon(icon);
@ -61,6 +65,8 @@
this.saveGameLog(gameEndView); this.saveGameLog(gameEndView);
} }
DateFormat df = DateFormat.getDateTimeInstance();
// game duration // game duration
txtDurationGame.setText(" " + Format.getDuration(gameEndView.getStartTime(), gameEndView.getEndTime())); txtDurationGame.setText(" " + Format.getDuration(gameEndView.getStartTime(), gameEndView.getEndTime()));
txtDurationGame.setToolTipText(new StringBuilder(df.format(gameEndView.getStartTime())).append(" - ").append(df.format(gameEndView.getEndTime())).toString()); txtDurationGame.setToolTipText(new StringBuilder(df.format(gameEndView.getStartTime())).append(" - ").append(df.format(gameEndView.getEndTime())).toString());

View file

@ -6236,6 +6236,114 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="tabThemes">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Themes">
<Property name="tabTitle" type="java.lang.String" value="Themes"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="750" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="themesCategory" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="526" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
<Component id="themesCategory" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="430" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="themesCategory">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Themes">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</TitledBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lbSelectLabel" min="-2" pref="96" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lbThemeHint" min="-2" max="-2" attributes="0"/>
<Component id="cbTheme" min="-2" pref="303" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="303" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="cbTheme" min="-2" max="-2" attributes="0"/>
<Component id="lbSelectLabel" min="-2" pref="22" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbThemeHint" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lbSelectLabel">
<Properties>
<Property name="horizontalAlignment" type="int" value="2"/>
<Property name="text" type="java.lang.String" value="Select a theme:"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="horizontalTextPosition" type="int" value="10"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[110, 16]"/>
</Property>
<Property name="verticalTextPosition" type="int" value="1"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbTheme">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbThemeActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;ThemeType&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="lbThemeHint">
<Properties>
<Property name="text" type="java.lang.String" value="Requires a restart to apply new theme."/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JButton" name="saveButton"> <Component class="javax.swing.JButton" name="saveButton">

View file

@ -15,6 +15,7 @@ import mage.remote.Connection;
import mage.remote.Connection.ProxyType; import mage.remote.Connection.ProxyType;
import mage.view.UserRequestMessage; import mage.view.UserRequestMessage;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import mage.client.themes.ThemeType;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
@ -100,6 +101,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled"; public static final String KEY_BIG_CARD_TOGGLED = "bigCardToggled";
// Themes
public static final String KEY_THEME = "themeSelection";
// Phases // Phases
public static final String UPKEEP_YOU = "upkeepYou"; public static final String UPKEEP_YOU = "upkeepYou";
public static final String DRAW_YOU = "drawYou"; public static final String DRAW_YOU = "drawYou";
@ -310,6 +314,16 @@ public class PreferencesDialog extends javax.swing.JDialog {
private static int selectedAvatarId; private static int selectedAvatarId;
private static ThemeType currentTheme = null;
public static ThemeType getCurrentTheme() {
if (currentTheme == null) {
currentTheme = ThemeType.valueByName(getCachedValue(KEY_THEME, "Default Theme"));
}
return currentTheme;
}
private final JFileChooser fc = new JFileChooser(); private final JFileChooser fc = new JFileChooser();
{ {
@ -359,6 +373,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
initComponents(); initComponents();
txtImageFolderPath.setEditable(false); txtImageFolderPath.setEditable(false);
cbProxyType.setModel(new DefaultComboBoxModel<>(Connection.ProxyType.values())); cbProxyType.setModel(new DefaultComboBoxModel<>(Connection.ProxyType.values()));
cbTheme.setModel(new DefaultComboBoxModel<>(ThemeType.values()));
addAvatars(); addAvatars();
cbPreferedImageLanguage.setModel(new DefaultComboBoxModel<>(CardLanguage.toList())); cbPreferedImageLanguage.setModel(new DefaultComboBoxModel<>(CardLanguage.toList()));
@ -469,7 +484,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtImageFolderPath = new javax.swing.JTextField(); txtImageFolderPath = new javax.swing.JTextField();
btnBrowseImageLocation = new javax.swing.JButton(); btnBrowseImageLocation = new javax.swing.JButton();
cbSaveToZipFiles = new javax.swing.JCheckBox(); cbSaveToZipFiles = new javax.swing.JCheckBox();
cbPreferedImageLanguage = new javax.swing.JComboBox<>(); cbPreferedImageLanguage = new javax.swing.JComboBox<String>();
labelPreferedImageLanguage = new javax.swing.JLabel(); labelPreferedImageLanguage = new javax.swing.JLabel();
labelNumberOfDownloadThreads = new javax.swing.JLabel(); labelNumberOfDownloadThreads = new javax.swing.JLabel();
cbNumberOfDownloadThreads = new javax.swing.JComboBox(); cbNumberOfDownloadThreads = new javax.swing.JComboBox();
@ -530,7 +545,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtURLServerList = new javax.swing.JTextField(); txtURLServerList = new javax.swing.JTextField();
jLabel17 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel();
lblProxyType = new javax.swing.JLabel(); lblProxyType = new javax.swing.JLabel();
cbProxyType = new javax.swing.JComboBox<>(); cbProxyType = new javax.swing.JComboBox<ProxyType>();
pnlProxySettings = new javax.swing.JPanel(); pnlProxySettings = new javax.swing.JPanel();
pnlProxy = new javax.swing.JPanel(); pnlProxy = new javax.swing.JPanel();
lblProxyServer = new javax.swing.JLabel(); lblProxyServer = new javax.swing.JLabel();
@ -568,6 +583,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
keyToggleRecordMacro = new KeyBindButton(this, KEY_CONTROL_TOGGLE_MACRO); keyToggleRecordMacro = new KeyBindButton(this, KEY_CONTROL_TOGGLE_MACRO);
labelSwitchChat = new javax.swing.JLabel(); labelSwitchChat = new javax.swing.JLabel();
keySwitchChat = new KeyBindButton(this, KEY_CONTROL_SWITCH_CHAT); keySwitchChat = new KeyBindButton(this, KEY_CONTROL_SWITCH_CHAT);
tabThemes = new javax.swing.JPanel();
themesCategory = new javax.swing.JPanel();
lbSelectLabel = new javax.swing.JLabel();
cbTheme = new javax.swing.JComboBox<ThemeType>();
lbThemeHint = new javax.swing.JLabel();
saveButton = new javax.swing.JButton(); saveButton = new javax.swing.JButton();
exitButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton();
@ -1534,7 +1554,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}); });
cbPreferedImageLanguage.setMaximumRowCount(20); cbPreferedImageLanguage.setMaximumRowCount(20);
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"})); cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
labelPreferedImageLanguage.setText("Default images language:"); labelPreferedImageLanguage.setText("Default images language:");
labelPreferedImageLanguage.setFocusable(false); labelPreferedImageLanguage.setFocusable(false);
@ -2663,6 +2683,70 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabsPanel.addTab("Controls", tabControls); tabsPanel.addTab("Controls", tabControls);
themesCategory.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Themes"));
lbSelectLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
lbSelectLabel.setText("Select a theme:");
lbSelectLabel.setToolTipText("");
lbSelectLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
lbSelectLabel.setPreferredSize(new java.awt.Dimension(110, 16));
lbSelectLabel.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
cbTheme.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbThemeActionPerformed(evt);
}
});
lbThemeHint.setText("Requires a restart to apply new theme.");
org.jdesktop.layout.GroupLayout themesCategoryLayout = new org.jdesktop.layout.GroupLayout(themesCategory);
themesCategory.setLayout(themesCategoryLayout);
themesCategoryLayout.setHorizontalGroup(
themesCategoryLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(themesCategoryLayout.createSequentialGroup()
.addContainerGap()
.add(lbSelectLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 96, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(themesCategoryLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(lbThemeHint)
.add(cbTheme, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 303, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addContainerGap(303, Short.MAX_VALUE))
);
themesCategoryLayout.setVerticalGroup(
themesCategoryLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(themesCategoryLayout.createSequentialGroup()
.add(themesCategoryLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(cbTheme, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(lbSelectLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(lbThemeHint)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
org.jdesktop.layout.GroupLayout tabThemesLayout = new org.jdesktop.layout.GroupLayout(tabThemes);
tabThemes.setLayout(tabThemesLayout);
tabThemesLayout.setHorizontalGroup(
tabThemesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 750, Short.MAX_VALUE)
.add(tabThemesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabThemesLayout.createSequentialGroup()
.addContainerGap()
.add(themesCategory, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap()))
);
tabThemesLayout.setVerticalGroup(
tabThemesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(0, 526, Short.MAX_VALUE)
.add(tabThemesLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(tabThemesLayout.createSequentialGroup()
.add(21, 21, 21)
.add(themesCategory, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(430, Short.MAX_VALUE)))
);
tabsPanel.addTab("Themes", tabThemes);
saveButton.setLabel("Save"); saveButton.setLabel("Save");
saveButton.setMaximumSize(new java.awt.Dimension(100, 30)); saveButton.setMaximumSize(new java.awt.Dimension(100, 30));
saveButton.setMinimumSize(new java.awt.Dimension(100, 30)); saveButton.setMinimumSize(new java.awt.Dimension(100, 30));
@ -2879,6 +2963,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.keyToggleRecordMacro); save(prefs, dialog.keyToggleRecordMacro);
save(prefs, dialog.keySwitchChat); save(prefs, dialog.keySwitchChat);
// Themes
save(prefs, dialog.cbTheme, KEY_THEME);
// Avatar // Avatar
if (selectedAvatarId < MIN_AVATAR_ID || selectedAvatarId > MAX_AVATAR_ID) { if (selectedAvatarId < MIN_AVATAR_ID || selectedAvatarId > MAX_AVATAR_ID) {
selectedAvatarId = DEFAULT_AVATAR_ID; selectedAvatarId = DEFAULT_AVATAR_ID;
@ -3184,6 +3271,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
} }
}//GEN-LAST:event_cbUseDefaultImageFolderActionPerformed }//GEN-LAST:event_cbUseDefaultImageFolderActionPerformed
private void cbThemeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbThemeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbThemeActionPerformed
private void showProxySettings() { private void showProxySettings() {
Connection.ProxyType proxyType = (Connection.ProxyType) cbProxyType.getSelectedItem(); Connection.ProxyType proxyType = (Connection.ProxyType) cbProxyType.getSelectedItem();
switch (proxyType) { switch (proxyType) {
@ -3268,6 +3359,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
// Controls // Controls
loadControlSettings(prefs); loadControlSettings(prefs);
// Themes
loadThemeSettings(prefs);
// Selected avatar // Selected avatar
loadSelectedAvatar(prefs); loadSelectedAvatar(prefs);
@ -3457,6 +3551,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.keySwitchChat); load(prefs, dialog.keySwitchChat);
} }
private static void loadThemeSettings(Preferences prefs) {
dialog.cbTheme.setSelectedItem(PreferencesDialog.getCurrentTheme());
}
private static void loadSelectedAvatar(Preferences prefs) { private static void loadSelectedAvatar(Preferences prefs) {
getSelectedAvatar(); getSelectedAvatar();
dialog.setSelectedId(selectedAvatarId); dialog.setSelectedId(selectedAvatarId);
@ -3916,6 +4014,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JCheckBox cbStopOnAllEnd; private javax.swing.JCheckBox cbStopOnAllEnd;
private javax.swing.JCheckBox cbStopOnAllMain; private javax.swing.JCheckBox cbStopOnAllMain;
private javax.swing.JCheckBox cbStopOnNewStackObjects; private javax.swing.JCheckBox cbStopOnNewStackObjects;
private javax.swing.JComboBox<ThemeType> cbTheme;
private javax.swing.JCheckBox cbUseDefaultBackground; private javax.swing.JCheckBox cbUseDefaultBackground;
private javax.swing.JCheckBox cbUseDefaultBattleImage; private javax.swing.JCheckBox cbUseDefaultBattleImage;
private javax.swing.JCheckBox cbUseDefaultImageFolder; private javax.swing.JCheckBox cbUseDefaultImageFolder;
@ -4015,6 +4114,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JLabel labelToggleRecordMacro; private javax.swing.JLabel labelToggleRecordMacro;
private javax.swing.JLabel labelTooltipSize; private javax.swing.JLabel labelTooltipSize;
private javax.swing.JLabel labelYourTurn; private javax.swing.JLabel labelYourTurn;
private javax.swing.JLabel lbSelectLabel;
private javax.swing.JLabel lbThemeHint;
private javax.swing.JLabel lblBattlefieldFeedbackColorizingMode; private javax.swing.JLabel lblBattlefieldFeedbackColorizingMode;
private javax.swing.JLabel lblProxyPassword; private javax.swing.JLabel lblProxyPassword;
private javax.swing.JLabel lblProxyPort; private javax.swing.JLabel lblProxyPort;
@ -4062,7 +4163,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JPanel tabMain; private javax.swing.JPanel tabMain;
private javax.swing.JPanel tabPhases; private javax.swing.JPanel tabPhases;
private javax.swing.JPanel tabSounds; private javax.swing.JPanel tabSounds;
private javax.swing.JPanel tabThemes;
private javax.swing.JTabbedPane tabsPanel; private javax.swing.JTabbedPane tabsPanel;
private javax.swing.JPanel themesCategory;
private javax.swing.JSlider tooltipDelay; private javax.swing.JSlider tooltipDelay;
private javax.swing.JLabel tooltipDelayLabel; private javax.swing.JLabel tooltipDelayLabel;
private javax.swing.JTextField txtBackgroundImagePath; private javax.swing.JTextField txtBackgroundImagePath;

View file

@ -10,6 +10,7 @@ package mage.client.game;
import java.awt.Component; import java.awt.Component;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -46,6 +47,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
private MageDialog connectedDialog; private MageDialog connectedDialog;
private ChatPanelBasic connectedChatPanel; private ChatPanelBasic connectedChatPanel;
private int lastMessageId; private int lastMessageId;
private LocalDateTime lastResponse;
private static final ScheduledExecutorService WORKER = Executors.newSingleThreadScheduledExecutor(); private static final ScheduledExecutorService WORKER = Executors.newSingleThreadScheduledExecutor();
@ -85,6 +87,13 @@ public class FeedbackPanel extends javax.swing.JPanel {
String lblText = addAdditionalText(message, options); String lblText = addAdditionalText(message, options);
this.helper.setTextArea(lblText); this.helper.setTextArea(lblText);
//this.lblMessage.setText(lblText); //this.lblMessage.setText(lblText);
// Alert user when needing feedback if last dialog was informative, and it has been over 2 seconds since last input
if (this.mode == FeedbackMode.INFORM && mode != FeedbackMode.INFORM
&& (this.lastResponse == null || this.lastResponse.isBefore(LocalDateTime.now().minusSeconds(2)))) {
AudioManager.playFeedbackNeeded();
}
this.mode = mode; this.mode = mode;
switch (this.mode) { switch (this.mode) {
case INFORM: case INFORM:
@ -244,6 +253,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
} }
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
setLastResponse();
if (connectedDialog != null) { if (connectedDialog != null) {
connectedDialog.removeDialog(); connectedDialog.removeDialog();
connectedDialog = null; connectedDialog = null;
@ -262,15 +272,18 @@ public class FeedbackPanel extends javax.swing.JPanel {
}//GEN-LAST:event_btnRightActionPerformed }//GEN-LAST:event_btnRightActionPerformed
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
setLastResponse();
SessionHandler.sendPlayerBoolean(gameId, true); SessionHandler.sendPlayerBoolean(gameId, true);
AudioManager.playButtonCancel(); AudioManager.playButtonCancel();
}//GEN-LAST:event_btnLeftActionPerformed }//GEN-LAST:event_btnLeftActionPerformed
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
setLastResponse();
SessionHandler.sendPlayerString(gameId, "special"); SessionHandler.sendPlayerString(gameId, "special");
}//GEN-LAST:event_btnSpecialActionPerformed }//GEN-LAST:event_btnSpecialActionPerformed
private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) { private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {
setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.UNDO, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.UNDO, gameId, null);
} }
@ -302,6 +315,10 @@ public class FeedbackPanel extends javax.swing.JPanel {
this.helper.setUndoEnabled(false); this.helper.setUndoEnabled(false);
} }
public void setLastResponse() {
this.lastResponse = LocalDateTime.now();
}
private javax.swing.JButton btnLeft; private javax.swing.JButton btnLeft;
private javax.swing.JButton btnRight; private javax.swing.JButton btnRight;
private javax.swing.JButton btnSpecial; private javax.swing.JButton btnSpecial;

View file

@ -18,6 +18,7 @@ import mage.client.dialog.CardInfoWindowDialog.ShowType;
import mage.client.game.FeedbackPanel.FeedbackMode; import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.plugins.adapters.MageActionCallback; import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.themes.ThemeType;
import mage.client.util.Event; import mage.client.util.Event;
import mage.client.util.*; import mage.client.util.*;
import mage.client.util.audio.AudioManager; import mage.client.util.audio.AudioManager;
@ -1575,7 +1576,6 @@ public final class GamePanel extends javax.swing.JPanel {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void initComponents() { private void initComponents() {
abilityPicker = new mage.client.components.ability.AbilityPicker(); abilityPicker = new mage.client.components.ability.AbilityPicker();
jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane1 = new javax.swing.JSplitPane();
jSplitPane0 = new javax.swing.JSplitPane(); jSplitPane0 = new javax.swing.JSplitPane();
@ -1610,14 +1610,16 @@ public final class GamePanel extends javax.swing.JPanel {
txtHoldPriority.setToolTipText("Holding priority after the next spell cast or ability activation"); txtHoldPriority.setToolTipText("Holding priority after the next spell cast or ability activation");
txtHoldPriority.setVisible(false); txtHoldPriority.setVisible(false);
btnToggleMacro = new KeyboundButton(KEY_CONTROL_TOGGLE_MACRO); boolean displayButtonText = PreferencesDialog.getCurrentTheme().isShortcutsVisibleForSkipButtons();
btnCancelSkip = new KeyboundButton(KEY_CONTROL_CANCEL_SKIP); // F3
btnSkipToNextTurn = new KeyboundButton(KEY_CONTROL_NEXT_TURN); // F4 btnToggleMacro = new KeyboundButton(KEY_CONTROL_TOGGLE_MACRO, displayButtonText);
btnSkipToEndTurn = new KeyboundButton(KEY_CONTROL_END_STEP); // F5 btnCancelSkip = new KeyboundButton(KEY_CONTROL_CANCEL_SKIP, displayButtonText); // F3
btnSkipToNextMain = new KeyboundButton(KEY_CONTROL_MAIN_STEP); // F7 btnSkipToNextTurn = new KeyboundButton(KEY_CONTROL_NEXT_TURN, displayButtonText); // F4
btnSkipStack = new KeyboundButton(KEY_CONTROL_SKIP_STACK); // F10 btnSkipToEndTurn = new KeyboundButton(KEY_CONTROL_END_STEP, displayButtonText); // F5
btnSkipToYourTurn = new KeyboundButton(KEY_CONTROL_YOUR_TURN); // F9 btnSkipToNextMain = new KeyboundButton(KEY_CONTROL_MAIN_STEP, displayButtonText); // F7
btnSkipToEndStepBeforeYourTurn = new KeyboundButton(KEY_CONTROL_PRIOR_END); // F11 btnSkipStack = new KeyboundButton(KEY_CONTROL_SKIP_STACK, displayButtonText); // F10
btnSkipToYourTurn = new KeyboundButton(KEY_CONTROL_YOUR_TURN, displayButtonText); // F9
btnSkipToEndStepBeforeYourTurn = new KeyboundButton(KEY_CONTROL_PRIOR_END, displayButtonText); // F11
btnConcede = new javax.swing.JButton(); btnConcede = new javax.swing.JButton();
btnSwitchHands = new javax.swing.JButton(); btnSwitchHands = new javax.swing.JButton();
@ -2353,6 +2355,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) { private void btnEndTurnActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_NEXT_TURN); skipButtons.activateSkipButton(KEY_CONTROL_NEXT_TURN);
@ -2376,6 +2379,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) { private void btnUntilEndOfTurnActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_END_STEP); skipButtons.activateSkipButton(KEY_CONTROL_END_STEP);
@ -2393,6 +2397,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) { private void btnUntilNextMainPhaseActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_MAIN_STEP); skipButtons.activateSkipButton(KEY_CONTROL_MAIN_STEP);
@ -2401,6 +2406,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) { private void btnPassPriorityUntilNextYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_YOUR_TURN); skipButtons.activateSkipButton(KEY_CONTROL_YOUR_TURN);
@ -2409,6 +2415,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) { private void btnPassPriorityUntilStackResolvedActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_STACK_RESOLVED, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_SKIP_STACK); skipButtons.activateSkipButton(KEY_CONTROL_SKIP_STACK);
@ -2417,6 +2424,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void btnSkipToEndStepBeforeYourTurnActionPerformed(java.awt.event.ActionEvent evt) { private void btnSkipToEndStepBeforeYourTurnActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
skipButtons.activateSkipButton(KEY_CONTROL_PRIOR_END); skipButtons.activateSkipButton(KEY_CONTROL_PRIOR_END);
@ -2425,6 +2433,7 @@ public final class GamePanel extends javax.swing.JPanel {
} }
private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) { private void restorePriorityActionPerformed(java.awt.event.ActionEvent evt) {
this.feedbackPanel.setLastResponse();
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null); SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
skipButtons.activateSkipButton(""); skipButtons.activateSkipButton("");

View file

@ -16,6 +16,7 @@ import mage.client.components.HoverButton;
import mage.client.components.MageRoundPane; import mage.client.components.MageRoundPane;
import mage.client.components.ext.dlg.DialogManager; import mage.client.components.ext.dlg.DialogManager;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import mage.client.themes.ThemeType;
import mage.client.util.CardsViewUtil; import mage.client.util.CardsViewUtil;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.BufferedImageBuilder;
@ -56,9 +57,9 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private static final Border GREEN_BORDER = new LineBorder(Color.green, 3); private static final Border GREEN_BORDER = new LineBorder(Color.green, 3);
private static final Border RED_BORDER = new LineBorder(Color.red, 2); private static final Border RED_BORDER = new LineBorder(Color.red, 2);
private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0);
private final Color inactiveBackgroundColor = new Color(200, 200, 180, 200); private final Color inactiveBackgroundColor;
private final Color activeBackgroundColor = new Color(200, 255, 200, 200); private final Color activeBackgroundColor;
private final Color deadBackgroundColor = new Color(131, 94, 83, 200); private final Color deadBackgroundColor;
private final Color activeValueColor = new Color(244, 9, 47); private final Color activeValueColor = new Color(244, 9, 47);
private final Font fontValuesZero = this.getFont().deriveFont(Font.PLAIN); private final Font fontValuesZero = this.getFont().deriveFont(Font.PLAIN);
@ -78,6 +79,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT)); setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
initComponents(); initComponents();
setGUISize(); setGUISize();
ThemeType currentTheme = PreferencesDialog.getCurrentTheme();
inactiveBackgroundColor = currentTheme.getPlayerPanel_inactiveBackgroundColor();
activeBackgroundColor = currentTheme.getPlayerPanel_activeBackgroundColor();
deadBackgroundColor = currentTheme.getPlayerPanel_deadBackgroundColor();
} }
public void init(UUID gameId, UUID playerId, BigCard bigCard, int priorityTime) { public void init(UUID gameId, UUID playerId, BigCard bigCard, int priorityTime) {

View file

@ -0,0 +1,270 @@
package mage.client.themes;
import java.awt.*;
public enum ThemeType {
// https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html
DEFAULT("Default Theme",
"",
true,
false,
true,
true,
true,
true,
true,
new Color(169,176,190), // nimbusBlueGrey
new Color(214,217,223), // control
new Color(255,255,255), // nimbusLightBackground
new Color(242,242,189), // info
new Color(51,98,140), // nimbusBase
null, // mageToolbar
new Color(200, 200, 180, 200), // playerPanel_inactiveBackgroundColor
new Color(200, 255, 200, 200), // playerPanel_activeBackgroundColor
new Color(131, 94, 83, 200) // playerPanel_deadBackgroundColor
),
GREY("GREY",
"grey-theme/",
false,
false,
false,
false,
false,
true,
true,
new Color(158, 158, 158), // nimbusBlueGrey
new Color(212, 212, 212), // control
new Color(215, 215, 215), // nimbusLightBackground
new Color(189, 189, 164), // info
new Color(102, 102, 102), // nimbusBase
null, // mageToolbar
new Color(172, 172, 172, 200), // playerPanel_inactiveBackgroundColor
new Color(180, 234, 180, 200), // playerPanel_activeBackgroundColor
new Color(99, 99, 99, 200) // playerPanel_deadBackgroundColor
),
SUNSET_VAPORWAVE("Sunset Vaporwave",
"16bit-theme/",
true,
true,
false,
true,
true,
true,
false,
new Color(246, 136, 158),
new Color(243, 233, 164),
new Color(204, 236, 201),
new Color(117, 174, 238),
new Color(106, 0, 255),
new Color(192, 166, 232),
new Color(243, 233, 164),
new Color(204, 236, 201),
new Color(106, 0, 255)
),
COFFEE("Coffee",
"coffee-theme/",
true,
true,
true,
true,
true,
true,
false,
new Color(219, 193, 172), // nimbusBlueGrey
new Color(182, 157, 135), // control
new Color(219, 193, 172), // nimbusLightBackground
new Color(219, 197, 182), // info
new Color(97, 27, 0), // nimbusBase
new Color(219, 193, 172), // mageToolbar
new Color(219, 193, 172),
new Color(204, 236, 201),
new Color(99, 72, 50, 255)
),
ISLAND("Island",
"island-theme/",
true,
true,
false,
true,
true,
true,
false,
new Color(172, 197, 219), // nimbusBlueGrey
new Color(135, 158, 182), // control
new Color(172, 197, 219), // nimbusLightBackground
new Color(182, 200, 219), // info
new Color(0, 78, 97), // nimbusBase
new Color(172, 195, 219), // mageToolbar
new Color(172, 195, 219),
new Color(204, 236, 201),
new Color(50, 68, 99, 255)
);
private final String name;
private final String path;
private final boolean hasBackground;
private final boolean hasLoginBackground;
private final boolean hasBattleBackground;
private final boolean hasSkipButtons;
private final boolean hasPhaseIcons;
private final boolean hasWinLossImages;
private final boolean shortcutsVisibleForSkipButtons; // Whether or not to display skip button shortcuts
private final Color nimbusBlueGrey; // buttons, scrollbar background, disabled inputs
private final Color control; // window bg
private final Color nimbusLightBackground; // inputs, table rows
private final Color info;// tooltips
private final Color nimbusBase;// title bars, scrollbar foreground
private final Color mageToolbar;
private final Color playerPanel_inactiveBackgroundColor;
private final Color playerPanel_activeBackgroundColor;
private final Color playerPanel_deadBackgroundColor;
ThemeType(String name,
String path,
boolean hasBackground,
boolean hasLoginBackground,
boolean hasBattleBackground,
boolean hasSkipButtons,
boolean hasPhaseIcons,
boolean hasWinLossImages,
boolean shortcutsVisibleForSkipButtons,
Color nimbusBlueGrey,
Color control,
Color nimbusLightBackground,
Color info,
Color nimbusBase,
Color mageToolbar,
Color playerPanel_inactiveBackgroundColor,
Color playerPanel_activeBackgroundColor,
Color playerPanel_deadBackgroundColor
) {
this.name = name;
this.path = path;
this.hasBackground = hasBackground;
this.hasLoginBackground = hasLoginBackground;
this.hasBattleBackground = hasBattleBackground;
this.hasSkipButtons = hasSkipButtons;
this.hasPhaseIcons = hasPhaseIcons;
this.hasWinLossImages = hasWinLossImages;
this.shortcutsVisibleForSkipButtons = shortcutsVisibleForSkipButtons;
this.nimbusBlueGrey = nimbusBlueGrey;
this.control = control;
this.nimbusLightBackground = nimbusLightBackground;
this.info = info;
this.nimbusBase = nimbusBase;
this.mageToolbar = mageToolbar;
this.playerPanel_activeBackgroundColor = playerPanel_activeBackgroundColor;
this.playerPanel_deadBackgroundColor = playerPanel_deadBackgroundColor;
this.playerPanel_inactiveBackgroundColor = playerPanel_inactiveBackgroundColor;
}
@Override
public String toString() {
return name;
}
public static ThemeType valueByName(String value) {
for (ThemeType themeType : values()) {
if (themeType.name.equals(value)) {
return themeType;
}
}
return DEFAULT;
}
public String getName() {
return name;
}
public boolean isShortcutsVisibleForSkipButtons() {
return shortcutsVisibleForSkipButtons;
}
public Color getNimbusBlueGrey() {
return nimbusBlueGrey;
}
public Color getControl() {
return control;
}
public Color getNimbusLightBackground() {
return nimbusLightBackground;
}
public Color getInfo() {
return info;
}
public Color getNimbusBase() {
return nimbusBase;
}
public Color getMageToolbar() {
return mageToolbar;
}
public Color getPlayerPanel_inactiveBackgroundColor() {
return playerPanel_inactiveBackgroundColor;
}
public Color getPlayerPanel_activeBackgroundColor() {
return playerPanel_activeBackgroundColor;
}
public Color getPlayerPanel_deadBackgroundColor() {
return playerPanel_deadBackgroundColor;
}
private String getImagePath(String imageType, String name) {
return "/" + imageType + "/" + path + name;
}
public String getButtonPath(String name) {
if (hasSkipButtons) {
return getImagePath("buttons", name);
} else {
return "/buttons/" + name;
}
}
public String getPhasePath(String name) {
if (hasPhaseIcons) {
return getImagePath("phases", name);
} else {
return "/phases/" + name;
}
}
public String getWinlossPath(String name) {
if (hasWinLossImages) {
return getImagePath("winloss", name);
} else {
return "/winloss/" + name;
}
}
public String getBackgroundPath() {
if (hasBackground) {
return getImagePath("background", "background.png");
} else {
return "/background/background.png";
}
}
public String getLoginBackgroundPath() {
if (hasLoginBackground) {
return getImagePath("background", "login-background.png");
} else {
return getBackgroundPath();
}
}
public String getBattleBackgroundPath() {
if (hasBattleBackground) {
return getImagePath("background", "battle-background.png");
} else {
return getBackgroundPath();
}
}
}

View file

@ -47,6 +47,7 @@ public class AudioManager {
private MageClip playerQuitTournament = null; private MageClip playerQuitTournament = null;
private MageClip playerWon = null; private MageClip playerWon = null;
private MageClip playerLost = null; private MageClip playerLost = null;
private MageClip feedbackNeeded = null;
/** /**
* AudioManager singleton. * AudioManager singleton.
*/ */
@ -285,6 +286,13 @@ public class AudioManager {
checkAndPlayClip(audioManager.playerWon); checkAndPlayClip(audioManager.playerWon);
} }
public static void playFeedbackNeeded() {
if (audioManager.feedbackNeeded == null) {
audioManager.feedbackNeeded = new MageClip(Constants.BASE_SOUND_PATH + "FeedbackNeeded.wav", AudioGroup.GameSounds);
}
checkAndPlayClip(audioManager.feedbackNeeded);
}
private static boolean audioGroupEnabled(AudioGroup audioGroup) { private static boolean audioGroupEnabled(AudioGroup audioGroup) {
switch (audioGroup) { switch (audioGroup) {
case GameSounds: case GameSounds:

View file

@ -14,6 +14,8 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.BufferedImageBuilder;
import org.mage.plugins.card.utils.ImageManager; import org.mage.plugins.card.utils.ImageManager;
import org.mage.plugins.card.utils.Transparency; import org.mage.plugins.card.utils.Transparency;
@ -31,7 +33,9 @@ public enum ImageManagerImpl implements ImageManager {
"Main2", "Cleanup", "Next_Turn"}; "Main2", "Cleanup", "Next_Turn"};
phasesImages = new HashMap<>(); phasesImages = new HashMap<>();
for (String name : phases) { for (String name : phases) {
Image image = getImageFromResource("/phases/phase_" + name.toLowerCase(Locale.ENGLISH) + ".png", new Rectangle(36, 36)); Image image = getImageFromResource(
PreferencesDialog.getCurrentTheme().getPhasePath("phase_" + name.toLowerCase(Locale.ENGLISH) + ".png"),
new Rectangle(36, 36));
phasesImages.put(name, image); phasesImages.put(name, image);
} }
} }
@ -263,7 +267,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getConcedeButtonImage() { public Image getConcedeButtonImage() {
if (imageConcedeButton == null) { if (imageConcedeButton == null) {
imageConcedeButton = getBufferedImageFromResource("/buttons/concede.png"); imageConcedeButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("concede.png"));
} }
return imageConcedeButton; return imageConcedeButton;
} }
@ -271,7 +276,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSwitchHandsButtonImage() { public Image getSwitchHandsButtonImage() {
if (imageSwitchHandsButton == null) { if (imageSwitchHandsButton == null) {
imageSwitchHandsButton = getBufferedImageFromResource("/buttons/switch_hands.png"); imageSwitchHandsButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("switch_hands.png"));
} }
return imageSwitchHandsButton; return imageSwitchHandsButton;
} }
@ -279,7 +285,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getStopWatchButtonImage() { public Image getStopWatchButtonImage() {
if (imageStopWatchingButton == null) { if (imageStopWatchingButton == null) {
imageStopWatchingButton = getBufferedImageFromResource("/buttons/stop_watching.png"); imageStopWatchingButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("stop_watching.png"));
} }
return imageStopWatchingButton; return imageStopWatchingButton;
} }
@ -287,7 +294,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getCancelSkipButtonImage() { public Image getCancelSkipButtonImage() {
if (imageCancelSkipButton == null) { if (imageCancelSkipButton == null) {
imageCancelSkipButton = getBufferedImageFromResource("/buttons/cancel_skip.png"); imageCancelSkipButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("cancel_skip.png"));
} }
return imageCancelSkipButton; return imageCancelSkipButton;
} }
@ -295,7 +303,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSkipNextTurnButtonImage() { public Image getSkipNextTurnButtonImage() {
if (imageSkipNextTurnButton == null) { if (imageSkipNextTurnButton == null) {
imageSkipNextTurnButton = getBufferedImageFromResource("/buttons/skip_turn.png"); imageSkipNextTurnButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("skip_turn.png"));
} }
return imageSkipNextTurnButton; return imageSkipNextTurnButton;
} }
@ -303,7 +312,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSkipEndTurnButtonImage() { public Image getSkipEndTurnButtonImage() {
if (imageSkipToEndTurnButton == null) { if (imageSkipToEndTurnButton == null) {
imageSkipToEndTurnButton = getBufferedImageFromResource("/buttons/skip_to_end.png"); imageSkipToEndTurnButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("skip_to_end.png"));
} }
return imageSkipToEndTurnButton; return imageSkipToEndTurnButton;
} }
@ -311,7 +321,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSkipMainButtonImage() { public Image getSkipMainButtonImage() {
if (imageSkipToMainButton == null) { if (imageSkipToMainButton == null) {
imageSkipToMainButton = getBufferedImageFromResource("/buttons/skip_to_main.png"); imageSkipToMainButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("skip_to_main.png"));
} }
return imageSkipToMainButton; return imageSkipToMainButton;
} }
@ -319,7 +330,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSkipStackButtonImage() { public Image getSkipStackButtonImage() {
if (imageSkipStackButton == null) { if (imageSkipStackButton == null) {
imageSkipStackButton = getBufferedImageFromResource("/buttons/skip_stack.png"); imageSkipStackButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("skip_stack.png"));
} }
return imageSkipStackButton; return imageSkipStackButton;
} }
@ -327,7 +339,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSkipEndStepBeforeYourTurnButtonImage() { public Image getSkipEndStepBeforeYourTurnButtonImage() {
if (imageSkipUntilEndStepBeforeYourTurnButton == null) { if (imageSkipUntilEndStepBeforeYourTurnButton == null) {
imageSkipUntilEndStepBeforeYourTurnButton = getBufferedImageFromResource("/buttons/skip_to_previous_end.png"); imageSkipUntilEndStepBeforeYourTurnButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("skip_to_previous_end.png"));
} }
return imageSkipUntilEndStepBeforeYourTurnButton; return imageSkipUntilEndStepBeforeYourTurnButton;
} }
@ -335,7 +348,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getSkipYourNextTurnButtonImage() { public Image getSkipYourNextTurnButtonImage() {
if (imageSkipYourNextTurnButton == null) { if (imageSkipYourNextTurnButton == null) {
imageSkipYourNextTurnButton = getBufferedImageFromResource("/buttons/skip_all.png"); imageSkipYourNextTurnButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("skip_all.png"));
} }
return imageSkipYourNextTurnButton; return imageSkipYourNextTurnButton;
} }
@ -343,7 +357,8 @@ public enum ImageManagerImpl implements ImageManager {
@Override @Override
public Image getToggleRecordMacroButtonImage() { public Image getToggleRecordMacroButtonImage() {
if (imageToggleRecordMacroButton == null) { if (imageToggleRecordMacroButton == null) {
imageToggleRecordMacroButton = getBufferedImageFromResource("/buttons/toggle_macro.png"); imageToggleRecordMacroButton = getBufferedImageFromResource(
PreferencesDialog.getCurrentTheme().getButtonPath("toggle_macro.png"));
} }
return imageToggleRecordMacroButton; return imageToggleRecordMacroButton;
} }

View file

@ -12,7 +12,6 @@ import mage.components.ImagePanel;
import mage.components.ImagePanelStyle; import mage.components.ImagePanelStyle;
import mage.interfaces.plugin.ThemePlugin; import mage.interfaces.plugin.ThemePlugin;
import net.xeoh.plugins.base.annotations.PluginImplementation; import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init;
import net.xeoh.plugins.base.annotations.events.PluginLoaded; import net.xeoh.plugins.base.annotations.events.PluginLoaded;
import net.xeoh.plugins.base.annotations.meta.Author; import net.xeoh.plugins.base.annotations.meta.Author;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -27,10 +26,6 @@ public class ThemePluginImpl implements ThemePlugin {
private final List flist = new List(); private final List flist = new List();
private final String BackgroundDir = "backgrounds" + File.separator; private final String BackgroundDir = "backgrounds" + File.separator;
@Init
public void init() {
}
@PluginLoaded @PluginLoaded
public void newPlugin(ThemePlugin plugin) { public void newPlugin(ThemePlugin plugin) {
log.info(plugin.toString() + " has been loaded."); log.info(plugin.toString() + " has been loaded.");
@ -104,10 +99,11 @@ public class ThemePluginImpl implements ThemePlugin {
} }
} }
// Sets background for in-battle
// loadbuffer_default - Only apply theme background if no custom user background set
private BufferedImage loadbuffer_default() throws IOException { private BufferedImage loadbuffer_default() throws IOException {
String filename = "/dragon.png";
BufferedImage res; BufferedImage res;
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(PreferencesDialog.getCurrentTheme().getBattleBackgroundPath());
res = ImageIO.read(is); res = ImageIO.read(is);
return res; return res;
} }
@ -150,14 +146,14 @@ public class ThemePluginImpl implements ThemePlugin {
return bgPanel; return bgPanel;
} }
// Sets background for logged in user for tables/deck editor/card viewer/etc
private synchronized ImagePanel createImagePanelInstance() { private synchronized ImagePanel createImagePanelInstance() {
if (background == null) { if (background == null) {
String filename = "/background.png";
try { try {
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) { if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) {
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(PreferencesDialog.getCurrentTheme().getBackgroundPath());
if (is == null) { if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources."); throw new FileNotFoundException("Couldn't find " + PreferencesDialog.getCurrentTheme().getBackgroundPath() + " in resources.");
} }
background = ImageIO.read(is); background = ImageIO.read(is);
} else { } else {
@ -174,15 +170,16 @@ public class ThemePluginImpl implements ThemePlugin {
} }
} }
if (background == null) { if (background == null) {
String filename = "/background/background.png";
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(filename);
if (is == null) { if (is == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources."); throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
} }
background = ImageIO.read(is); background = ImageIO.read(is);
}
if (background == null) { if (background == null) {
throw new FileNotFoundException("Couldn't find " + filename + " in resources."); throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
} }
}
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return null; return null;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 KiB

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

Before

Width:  |  Height:  |  Size: 2 MiB

After

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Some files were not shown because too many files have changed in this diff Show more