added New Turn visual indicator.
parent
d57fe8724d
commit
80522c28dd
|
@ -52,6 +52,7 @@ public class GeneralConfig {
|
|||
private static final String ANIMATE_GAMEPLAY = "animateGameplay";
|
||||
private static final String DECK_FILE_MAX_LINES = "deckFileMaxLines";
|
||||
private static final String PROXY_SETTINGS = "proxySettings";
|
||||
private static final String NEW_TURN_VISUAL_CUE = "newTurnVisualCue";
|
||||
|
||||
// The most common size of card retrieved from http://mtgimage.com.
|
||||
public static final Dimension PREFERRED_CARD_SIZE = HIGH_QUALITY_IMAGE_SIZE;
|
||||
|
@ -123,6 +124,7 @@ public class GeneralConfig {
|
|||
private boolean animateGameplay = true;
|
||||
private int deckFileMaxLines = DEFAULT_DECK_FILE_MAX_LINES;
|
||||
private String proxySettings = DEFAULT_PROXY_SETTINGS;
|
||||
private boolean showNewTurnVisualCue = true;
|
||||
|
||||
private GeneralConfig() { }
|
||||
|
||||
|
@ -441,6 +443,12 @@ public class GeneralConfig {
|
|||
CardDefinitions.resetMissingCardData();
|
||||
}
|
||||
|
||||
public boolean showNewTurnVisualCue() {
|
||||
return showNewTurnVisualCue;
|
||||
}
|
||||
public void setShowNewTurnVisualCue(boolean b) {
|
||||
showNewTurnVisualCue = b;
|
||||
}
|
||||
|
||||
private void load(final Properties properties) {
|
||||
left=Integer.parseInt(properties.getProperty(LEFT,""+DEFAULT_LEFT));
|
||||
|
@ -477,6 +485,7 @@ public class GeneralConfig {
|
|||
animateGameplay = Boolean.parseBoolean(properties.getProperty(ANIMATE_GAMEPLAY, "" + true));
|
||||
deckFileMaxLines = Integer.parseInt(properties.getProperty(DECK_FILE_MAX_LINES, ""+DEFAULT_DECK_FILE_MAX_LINES));
|
||||
proxySettings = properties.getProperty(PROXY_SETTINGS, "");
|
||||
showNewTurnVisualCue = Boolean.parseBoolean(properties.getProperty(NEW_TURN_VISUAL_CUE, "" + true));
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
@ -517,6 +526,7 @@ public class GeneralConfig {
|
|||
properties.setProperty(CARD_IMAGES_PATH, cardImagesPath);
|
||||
properties.setProperty(ANIMATE_GAMEPLAY, String.valueOf(animateGameplay));
|
||||
properties.setProperty(PROXY_SETTINGS, proxySettings);
|
||||
properties.setProperty(NEW_TURN_VISUAL_CUE, String.valueOf(showNewTurnVisualCue));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
|
|
@ -61,6 +61,7 @@ public class GameController implements ILogBookListener {
|
|||
private MagicTarget choiceClicked = MagicTargetNone.getInstance();
|
||||
private MagicCardDefinition sourceCardDefinition = MagicCardDefinition.UNKNOWN;
|
||||
private BlockingQueue<Boolean> input = new SynchronousQueue<Boolean>();
|
||||
private int gameTurn = 0;
|
||||
|
||||
public GameController(final GamePanel aGamePanel,final MagicGame aGame) {
|
||||
gamePanel = aGamePanel;
|
||||
|
@ -356,6 +357,17 @@ public class GameController implements ILogBookListener {
|
|||
* Update/render the gui based on the model state.
|
||||
*/
|
||||
public void update() {
|
||||
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
if (game.getTurn() != gameTurn) {
|
||||
gameTurn = game.getTurn();
|
||||
final boolean isShowingMulliganScreen = CONFIG.showMulliganScreen() && game.getTurn() == 1;
|
||||
if (!isShowingMulliganScreen && CONFIG.showNewTurnVisualCue()) {
|
||||
gamePanel.doNewTurnNotification(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gamePanel.updateInfo();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
package magic.ui;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
import magic.data.GeneralConfig;
|
||||
import magic.model.MagicCardDefinition;
|
||||
import magic.model.MagicCardList;
|
||||
|
@ -30,20 +42,6 @@ import magic.ui.widget.FontsAndBorders;
|
|||
import magic.ui.widget.ZoneBackgroundLabel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public final class GamePanel extends JPanel {
|
||||
|
||||
|
@ -450,4 +448,36 @@ public final class GamePanel extends JPanel {
|
|||
private Point getLocationOnGamePanel(final JComponent component) {
|
||||
return SwingUtilities.convertPoint(component.getParent(), component.getLocation(), this);
|
||||
}
|
||||
|
||||
private void doThreadSleep(final long msecs) {
|
||||
try {
|
||||
Thread.sleep(msecs);
|
||||
} catch (InterruptedException e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move up into GameController?
|
||||
void doNewTurnNotification(final MagicGame game) {
|
||||
|
||||
assert !SwingUtilities.isEventDispatchThread();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gameDuelViewer.showNewTurnNotification(game);
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: do while gameDuelViewer.isBusy() { sleep(100); }
|
||||
doThreadSleep(3000);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gameDuelViewer.hideNewTurnNotification();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue