CMessage no longer stores game as model, instead updates follow visitor pattern (which ever game called update, get its information displayed)

Remove unused imports
This commit is contained in:
Maxmtg
2013-06-29 22:04:33 +00:00
parent 8e1b3185fe
commit c811662d6f
5 changed files with 6 additions and 19 deletions

View File

@@ -31,8 +31,6 @@ import forge.card.ability.AbilityFactory;
import forge.card.ability.AbilityUtils;
import forge.card.spellability.SpellAbility;
import forge.game.Game;
import forge.game.ai.ComputerUtil;
import forge.game.player.HumanPlay;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;

View File

@@ -23,7 +23,6 @@ import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterables;
import forge.Card;
import forge.CardCharacteristicName;
import forge.ITargetable;
import forge.card.CardType;
import forge.card.ability.AbilityUtils;

View File

@@ -414,7 +414,6 @@ public enum FControl {
CDock.SINGLETON_INSTANCE.setModel(game, humanLobbyPlayer);
CStack.SINGLETON_INSTANCE.setModel(game.getStack(), humanLobbyPlayer);
CLog.SINGLETON_INSTANCE.setModel(game.getGameLog());
CMessage.SINGLETON_INSTANCE.setModel(game);
Singletons.getModel().getPreferences().actuateMatchPreferences();

View File

@@ -8,6 +8,7 @@ import com.google.common.eventbus.Subscribe;
import forge.Card;
import forge.FThreads;
import forge.game.Game;
import forge.game.event.GameEvent;
import forge.game.event.GameEventAnteCardsSelected;
import forge.game.event.GameEventGameFinished;
@@ -85,11 +86,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
public Void visit(GameEventTurnBegan event) {
if ( turnUpdPlanned.getAndSet(true) ) return null;
final Game game = fc.getObservedGame(); // to make sure control gets a correct game instance
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override
public void run() {
turnUpdPlanned.set(false);
CMessage.SINGLETON_INSTANCE.updateText();
CMessage.SINGLETON_INSTANCE.updateText(game);
}
});
return null;

View File

@@ -69,7 +69,6 @@ public enum CMessage implements ICDoc {
}
}
};
private Game game;
private void _initButton(JButton button, ActionListener onClick) {
// remove to ensure listeners don't accumulate over many initializations
@@ -116,10 +115,10 @@ public enum CMessage implements ICDoc {
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
*/
public void updateText() {
public void updateText(Game game) {
FThreads.assertExecutedByEdt(true);
Match match = game.getMatch();
String text = String.format("%s: Game #%d of %d, turn %d", match.getGameType(), match.getPlayedGames().size() + 1, match.getGamesPerMatch(), game.getPhaseHandler().getTurn());
final Match match = game.getMatch();
final String text = String.format("%s: Game #%d of %d, turn %d", match.getGameType(), match.getPlayedGames().size() + 1, match.getGamesPerMatch(), game.getPhaseHandler().getTurn());
view.getLblGames().setText(text);
}
@@ -130,14 +129,4 @@ public enum CMessage implements ICDoc {
lastFocusedButton.requestFocusInWindow();
}
}
/**
* TODO: Write javadoc for this method.
* @param match
*/
public void setModel(Game game0) {
game = game0;
update();
}
}