UI: added green colorized panel on player's priority (see #1201)

This commit is contained in:
Oleg Agafonov 2018-02-04 12:09:21 +04:00
parent 5fa20278b0
commit 5947326a4f
3 changed files with 36 additions and 21 deletions

View file

@ -97,7 +97,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
private void setGUISize() {
}
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options, int messageId) {
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options, int messageId, boolean gameNeedUserFeedback) {
synchronized (this) {
if (messageId < this.lastMessageId) {
LOGGER.warn("ignoring message from later source: " + messageId + ", text=" + message);
@ -151,7 +151,8 @@ public class FeedbackPanel extends javax.swing.JPanel {
this.helper.setLinks(btnLeft, btnRight, btnSpecial, btnUndo);
this.helper.setVisible(true);
this.helper.autoSizeButtons();
this.helper.setGameNeedFeedback(gameNeedUserFeedback);
this.helper.autoSizeButtonsAndFeedbackState();
}
private void setButtonState(String leftText, String rightText, FeedbackMode mode) {
@ -213,7 +214,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
connectedDialog = (MageDialog) options.get("dialog");
}
this.helper.autoSizeButtons();
this.helper.autoSizeButtonsAndFeedbackState();
}
}

View file

@ -1064,7 +1064,7 @@ public final class GamePanel extends javax.swing.JPanel {
public void ask(String question, GameView gameView, int messageId, Map<String, Serializable> options) {
updateGame(gameView);
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, options, messageId);
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, options, messageId, true);
}
/**
@ -1113,7 +1113,7 @@ public final class GamePanel extends javax.swing.JPanel {
dialog = showCards(message, cardView, required, options0, popupMenuType);
options0.put("dialog", dialog);
}
this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId);
this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId, true);
if (dialog != null) {
this.pickTarget.add(dialog); // TODO: 01.01.2018, JayDi85: why feedbackPanel saved to pickTarget list? Need to research
}
@ -1121,11 +1121,11 @@ public final class GamePanel extends javax.swing.JPanel {
public void inform(String information, GameView gameView, int messageId) {
updateGame(gameView);
this.feedbackPanel.getFeedback(FeedbackMode.INFORM, information, gameView.getSpecial(), null, messageId);
this.feedbackPanel.getFeedback(FeedbackMode.INFORM, information, gameView.getSpecial(), null, messageId, false);
}
public void endMessage(String message, int messageId) {
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null, messageId);
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null, messageId, true);
ArrowBuilder.getBuilder().removeAllArrows(gameId);
}
@ -1168,19 +1168,19 @@ public final class GamePanel extends javax.swing.JPanel {
priorityPlayerText = " / priority " + gameView.getPriorityPlayerName();
}
String messageToDisplay = message + FeedbackPanel.getSmallText(activePlayerText + " / " + gameView.getStep().toString() + priorityPlayerText);
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId, true);
}
public void playMana(String message, GameView gameView, Map<String, Serializable> options, int messageId) {
updateGame(gameView);
DialogManager.getManager(gameId).fadeOut();
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), options, messageId);
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), options, messageId, true);
}
public void playXMana(String message, GameView gameView, int messageId) {
updateGame(gameView);
DialogManager.getManager(gameId).fadeOut();
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null, messageId);
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null, messageId, true);
}
public void replayMessage(String message) {

View file

@ -39,7 +39,6 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Random;
import java.util.UUID;
import javax.swing.JButton;
import javax.swing.JMenuItem;
@ -50,7 +49,6 @@ import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import mage.client.SessionHandler;
import mage.client.components.MageTextArea;
@ -59,7 +57,6 @@ import mage.client.game.FeedbackPanel.FeedbackMode;
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
import mage.client.util.GUISizeHelper;
import mage.util.RandomUtil;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_NO;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_YES;
@ -70,7 +67,7 @@ import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_TEXT_YES;
/**
* Panel with buttons that copy the state of feedback panel.
*
* @author ayrat
* @author ayrat, JayDi85
*/
public class HelperPanel extends JPanel {
@ -107,6 +104,7 @@ public class HelperPanel extends JPanel {
private String message;
private UUID gameId;
private boolean gameNeedFeedback = false;
public HelperPanel() {
initComponents();
@ -147,7 +145,7 @@ public class HelperPanel extends JPanel {
}
}
autoSizeButtons();
autoSizeButtonsAndFeedbackState();
GUISizeHelper.changePopupMenuFont(popupMenuAskNo);
GUISizeHelper.changePopupMenuFont(popupMenuAskYes);
@ -178,7 +176,7 @@ public class HelperPanel extends JPanel {
buttonContainer.setOpaque(false);
add(buttonContainer);
buttonGrid = new JPanel(); // buttons layout auto changes by autoSizeButtons
buttonGrid = new JPanel(); // buttons layout auto changes by autoSizeButtonsAndFeedbackState
buttonGrid.setOpaque(false);
buttonContainer.add(buttonGrid);
@ -292,7 +290,7 @@ public class HelperPanel extends JPanel {
this.btnRight.setActionCommand(mode.toString() + txtRight);
}
}
autoSizeButtons();
autoSizeButtonsAndFeedbackState();
}
public void setSpecial(String txtSpecial, boolean specialVisible) {
@ -302,7 +300,7 @@ public class HelperPanel extends JPanel {
public void setUndoEnabled(boolean enabled) {
this.btnUndo.setVisible(enabled);
autoSizeButtons();
autoSizeButtonsAndFeedbackState();
}
public void setLeft(String text, boolean visible) {
@ -310,7 +308,7 @@ public class HelperPanel extends JPanel {
if (!text.isEmpty()) {
this.btnLeft.setText(text);
}
autoSizeButtons();
autoSizeButtonsAndFeedbackState();
}
public void setRight(String txtRight, boolean rightVisible) {
@ -318,13 +316,19 @@ public class HelperPanel extends JPanel {
if (!txtRight.isEmpty()) {
this.btnRight.setText(txtRight);
}
autoSizeButtons();
autoSizeButtonsAndFeedbackState();
}
public void autoSizeButtons() {
public void setGameNeedFeedback(boolean need) {
this.gameNeedFeedback = need;
}
public void autoSizeButtonsAndFeedbackState() {
// two mode: same size for small texts (flow), different size for long texts (grid)
// plus colorize feedback panel on player's priority
int BUTTONS_H_GAP = 15;
Color ACTIVE_FEEDBACK_BACKGROUND_COLOR = new Color(0, 255, 0, 50);
// cleanup current settings to default (flow layout - different sizes)
this.buttonGrid.setLayout(new FlowLayout(FlowLayout.CENTER, BUTTONS_H_GAP, 0));
@ -336,6 +340,16 @@ public class HelperPanel extends JPanel {
if (this.btnSpecial.isVisible()) { buttons.add(this.btnSpecial); }
if (this.btnUndo.isVisible()) { buttons.add(this.btnUndo); }
// color panel on player's feedback waiting
if (this.gameNeedFeedback) {
// wait player's action
this.setOpaque(true);
this.setBackground(ACTIVE_FEEDBACK_BACKGROUND_COLOR);
} else {
// inform about other players
this.setOpaque(false);
}
if (buttons.size() == 0) {
return;
}