mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
gui: fixed possible game error with player timer on client side
This commit is contained in:
parent
30269243bb
commit
01dd8c33ba
3 changed files with 21 additions and 11 deletions
|
|
@ -104,20 +104,26 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
int priorityTimeValue = pt.getCount() + pt.getBufferCount();
|
||||
String text = getPriorityTimeLeftString(priorityTimeValue);
|
||||
// Set timer text colors (note, if you change it here, change it in update() as well)
|
||||
Color textColor = null; // use default in HoverButton
|
||||
Color foregroundColor = Color.BLACK;
|
||||
final Color textColor; // use default in HoverButton
|
||||
final Color foregroundColor;
|
||||
if (pt.getBufferCount() > 0) {
|
||||
textColor = Color.GREEN;
|
||||
foregroundColor = Color.GREEN.darker().darker();
|
||||
} else if (pt.getCount() < 300) { // visual indication for under 5 minutes
|
||||
textColor = Color.RED;
|
||||
foregroundColor = Color.RED.darker().darker();
|
||||
} else {
|
||||
textColor = null;
|
||||
foregroundColor = Color.BLACK;
|
||||
}
|
||||
PlayerPanelExt.this.avatar.setTopText(text);
|
||||
PlayerPanelExt.this.avatar.setTopTextColor(textColor);
|
||||
PlayerPanelExt.this.timerLabel.setText(text);
|
||||
PlayerPanelExt.this.timerLabel.setForeground(foregroundColor);
|
||||
PlayerPanelExt.this.avatar.repaint();
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
PlayerPanelExt.this.avatar.setTopText(text);
|
||||
PlayerPanelExt.this.avatar.setTopTextColor(textColor);
|
||||
PlayerPanelExt.this.timerLabel.setText(text);
|
||||
PlayerPanelExt.this.timerLabel.setForeground(foregroundColor);
|
||||
PlayerPanelExt.this.avatar.repaint();
|
||||
});
|
||||
});
|
||||
timer.init(gameId);
|
||||
}
|
||||
|
|
@ -318,14 +324,17 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
this.avatar.setTopText(priorityTimeValue);
|
||||
this.timerLabel.setText(priorityTimeValue);
|
||||
// Set timer text colors (note, if you change it here, change it in init()::timer.setTaskOnTick() as well)
|
||||
Color textColor = null; // use default in HoverButton
|
||||
Color foregroundColor = Color.BLACK;
|
||||
final Color textColor; // use default in HoverButton
|
||||
final Color foregroundColor;
|
||||
if (player.getBufferTimeLeft() > 0) {
|
||||
textColor = Color.GREEN;
|
||||
foregroundColor = Color.GREEN.darker().darker();
|
||||
} else if (player.getPriorityTimeLeft() < 300) { // visual indication for under 5 minutes
|
||||
textColor = Color.RED;
|
||||
foregroundColor = Color.RED.darker().darker();
|
||||
} else {
|
||||
textColor = null;
|
||||
foregroundColor = Color.BLACK;
|
||||
}
|
||||
this.avatar.setTopTextColor(textColor);
|
||||
this.timerLabel.setForeground(foregroundColor);
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ public class GameView implements Serializable {
|
|||
private UUID myPlayerId = null; // null for watcher
|
||||
private final CardsView myHand = new CardsView();
|
||||
private PlayableObjectsList canPlayObjects;
|
||||
private Map<String, SimpleCardsView> opponentHands = new HashMap<>();
|
||||
private Map<String, SimpleCardsView> watchedHands = new HashMap<>();
|
||||
private final Map<String, SimpleCardsView> opponentHands = new HashMap<>();
|
||||
private final Map<String, SimpleCardsView> watchedHands = new HashMap<>();
|
||||
private final CardsView stack = new CardsView();
|
||||
private final List<ExileView> exiles = new ArrayList<>();
|
||||
private final List<RevealedView> revealed = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ public class GameController implements GameCallback {
|
|||
long delayMs = 250L; // run each 250 ms
|
||||
|
||||
Action executeOnNoTimeLeft = () -> {
|
||||
// TODO: buggy, must run in game thread, not in timer thread
|
||||
game.timerTimeout(initPlayerId);
|
||||
logger.debug("Player has no time left to end the match: " + initPlayerId + ". Conceding.");
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue