mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
changes from trunk commited
This commit is contained in:
@@ -89,41 +89,20 @@ public class GuiChoose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returned Object will never be null
|
// returned Object will never be null
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getChoices.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* a T object.
|
|
||||||
* @param message
|
|
||||||
* a {@link java.lang.String} object.
|
|
||||||
* @param min
|
|
||||||
* a int.
|
|
||||||
* @param max
|
|
||||||
* a int.
|
|
||||||
* @param choices
|
|
||||||
* a T object.
|
|
||||||
* @return a {@link java.util.List} object.
|
|
||||||
*/
|
|
||||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final T[] choices) {
|
public static <T> List<T> getChoices(final String message, final int min, final int max, final T[] choices) {
|
||||||
final ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
return getChoices(message, min, max, Arrays.asList(choices));
|
||||||
return getChoices(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices) {
|
public static <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices) {
|
||||||
final ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
if (null == choices || choices.isEmpty()) {
|
||||||
return getChoices(c);
|
if (0 == min) {
|
||||||
|
return new ArrayList<T>();
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("choice required from empty list");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing to choose here. Code uses this to just show a card.
|
ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
|
||||||
public static Card show(final String message, final Card singleChoice) {
|
|
||||||
List<Card> choices = new ArrayList<Card>();
|
|
||||||
choices.add(singleChoice);
|
|
||||||
return one(message, choices);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> List<T> getChoices(final ListChooser<T> c) {
|
|
||||||
final JList list = c.getJList();
|
final JList list = c.getJList();
|
||||||
list.addListSelectionListener(new ListSelectionListener() {
|
list.addListSelectionListener(new ListSelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -142,7 +121,14 @@ public class GuiChoose {
|
|||||||
c.show();
|
c.show();
|
||||||
GuiUtils.clearPanelSelections();
|
GuiUtils.clearPanelSelections();
|
||||||
return c.getSelectedValues();
|
return c.getSelectedValues();
|
||||||
} // getChoice()
|
}
|
||||||
|
|
||||||
|
// Nothing to choose here. Code uses this to just show a card.
|
||||||
|
public static Card show(final String message, final Card singleChoice) {
|
||||||
|
List<Card> choices = new ArrayList<Card>();
|
||||||
|
choices.add(singleChoice);
|
||||||
|
return one(message, choices);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> List<T> order(final String title, final String top, int remainingObjects,
|
public static <T> List<T> order(final String title, final String top, int remainingObjects,
|
||||||
final List<T> sourceChoices, List<T> destChoices, Card referenceCard) {
|
final List<T> sourceChoices, List<T> destChoices, Card referenceCard) {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowFocusListener;
|
import java.awt.event.WindowFocusListener;
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -84,10 +83,6 @@ public class ListChooser<T> {
|
|||||||
private JOptionPane optionPane;
|
private JOptionPane optionPane;
|
||||||
private Action ok, cancel;
|
private Action ok, cancel;
|
||||||
|
|
||||||
public ListChooser(final String title, final int minChoices, final int maxChoices, final T[] list) {
|
|
||||||
this(title, minChoices, maxChoices, Arrays.asList(list));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list) {
|
public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.minChoices = minChoices;
|
this.minChoices = minChoices;
|
||||||
@@ -125,7 +120,7 @@ public class ListChooser<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return boolean */
|
/** @return boolean */
|
||||||
public synchronized boolean show() {
|
public boolean show() {
|
||||||
return show(list.get(0));
|
return show(list.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +130,7 @@ public class ListChooser<T> {
|
|||||||
* @param index0 index to select when shown
|
* @param index0 index to select when shown
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public synchronized boolean show(T item) {
|
public boolean show(T item) {
|
||||||
if (this.called) {
|
if (this.called) {
|
||||||
throw new IllegalStateException("Already shown");
|
throw new IllegalStateException("Already shown");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ public class ControlWinLose {
|
|||||||
cDeck.getMain().remove(toRemove);
|
cDeck.getMain().remove(toRemove);
|
||||||
if ( cDeck != oDeck )
|
if ( cDeck != oDeck )
|
||||||
oDeck.getMain().remove(toRemove);
|
oDeck.getMain().remove(toRemove);
|
||||||
|
losses.add(toRemove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user