Fix local Multiplayer Phase Indicator

This commit is contained in:
Anthony Calosa
2021-10-02 13:56:40 +08:00
parent 10a21fb1a6
commit 3bf4c33044
4 changed files with 25 additions and 14 deletions

View File

@@ -89,6 +89,15 @@ public class GameView extends TrackableObject {
}
void updatePhase(PhaseHandler phaseHandler) {
set(TrackableProperty.Phase, phaseHandler.getPhase());
set(TrackableProperty.PhaseLabelUpdate, true);
}
public boolean getPhaseLabelUpdate() {
if (get(TrackableProperty.PhaseLabelUpdate) == null)
return false;
return get(TrackableProperty.PhaseLabelUpdate);
}
public void clearPhaseLabelUpdate() {
set(TrackableProperty.PhaseLabelUpdate, false);
}
public PlayerView getPlayerTurn() {
return get(TrackableProperty.PlayerTurn);

View File

@@ -254,6 +254,7 @@ public enum TrackableProperty {
GameOver(TrackableTypes.BooleanType),
PoisonCountersToLose(TrackableTypes.IntegerType),
GameLog(TrackableTypes.StringType),
PhaseLabelUpdate(TrackableTypes.BooleanType),
PlayerTurn(TrackableTypes.PlayerViewType),
Phase(TrackableTypes.EnumType(PhaseType.class));

View File

@@ -51,7 +51,6 @@ import forge.player.PlayerZoneUpdates;
import forge.screens.match.views.VAssignCombatDamage;
import forge.screens.match.views.VAssignGenericAmount;
import forge.screens.match.views.VPhaseIndicator;
import forge.screens.match.views.VPhaseIndicator.PhaseLabel;
import forge.screens.match.views.VPlayerPanel;
import forge.screens.match.views.VPlayerPanel.InfoTab;
import forge.screens.match.views.VPrompt;
@@ -213,21 +212,8 @@ public class MatchController extends AbstractGuiGame {
@Override
public void updatePhase(boolean saveState) {
final PlayerView p = getGameView().getPlayerTurn();
final PhaseType ph = getGameView().getPhase();
PhaseLabel lbl = null;
if(ph!=null) {
lbl = p == null ? null : view.getPlayerPanel(p).getPhaseIndicator().getLabel(ph);
} else {
System.err.println("getGameView().getPhase() returned 'null'");
}
view.resetAllPhaseButtons();
if (lbl != null) {
lbl.setActive(true);
}
if(GuiBase.isNetworkplay())
checkStack();

View File

@@ -358,6 +358,21 @@ public class MatchScreen extends FScreen {
final GameView game = MatchController.instance.getGameView();
if (game == null) { return; }
//updatePhase to make it work with local MultiPlayer
if (game.getPhaseLabelUpdate()) {
PlayerView currentPlayer = game.getPlayerTurn();
PhaseType phaseType = game.getPhase();
//reset
game.clearPhaseLabelUpdate();
resetAllPhaseButtons();
//set phaselabel
try {
getPlayerPanel(currentPlayer).getPhaseIndicator().getLabel(phaseType).setActive(true);
} catch (Exception e) {
//FIXME: it seems getting the phase or label causes NPE particularly after End of Turn, don't know why...
}
}
if(gameMenu!=null) {
if(gameMenu.getChildCount()>3){
if(viewWinLose == null) {