UI: added different colors for current turn phase (same as buttons -- see #1201)

This commit is contained in:
Oleg Agafonov 2018-02-04 12:48:50 +04:00
parent 5947326a4f
commit ec5c8a01df
3 changed files with 36 additions and 12 deletions

View file

@ -52,6 +52,7 @@ import static mage.constants.Constants.Option.ORIGINAL_ID;
import static mage.constants.Constants.Option.SECOND_MESSAGE;
import static mage.constants.Constants.Option.SPECIAL_BUTTON;
import mage.constants.PlayerAction;
import mage.constants.TurnPhase;
import org.apache.log4j.Logger;
/**
@ -97,7 +98,8 @@ 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, boolean gameNeedUserFeedback) {
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options,
int messageId, boolean gameNeedUserFeedback, TurnPhase gameTurnPhase) {
synchronized (this) {
if (messageId < this.lastMessageId) {
LOGGER.warn("ignoring message from later source: " + messageId + ", text=" + message);
@ -151,7 +153,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
this.helper.setLinks(btnLeft, btnRight, btnSpecial, btnUndo);
this.helper.setVisible(true);
this.helper.setGameNeedFeedback(gameNeedUserFeedback);
this.helper.setGameNeedFeedback(gameNeedUserFeedback, gameTurnPhase);
this.helper.autoSizeButtonsAndFeedbackState();
}

View file

@ -52,6 +52,7 @@ import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.MageDialogState;
import mage.constants.*;
import mage.game.events.PlayerQueryEvent;
import mage.game.turn.Phase;
import mage.view.*;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardPanel;
@ -1064,7 +1065,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, true);
this.feedbackPanel.getFeedback(FeedbackMode.QUESTION, question, false, options, messageId, true, gameView.getPhase());
}
/**
@ -1113,7 +1114,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, true);
this.feedbackPanel.getFeedback(required ? FeedbackMode.INFORM : FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId, true, gameView.getPhase());
if (dialog != null) {
this.pickTarget.add(dialog); // TODO: 01.01.2018, JayDi85: why feedbackPanel saved to pickTarget list? Need to research
}
@ -1121,11 +1122,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, false);
this.feedbackPanel.getFeedback(FeedbackMode.INFORM, information, gameView.getSpecial(), null, messageId, false, gameView.getPhase());
}
public void endMessage(String message, int messageId) {
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null, messageId, true);
this.feedbackPanel.getFeedback(FeedbackMode.END, message, false, null, messageId, true, null);
ArrowBuilder.getBuilder().removeAllArrows(gameId);
}
@ -1168,19 +1169,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, true);
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId, true, gameView.getPhase());
}
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, true);
this.feedbackPanel.getFeedback(FeedbackMode.CANCEL, message, gameView.getSpecial(), options, messageId, true, gameView.getPhase());
}
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, true);
this.feedbackPanel.getFeedback(FeedbackMode.CONFIRM, message, gameView.getSpecial(), null, messageId, true, gameView.getPhase());
}
public void replayMessage(String message) {

View file

@ -49,6 +49,7 @@ 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;
@ -57,6 +58,7 @@ import mage.client.game.FeedbackPanel.FeedbackMode;
import static mage.client.game.FeedbackPanel.FeedbackMode.QUESTION;
import mage.client.util.GUISizeHelper;
import mage.constants.TurnPhase;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_NO;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_YES;
@ -105,6 +107,7 @@ public class HelperPanel extends JPanel {
private UUID gameId;
private boolean gameNeedFeedback = false;
private TurnPhase gameTurnPhase = null;
public HelperPanel() {
initComponents();
@ -319,8 +322,9 @@ public class HelperPanel extends JPanel {
autoSizeButtonsAndFeedbackState();
}
public void setGameNeedFeedback(boolean need) {
public void setGameNeedFeedback(boolean need, TurnPhase gameTurnPhase) {
this.gameNeedFeedback = need;
this.gameTurnPhase = gameTurnPhase;
}
public void autoSizeButtonsAndFeedbackState() {
@ -328,7 +332,9 @@ public class HelperPanel extends JPanel {
// plus colorize feedback panel on player's priority
int BUTTONS_H_GAP = 15;
Color ACTIVE_FEEDBACK_BACKGROUND_COLOR = new Color(0, 255, 0, 50);
Color ACTIVE_FEEDBACK_BACKGROUND_COLOR_MAIN = new Color(0, 0, 255, 50);
Color ACTIVE_FEEDBACK_BACKGROUND_COLOR_BATTLE = new Color(255, 0, 0, 50);
Color ACTIVE_FEEDBACK_BACKGROUND_COLOR_OTHER = 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));
@ -344,7 +350,22 @@ public class HelperPanel extends JPanel {
if (this.gameNeedFeedback) {
// wait player's action
this.setOpaque(true);
this.setBackground(ACTIVE_FEEDBACK_BACKGROUND_COLOR);
// different colors for different game phases
Color backColor = ACTIVE_FEEDBACK_BACKGROUND_COLOR_OTHER;
if (this.gameTurnPhase != null) {
switch (this.gameTurnPhase) {
case PRECOMBAT_MAIN:
case POSTCOMBAT_MAIN:
backColor = ACTIVE_FEEDBACK_BACKGROUND_COLOR_MAIN;
break;
case COMBAT:
backColor = ACTIVE_FEEDBACK_BACKGROUND_COLOR_BATTLE;
break;
}
}
this.setBackground(backColor);
} else {
// inform about other players
this.setOpaque(false);