mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Controllers for color and custom submenus.
Update to submenu control interface.
This commit is contained in:
5
.gitattributes
vendored
5
.gitattributes
vendored
@@ -11217,6 +11217,8 @@ src/main/java/forge/control/home/ControlSealed.java -text
|
||||
src/main/java/forge/control/home/ControlSettings.java -text
|
||||
src/main/java/forge/control/home/ControlUtilities.java -text
|
||||
src/main/java/forge/control/home/IControlSubmenu.java -text
|
||||
src/main/java/forge/control/home/constructed/ControlSubmenuColors.java -text
|
||||
src/main/java/forge/control/home/constructed/ControlSubmenuCustom.java -text
|
||||
src/main/java/forge/control/home/package-info.java -text svneol=native#text/plain
|
||||
src/main/java/forge/control/input/Input.java svneol=native#text/plain
|
||||
src/main/java/forge/control/input/InputAttack.java svneol=native#text/plain
|
||||
@@ -11424,7 +11426,8 @@ src/main/java/forge/view/home/ViewQuest.java -text
|
||||
src/main/java/forge/view/home/ViewSealed.java -text
|
||||
src/main/java/forge/view/home/ViewSettings.java -text
|
||||
src/main/java/forge/view/home/ViewUtilities.java -text
|
||||
src/main/java/forge/view/home/constructed/SubmenuColors.java -text
|
||||
src/main/java/forge/view/home/constructed/ViewSubmenuColors.java -text
|
||||
src/main/java/forge/view/home/constructed/ViewSubmenuCustom.java -text
|
||||
src/main/java/forge/view/home/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/view/match/QuestWinLoseCardViewer.java -text
|
||||
src/main/java/forge/view/match/QuestWinLoseHandler.java -text
|
||||
|
||||
@@ -216,6 +216,24 @@ public enum FControl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exhaustively converts object array to string array.
|
||||
* Probably a much easier way to do this.
|
||||
* And, there must be a better place for this.
|
||||
*
|
||||
* @param o0   Object[]
|
||||
* @return String[]
|
||||
*/
|
||||
public static String[] oa2sa(final Object[] o0) {
|
||||
final String[] output = new String[o0.length];
|
||||
|
||||
for (int i = 0; i < o0.length; i++) {
|
||||
output[i] = o0[i].toString();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/** Sizes children of JLayeredPane to fully fit their layers. */
|
||||
private void sizeChildren() {
|
||||
Component[] children = display.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package forge.control.home.constructed;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JList;
|
||||
|
||||
import forge.Command;
|
||||
import forge.control.home.IControlSubmenu;
|
||||
import forge.view.home.constructed.ViewSubmenuColors;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum ControlSubmenuColors implements IControlSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private final Map<String, String> colorVals = new HashMap<String, String>();
|
||||
|
||||
private ControlSubmenuColors() {
|
||||
colorVals.clear();
|
||||
colorVals.put("Random 1", "AI");
|
||||
colorVals.put("Random 2", "AI");
|
||||
colorVals.put("Random 3", "AI");
|
||||
colorVals.put("Random 4", "AI");
|
||||
colorVals.put("Black", "black");
|
||||
colorVals.put("Blue", "blue");
|
||||
colorVals.put("Green", "green");
|
||||
colorVals.put("Red", "red");
|
||||
colorVals.put("White", "white");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
ViewSubmenuColors.SINGLETON_INSTANCE.populate();
|
||||
ControlSubmenuColors.SINGLETON_INSTANCE.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#getCommand()
|
||||
*/
|
||||
@Override
|
||||
public Command getMenuCommand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
for (JList lst : ViewSubmenuColors.SINGLETON_INSTANCE.getLists()) {
|
||||
lst.setListData(new String[] {"Random 1", "Random 2", "Random 3",
|
||||
"Random 4", "Black", "Blue", "Green", "Red", "White"});
|
||||
}
|
||||
}
|
||||
|
||||
/** */
|
||||
public void randomSelect() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package forge.control.home.constructed;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JList;
|
||||
|
||||
import forge.Command;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.control.home.IControlSubmenu;
|
||||
import forge.deck.Deck;
|
||||
import forge.util.IFolderMap;
|
||||
import forge.view.home.constructed.ViewSubmenuCustom;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public enum ControlSubmenuCustom implements IControlSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#getMenuCommand()
|
||||
*/
|
||||
@Override
|
||||
public Command getMenuCommand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#initialize()
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
ViewSubmenuCustom.SINGLETON_INSTANCE.populate();
|
||||
ControlSubmenuCustom.SINGLETON_INSTANCE.update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.control.home.IControlSubmenu#update()
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
final List<String> customNames = new ArrayList<String>();
|
||||
final IFolderMap<Deck> allDecks = Singletons.getModel().getDecks().getConstructed();
|
||||
for (final Deck d : allDecks) { customNames.add(d.getName()); }
|
||||
|
||||
for (JList lst : ViewSubmenuCustom.SINGLETON_INSTANCE.getLists()) {
|
||||
lst.setListData(FControl.oa2sa(customNames.toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
/** */
|
||||
public void randomSelect() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,11 @@ import javax.swing.JPanel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Command;
|
||||
import forge.Player;
|
||||
import forge.control.home.IControlSubmenu;
|
||||
import forge.control.home.constructed.ControlSubmenuColors;
|
||||
import forge.model.home.MenuGroup;
|
||||
import forge.view.home.IViewSubmenu;
|
||||
import forge.view.home.StartButton;
|
||||
@@ -23,7 +24,7 @@ import forge.view.toolbox.FScrollPane;
|
||||
* Singleton instance of "Colors" submenu in "Constructed" group.
|
||||
*
|
||||
*/
|
||||
public enum SubmenuColors implements IViewSubmenu {
|
||||
public enum ViewSubmenuColors implements IViewSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
@@ -32,16 +33,12 @@ public enum SubmenuColors implements IViewSubmenu {
|
||||
private final StartButton btnStart = new StartButton();
|
||||
private final List<JList> allLists = new ArrayList<JList>();
|
||||
|
||||
private SubmenuColors() {
|
||||
populate();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
final String lstConstraints = "w 41%!, h 32%, gap 6% 0 4% 2%";
|
||||
final String lstConstraints = "w 41%!, h 300px!, gap 6% 0 4% 2%";
|
||||
final String btnConstraints = "newline, ax center, gap 6% 0 0 0, span 2 1";
|
||||
final List<Player> players = AllZone.getPlayersInGame();
|
||||
|
||||
@@ -95,13 +92,20 @@ public enum SubmenuColors implements IViewSubmenu {
|
||||
@SuppressWarnings("serial")
|
||||
private class ColorSelectPanel extends JPanel {
|
||||
public ColorSelectPanel(final Player p0) {
|
||||
final Command cmdRandom = new Command() { @Override
|
||||
public void execute() { ControlSubmenuColors.SINGLETON_INSTANCE.randomSelect(); } };
|
||||
allLists.add(new FList());
|
||||
allLists.get(allLists.size() - 1).setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
|
||||
this.setOpaque(false);
|
||||
this.setLayout(new MigLayout("insets 0, gap 0, wrap"));
|
||||
this.add(new FLabel.Builder().text(p0.getName()).fontSize(14).fontScaleAuto(false).build(), "w 100%!, h 25px!, gap 0 0 0 8px");
|
||||
this.add(new FLabel.Builder().text(p0.getName()).fontSize(14)
|
||||
.fontScaleAuto(false).build(),
|
||||
"w 100%!, h 25px!, gap 0 0 0 8px");
|
||||
this.add(new FScrollPane(allLists.get(allLists.size() - 1)), "w 100%!, pushy, growy");
|
||||
this.add(new FLabel.Builder().text("Random").fontSize(14).opaque(true)
|
||||
.hoverable(true).cmdClick(cmdRandom).fontScaleAuto(false).build(),
|
||||
"w 100%!, h 25px!, gap 0 0 8px 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
115
src/main/java/forge/view/home/constructed/ViewSubmenuCustom.java
Normal file
115
src/main/java/forge/view/home/constructed/ViewSubmenuCustom.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package forge.view.home.constructed;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.AllZone;
|
||||
import forge.Command;
|
||||
import forge.Player;
|
||||
import forge.control.home.IControlSubmenu;
|
||||
import forge.control.home.constructed.ControlSubmenuCustom;
|
||||
import forge.model.home.MenuGroup;
|
||||
import forge.view.home.IViewSubmenu;
|
||||
import forge.view.home.StartButton;
|
||||
import forge.view.toolbox.FLabel;
|
||||
import forge.view.toolbox.FList;
|
||||
import forge.view.toolbox.FScrollPane;
|
||||
|
||||
/**
|
||||
* Singleton instance of "Colors" submenu in "Constructed" group.
|
||||
*
|
||||
*/
|
||||
public enum ViewSubmenuCustom implements IViewSubmenu {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
/** */
|
||||
private final JPanel pnl = new JPanel();
|
||||
private final StartButton btnStart = new StartButton();
|
||||
private final List<JList> allLists = new ArrayList<JList>();
|
||||
|
||||
private ViewSubmenuCustom() {
|
||||
populate();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#populate()
|
||||
*/
|
||||
@Override
|
||||
public void populate() {
|
||||
final String lstConstraints = "w 41%!, h 32%, gap 6% 0 4% 2%";
|
||||
final String btnConstraints = "newline, ax center, gap 6% 0 0 0, span 2 1";
|
||||
final List<Player> players = AllZone.getPlayersInGame();
|
||||
|
||||
allLists.clear();
|
||||
pnl.removeAll();
|
||||
|
||||
pnl.setOpaque(false);
|
||||
pnl.setLayout(new MigLayout("insets 0, gap 0"));
|
||||
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
if (i % 2 == 1) {
|
||||
pnl.add(new CustomSelectPanel(players.get(i)), lstConstraints + ", wrap");
|
||||
}
|
||||
else {
|
||||
pnl.add(new CustomSelectPanel(players.get(i)), lstConstraints);
|
||||
}
|
||||
}
|
||||
|
||||
pnl.add(btnStart, btnConstraints);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getControl()
|
||||
*/
|
||||
@Override
|
||||
public IControlSubmenu getControl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getGroup()
|
||||
*/
|
||||
@Override
|
||||
public MenuGroup getGroup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.view.home.IViewSubmenu#getPanel()
|
||||
*/
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
return pnl;
|
||||
}
|
||||
|
||||
/** @return {@link java.util.List}<{@link javax.swing.JList}> */
|
||||
public List<JList> getLists() {
|
||||
return allLists;
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private class CustomSelectPanel extends JPanel {
|
||||
public CustomSelectPanel(final Player p0) {
|
||||
final Command cmdRandom = new Command() { @Override
|
||||
public void execute() { ControlSubmenuCustom.SINGLETON_INSTANCE.randomSelect(); } };
|
||||
allLists.add(new FList());
|
||||
allLists.get(allLists.size() - 1).setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
|
||||
this.setOpaque(false);
|
||||
this.setLayout(new MigLayout("insets 0, gap 0, wrap"));
|
||||
this.add(new FLabel.Builder().text(p0.getName()).fontSize(14)
|
||||
.fontScaleAuto(false).build(),
|
||||
"w 100%!, h 25px!, gap 0 0 0 8px");
|
||||
this.add(new FScrollPane(allLists.get(allLists.size() - 1)), "w 100%!, pushy, growy");
|
||||
this.add(new FLabel.Builder().text("Random").fontSize(14).opaque(true)
|
||||
.hoverable(true).cmdClick(cmdRandom).fontScaleAuto(false).build(),
|
||||
"w 100%!, h 25px!, gap 0 0 8px 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user