mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
GUI, game: added card popup support in choose target amount dialogs (example: damage distribution, related to #9827)
This commit is contained in:
parent
0fbd9bb60f
commit
1ec277631f
6 changed files with 43 additions and 24 deletions
|
|
@ -41,7 +41,7 @@ public class MageTextArea extends MageEditorPane {
|
|||
|
||||
// prepare text format as header and details texts
|
||||
|
||||
final StringBuilder buffer = new StringBuilder(512);
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
// Dialog is a java logical font family, so it should work on all systems
|
||||
buffer.append("<body style='font-family:Dialog;font-size:");
|
||||
buffer.append(GUISizeHelper.gameFeedbackPanelMainMessageFontSize);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.components.MageTextArea;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.util.MultiAmountMessage;
|
||||
|
||||
|
|
@ -11,20 +13,24 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Game GUI: dialog to distribute values between multiple items
|
||||
* (used for some cards and add lands in cheat menu, search by MultiAmountMessage)
|
||||
*
|
||||
* @author weirddan455
|
||||
* @author weirddan455, JayDi85
|
||||
*/
|
||||
public class PickMultiNumberDialog extends MageDialog {
|
||||
|
||||
private boolean cancel;
|
||||
private PickMultiNumberCallback callback = null;
|
||||
|
||||
private List<JLabel> labelList = null;
|
||||
private UUID gameId = null;
|
||||
private BigCard bigCard = null;
|
||||
|
||||
private List<MageTextArea> infoList = null;
|
||||
private List<JSpinner> spinnerList = null;
|
||||
|
||||
public PickMultiNumberDialog() {
|
||||
|
|
@ -36,6 +42,11 @@ public class PickMultiNumberDialog extends MageDialog {
|
|||
void onChoiceDone();
|
||||
}
|
||||
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
public void showDialog(List<MultiAmountMessage> messages, int min, int max, Map<String, Serializable> options, PickMultiNumberCallback callback) {
|
||||
this.cancel = false;
|
||||
this.callback = callback;
|
||||
|
|
@ -46,9 +57,10 @@ public class PickMultiNumberDialog extends MageDialog {
|
|||
boolean canCancel = options.get("canCancel") != null && (boolean) options.get("canCancel");
|
||||
btnCancel.setVisible(canCancel);
|
||||
|
||||
if (labelList != null) {
|
||||
for (JLabel label : labelList) {
|
||||
jPanel1.remove(label);
|
||||
// clean
|
||||
if (infoList != null) {
|
||||
for (MageTextArea info : infoList) {
|
||||
jPanel1.remove(info);
|
||||
}
|
||||
}
|
||||
if (spinnerList != null) {
|
||||
|
|
@ -56,14 +68,15 @@ public class PickMultiNumberDialog extends MageDialog {
|
|||
jPanel1.remove(spinner);
|
||||
}
|
||||
}
|
||||
|
||||
int size = messages.size();
|
||||
labelList = new ArrayList<>(size);
|
||||
infoList = new ArrayList<>(size);
|
||||
spinnerList = new ArrayList<>(size);
|
||||
jPanel1.setLayout(new GridBagLayout());
|
||||
GridBagConstraints labelC = new GridBagConstraints();
|
||||
GridBagConstraints spinnerC = new GridBagConstraints();
|
||||
for (int i = 0; i < size; i++) {
|
||||
JLabel label = new JLabel();
|
||||
MageTextArea info = new MageTextArea();
|
||||
info.enableTextLabelMode();
|
||||
info.setGameData(this.gameId, this.bigCard);
|
||||
|
||||
// mana mode
|
||||
String manaText = null;
|
||||
|
|
@ -86,24 +99,23 @@ public class PickMultiNumberDialog extends MageDialog {
|
|||
break;
|
||||
}
|
||||
if (manaText != null) {
|
||||
label.setText("<html>" + manaText);
|
||||
Image image = ManaSymbols.getSizedManaSymbol(input);
|
||||
if (image != null) {
|
||||
label.setIcon(new ImageIcon(image));
|
||||
}
|
||||
// mana mode
|
||||
info.setText("{" + input + "}" + " " + manaText);
|
||||
} else {
|
||||
// text mode
|
||||
label.setText("<html>" + ManaSymbols.replaceSymbolsWithHTML(input, ManaSymbols.Type.DIALOG));
|
||||
info.setText(input);
|
||||
}
|
||||
|
||||
labelC.weightx = 0.5;
|
||||
labelC.gridx = 0;
|
||||
labelC.gridy = i;
|
||||
jPanel1.add(label, labelC);
|
||||
labelList.add(label);
|
||||
GridBagConstraints infoC = new GridBagConstraints();
|
||||
infoC.weightx = 0.5;
|
||||
infoC.gridx = 0;
|
||||
infoC.gridy = i;
|
||||
jPanel1.add(info, infoC);
|
||||
infoList.add(info);
|
||||
|
||||
JSpinner spinner = new JSpinner();
|
||||
spinner.setModel(new SpinnerNumberModel(messages.get(i).defaultValue, messages.get(i).min, messages.get(i).max, 1));
|
||||
GridBagConstraints spinnerC = new GridBagConstraints();
|
||||
spinnerC.weightx = 0.5;
|
||||
spinnerC.gridx = 1;
|
||||
spinnerC.gridy = i;
|
||||
|
|
|
|||
|
|
@ -650,6 +650,11 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.abilityPicker.fullRefresh(GUISizeHelper.dialogGuiScale);
|
||||
this.abilityPicker.init(gameId, bigCard);
|
||||
}
|
||||
if (this.pickMultiNumber != null && !this.pickMultiNumber.isVisible()) {
|
||||
// TODO: add pick number dialogs support here
|
||||
//this.pickMultiNumber.fullRefresh(GUISizeHelper.dialogGuiScale);
|
||||
this.pickMultiNumber.init(gameId, bigCard);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSkipButtonImage(JButton button, Image image) {
|
||||
|
|
@ -819,6 +824,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
MageFrame.addGame(gameId, this);
|
||||
this.feedbackPanel.init(gameId, bigCard);
|
||||
this.feedbackPanel.clear();
|
||||
this.pickMultiNumber.init(gameId, bigCard);
|
||||
this.abilityPicker.init(gameId, bigCard);
|
||||
this.btnConcede.setVisible(true);
|
||||
this.btnStopWatching.setVisible(false);
|
||||
|
|
@ -2177,6 +2183,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
hideAll();
|
||||
DialogManager.getManager(gameId).fadeOut();
|
||||
|
||||
pickMultiNumber.init(gameId, bigCard);
|
||||
pickMultiNumber.showDialog(messages, min, max, lastGameData.options, () -> {
|
||||
if (pickMultiNumber.isCancel()) {
|
||||
SessionHandler.sendPlayerBoolean(gameId, false);
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
MageObject targetObject = game.getObject(targetId);
|
||||
if (targetObject != null) {
|
||||
targetNames.add(String.format("%s, P/T: %d/%d",
|
||||
targetObject.getIdName(),
|
||||
targetObject.getLogName(),
|
||||
targetObject.getPower().getValue(),
|
||||
targetObject.getToughness().getValue()
|
||||
));
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class MasterOfTheWildHuntEffect extends OneShotEffect {
|
|||
int totalDamage = target.getPower().getValue();
|
||||
List<String> messages = new ArrayList<>();
|
||||
wolves.forEach(permanent -> {
|
||||
String info = String.format("%s (%s/%s)",
|
||||
String info = String.format("%s, P/T: %d/%d",
|
||||
permanent.getLogName(),
|
||||
permanent.getPower().getValue(),
|
||||
permanent.getToughness().getValue()
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
private Watchers watchers;
|
||||
private Turn turn;
|
||||
private TurnMods turnMods; // one time turn modifications (turn, phase or step)
|
||||
private UUID activePlayerId; // playerId which turn it is
|
||||
private UUID activePlayerId; // player which turn it is
|
||||
private UUID priorityPlayerId; // player that has currently priority (setup before any choose)
|
||||
private UUID playerByOrderId; // player that has currently priority
|
||||
private UUID monarchId; // player that is the monarch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue