mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Fix up some stuff around deck editing & loading for tiny leaders format.
This commit is contained in:
@@ -70,6 +70,15 @@ public class FScreen {
|
|||||||
"Close Editor",
|
"Close Editor",
|
||||||
ForgeConstants.EDITOR_LAYOUT_FILE,
|
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||||
false);
|
false);
|
||||||
|
public static final FScreen DECK_EDITOR_TINY_LEADERS = new FScreen(
|
||||||
|
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||||
|
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||||
|
"Tiny Leaders Deck Editor",
|
||||||
|
FSkin.getImage(FSkinProp.IMG_PACK),
|
||||||
|
true,
|
||||||
|
"Close Editor",
|
||||||
|
ForgeConstants.EDITOR_LAYOUT_FILE,
|
||||||
|
false);
|
||||||
public static final FScreen DECK_EDITOR_PLANECHASE = new FScreen(
|
public static final FScreen DECK_EDITOR_PLANECHASE = new FScreen(
|
||||||
VDeckEditorUI.SINGLETON_INSTANCE,
|
VDeckEditorUI.SINGLETON_INSTANCE,
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE,
|
CDeckEditorUI.SINGLETON_INSTANCE,
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public enum CCurrentDeck implements ICDoc {
|
|||||||
|
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
//BugReporter.reportException(ex);
|
//BugReporter.reportException(ex);
|
||||||
throw new RuntimeException("Error importing deck." + ex);
|
throw new RuntimeException("Error importing deck.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
|||||||
* all cards are available.
|
* all cards are available.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public CEditorCommander(final CDetailPicture cDetailPicture) {
|
public CEditorCommander(final CDetailPicture cDetailPicture, boolean tinyLeaders) {
|
||||||
super(FScreen.DECK_EDITOR_COMMANDER, cDetailPicture);
|
super(tinyLeaders ? FScreen.DECK_EDITOR_TINY_LEADERS : FScreen.DECK_EDITOR_COMMANDER, cDetailPicture);
|
||||||
allSections.add(DeckSection.Main);
|
allSections.add(DeckSection.Main);
|
||||||
allSections.add(DeckSection.Sideboard);
|
allSections.add(DeckSection.Sideboard);
|
||||||
allSections.add(DeckSection.Commander);
|
allSections.add(DeckSection.Commander);
|
||||||
@@ -89,7 +89,7 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
|||||||
return new Deck();
|
return new Deck();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.controller = new DeckController<Deck>(FModel.getDecks().getCommander(), this, newCreator);
|
this.controller = new DeckController<Deck>(tinyLeaders ? FModel.getDecks().getTinyLeaders() :FModel.getDecks().getCommander(), this, newCreator);
|
||||||
|
|
||||||
getBtnAddBasicLands().setCommand(new UiCommand() {
|
getBtnAddBasicLands().setCommand(new UiCommand() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,99 +25,43 @@ public class CLobby {
|
|||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addDecks(final Iterable<DeckProxy> commanderDecks, FList<Object> deckList, String... initialItems) {
|
||||||
|
Vector<Object> listData = new Vector<Object>();
|
||||||
|
for (String item : initialItems) {
|
||||||
|
listData.add(item);
|
||||||
|
}
|
||||||
|
listData.add("Generate");
|
||||||
|
if (!Iterables.isEmpty(commanderDecks)) {
|
||||||
|
listData.add("Random");
|
||||||
|
for (DeckProxy comDeck : commanderDecks) {
|
||||||
|
listData.add(comDeck.getDeck());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object val = deckList.getSelectedValue();
|
||||||
|
deckList.setListData(listData);
|
||||||
|
if (null != val) {
|
||||||
|
deckList.setSelectedValue(val, true);
|
||||||
|
}
|
||||||
|
if (-1 == deckList.getSelectedIndex()) {
|
||||||
|
deckList.setSelectedIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override public final void run() {
|
@Override public final void run() {
|
||||||
final Iterable<DeckProxy> commanderDecks = DeckProxy.getAllCommanderDecks();
|
final Iterable<DeckProxy> commanderDecks = DeckProxy.getAllCommanderDecks();
|
||||||
final Iterable<DeckProxy> tinyLeadersDecks = DeckProxy.getAllTinyLeadersDecks();
|
final Iterable<DeckProxy> tinyLeadersDecks = DeckProxy.getAllTinyLeadersDecks();
|
||||||
final Iterable<DeckProxy> planarDecks = DeckProxy.getAllPlanarDecks();
|
|
||||||
final Iterable<DeckProxy> schemeDecks = DeckProxy.getAllSchemeDecks();
|
final Iterable<DeckProxy> schemeDecks = DeckProxy.getAllSchemeDecks();
|
||||||
FList<Object> deckList;
|
final Iterable<DeckProxy> planarDecks = DeckProxy.getAllPlanarDecks();
|
||||||
Vector<Object> listData;
|
|
||||||
Object val;
|
|
||||||
|
|
||||||
for (int i = 0; i < VLobby.MAX_PLAYERS; i++) {
|
for (int i = 0; i < VLobby.MAX_PLAYERS; i++) {
|
||||||
// Commander: reinit deck list and restore last selections (if any)
|
addDecks(commanderDecks, view.getCommanderDeckLists().get(i));
|
||||||
deckList = view.getCommanderDeckLists().get(i);
|
addDecks(tinyLeadersDecks, view.getTinyLeadersDeckLists().get(i));
|
||||||
listData = new Vector<Object>();
|
addDecks(schemeDecks, view.getSchemeDeckLists().get(i),
|
||||||
listData.add("Generate");
|
"Use deck's scheme section (random if unavailable)");
|
||||||
if (!Iterables.isEmpty(commanderDecks)) {
|
addDecks(planarDecks, view.getPlanarDeckLists().get(i),
|
||||||
listData.add("Random");
|
"Use deck's planes section (random if unavailable)");
|
||||||
for (DeckProxy comDeck : commanderDecks) {
|
|
||||||
listData.add(comDeck.getDeck());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val = deckList.getSelectedValue();
|
|
||||||
deckList.setListData(listData);
|
|
||||||
if (null != val) {
|
|
||||||
deckList.setSelectedValue(val, true);
|
|
||||||
}
|
|
||||||
if (-1 == deckList.getSelectedIndex()) {
|
|
||||||
deckList.setSelectedIndex(0);
|
|
||||||
} // End Commander
|
|
||||||
|
|
||||||
// Tiny Leaders: reinit deck list and restore last selections (if any)
|
|
||||||
deckList = view.getTinyLeadersDeckLists().get(i);
|
|
||||||
listData = new Vector<Object>();
|
|
||||||
listData.add("Generate");
|
|
||||||
if (!Iterables.isEmpty(tinyLeadersDecks)) {
|
|
||||||
listData.add("Random");
|
|
||||||
for (DeckProxy tlDeck : tinyLeadersDecks) {
|
|
||||||
listData.add(tlDeck.getDeck());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val = deckList.getSelectedValue();
|
|
||||||
deckList.setListData(listData);
|
|
||||||
if (null != val) {
|
|
||||||
deckList.setSelectedValue(val, true);
|
|
||||||
}
|
|
||||||
if (-1 == deckList.getSelectedIndex()) {
|
|
||||||
deckList.setSelectedIndex(0);
|
|
||||||
} // Tiny Leaders
|
|
||||||
|
|
||||||
// Archenemy: reinit deck list and restore last selections (if any)
|
|
||||||
deckList = view.getSchemeDeckLists().get(i);
|
|
||||||
listData = new Vector<Object>();
|
|
||||||
listData.add("Use deck's scheme section (random if unavailable)");
|
|
||||||
listData.add("Generate");
|
|
||||||
if (!Iterables.isEmpty(schemeDecks)) {
|
|
||||||
listData.add("Random");
|
|
||||||
for (DeckProxy schemeDeck : schemeDecks) {
|
|
||||||
listData.add(schemeDeck.getDeck());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val = deckList.getSelectedValue();
|
|
||||||
deckList.setListData(listData);
|
|
||||||
if (null != val) {
|
|
||||||
deckList.setSelectedValue(val, true);
|
|
||||||
}
|
|
||||||
if (-1 == deckList.getSelectedIndex()) {
|
|
||||||
deckList.setSelectedIndex(0);
|
|
||||||
} // End Archenemy
|
|
||||||
|
|
||||||
// Planechase: reinit deck lists and restore last selections (if any)
|
|
||||||
deckList = view.getPlanarDeckLists().get(i);
|
|
||||||
listData = new Vector<Object>();
|
|
||||||
|
|
||||||
listData.add("Use deck's planes section (random if unavailable)");
|
|
||||||
listData.add("Generate");
|
|
||||||
if (!Iterables.isEmpty(planarDecks)) {
|
|
||||||
listData.add("Random");
|
|
||||||
for (DeckProxy planarDeck : planarDecks) {
|
|
||||||
listData.add(planarDeck.getDeck());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val = deckList.getSelectedValue();
|
|
||||||
deckList.setListData(listData);
|
|
||||||
if (null != val) {
|
|
||||||
deckList.setSelectedValue(val, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-1 == deckList.getSelectedIndex()) {
|
|
||||||
deckList.setSelectedIndex(0);
|
|
||||||
} // End Planechase
|
|
||||||
|
|
||||||
view.updateVanguardList(i);
|
view.updateVanguardList(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -492,9 +492,15 @@ public class PlayerPanel extends FPanel {
|
|||||||
cmdDeckEditor.setCommand(new UiCommand() {
|
cmdDeckEditor.setCommand(new UiCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
lobby.setCurrentGameMode(lobby.hasVariant(GameType.TinyLeaders) ? GameType.TinyLeaders : GameType.Commander);
|
if (lobby.hasVariant(GameType.TinyLeaders)) {
|
||||||
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_COMMANDER);
|
lobby.setCurrentGameMode(GameType.TinyLeaders);
|
||||||
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()));
|
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_TINY_LEADERS);
|
||||||
|
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), true));
|
||||||
|
} else {
|
||||||
|
lobby.setCurrentGameMode(GameType.Commander);
|
||||||
|
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_COMMANDER);
|
||||||
|
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ public class VLobby implements ILobbyView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Object selected = getCommanderDeckLists().get(playerIndex).getSelectedValue();
|
final Object selected = getTinyLeadersDeckLists().get(playerIndex).getSelectedValue();
|
||||||
Deck deck = null;
|
Deck deck = null;
|
||||||
if (selected instanceof String) {
|
if (selected instanceof String) {
|
||||||
if (selected.equals("Random")) {
|
if (selected.equals("Random")) {
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ public class DeckProxy implements InventoryItem {
|
|||||||
else {
|
else {
|
||||||
filter = Predicates.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(), filter);
|
filter = Predicates.and(DeckFormat.TinyLeaders.hasLegalCardsPredicate(), filter);
|
||||||
}
|
}
|
||||||
addDecksRecursivelly("Tiny Leaders", GameType.TinyLeaders, result, "", FModel.getDecks().getCommander(), filter);
|
addDecksRecursivelly("Tiny Leaders", GameType.TinyLeaders, result, "", FModel.getDecks().getTinyLeaders(), filter);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public class CardCollections {
|
|||||||
private final IStorage<Deck> scheme;
|
private final IStorage<Deck> scheme;
|
||||||
private final IStorage<Deck> plane;
|
private final IStorage<Deck> plane;
|
||||||
private final IStorage<Deck> commander;
|
private final IStorage<Deck> commander;
|
||||||
|
private final IStorage<Deck> tinyLeaders;
|
||||||
|
|
||||||
public CardCollections() {
|
public CardCollections() {
|
||||||
final StopWatch sw = new StopWatch();
|
final StopWatch sw = new StopWatch();
|
||||||
@@ -54,6 +55,7 @@ public class CardCollections {
|
|||||||
scheme = new StorageImmediatelySerialized<Deck> ("Archenemy decks", new DeckStorage(new File(ForgeConstants.DECK_SCHEME_DIR), ForgeConstants.DECK_BASE_DIR));
|
scheme = new StorageImmediatelySerialized<Deck> ("Archenemy decks", new DeckStorage(new File(ForgeConstants.DECK_SCHEME_DIR), ForgeConstants.DECK_BASE_DIR));
|
||||||
plane = new StorageImmediatelySerialized<Deck> ("Planechase decks", new DeckStorage(new File(ForgeConstants.DECK_PLANE_DIR), ForgeConstants.DECK_BASE_DIR));
|
plane = new StorageImmediatelySerialized<Deck> ("Planechase decks", new DeckStorage(new File(ForgeConstants.DECK_PLANE_DIR), ForgeConstants.DECK_BASE_DIR));
|
||||||
commander = new StorageImmediatelySerialized<Deck> ("Commander decks", new DeckStorage(new File(ForgeConstants.DECK_COMMANDER_DIR), ForgeConstants.DECK_BASE_DIR));
|
commander = new StorageImmediatelySerialized<Deck> ("Commander decks", new DeckStorage(new File(ForgeConstants.DECK_COMMANDER_DIR), ForgeConstants.DECK_BASE_DIR));
|
||||||
|
tinyLeaders = new StorageImmediatelySerialized<Deck> ("Tiny Leaders decks", new DeckStorage(new File(ForgeConstants.DECK_TINY_LEADERS_DIR), ForgeConstants.DECK_BASE_DIR));
|
||||||
sw.stop();
|
sw.stop();
|
||||||
System.out.printf("Read decks (%d ms): %d constructed, %d sealed, %d draft, %d cubes, %d scheme, %d planar, %d commander.%n", sw.getTime(), constructed.size(), sealed.size(), draft.size(), cube.size(), scheme.size(), plane.size(), commander.size());
|
System.out.printf("Read decks (%d ms): %d constructed, %d sealed, %d draft, %d cubes, %d scheme, %d planar, %d commander.%n", sw.getTime(), constructed.size(), sealed.size(), draft.size(), cube.size(), scheme.size(), plane.size(), commander.size());
|
||||||
}
|
}
|
||||||
@@ -89,4 +91,8 @@ public class CardCollections {
|
|||||||
public IStorage<Deck> getCommander() {
|
public IStorage<Deck> getCommander() {
|
||||||
return commander;
|
return commander;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IStorage<Deck> getTinyLeaders() {
|
||||||
|
return tinyLeaders;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ public final class ForgeConstants {
|
|||||||
public static final String DECK_NET_DIR = DECK_BASE_DIR + "net" + PATH_SEPARATOR;
|
public static final String DECK_NET_DIR = DECK_BASE_DIR + "net" + PATH_SEPARATOR;
|
||||||
public static final String QUEST_SAVE_DIR = USER_QUEST_DIR + "saves" + PATH_SEPARATOR;
|
public static final String QUEST_SAVE_DIR = USER_QUEST_DIR + "saves" + PATH_SEPARATOR;
|
||||||
public static final String CONQUEST_SAVE_DIR = USER_CONQUEST_DIR + "saves" + PATH_SEPARATOR;
|
public static final String CONQUEST_SAVE_DIR = USER_CONQUEST_DIR + "saves" + PATH_SEPARATOR;
|
||||||
|
public static final String DECK_TINY_LEADERS_DIR= DECK_BASE_DIR + "tiny_leaders" + PATH_SEPARATOR;
|
||||||
public static final String MAIN_PREFS_FILE = USER_PREFS_DIR + "forge.preferences";
|
public static final String MAIN_PREFS_FILE = USER_PREFS_DIR + "forge.preferences";
|
||||||
public static final String CARD_PREFS_FILE = USER_PREFS_DIR + "card.preferences";
|
public static final String CARD_PREFS_FILE = USER_PREFS_DIR + "card.preferences";
|
||||||
public static final String DECK_PREFS_FILE = USER_PREFS_DIR + "deck.preferences";
|
public static final String DECK_PREFS_FILE = USER_PREFS_DIR + "deck.preferences";
|
||||||
|
|||||||
Reference in New Issue
Block a user