mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Aesthetic changes to constructed mode view in home screen.
Also, a few checkstyle and compiler warning fixes.
This commit is contained in:
@@ -38,8 +38,8 @@ import forge.view.home.ViewConstructed;
|
|||||||
public class ControlConstructed {
|
public class ControlConstructed {
|
||||||
private ViewConstructed view;
|
private ViewConstructed view;
|
||||||
|
|
||||||
private JList currentHumanSelection = null;
|
private JList<String> currentHumanSelection = null;
|
||||||
private JList currentAISelection = null;
|
private JList<String> currentAISelection = null;
|
||||||
|
|
||||||
private Map<String, String> colorVals;
|
private Map<String, String> colorVals;
|
||||||
private List<String> themeNames;
|
private List<String> themeNames;
|
||||||
@@ -196,7 +196,7 @@ public class ControlConstructed {
|
|||||||
*
|
*
|
||||||
* @param lst0   a JList that has been clicked
|
* @param lst0   a JList that has been clicked
|
||||||
*/
|
*/
|
||||||
public void regulateHuman(JList lst0) {
|
public void regulateHuman(JList<String> lst0) {
|
||||||
if (currentHumanSelection != null && lst0 != currentHumanSelection) {
|
if (currentHumanSelection != null && lst0 != currentHumanSelection) {
|
||||||
currentHumanSelection.clearSelection();
|
currentHumanSelection.clearSelection();
|
||||||
}
|
}
|
||||||
@@ -222,6 +222,14 @@ public class ControlConstructed {
|
|||||||
while (i == 0) { i = r.nextInt(deckNames.size()); }
|
while (i == 0) { i = r.nextInt(deckNames.size()); }
|
||||||
lst0.setSelectedIndex(i);
|
lst0.setSelectedIndex(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Toggle "view" button accordingly
|
||||||
|
if (lst0.getName() != null && lst0.getName().equals("lstDecksHuman")) {
|
||||||
|
view.getBtnHumanDeckList().setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
view.getBtnHumanDeckList().setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -229,7 +237,7 @@ public class ControlConstructed {
|
|||||||
*
|
*
|
||||||
* @param lst0   a JList that has been clicked
|
* @param lst0   a JList that has been clicked
|
||||||
*/
|
*/
|
||||||
public void regulateAI(JList lst0) {
|
public void regulateAI(JList<String> lst0) {
|
||||||
if (currentAISelection != null && lst0 != currentAISelection) {
|
if (currentAISelection != null && lst0 != currentAISelection) {
|
||||||
currentAISelection.clearSelection();
|
currentAISelection.clearSelection();
|
||||||
}
|
}
|
||||||
@@ -255,6 +263,14 @@ public class ControlConstructed {
|
|||||||
while (i == 0) { i = r.nextInt(deckNames.size()); }
|
while (i == 0) { i = r.nextInt(deckNames.size()); }
|
||||||
lst0.setSelectedIndex(i);
|
lst0.setSelectedIndex(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Toggle "view" button accordingly
|
||||||
|
if (lst0.getName() != null && lst0.getName().equals("lstDecksAI")) {
|
||||||
|
view.getBtnAIDeckList().setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
view.getBtnAIDeckList().setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//========= DECK GENERATION
|
//========= DECK GENERATION
|
||||||
@@ -457,19 +473,19 @@ public class ControlConstructed {
|
|||||||
*/
|
*/
|
||||||
public Object[] getDeckNames() {
|
public Object[] getDeckNames() {
|
||||||
deckNames = new ArrayList<String>();
|
deckNames = new ArrayList<String>();
|
||||||
|
deckNames.add(0, "Random");
|
||||||
|
|
||||||
Collection<Deck> allDecks = AllZone.getDeckManager().getConstructedDecks();
|
Collection<Deck> allDecks = AllZone.getDeckManager().getConstructedDecks();
|
||||||
for (Deck d : allDecks) {
|
for (Deck d : allDecks) {
|
||||||
deckNames.add(d.getName());
|
deckNames.add(d.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
//list is alphabetized, but we want the "Random" option first
|
|
||||||
deckNames.add(0, "Random");
|
|
||||||
// No pre-constructed decks?
|
// No pre-constructed decks?
|
||||||
if (deckNames.size() == 1) { deckNames = new ArrayList<String>(); }
|
if (deckNames.size() == 1) { deckNames = new ArrayList<String>(); }
|
||||||
|
|
||||||
return deckNames.toArray();
|
return deckNames.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View deck list.
|
* View deck list.
|
||||||
*/
|
*/
|
||||||
@@ -478,7 +494,7 @@ public class ControlConstructed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives click and programmatic requests for viewing card in a player's deck
|
* Receives click and programmatic requests for viewing card in a player's deck.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private class DeckListAction {
|
private class DeckListAction {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import forge.CardList;
|
|||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Display;
|
import forge.Display;
|
||||||
import forge.GuiMultipleBlockers;
|
import forge.GuiMultipleBlockers;
|
||||||
import forge.ImageCache;
|
|
||||||
import forge.MyButton;
|
import forge.MyButton;
|
||||||
import forge.Player;
|
import forge.Player;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
@@ -41,7 +40,6 @@ import forge.control.ControlAllUI;
|
|||||||
import forge.control.match.ControlField;
|
import forge.control.match.ControlField;
|
||||||
import forge.properties.ForgePreferences;
|
import forge.properties.ForgePreferences;
|
||||||
import forge.view.match.ViewField;
|
import forge.view.match.ViewField;
|
||||||
import forge.view.swing.OldGuiNewGame;
|
|
||||||
import forge.view.toolbox.FOverlay;
|
import forge.view.toolbox.FOverlay;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package forge.view.home;
|
package forge.view.home;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ import forge.view.toolbox.FSkin;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class SubButton extends JButton {
|
public class SubButton extends JButton {
|
||||||
|
private FSkin skin;
|
||||||
/** */
|
/** */
|
||||||
public SubButton() {
|
public SubButton() {
|
||||||
this("");
|
this("");
|
||||||
@@ -28,19 +30,27 @@ public class SubButton extends JButton {
|
|||||||
*/
|
*/
|
||||||
public SubButton(String txt0) {
|
public SubButton(String txt0) {
|
||||||
super(txt0);
|
super(txt0);
|
||||||
final FSkin skin = AllZone.getSkin();
|
skin = AllZone.getSkin();
|
||||||
setBorder(new LineBorder(skin.getColor("borders"), 1));
|
setBorder(new LineBorder(skin.getColor("borders"), 1));
|
||||||
setBackground(skin.getColor("inactive"));
|
setBackground(skin.getColor("inactive"));
|
||||||
setForeground(skin.getColor("text"));
|
setForeground(skin.getColor("text"));
|
||||||
|
|
||||||
this.addMouseListener(new MouseAdapter() {
|
this.addMouseListener(new MouseAdapter() {
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
setBackground(skin.getColor("hover"));
|
if (isEnabled()) { setBackground(skin.getColor("hover")); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e) {
|
public void mouseExited(MouseEvent e) {
|
||||||
setBackground(skin.getColor("inactive"));
|
if (isEnabled()) { setBackground(skin.getColor("inactive")); }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean b0) {
|
||||||
|
super.setEnabled(b0);
|
||||||
|
|
||||||
|
if (b0) { setBackground(skin.getColor("inactive")); }
|
||||||
|
else { setBackground(new Color(220, 220, 220)); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ public class ViewConstructed extends JPanel {
|
|||||||
|
|
||||||
private Timer timer1 = null;
|
private Timer timer1 = null;
|
||||||
private int counter;
|
private int counter;
|
||||||
private JList lstColorsHuman, lstColorsAI, lstThemesHuman,
|
private JList<String> lstColorsHuman, lstColorsAI, lstThemesHuman,
|
||||||
lstThemesAI, lstDecksHuman, lstDecksAI;
|
lstThemesAI, lstDecksHuman, lstDecksAI;
|
||||||
private SubButton viewHumanDeckList, viewAIDeckList;
|
private SubButton btnHumanDeckList, btnAIDeckList;
|
||||||
private ControlConstructed control;
|
private ControlConstructed control;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,12 +53,23 @@ public class ViewConstructed extends JPanel {
|
|||||||
control = new ControlConstructed(this);
|
control = new ControlConstructed(this);
|
||||||
|
|
||||||
// Assemble JLists with arrays from above.
|
// Assemble JLists with arrays from above.
|
||||||
lstColorsHuman = new JList(control.getColorNames());
|
lstColorsHuman = new JList<String>();
|
||||||
lstColorsAI = new JList(control.getColorNames());
|
lstColorsHuman.setListData(control.oa2sa(control.getColorNames()));
|
||||||
lstDecksHuman = new JList(control.getDeckNames());
|
|
||||||
lstDecksAI = new JList(control.getDeckNames());
|
lstColorsAI = new JList<String>();
|
||||||
lstThemesHuman = new JList(control.getThemeNames());
|
lstColorsAI.setListData(control.oa2sa(control.getColorNames()));
|
||||||
lstThemesAI = new JList(control.getThemeNames());
|
|
||||||
|
lstDecksHuman = new JList<String>();
|
||||||
|
lstDecksHuman.setListData(control.oa2sa(control.getDeckNames()));
|
||||||
|
|
||||||
|
lstDecksAI = new JList<String>();
|
||||||
|
lstDecksAI.setListData(control.oa2sa(control.getDeckNames()));
|
||||||
|
|
||||||
|
lstThemesHuman = new JList<String>();
|
||||||
|
lstThemesHuman.setListData(control.oa2sa(control.getThemeNames()));
|
||||||
|
|
||||||
|
lstThemesAI = new JList<String>();
|
||||||
|
lstThemesAI.setListData(control.oa2sa(control.getThemeNames()));
|
||||||
|
|
||||||
// Human deck options area
|
// Human deck options area
|
||||||
JLabel lblHuman = new JLabel("Choose a deck for the human player:");
|
JLabel lblHuman = new JLabel("Choose a deck for the human player:");
|
||||||
@@ -66,23 +77,26 @@ public class ViewConstructed extends JPanel {
|
|||||||
lblHuman.setForeground(skin.getColor("text"));
|
lblHuman.setForeground(skin.getColor("text"));
|
||||||
this.add(lblHuman, "w 90%!, h 5%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
this.add(lblHuman, "w 90%!, h 5%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
||||||
|
|
||||||
constraints = "w 28%!, h 30%!";
|
// Human deck list button
|
||||||
this.add(new JScrollPane(lstColorsHuman), constraints + ", gapleft 3%");
|
btnHumanDeckList = new SubButton();
|
||||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
btnHumanDeckList.setAction(new AbstractAction() {
|
||||||
this.add(new JScrollPane(lstThemesHuman), constraints);
|
|
||||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
|
||||||
this.add(new JScrollPane(lstDecksHuman), constraints + ", wrap");
|
|
||||||
|
|
||||||
viewHumanDeckList = new SubButton();
|
|
||||||
viewHumanDeckList.setAction(new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
ViewConstructed.this.control.viewDeckList("Human");
|
ViewConstructed.this.control.viewDeckList("Human");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewHumanDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
|
||||||
viewHumanDeckList.setText("View Human Deck List");
|
btnHumanDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
||||||
viewHumanDeckList.setVerticalTextPosition(SwingConstants.CENTER);
|
btnHumanDeckList.setText("View selected deck");
|
||||||
this.add(viewHumanDeckList, "w 20%!, h 3%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
btnHumanDeckList.setVerticalTextPosition(SwingConstants.CENTER);
|
||||||
|
|
||||||
|
// Add components
|
||||||
|
constraints = "w 28%!, h 30%!, span 1 2";
|
||||||
|
this.add(new JScrollPane(lstColorsHuman), constraints + ", gapleft 3%");
|
||||||
|
this.add(new OrPanel(), "w 5%!, h 30%!, span 1 2");
|
||||||
|
this.add(new JScrollPane(lstThemesHuman), constraints);
|
||||||
|
this.add(new OrPanel(), "w 5%!, h 30%!, span 1 2");
|
||||||
|
this.add(new JScrollPane(lstDecksHuman), "w 28%!, h 25%!, gapbottom 1%, wrap");
|
||||||
|
this.add(btnHumanDeckList, "w 28%!, h 4%!, wrap");
|
||||||
|
|
||||||
// AI deck options area
|
// AI deck options area
|
||||||
JLabel lblAI = new JLabel("Choose a deck for the AI player:");
|
JLabel lblAI = new JLabel("Choose a deck for the AI player:");
|
||||||
@@ -90,21 +104,23 @@ public class ViewConstructed extends JPanel {
|
|||||||
lblAI.setForeground(skin.getColor("text"));
|
lblAI.setForeground(skin.getColor("text"));
|
||||||
this.add(lblAI, "w 90%!, h 5%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
this.add(lblAI, "w 90%!, h 5%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
||||||
|
|
||||||
this.add(new JScrollPane(lstColorsAI), constraints + ", gapleft 3%");
|
// AI deck list button
|
||||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
btnAIDeckList = new SubButton();
|
||||||
this.add(new JScrollPane(lstThemesAI), constraints);
|
btnAIDeckList.setAction(new AbstractAction() {
|
||||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
|
||||||
this.add(new JScrollPane(lstDecksAI), constraints + ", wrap");
|
|
||||||
|
|
||||||
viewAIDeckList = new SubButton();
|
|
||||||
viewAIDeckList.setAction(new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
ViewConstructed.this.control.viewDeckList("Computer");
|
ViewConstructed.this.control.viewDeckList("Computer");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewAIDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
btnAIDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
||||||
viewAIDeckList.setText("View AI Deck List");
|
btnAIDeckList.setText("View selected deck");
|
||||||
this.add(viewAIDeckList, "w 20%!, h 3%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
|
||||||
|
// Add components
|
||||||
|
this.add(new JScrollPane(lstColorsAI), constraints + ", gapleft 3%");
|
||||||
|
this.add(new OrPanel(), "w 5%!, h 30%!, span 1 2");
|
||||||
|
this.add(new JScrollPane(lstThemesAI), constraints);
|
||||||
|
this.add(new OrPanel(), "w 5%!, h 30%!, span 1 2");
|
||||||
|
this.add(new JScrollPane(lstDecksAI), "w 28%!, h 25%!, gapbottom 1%, wrap");
|
||||||
|
this.add(btnAIDeckList, "w 28%!, h 4%!, wrap");
|
||||||
|
|
||||||
// List box properties
|
// List box properties
|
||||||
this.lstColorsHuman.setName("lstColorsHuman");
|
this.lstColorsHuman.setName("lstColorsHuman");
|
||||||
@@ -178,10 +194,10 @@ public class ViewConstructed extends JPanel {
|
|||||||
*
|
*
|
||||||
* @param lst0   JList
|
* @param lst0   JList
|
||||||
*/
|
*/
|
||||||
public void remind(JList lst0) {
|
public void remind(JList<String> lst0) {
|
||||||
if (timer1 != null) { return; }
|
if (timer1 != null) { return; }
|
||||||
|
|
||||||
final JList target = lst0;
|
final JList<String> target = lst0;
|
||||||
final int[] steps = {210, 215, 220, 220, 220, 215, 210};
|
final int[] steps = {210, 215, 220, 220, 220, 215, 210};
|
||||||
final Color oldBG = lst0.getBackground();
|
final Color oldBG = lst0.getBackground();
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@@ -207,32 +223,43 @@ public class ViewConstructed extends JPanel {
|
|||||||
|
|
||||||
//========= RETRIEVAL FUNCTIONS
|
//========= RETRIEVAL FUNCTIONS
|
||||||
/** @return JList */
|
/** @return JList */
|
||||||
public JList getLstColorsHuman() {
|
public JList<String> getLstColorsHuman() {
|
||||||
return lstColorsHuman;
|
return lstColorsHuman;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return JList */
|
/** @return JList */
|
||||||
public JList getLstThemesHuman() {
|
public JList<String> getLstThemesHuman() {
|
||||||
return lstThemesHuman;
|
return lstThemesHuman;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return JList */
|
/** @return JList */
|
||||||
public JList getLstDecksHuman() {
|
public JList<String> getLstDecksHuman() {
|
||||||
return lstDecksHuman;
|
return lstDecksHuman;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return JList */
|
/** @return JList */
|
||||||
public JList getLstColorsAI() {
|
public JList<String> getLstColorsAI() {
|
||||||
return lstColorsAI;
|
return lstColorsAI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return JList */
|
/** @return JList */
|
||||||
public JList getLstThemesAI() {
|
public JList<String> getLstThemesAI() {
|
||||||
return lstThemesAI;
|
return lstThemesAI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return JList */
|
/** @return JList */
|
||||||
public JList getLstDecksAI() {
|
public JList<String> getLstDecksAI() {
|
||||||
return lstDecksAI;
|
return lstDecksAI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return JButton */
|
||||||
|
public JButton getBtnHumanDeckList() {
|
||||||
|
return btnHumanDeckList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return JButton */
|
||||||
|
public JButton getBtnAIDeckList() {
|
||||||
|
return btnAIDeckList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class CardViewer extends JPanel {
|
|||||||
this.jList.setSelectedIndex(0);
|
this.jList.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChooserListModel extends AbstractListModel {
|
private class ChooserListModel extends AbstractListModel<Object> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3871965346333840556L;
|
private static final long serialVersionUID = 3871965346333840556L;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user