[Mobile] refactor netplay phase indicator

This commit is contained in:
Anthony Calosa
2021-10-06 21:28:39 +08:00
parent 38f7d1ba83
commit 050ecb51bd
4 changed files with 29 additions and 0 deletions

View File

@@ -96,6 +96,19 @@ public class GameView extends TrackableObject {
void updatePlayerTurn(PhaseHandler phaseHandler) {
set(TrackableProperty.PlayerTurn, PlayerView.get(phaseHandler.getPlayerTurn()));
}
public void updateNeedsPhaseRedrawn(PlayerView p, PhaseType ph) {
set(TrackableProperty.PlayerTurn, p);
set(TrackableProperty.Phase, ph);
set(TrackableProperty.NeedsPhaseRedrawn, true);
}
public boolean getNeedsPhaseRedrawn() {
if (get(TrackableProperty.NeedsPhaseRedrawn) == null)
return false;
return get(TrackableProperty.NeedsPhaseRedrawn);
}
public void clearNeedsPhaseRedrawn() {
set(TrackableProperty.NeedsPhaseRedrawn, false);
}
public void updatePlanarPlayer(PlayerView p) {
set(TrackableProperty.PlanarPlayer, p);

View File

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

View File

@@ -223,11 +223,15 @@ public class MatchController extends AbstractGuiGame {
final VPhaseIndicator.PhaseLabel phaseLabel = view.getPlayerPanel(lastPlayer).getPhaseIndicator().getLabel(ph);
if (phaseLabel != null)
phaseLabel.setActive(true);
if (GuiBase.isNetworkplay())
getGameView().updateNeedsPhaseRedrawn(lastPlayer, PhaseType.CLEANUP);
} else if (getGameView().getPlayerTurn() != null) {
//set phaselabel
final VPhaseIndicator.PhaseLabel phaseLabel = view.getPlayerPanel(getGameView().getPlayerTurn()).getPhaseIndicator().getLabel(ph);
if (phaseLabel != null)
phaseLabel.setActive(true);
if (GuiBase.isNetworkplay())
getGameView().updateNeedsPhaseRedrawn(getGameView().getPlayerTurn(), ph);
}
}

View File

@@ -442,6 +442,17 @@ public class MatchScreen extends FScreen {
if (activeEffect != null) {
activeEffect.draw(g, 10, 10, 100, 100);
}
if (game.getNeedsPhaseRedrawn()) {
resetAllPhaseButtons();
if (game.getPlayerTurn() != null && game.getPhase() != null) {
final PhaseLabel phaseLabel = getPlayerPanel(game.getPlayerTurn()).getPhaseIndicator().getLabel(game.getPhase());
if (phaseLabel != null) {
phaseLabel.setActive(true);
game.clearNeedsPhaseRedrawn();
}
}
}
}
@Override