[Mobile] Preferred Art Options

This commit is contained in:
Anthony Calosa
2021-03-22 21:46:39 +08:00
parent 17352940ab
commit e4a0ce9165
14 changed files with 92 additions and 11 deletions

View File

@@ -54,6 +54,8 @@ public class StaticData {
private MulliganDefs.MulliganRule mulliganRule = MulliganDefs.getDefaultRule(); private MulliganDefs.MulliganRule mulliganRule = MulliganDefs.getDefaultRule();
private String prefferedArt;
// Loaded lazily: // Loaded lazily:
private IStorage<SealedProduct.Template> boosters; private IStorage<SealedProduct.Template> boosters;
private IStorage<SealedProduct.Template> specialBoosters; private IStorage<SealedProduct.Template> specialBoosters;
@@ -64,17 +66,18 @@ public class StaticData {
private static StaticData lastInstance = null; private static StaticData lastInstance = null;
public StaticData(CardStorageReader cardReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, boolean enableUnknownCards, boolean loadNonLegalCards) { public StaticData(CardStorageReader cardReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String prefferedArt, boolean enableUnknownCards, boolean loadNonLegalCards) {
this(cardReader, null, customCardReader, editionFolder, customEditionsFolder, blockDataFolder, enableUnknownCards, loadNonLegalCards); this(cardReader, null, customCardReader, editionFolder, customEditionsFolder, blockDataFolder, prefferedArt, enableUnknownCards, loadNonLegalCards);
} }
public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, boolean enableUnknownCards, boolean loadNonLegalCards) { public StaticData(CardStorageReader cardReader, CardStorageReader tokenReader, CardStorageReader customCardReader, String editionFolder, String customEditionsFolder, String blockDataFolder, String prefferedArt, boolean enableUnknownCards, boolean loadNonLegalCards) {
this.cardReader = cardReader; this.cardReader = cardReader;
this.tokenReader = tokenReader; this.tokenReader = tokenReader;
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder))); this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder)));
this.blockDataFolder = blockDataFolder; this.blockDataFolder = blockDataFolder;
this.customCardReader = customCardReader; this.customCardReader = customCardReader;
this.customEditions = new CardEdition.Collection(new CardEdition.Reader(new File(customEditionsFolder))); this.customEditions = new CardEdition.Collection(new CardEdition.Reader(new File(customEditionsFolder)));
this.prefferedArt = prefferedArt;
lastInstance = this; lastInstance = this;
{ {
@@ -275,6 +278,8 @@ public class StaticData {
public Predicate<PaperCard> getBrawlPredicate() { return brawlPredicate; } public Predicate<PaperCard> getBrawlPredicate() { return brawlPredicate; }
public String getPrefferedArtOption() { return prefferedArt; }
public void setFilteredHandsEnabled(boolean filteredHandsEnabled){ public void setFilteredHandsEnabled(boolean filteredHandsEnabled){
this.filteredHandsEnabled = filteredHandsEnabled; this.filteredHandsEnabled = filteredHandsEnabled;
} }
@@ -333,6 +338,30 @@ public class StaticData {
return card; return card;
} }
public PaperCard getCardFromEarliestCoreExp(PaperCard card) {
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.EarliestCoreExp, card.getArtIndex());
if (null != c && c.hasImage()) {
return c;
}
c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.EarliestCoreExp, -1);
if (null != c && c.hasImage()) {
return c;
}
c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.Earliest, -1);
if (null != c) {
return c;
}
// I give up!
return card;
}
public boolean getFilteredHandsEnabled(){ public boolean getFilteredHandsEnabled(){
return filteredHandsEnabled; return filteredHandsEnabled;
} }

View File

@@ -31,6 +31,7 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import forge.StaticData;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@@ -414,8 +415,9 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
} }
@Override @Override
public PaperCard getCardFromEdition(final String cardName, final Date printedBefore, final SetPreference fromSet, int artIndex) { public PaperCard getCardFromEdition(final String cardName, final Date printedBefore, final SetPreference fromSets, int artIndex) {
final CardRequest cr = CardRequest.fromString(cardName); final CardRequest cr = CardRequest.fromString(cardName);
SetPreference fromSet = fromSets;
List<PaperCard> cards = getAllCards(cr.cardName); List<PaperCard> cards = getAllCards(cr.cardName);
if (printedBefore != null){ if (printedBefore != null){
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() { cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
@@ -429,6 +431,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
return null; return null;
boolean cardsListReadOnly = true; boolean cardsListReadOnly = true;
//overrides
if (StaticData.instance().getPrefferedArtOption().equals("Earliest"))
fromSet = SetPreference.EarliestCoreExp;
if (StringUtils.isNotBlank(cr.edition)) { if (StringUtils.isNotBlank(cr.edition)) {
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() { cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
@Override public boolean apply(PaperCard input) { return input.getEdition().equalsIgnoreCase(cr.edition); } @Override public boolean apply(PaperCard input) { return input.getEdition().equalsIgnoreCase(cr.edition); }

View File

@@ -19,6 +19,7 @@ package forge.deck;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -259,7 +260,8 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
} }
private void convertByXitaxMethod() { private void convertByXitaxMethod() {
//Date dateWithAllCards = StaticData.instance().getEditions().getEarliestDateWithAllCards(getAllCardsInASinglePool()); Date dateWithAllCards = StaticData.instance().getEditions().getEarliestDateWithAllCards(getAllCardsInASinglePool());
String artOption = StaticData.instance().getPrefferedArtOption();
for(Entry<DeckSection, CardPool> p : parts.entrySet()) { for(Entry<DeckSection, CardPool> p : parts.entrySet()) {
if( p.getKey() == DeckSection.Planes || p.getKey() == DeckSection.Schemes || p.getKey() == DeckSection.Avatar) if( p.getKey() == DeckSection.Planes || p.getKey() == DeckSection.Schemes || p.getKey() == DeckSection.Avatar)
@@ -271,7 +273,17 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
PaperCard card = cp.getKey(); PaperCard card = cp.getKey();
int count = cp.getValue(); int count = cp.getValue();
PaperCard replacementCard = StaticData.instance().getCardFromLatestorEarliest(card); PaperCard replacementCard;
switch (artOption) {
case "Latest":
replacementCard = StaticData.instance().getCardFromLatestorEarliest(card);
break;
case "Earliest":
replacementCard = StaticData.instance().getCardFromEarliestCoreExp(card);
break;
default:
replacementCard = StaticData.instance().getCardByEditionDate(card, dateWithAllCards);
}
if (replacementCard.getArtIndex() == card.getArtIndex()) { if (replacementCard.getArtIndex() == card.getArtIndex()) {
if (card.hasImage()) if (card.hasImage())

View File

@@ -30,7 +30,7 @@ public class CardDatabaseHelper {
private static void initialize() { private static void initialize() {
final CardStorageReader reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, null, FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY)); final CardStorageReader reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, null, FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY));
final CardStorageReader customReader = new CardStorageReader(ForgeConstants.USER_CUSTOM_CARDS_DIR, null, FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY)); final CardStorageReader customReader = new CardStorageReader(ForgeConstants.USER_CUSTOM_CARDS_DIR, null, FModel.getPreferences().getPrefBoolean(FPref.LOAD_CARD_SCRIPTS_LAZILY));
staticData = new StaticData(reader, customReader, ForgeConstants.EDITIONS_DIR, ForgeConstants.USER_CUSTOM_EDITIONS_DIR ,ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS)); staticData = new StaticData(reader, customReader, ForgeConstants.EDITIONS_DIR, ForgeConstants.USER_CUSTOM_EDITIONS_DIR ,ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPref(FPref.UI_PREFERRED_ART), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS));
} }
private static boolean hasBeenInitialized() { private static boolean hasBeenInitialized() {

View File

@@ -239,9 +239,7 @@ public class MatchController extends AbstractGuiGame {
}; };
try { try {
phaseGameState.initFromGame(getGameView().getGame()); phaseGameState.initFromGame(getGameView().getGame());
} catch (Exception e) { } catch (Exception e) {}
System.out.println(phaseGameState);
}
} }
} }

View File

@@ -396,6 +396,29 @@ public class SettingsPage extends TabPage<SettingsScreen> {
localizer.getMessage("cbImageFetcher"), localizer.getMessage("cbImageFetcher"),
localizer.getMessage("nlImageFetcher")), localizer.getMessage("nlImageFetcher")),
4); 4);
lstSettings.addItem(new CustomSelectSetting(FPref.UI_PREFERRED_ART,
localizer.getMessage("lblPreferredArt"),
localizer.getMessage("nlPreferredArt"),
new String[]{"Latest", "Earliest", "Default"}) {
@Override
public void valueChanged(String newValue) {
super.valueChanged(newValue);
FOptionPane.showConfirmDialog (
localizer.getMessage("lblRestartForgeDescription"),
localizer.getMessage("lblRestartForge"),
localizer.getMessage("lblRestart"),
localizer.getMessage("lblLater"), new Callback<Boolean>() {
@Override
public void run(Boolean result) {
if (result) {
Forge.restart(true);
}
}
}
);
}
},
4);
lstSettings.addItem(new BooleanSetting(FPref.UI_OVERLAY_FOIL_EFFECT, lstSettings.addItem(new BooleanSetting(FPref.UI_OVERLAY_FOIL_EFFECT,
localizer.getMessage("cbDisplayFoil"), localizer.getMessage("cbDisplayFoil"),
localizer.getMessage("nlDisplayFoil")), localizer.getMessage("nlDisplayFoil")),

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=Markeranzeige Ort
cbpGraveyardOrdering=Genaue Reihenfolge im Friedhof einhalten cbpGraveyardOrdering=Genaue Reihenfolge im Friedhof einhalten
lblAltLifeDisplay=Alternatives Spieler-Layout (Landscape-Modus) lblAltLifeDisplay=Alternatives Spieler-Layout (Landscape-Modus)
nlAltLifeDisplay=Alternative Anzeige von Lebens-, Gift-, Energie- und Erfahrungspunkten. nlAltLifeDisplay=Alternative Anzeige von Lebens-, Gift-, Energie- und Erfahrungspunkten.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=Fehlerbehebung Troubleshooting=Fehlerbehebung
GeneralConfiguration=Allgemeine Einstellungen GeneralConfiguration=Allgemeine Einstellungen
lblPlayerName=Spielername lblPlayerName=Spielername

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=Counter Display Location
cbpGraveyardOrdering=Allow Ordering Cards Put in Graveyard cbpGraveyardOrdering=Allow Ordering Cards Put in Graveyard
lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) lblAltLifeDisplay=Alternate Player Layout (Landscape Mode)
nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards (RESTART REQUIRED).
Troubleshooting=Troubleshooting Troubleshooting=Troubleshooting
GeneralConfiguration=General Configuration GeneralConfiguration=General Configuration
lblPlayerName=Player Name lblPlayerName=Player Name

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=Ubicación del contador
cbpGraveyardOrdering=Permitir ordenar cartas puestas en el cementerio cbpGraveyardOrdering=Permitir ordenar cartas puestas en el cementerio
lblAltLifeDisplay=Diseño alternativo de jugador (Modo apaisado) lblAltLifeDisplay=Diseño alternativo de jugador (Modo apaisado)
nlAltLifeDisplay=Permite un diseño alternativo para mostrar los contadores de vida, veneno, energía y experiencia. nlAltLifeDisplay=Permite un diseño alternativo para mostrar los contadores de vida, veneno, energía y experiencia.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=Solución de problemas Troubleshooting=Solución de problemas
GeneralConfiguration=Configuración general GeneralConfiguration=Configuración general
lblPlayerName=Nombre Jugador lblPlayerName=Nombre Jugador

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=Posizione display contatore
cbpGraveyardOrdering=Consenti l''ordinazione di carte messe nel cimitero cbpGraveyardOrdering=Consenti l''ordinazione di carte messe nel cimitero
lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) lblAltLifeDisplay=Alternate Player Layout (Landscape Mode)
nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=Risoluzione dei problemi Troubleshooting=Risoluzione dei problemi
GeneralConfiguration=Configurazione generale GeneralConfiguration=Configurazione generale
lblPlayerName=Nome del giocatore lblPlayerName=Nome del giocatore

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=カウンター表示場所
cbpGraveyardOrdering=墓地に置かれるカードの順番指定を許可する cbpGraveyardOrdering=墓地に置かれるカードの順番指定を許可する
lblAltLifeDisplay=代替のプレイヤーレイアウト(ランドスケープモード時) lblAltLifeDisplay=代替のプレイヤーレイアウト(ランドスケープモード時)
nlAltLifeDisplay=代替のレイアウトでプレイヤーライフ、毒、エネルギーと経験カウンターを表示する nlAltLifeDisplay=代替のレイアウトでプレイヤーライフ、毒、エネルギーと経験カウンターを表示する
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=トラブルシューティング Troubleshooting=トラブルシューティング
GeneralConfiguration=一般設定 GeneralConfiguration=一般設定
lblPlayerName=プレイヤー名 lblPlayerName=プレイヤー名

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=计数器显示区域
cbpGraveyardOrdering=允许指衍生物进入墓地 cbpGraveyardOrdering=允许指衍生物进入墓地
lblAltLifeDisplay=备用牌手布局(横向模式) lblAltLifeDisplay=备用牌手布局(横向模式)
nlAltLifeDisplay=启用备用牌手布局以显示玩家的生命以及中毒,能量和经验指示物。 nlAltLifeDisplay=启用备用牌手布局以显示玩家的生命以及中毒,能量和经验指示物。
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=故障排除 Troubleshooting=故障排除
GeneralConfiguration=常规配置 GeneralConfiguration=常规配置
lblPlayerName=玩家名称 lblPlayerName=玩家名称

