forked from External/mage
UI: added green colorized panel on player's priority (see #1201)
This commit is contained in:
parent
5fa20278b0
commit
5947326a4f
3 changed files with 36 additions and 21 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue