applied auto fix layout to deck editor

This commit is contained in:
Maxmtg
2013-06-21 01:06:25 +00:00
parent 8a50df0e06
commit 775588b300
7 changed files with 38 additions and 32 deletions

View File

@@ -264,6 +264,18 @@ public enum FControl {
}
}
public void changeStateAutoFixLayout(Screens newState, String stateName) {
try {
changeState(newState);
} catch (InvalidLayoutFileException ex) {
GuiDialog.message("Your " + stateName + " layout file could not be read. It will be deleted after you press OK.\nThe game will proceed with default layout.");
File fLayout = new File(SLayoutIO.getFilePreferred(newState));
fLayout.delete();
// try again
changeState(newState);
}
}
/**
* Returns the int reflecting the current state of the top level frame
* (see field definitions and class methods for details).
@@ -409,15 +421,7 @@ public enum FControl {
Singletons.getModel().getPreferences().actuateMatchPreferences();
try {
Singletons.getControl().changeState(Screens.MATCH_SCREEN);
} catch (InvalidLayoutFileException ex) {
GuiDialog.message("Your match layout file could not be read. It will be deleted after you press OK.\nThe game will proceed with default layout.");
File fLayout = new File(SLayoutIO.getFilePreferred(Screens.MATCH_SCREEN));
fLayout.delete();
// try again
Singletons.getControl().changeState(Screens.MATCH_SCREEN);
}
changeStateAutoFixLayout(Screens.MATCH_SCREEN, "match");
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
CMessage.SINGLETON_INSTANCE.getInputControl().setGame(game);

View File

@@ -66,7 +66,7 @@ public enum CHomeUI implements ICDoc {
VHomeUI.SINGLETON_INSTANCE.getLblEditor().setCommand(new Command() {
@Override
public void run() {
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_CONSTRUCTED);
Singletons.getControl().changeStateAutoFixLayout(FControl.Screens.DECK_EDITOR_CONSTRUCTED, "deck editor");
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(new CEditorConstructed());
}
});

View File

@@ -51,7 +51,7 @@ public enum CSubmenuQuestDecks implements ICDoc {
if (!SSubmenuQuestUtil.checkActiveQuest("Create a Deck.")) {
return;
}
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_QUEST);
Singletons.getControl().changeStateAutoFixLayout(FControl.Screens.DECK_EDITOR_QUEST, "deck editor");
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(new CEditorQuest(Singletons.getModel().getQuest()));
}
});

View File

@@ -207,7 +207,7 @@ public enum CSubmenuSealed implements ICDoc {
final ACEditorBase<? extends InventoryItem, T> editor = (ACEditorBase<? extends InventoryItem, T>) new CEditorLimited(
Singletons.getModel().getDecks().getSealed());
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_LIMITED);
Singletons.getControl().changeStateAutoFixLayout(FControl.Screens.DECK_EDITOR_LIMITED, "deck editor");
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(editor);
editor.getDeckController().setModel((T) sealed);
}

View File

@@ -99,7 +99,7 @@ public enum CSubmenuArchenemy implements ICDoc {
}
};
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_CONSTRUCTED);
Singletons.getControl().changeStateAutoFixLayout(FControl.Screens.DECK_EDITOR_CONSTRUCTED, "deck editor");
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(
new CEditorVariant(Singletons.getModel().getDecks().getScheme(),predSchemes,EDocID.HOME_ARCHENEMY));
}

View File

@@ -93,7 +93,7 @@ public enum CSubmenuPlanechase implements ICDoc {
}
};
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_CONSTRUCTED);
Singletons.getControl().changeStateAutoFixLayout(FControl.Screens.DECK_EDITOR_CONSTRUCTED, "deck editor");
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(
new CEditorVariant(Singletons.getModel().getDecks().getPlane(), predPlanes, EDocID.HOME_PLANECHASE));
}

View File

@@ -45,10 +45,12 @@ import forge.deck.DeckBase;
import forge.deck.DeckSection;
import forge.game.GameType;
import forge.gui.deckeditor.CDeckEditorUI;
import forge.gui.deckeditor.controllers.ACEditorBase;
import forge.gui.deckeditor.controllers.CEditorConstructed;
import forge.gui.deckeditor.controllers.CEditorLimited;
import forge.gui.deckeditor.controllers.CEditorQuest;
import forge.gui.framework.ILocalRepaint;
import forge.item.InventoryItem;
/**
* Creates deck list for selected decks for quick deleting, editing, and basic
@@ -420,35 +422,35 @@ public class DeckLister extends JPanel implements ILocalRepaint {
}
}
private <T extends DeckBase> void editDeck(final Deck d0) {
ACEditorBase<? extends InventoryItem, ? extends DeckBase> editorCtrl = null;
FControl.Screens newState = null;
switch (this.gametype) {
case Quest:
final CEditorQuest qEditor = new CEditorQuest(Singletons.getModel().getQuest());
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_QUEST);
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(qEditor);
qEditor.getDeckController().load(d0.getName());
editorCtrl = new CEditorQuest(Singletons.getModel().getQuest());
newState = FControl.Screens.DECK_EDITOR_QUEST;
break;
case Constructed:
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_CONSTRUCTED);
final CEditorConstructed cEditor = new CEditorConstructed();
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(cEditor);
cEditor.getDeckController().load(d0.getName());
newState = FControl.Screens.DECK_EDITOR_CONSTRUCTED;
editorCtrl = new CEditorConstructed();
break;
case Sealed:
final CEditorLimited sEditor = new CEditorLimited(Singletons.getModel().getDecks().getSealed());
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_LIMITED);
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(sEditor);
sEditor.getDeckController().load(d0.getName());
editorCtrl = new CEditorLimited(Singletons.getModel().getDecks().getSealed());
newState = FControl.Screens.DECK_EDITOR_LIMITED;
break;
case Draft:
final CEditorLimited dEditor = new CEditorLimited(Singletons.getModel().getDecks().getDraft());
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_LIMITED);
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(dEditor);
dEditor.getDeckController().load(d0.getName());
editorCtrl = new CEditorLimited(Singletons.getModel().getDecks().getDraft());
newState = FControl.Screens.DECK_EDITOR_LIMITED;
break;
default:
break;
return;
}
Singletons.getControl().changeStateAutoFixLayout(newState, "deck editor");
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(editorCtrl);
editorCtrl.getDeckController().load(d0.getName());
}
private void deleteDeck(final RowPanel r0) {