mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Fix issue with saving draft decks and saving after renaming deck
Version bump to 1.5.20.004
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<packaging.type>jar</packaging.type>
|
<packaging.type>jar</packaging.type>
|
||||||
<build.min.memory>-Xms128m</build.min.memory>
|
<build.min.memory>-Xms128m</build.min.memory>
|
||||||
<build.max.memory>-Xmx2048m</build.max.memory>
|
<build.max.memory>-Xmx2048m</build.max.memory>
|
||||||
<alpha-version>1.5.20.003</alpha-version>
|
<alpha-version>1.5.20.004</alpha-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import forge.util.FileUtil;
|
|||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class Forge implements ApplicationListener {
|
public class Forge implements ApplicationListener {
|
||||||
public static final String CURRENT_VERSION = "1.5.20.003";
|
public static final String CURRENT_VERSION = "1.5.20.004";
|
||||||
|
|
||||||
private static final ApplicationListener app = new Forge();
|
private static final ApplicationListener app = new Forge();
|
||||||
private static Clipboard clipboard;
|
private static Clipboard clipboard;
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
editorType.getController().editor = this;
|
editorType.getController().editor = this;
|
||||||
|
|
||||||
if (StringUtils.isEmpty(editDeckName)) {
|
if (StringUtils.isEmpty(editDeckName)) {
|
||||||
deck = new Deck();
|
setDeck(new Deck());
|
||||||
if (editorType == EditorType.Draft) {
|
if (editorType == EditorType.Draft) {
|
||||||
//hide deck header on while drafting
|
//hide deck header on while drafting
|
||||||
deckHeader.setVisible(false);
|
deckHeader.setVisible(false);
|
||||||
@@ -186,7 +186,6 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
tabPages[0].hideTab(); //hide Draft Pack page if editing existing draft deck
|
tabPages[0].hideTab(); //hide Draft Pack page if editing existing draft deck
|
||||||
}
|
}
|
||||||
editorType.getController().load(editDeckPath, editDeckName);
|
editorType.getController().load(editDeckPath, editDeckName);
|
||||||
deck = editorType.getController().getDeck();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btnSave.setCommand(new FEventHandler() {
|
btnSave.setCommand(new FEventHandler() {
|
||||||
@@ -259,9 +258,8 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//cache specific pages and initialize all pages after fields set
|
//cache specific pages
|
||||||
for (int i = 0; i < tabPages.length; i++) {
|
for (TabPage<FDeckEditor> tabPage : tabPages) {
|
||||||
DeckEditorPage tabPage = (DeckEditorPage) tabPages[i];
|
|
||||||
if (tabPage instanceof CatalogPage) {
|
if (tabPage instanceof CatalogPage) {
|
||||||
catalogPage = (CatalogPage) tabPage;
|
catalogPage = (CatalogPage) tabPage;
|
||||||
}
|
}
|
||||||
@@ -274,7 +272,6 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
sideboardPage = deckSectionPage;
|
sideboardPage = deckSectionPage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tabPage.initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//if opening brand new sealed deck, show sideboard (card pool) by default
|
//if opening brand new sealed deck, show sideboard (card pool) by default
|
||||||
@@ -299,6 +296,15 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
public Deck getDeck() {
|
public Deck getDeck() {
|
||||||
return deck;
|
return deck;
|
||||||
}
|
}
|
||||||
|
public void setDeck(Deck deck0) {
|
||||||
|
if (deck == deck0) { return; }
|
||||||
|
deck = deck0;
|
||||||
|
|
||||||
|
//reinitialize tab pages when deck changes
|
||||||
|
for (TabPage<FDeckEditor> tabPage : tabPages) {
|
||||||
|
((DeckEditorPage)tabPage).initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected CatalogPage getCatalogPage() {
|
protected CatalogPage getCatalogPage() {
|
||||||
return catalogPage;
|
return catalogPage;
|
||||||
@@ -317,56 +323,23 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void save(final Callback<Boolean> callback) {
|
protected void save(final Callback<Boolean> callback) {
|
||||||
final DeckController<?> controller = editorType.getController();
|
if (StringUtils.isEmpty(deck.getName())) {
|
||||||
final String name = deck.getName();
|
FOptionPane.showInputDialog("Enter name for new deck:", "New Deck", new Callback<String>() {
|
||||||
|
@Override
|
||||||
// Warn if no name
|
public void run(String result) {
|
||||||
if (StringUtils.isEmpty(name)) {
|
editorType.getController().saveAs(result);
|
||||||
FOptionPane.showErrorDialog("Please name your deck using the 'Name' box.", "Save Error!");
|
if (callback != null) {
|
||||||
if (callback != null) {
|
callback.run(true);
|
||||||
callback.run(false);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Confirm if overwrite
|
|
||||||
if (controller.fileExists(name)) {
|
|
||||||
//prompt only if name was changed
|
|
||||||
if (!StringUtils.equals(name, controller.getModelName())) {
|
|
||||||
FOptionPane.showConfirmDialog("There is already a deck named '" + name + "'. Overwrite?",
|
|
||||||
"Overwrite Deck?", new Callback<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public void run(Boolean result) {
|
|
||||||
if (result) {
|
|
||||||
controller.save();
|
|
||||||
}
|
|
||||||
if (callback != null) {
|
|
||||||
callback.run(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
controller.save();
|
|
||||||
if (callback != null) {
|
|
||||||
callback.run(true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Confirm if a new deck will be created
|
|
||||||
FOptionPane.showConfirmDialog("This will create a new deck named '" +
|
|
||||||
name + "'. Continue?", "Create Deck?", new Callback<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public void run(Boolean result) {
|
|
||||||
if (result) {
|
|
||||||
controller.saveAs(name);
|
|
||||||
}
|
|
||||||
if (callback != null) {
|
|
||||||
callback.run(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
editorType.getController().save();
|
||||||
|
if (callback != null) {
|
||||||
|
callback.run(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -472,6 +445,8 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static class CatalogPage extends CardManagerPage {
|
protected static class CatalogPage extends CardManagerPage {
|
||||||
|
private boolean initialized;
|
||||||
|
|
||||||
protected CatalogPage() {
|
protected CatalogPage() {
|
||||||
this(ItemManagerConfig.CARD_CATALOG, "Catalog", FSkinImage.FOLDER);
|
this(ItemManagerConfig.CARD_CATALOG, "Catalog", FSkinImage.FOLDER);
|
||||||
}
|
}
|
||||||
@@ -481,6 +456,9 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
|
if (initialized) { return; } //prevent initializing more than once if deck changes
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
cardManager.setCaption(getItemManagerCaption());
|
cardManager.setCaption(getItemManagerCaption());
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@@ -680,6 +658,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
modelPath = "";
|
modelPath = "";
|
||||||
setSaved(true);
|
setSaved(true);
|
||||||
}
|
}
|
||||||
|
editor.setDeck(getDeck());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isModelInSyncWithFolder() {
|
private boolean isModelInSyncWithFolder() {
|
||||||
@@ -776,7 +755,7 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
editor.deck = getDeck();
|
editor.setDeck(getDeck());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
Reference in New Issue
Block a user