- Fix match music not stopping when moving Forge to background

- Fix quit warning not mentioning matches when one or more are active
- Some minor fixes and cleanup
This commit is contained in:
elcnesh
2015-02-22 00:18:50 +00:00
parent 215ccc4c78
commit ab1d24cc8a
8 changed files with 59 additions and 20 deletions

View File

@@ -30,7 +30,7 @@ public interface IGuiGame {
void setGameView(GameView gameView);
void setGameController(PlayerView player, IGameController gameController);
boolean resetForNewGame();
void openView(FCollectionView<PlayerView> myPlayers);
void openView(Iterable<PlayerView> myPlayers);
void afterGameEnd();
void showCombat();
void showPromptMessage(PlayerView playerView, String message);

View File

@@ -28,15 +28,16 @@ import forge.interfaces.IButton;
import forge.interfaces.IGameController;
import forge.interfaces.IGuiGame;
import forge.interfaces.IMayViewCards;
import forge.util.FCollection;
import forge.util.FCollectionView;
public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
private FCollectionView<PlayerView> localPlayers;
private FCollectionView<PlayerView> localPlayers = new FCollection<PlayerView>();
private PlayerView currentPlayer = null;
protected final void setLocalPlayers(final FCollectionView<PlayerView> players) {
this.localPlayers = players;
this.currentPlayer = players == null ? null : Iterables.getFirst(players, null);
protected final void setLocalPlayers(final Iterable<PlayerView> myPlayers) {
this.localPlayers = myPlayers == null ? new FCollection<PlayerView>() : new FCollection<PlayerView>(myPlayers);
this.currentPlayer = Iterables.getFirst(this.localPlayers, null);
}
public final boolean hasLocalPlayers() {
return localPlayers != null && !localPlayers.isEmpty();

View File

@@ -61,6 +61,7 @@ public class HostedMatch {
private FControlGamePlayback playbackControl = null;
private final MatchUiEventVisitor visitor = new MatchUiEventVisitor();
private final Map<PlayerControllerHuman, NextGameDecision> nextGameDecisions = Maps.newHashMap();
private boolean isMatchOver = false;
public HostedMatch() {
}
@@ -222,7 +223,7 @@ public class HostedMatch {
match.startGame(game);
// After game is over...
if (humanCount == 0) {
if (match.isMatchOver() && humanCount == 0) {
// ... if no human players, let AI decide next game
addNextGameDecision(null, NextGameDecision.CONTINUE);
}
@@ -256,6 +257,7 @@ public class HostedMatch {
humanController.getGui().afterGameEnd();
}
humanControllers.clear();
isMatchOver = true;
}
public void pause() {
@@ -273,6 +275,10 @@ public class HostedMatch {
SoundSystem.instance.resume();
}
public boolean isMatchOver() {
return isMatchOver;
}
/** Returns a random name from the supplied list. */
public static String getRandomName() {
final String playerName = GuiDisplayUtil.getPlayerName();