mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
gui: improved multi amount dialog (added cancel option, added mana symbols support in messages, improved form structure)
This commit is contained in:
parent
00fcdc4653
commit
81d44e615f
6 changed files with 211 additions and 120 deletions
|
|
@ -13,14 +13,21 @@ public enum MultiAmountType {
|
|||
MANA("Add mana", "Distribute mana among colors"),
|
||||
DAMAGE("Assign damage", "Assign damage among targets"),
|
||||
P1P1("Add +1/+1 counters", "Distribute +1/+1 counters among creatures"),
|
||||
COUNTERS("Choose counters", "Move counters");
|
||||
COUNTERS("Choose counters", "Move counters"),
|
||||
CHEAT_LANDS("Choose lands", "Add lands to your battlefield", true);
|
||||
|
||||
private final String title;
|
||||
private final String header;
|
||||
private final boolean canCancel; // choice dialog will return null instead default values
|
||||
|
||||
MultiAmountType(String title, String header) {
|
||||
this(title, header, false);
|
||||
}
|
||||
|
||||
MultiAmountType(String title, String header, boolean canCancel) {
|
||||
this.title = title;
|
||||
this.header = header;
|
||||
this.canCancel = canCancel;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
|
|
@ -31,9 +38,13 @@ public enum MultiAmountType {
|
|||
return header;
|
||||
}
|
||||
|
||||
public boolean isCanCancel() {
|
||||
return canCancel;
|
||||
}
|
||||
|
||||
public static List<Integer> prepareDefaltValues(List<MultiAmountMessage> constraints, int min, int max) {
|
||||
// default values must be assigned from first to last by minimum values
|
||||
List<Integer> res = constraints.stream().map(m -> m.min > Integer.MIN_VALUE ? m.min : (0 < max ? 0 : max))
|
||||
List<Integer> res = constraints.stream().map(m -> m.defaultValue > Integer.MIN_VALUE ? m.defaultValue : Math.min(0, max))
|
||||
.collect(Collectors.toList());
|
||||
if (res.isEmpty()) {
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -8,10 +8,16 @@ public class MultiAmountMessage implements Serializable {
|
|||
public String message;
|
||||
public int min;
|
||||
public int max;
|
||||
public int defaultValue;
|
||||
|
||||
public MultiAmountMessage(String message, int min, int max) {
|
||||
this(message, min, max, min);
|
||||
}
|
||||
|
||||
public MultiAmountMessage(String message, int min, int max, int defaultValue) {
|
||||
this.message = message;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue