mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Closing dialog in feedback "Cancel". Displaying dialog on the center.
This commit is contained in:
parent
af2c69b449
commit
86d27d84bb
3 changed files with 43 additions and 14 deletions
|
|
@ -34,20 +34,22 @@
|
|||
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.*;
|
||||
|
||||
import com.sun.deploy.panel.ITreeNode;
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.SettingsManager;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.view.AbilityView;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
|
|
@ -79,10 +81,24 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
}
|
||||
pack();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(modal);
|
||||
this.setVisible(true);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int width = ShowCardsDialog.this.getWidth();
|
||||
int height = ShowCardsDialog.this.getWidth();
|
||||
if (width > 0 && height > 0) {
|
||||
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
||||
ShowCardsDialog.this.setLocation(centered.x, centered.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
|
||||
}
|
||||
ShowCardsDialog.this.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import javax.swing.*;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.components.MageTextArea;
|
||||
import mage.client.components.arcane.GlowText;
|
||||
import mage.client.dialog.MageDialog;
|
||||
import mage.remote.Session;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -66,12 +67,13 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private UUID gameId;
|
||||
private Session session;
|
||||
private FeedbackMode mode;
|
||||
private MageDialog connectedDialog;
|
||||
|
||||
/** Creates new form FeedbackPanel */
|
||||
public FeedbackPanel() {
|
||||
//initComponents();
|
||||
customInitComponents();
|
||||
}
|
||||
/** Creates new form FeedbackPanel */
|
||||
public FeedbackPanel() {
|
||||
//initComponents();
|
||||
customInitComponents();
|
||||
}
|
||||
|
||||
public void init(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
|
|
@ -143,6 +145,9 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
this.btnRight.setText((String)options.get("UI.right.btn.text"));
|
||||
this.helper.setRight((String)options.get("UI.right.btn.text"), true);
|
||||
}
|
||||
if (options.containsKey("dialog")) {
|
||||
connectedDialog = (MageDialog) options.get("dialog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -342,10 +347,14 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
|
||||
this.selected = true;
|
||||
clear0();
|
||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK)
|
||||
if (connectedDialog != null) {
|
||||
connectedDialog.hideDialog();
|
||||
}
|
||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||
session.sendPlayerInteger(gameId, 0);
|
||||
else
|
||||
} else {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
}//GEN-LAST:event_btnRightActionPerformed
|
||||
|
||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||
|
|
|
|||
|
|
@ -448,10 +448,13 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
|
||||
public void pickTarget(String message, CardsView cardView, GameView gameView, Set<UUID> targets, boolean required, Map<String, Serializable> options) {
|
||||
updateGame(gameView);
|
||||
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, false, gameView.getSpecial(), options);
|
||||
Map<String, Serializable> options0 = options == null ? new HashMap<String, Serializable>() : options;
|
||||
if (cardView != null && cardView.size() > 0) {
|
||||
showCards(message, cardView, required);
|
||||
ShowCardsDialog dialog = showCards(message, cardView, required);
|
||||
options0.put("dialog", dialog);
|
||||
}
|
||||
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, false, gameView.getSpecial(), options0);
|
||||
|
||||
}
|
||||
|
||||
public void inform(String information, GameView gameView) {
|
||||
|
|
@ -502,9 +505,10 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
// showCards.loadCards(name, cards, bigCard, Config.dimensions, gameId, false);
|
||||
// }
|
||||
//
|
||||
private void showCards(String title, CardsView cards, boolean required) {
|
||||
private ShowCardsDialog showCards(String title, CardsView cards, boolean required) {
|
||||
ShowCardsDialog showCards = new ShowCardsDialog();
|
||||
showCards.loadCards(title, cards, bigCard, Config.dimensions, gameId, required);
|
||||
return showCards;
|
||||
}
|
||||
|
||||
public void getAmount(int min, int max, String message) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue