Moves "Current_Deck" from Quest Preferences to Quest Data.

Without this, the selected deck name was global for all quests - switching to another quest retained the deck name from the previous quest
and if the new quest had a deck with the identical name, selected that one, otherwise selected nothing. (in one weird case, this resulted in quest data that crashed caused bugs when loading forge - as quest was saved with a selected deck from another quest data.)
Preferred behavior is to select the deck that was last selected in THAT QUEST when switching to another quest.
This commit is contained in:
Seravy
2018-02-13 01:32:18 +01:00
parent 67e8046af6
commit 56983b2553
8 changed files with 26 additions and 11 deletions

View File

@@ -577,4 +577,12 @@ public class QuestController {
CardEdition randomLandSet = CardEdition.Predicates.getRandomSetWithAllBasicLands(availableEditions);
return randomLandSet == null ? FModel.getMagicDb().getEditions().get("ZEN") : randomLandSet;
}
public String getCurrentDeck() {
return model.currentDeck;
}
public void setCurrentDeck(String s) {
model.currentDeck = s;
}
}

View File

@@ -443,7 +443,7 @@ public class QuestUtil {
if (FModel.getQuest().getAssets() != null) {
d = FModel.getQuest().getMyDecks().get(
FModel.getQuestPreferences().getPref(QPref.CURRENT_DECK));
FModel.getQuest().getCurrentDeck());
}
return d;

View File

@@ -42,7 +42,7 @@ import java.util.Map;
*/
public final class QuestData {
/** Holds the latest version of the Quest Data. */
public static final int CURRENT_VERSION_NUMBER = 11;
public static final int CURRENT_VERSION_NUMBER = 12;
// This field places the version number into QD instance,
// but only when the object is created through the constructor
@@ -68,6 +68,8 @@ public final class QuestData {
public HashSet<StarRating> Ratings = new HashSet<StarRating>();
public String currentDeck = "DEFAULT";
public QuestData() { //needed for XML serialization
}

View File

@@ -17,6 +17,7 @@
*/
package forge.quest.io;
import forge.quest.data.QuestPreferences.QPref;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
@@ -201,6 +202,10 @@ public class QuestDataIO {
newData.Ratings.clear();
}
if (saveVersion < 12) {
// Current Deck moved from preferences to quest data - it should not be global for all quests!!!
QuestDataIO.setFinalField(QuestData.class, "currentDeck", newData, FModel.getQuestPreferences().getPref(QPref.CURRENT_DECK));
}
if (saveVersion < 13) {
// Migrate DraftTournaments to use new Tournament class
}