View File

@@ -81,6 +81,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
UI_OVERLAY_CARD_ID ("true"), UI_OVERLAY_CARD_ID ("true"),
UI_OVERLAY_ABILITY_ICONS("true"), UI_OVERLAY_ABILITY_ICONS("true"),
UI_ENABLE_ONLINE_IMAGE_FETCHER ("false"), UI_ENABLE_ONLINE_IMAGE_FETCHER ("false"),
UI_PREFERRED_ART ("Latest"),
UI_DISABLE_CARD_IMAGES ("false"), UI_DISABLE_CARD_IMAGES ("false"),
UI_IMAGE_CACHE_MAXIMUM("400"), UI_IMAGE_CACHE_MAXIMUM("400"),
UI_OVERLAY_FOIL_EFFECT ("true"), UI_OVERLAY_FOIL_EFFECT ("true"),

View File

@@ -183,7 +183,7 @@ public final class FModel {
} catch (Exception e) { } catch (Exception e) {
customReader = null; customReader = null;
} }
magicDb = new StaticData(reader, tokenReader, customReader, ForgeConstants.EDITIONS_DIR, ForgeConstants.USER_CUSTOM_EDITIONS_DIR,ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS)); magicDb = new StaticData(reader, tokenReader, customReader, ForgeConstants.EDITIONS_DIR, ForgeConstants.USER_CUSTOM_EDITIONS_DIR,ForgeConstants.BLOCK_DATA_DIR, FModel.getPreferences().getPref(FPref.UI_PREFERRED_ART), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_UNKNOWN_CARDS), FModel.getPreferences().getPrefBoolean(FPref.UI_LOAD_NONLEGAL_CARDS));
CardTranslation.preloadTranslation(preferences.getPref(FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR); CardTranslation.preloadTranslation(preferences.getPref(FPref.UI_LANGUAGE), ForgeConstants.LANG_DIR);
//create profile dirs if they don't already exist //create profile dirs if they don't already exist