mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
applied auto fix layout to deck editor
This commit is contained in:
@@ -263,6 +263,18 @@ public enum FControl {
|
|||||||
throw new RuntimeException("unhandled screen: " + screen);
|
throw new RuntimeException("unhandled screen: " + screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
* Returns the int reflecting the current state of the top level frame
|
||||||
@@ -409,15 +421,7 @@ public enum FControl {
|
|||||||
|
|
||||||
Singletons.getModel().getPreferences().actuateMatchPreferences();
|
Singletons.getModel().getPreferences().actuateMatchPreferences();
|
||||||
|
|
||||||
try {
|
changeStateAutoFixLayout(Screens.MATCH_SCREEN, "match");
|
||||||
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);
|
|
||||||
}
|
|
||||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||||
|
|
||||||
CMessage.SINGLETON_INSTANCE.getInputControl().setGame(game);
|
CMessage.SINGLETON_INSTANCE.getInputControl().setGame(game);
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public enum CHomeUI implements ICDoc {
|
|||||||
VHomeUI.SINGLETON_INSTANCE.getLblEditor().setCommand(new Command() {
|
VHomeUI.SINGLETON_INSTANCE.getLblEditor().setCommand(new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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());
|
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(new CEditorConstructed());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public enum CSubmenuQuestDecks implements ICDoc {
|
|||||||
if (!SSubmenuQuestUtil.checkActiveQuest("Create a Deck.")) {
|
if (!SSubmenuQuestUtil.checkActiveQuest("Create a Deck.")) {
|
||||||
return;
|
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()));
|
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(new CEditorQuest(Singletons.getModel().getQuest()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ public enum CSubmenuSealed implements ICDoc {
|
|||||||
final ACEditorBase<? extends InventoryItem, T> editor = (ACEditorBase<? extends InventoryItem, T>) new CEditorLimited(
|
final ACEditorBase<? extends InventoryItem, T> editor = (ACEditorBase<? extends InventoryItem, T>) new CEditorLimited(
|
||||||
Singletons.getModel().getDecks().getSealed());
|
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);
|
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(editor);
|
||||||
editor.getDeckController().setModel((T) sealed);
|
editor.getDeckController().setModel((T) sealed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(
|
||||||
new CEditorVariant(Singletons.getModel().getDecks().getScheme(),predSchemes,EDocID.HOME_ARCHENEMY));
|
new CEditorVariant(Singletons.getModel().getDecks().getScheme(),predSchemes,EDocID.HOME_ARCHENEMY));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(
|
||||||
new CEditorVariant(Singletons.getModel().getDecks().getPlane(), predPlanes, EDocID.HOME_PLANECHASE));
|
new CEditorVariant(Singletons.getModel().getDecks().getPlane(), predPlanes, EDocID.HOME_PLANECHASE));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,10 +45,12 @@ import forge.deck.DeckBase;
|
|||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
import forge.gui.deckeditor.CDeckEditorUI;
|
import forge.gui.deckeditor.CDeckEditorUI;
|
||||||
|
import forge.gui.deckeditor.controllers.ACEditorBase;
|
||||||
import forge.gui.deckeditor.controllers.CEditorConstructed;
|
import forge.gui.deckeditor.controllers.CEditorConstructed;
|
||||||
import forge.gui.deckeditor.controllers.CEditorLimited;
|
import forge.gui.deckeditor.controllers.CEditorLimited;
|
||||||
import forge.gui.deckeditor.controllers.CEditorQuest;
|
import forge.gui.deckeditor.controllers.CEditorQuest;
|
||||||
import forge.gui.framework.ILocalRepaint;
|
import forge.gui.framework.ILocalRepaint;
|
||||||
|
import forge.item.InventoryItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates deck list for selected decks for quick deleting, editing, and basic
|
* 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) {
|
private <T extends DeckBase> void editDeck(final Deck d0) {
|
||||||
|
|
||||||
|
ACEditorBase<? extends InventoryItem, ? extends DeckBase> editorCtrl = null;
|
||||||
|
FControl.Screens newState = null;
|
||||||
|
|
||||||
switch (this.gametype) {
|
switch (this.gametype) {
|
||||||
case Quest:
|
case Quest:
|
||||||
final CEditorQuest qEditor = new CEditorQuest(Singletons.getModel().getQuest());
|
editorCtrl = new CEditorQuest(Singletons.getModel().getQuest());
|
||||||
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_QUEST);
|
newState = FControl.Screens.DECK_EDITOR_QUEST;
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(qEditor);
|
|
||||||
qEditor.getDeckController().load(d0.getName());
|
|
||||||
break;
|
break;
|
||||||
case Constructed:
|
case Constructed:
|
||||||
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_CONSTRUCTED);
|
newState = FControl.Screens.DECK_EDITOR_CONSTRUCTED;
|
||||||
final CEditorConstructed cEditor = new CEditorConstructed();
|
editorCtrl = new CEditorConstructed();
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(cEditor);
|
|
||||||
cEditor.getDeckController().load(d0.getName());
|
|
||||||
break;
|
break;
|
||||||
case Sealed:
|
case Sealed:
|
||||||
final CEditorLimited sEditor = new CEditorLimited(Singletons.getModel().getDecks().getSealed());
|
editorCtrl = new CEditorLimited(Singletons.getModel().getDecks().getSealed());
|
||||||
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_LIMITED);
|
newState = FControl.Screens.DECK_EDITOR_LIMITED;
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(sEditor);
|
|
||||||
sEditor.getDeckController().load(d0.getName());
|
|
||||||
break;
|
break;
|
||||||
case Draft:
|
case Draft:
|
||||||
final CEditorLimited dEditor = new CEditorLimited(Singletons.getModel().getDecks().getDraft());
|
editorCtrl = new CEditorLimited(Singletons.getModel().getDecks().getDraft());
|
||||||
Singletons.getControl().changeState(FControl.Screens.DECK_EDITOR_LIMITED);
|
newState = FControl.Screens.DECK_EDITOR_LIMITED;
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(dEditor);
|
|
||||||
dEditor.getDeckController().load(d0.getName());
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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) {
|
private void deleteDeck(final RowPanel r0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user