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 {
|
||||
private ViewConstructed view;
|
||||
|
||||
private JList currentHumanSelection = null;
|
||||
private JList currentAISelection = null;
|
||||
private JList<String> currentHumanSelection = null;
|
||||
private JList<String> currentAISelection = null;
|
||||
|
||||
private Map<String, String> colorVals;
|
||||
private List<String> themeNames;
|
||||
@@ -196,7 +196,7 @@ public class ControlConstructed {
|
||||
*
|
||||
* @param lst0   a JList that has been clicked
|
||||
*/
|
||||
public void regulateHuman(JList lst0) {
|
||||
public void regulateHuman(JList<String> lst0) {
|
||||
if (currentHumanSelection != null && lst0 != currentHumanSelection) {
|
||||
currentHumanSelection.clearSelection();
|
||||
}
|
||||
@@ -222,6 +222,14 @@ public class ControlConstructed {
|
||||
while (i == 0) { i = r.nextInt(deckNames.size()); }
|
||||
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
|
||||
*/
|
||||
public void regulateAI(JList lst0) {
|
||||
public void regulateAI(JList<String> lst0) {
|
||||
if (currentAISelection != null && lst0 != currentAISelection) {
|
||||
currentAISelection.clearSelection();
|
||||
}
|
||||
@@ -255,6 +263,14 @@ public class ControlConstructed {
|
||||
while (i == 0) { i = r.nextInt(deckNames.size()); }
|
||||
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
|
||||
@@ -457,13 +473,13 @@ public class ControlConstructed {
|
||||
*/
|
||||
public Object[] getDeckNames() {
|
||||
deckNames = new ArrayList<String>();
|
||||
deckNames.add(0, "Random");
|
||||
|
||||
Collection<Deck> allDecks = AllZone.getDeckManager().getConstructedDecks();
|
||||
for (Deck d : allDecks) {
|
||||
deckNames.add(d.getName());
|
||||
}
|
||||
|
||||
//list is alphabetized, but we want the "Random" option first
|
||||
deckNames.add(0, "Random");
|
||||
// No pre-constructed decks?
|
||||
if (deckNames.size() == 1) { deckNames = new ArrayList<String>(); }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -33,7 +33,6 @@ import forge.CardList;
|
||||
import forge.Constant;
|
||||
import forge.Display;
|
||||
import forge.GuiMultipleBlockers;
|
||||
import forge.ImageCache;
|
||||
import forge.MyButton;
|
||||
import forge.Player;
|
||||
import forge.Singletons;
|
||||
@@ -41,7 +40,6 @@ import forge.control.ControlAllUI;
|
||||
import forge.control.match.ControlField;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.view.match.ViewField;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
import forge.view.toolbox.FOverlay;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.view.home;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
@@ -15,6 +16,7 @@ import forge.view.toolbox.FSkin;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SubButton extends JButton {
|
||||
private FSkin skin;
|
||||
/** */
|
||||
public SubButton() {
|
||||
this("");
|
||||
@@ -28,19 +30,27 @@ public class SubButton extends JButton {
|
||||
*/
|
||||
public SubButton(String txt0) {
|
||||
super(txt0);
|
||||
final FSkin skin = AllZone.getSkin();
|
||||
skin = AllZone.getSkin();
|
||||
setBorder(new LineBorder(skin.getColor("borders"), 1));
|
||||
setBackground(skin.getColor("inactive"));
|
||||
setForeground(skin.getColor("text"));
|
||||
|
||||
this.addMouseListener(new MouseAdapter() {
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
setBackground(skin.getColor("hover"));
|
||||
if (isEnabled()) { setBackground(skin.getColor("hover")); }
|
||||
}
|
||||
|
||||
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 int counter;
|
||||
private JList lstColorsHuman, lstColorsAI, lstThemesHuman,
|
||||
private JList<String> lstColorsHuman, lstColorsAI, lstThemesHuman,
|
||||
lstThemesAI, lstDecksHuman, lstDecksAI;
|
||||
private SubButton viewHumanDeckList, viewAIDeckList;
|
||||
private SubButton btnHumanDeckList, btnAIDeckList;
|
||||
private ControlConstructed control;
|
||||
|
||||
/**
|
||||
@@ -53,12 +53,23 @@ public class ViewConstructed extends JPanel {
|
||||
control = new ControlConstructed(this);
|
||||
|
||||
// Assemble JLists with arrays from above.
|
||||
lstColorsHuman = new JList(control.getColorNames());
|
||||
lstColorsAI = new JList(control.getColorNames());
|
||||
lstDecksHuman = new JList(control.getDeckNames());
|
||||
lstDecksAI = new JList(control.getDeckNames());
|
||||
lstThemesHuman = new JList(control.getThemeNames());
|
||||
lstThemesAI = new JList(control.getThemeNames());
|
||||
lstColorsHuman = new JList<String>();
|
||||
lstColorsHuman.setListData(control.oa2sa(control.getColorNames()));
|
||||
|
||||
lstColorsAI = new JList<String>();
|
||||
lstColorsAI.setListData(control.oa2sa(control.getColorNames()));
|
||||
|
||||
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
|
||||
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"));
|
||||
this.add(lblHuman, "w 90%!, h 5%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
||||
|
||||
constraints = "w 28%!, h 30%!";
|
||||
this.add(new JScrollPane(lstColorsHuman), constraints + ", gapleft 3%");
|
||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
||||
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() {
|
||||
// Human deck list button
|
||||
btnHumanDeckList = new SubButton();
|
||||
btnHumanDeckList.setAction(new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
ViewConstructed.this.control.viewDeckList("Human");
|
||||
}
|
||||
});
|
||||
viewHumanDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
||||
viewHumanDeckList.setText("View Human Deck List");
|
||||
viewHumanDeckList.setVerticalTextPosition(SwingConstants.CENTER);
|
||||
this.add(viewHumanDeckList, "w 20%!, h 3%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
||||
|
||||
btnHumanDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
||||
btnHumanDeckList.setText("View selected deck");
|
||||
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
|
||||
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"));
|
||||
this.add(lblAI, "w 90%!, h 5%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
||||
|
||||
this.add(new JScrollPane(lstColorsAI), constraints + ", gapleft 3%");
|
||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
||||
this.add(new JScrollPane(lstThemesAI), constraints);
|
||||
this.add(new OrPanel(), "w 5%!, h 30%!");
|
||||
this.add(new JScrollPane(lstDecksAI), constraints + ", wrap");
|
||||
|
||||
viewAIDeckList = new SubButton();
|
||||
viewAIDeckList.setAction(new AbstractAction() {
|
||||
// AI deck list button
|
||||
btnAIDeckList = new SubButton();
|
||||
btnAIDeckList.setAction(new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
ViewConstructed.this.control.viewDeckList("Computer");
|
||||
}
|
||||
});
|
||||
viewAIDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
||||
viewAIDeckList.setText("View AI Deck List");
|
||||
this.add(viewAIDeckList, "w 20%!, h 3%!, gap 5% 5% 2% 0, wrap, span 5 1");
|
||||
btnAIDeckList.setFont(skin.getFont1().deriveFont(Font.PLAIN, 13));
|
||||
btnAIDeckList.setText("View selected deck");
|
||||
|
||||
// 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
|
||||
this.lstColorsHuman.setName("lstColorsHuman");
|
||||
@@ -178,10 +194,10 @@ public class ViewConstructed extends JPanel {
|
||||
*
|
||||
* @param lst0   JList
|
||||
*/
|
||||
public void remind(JList lst0) {
|
||||
public void remind(JList<String> lst0) {
|
||||
if (timer1 != null) { return; }
|
||||
|
||||
final JList target = lst0;
|
||||
final JList<String> target = lst0;
|
||||
final int[] steps = {210, 215, 220, 220, 220, 215, 210};
|
||||
final Color oldBG = lst0.getBackground();
|
||||
counter = 0;
|
||||
@@ -207,32 +223,43 @@ public class ViewConstructed extends JPanel {
|
||||
|
||||
//========= RETRIEVAL FUNCTIONS
|
||||
/** @return JList */
|
||||
public JList getLstColorsHuman() {
|
||||
public JList<String> getLstColorsHuman() {
|
||||
return lstColorsHuman;
|
||||
}
|
||||
|
||||
/** @return JList */
|
||||
public JList getLstThemesHuman() {
|
||||
public JList<String> getLstThemesHuman() {
|
||||
return lstThemesHuman;
|
||||
}
|
||||
|
||||
/** @return JList */
|
||||
public JList getLstDecksHuman() {
|
||||
public JList<String> getLstDecksHuman() {
|
||||
return lstDecksHuman;
|
||||
}
|
||||
|
||||
/** @return JList */
|
||||
public JList getLstColorsAI() {
|
||||
public JList<String> getLstColorsAI() {
|
||||
return lstColorsAI;
|
||||
}
|
||||
|
||||
/** @return JList */
|
||||
public JList getLstThemesAI() {
|
||||
public JList<String> getLstThemesAI() {
|
||||
return lstThemesAI;
|
||||
}
|
||||
|
||||
/** @return JList */
|
||||
public JList getLstDecksAI() {
|
||||
public JList<String> getLstDecksAI() {
|
||||
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);
|
||||
}
|
||||
|
||||
private class ChooserListModel extends AbstractListModel {
|
||||
private class ChooserListModel extends AbstractListModel<Object> {
|
||||
|
||||
private static final long serialVersionUID = 3871965346333840556L;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user