only display the ante tab when playing for ante

Closes: core-developers/forge#381

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
Jamin W. Collins
2018-08-16 17:52:42 -06:00
parent ab959890b8
commit b19eca2aff
2 changed files with 17 additions and 2 deletions

View File

@@ -432,7 +432,9 @@ public final class SLayoutIO {
for(EDocID edoc : kv.getValue()) { for(EDocID edoc : kv.getValue()) {
try { try {
//System.out.println(String.format("adding doc %s -> %s", edoc, edoc.getDoc())); //System.out.println(String.format("adding doc %s -> %s", edoc, edoc.getDoc()));
cell.addDoc(edoc.getDoc()); if (edoc.getDoc() != null ) {
cell.addDoc(edoc.getDoc());
}
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
System.err.println("Failed to get doc for " + edoc); System.err.println("Failed to get doc for " + edoc);

View File

@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.prefs.Preferences;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
@@ -143,7 +144,12 @@ public final class CMatchUI
this.myDocs = new EnumMap<EDocID, IVDoc<? extends ICDoc>>(EDocID.class); this.myDocs = new EnumMap<EDocID, IVDoc<? extends ICDoc>>(EDocID.class);
this.myDocs.put(EDocID.CARD_PICTURE, cDetailPicture.getCPicture().getView()); this.myDocs.put(EDocID.CARD_PICTURE, cDetailPicture.getCPicture().getView());
this.myDocs.put(EDocID.CARD_DETAIL, cDetailPicture.getCDetail().getView()); this.myDocs.put(EDocID.CARD_DETAIL, cDetailPicture.getCDetail().getView());
this.myDocs.put(EDocID.CARD_ANTES, cAntes.getView()); // only create an ante doc if playing for ante
if (isPreferenceEnabled(FPref.UI_ANTE)) {
this.myDocs.put(EDocID.CARD_ANTES, cAntes.getView());
} else {
this.myDocs.put(EDocID.CARD_ANTES, null);
}
this.myDocs.put(EDocID.REPORT_MESSAGE, getCPrompt().getView()); this.myDocs.put(EDocID.REPORT_MESSAGE, getCPrompt().getView());
this.myDocs.put(EDocID.REPORT_STACK, getCStack().getView()); this.myDocs.put(EDocID.REPORT_STACK, getCStack().getView());
this.myDocs.put(EDocID.REPORT_COMBAT, cCombat.getView()); this.myDocs.put(EDocID.REPORT_COMBAT, cCombat.getView());
@@ -158,6 +164,10 @@ public final class CMatchUI
} }
} }
private static boolean isPreferenceEnabled(final ForgePreferences.FPref preferenceName) {
return FModel.getPreferences().getPrefBoolean(preferenceName);
}
FScreen getScreen() { FScreen getScreen() {
return this.screen; return this.screen;
} }
@@ -486,6 +496,9 @@ public final class CMatchUI
updatePlayerControl(); updatePlayerControl();
KeyboardShortcuts.attachKeyboardShortcuts(this); KeyboardShortcuts.attachKeyboardShortcuts(this);
for (final IVDoc<? extends ICDoc> view : myDocs.values()) { for (final IVDoc<? extends ICDoc> view : myDocs.values()) {
if (view == null) {
continue;
}
final ICDoc layoutControl = view.getLayoutControl(); final ICDoc layoutControl = view.getLayoutControl();
layoutControl.initialize(); layoutControl.initialize();
layoutControl.update(); layoutControl.update();