mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
If switched to Combat pane when combat begins, switch back to previous pane when combat ends
This commit is contained in:
@@ -51,6 +51,7 @@ import forge.gui.events.UiEventBlockerAssigned;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.gui.match.controllers.CCombat;
|
||||
import forge.gui.match.controllers.CDetail;
|
||||
@@ -88,6 +89,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
private VMatchUI view;
|
||||
|
||||
private EventBus uiEvents;
|
||||
private IVDoc<? extends ICDoc> selectedDocBeforeCombat;
|
||||
private MatchUiEventVisitor visitor = new MatchUiEventVisitor();
|
||||
|
||||
private CMatchUI() {
|
||||
@@ -296,7 +298,22 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
|
||||
public void showCombat(Combat combat) {
|
||||
if (combat != null && combat.getAttackingPlayer().getGame().getStack().isEmpty()) {
|
||||
SDisplayUtil.showTab(EDocID.REPORT_COMBAT.getDoc());
|
||||
if (selectedDocBeforeCombat == null) {
|
||||
IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc();
|
||||
if (combatDoc.getParentCell() != null) {
|
||||
selectedDocBeforeCombat = combatDoc.getParentCell().getSelected();
|
||||
if (selectedDocBeforeCombat != combatDoc) {
|
||||
SDisplayUtil.showTab(combatDoc);
|
||||
}
|
||||
else {
|
||||
selectedDocBeforeCombat = null; //don't need to cache combat doc this way
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selectedDocBeforeCombat != null) { //re-select doc that was selected before once combat finished
|
||||
SDisplayUtil.showTab(selectedDocBeforeCombat);
|
||||
selectedDocBeforeCombat = null;
|
||||
}
|
||||
CCombat.SINGLETON_INSTANCE.setModel(combat);
|
||||
CCombat.SINGLETON_INSTANCE.update();
|
||||
|
||||
@@ -45,16 +45,16 @@ public enum CCombat implements ICDoc {
|
||||
@Override
|
||||
public void update() {
|
||||
Combat localCombat = this.combat; // noone will re-assign this from other thread.
|
||||
if (localCombat != null )
|
||||
if (localCombat != null) {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(localCombat.getAttackers().size(), getCombatDescription(localCombat));
|
||||
else
|
||||
}
|
||||
else {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(0, "");
|
||||
}
|
||||
}
|
||||
|
||||
public void setModel(Combat combat)
|
||||
{
|
||||
public void setModel(Combat combat) {
|
||||
this.combat = combat;
|
||||
|
||||
}
|
||||
|
||||
private static String getCombatDescription(Combat combat) {
|
||||
|
||||
Reference in New Issue
Block a user