Merge pull request #8750 from kevlahnota/master4

update FModel, add Icon Overlay for Horizontal tabs
This commit is contained in:
kevlahnota
2025-09-19 22:58:47 +08:00
committed by GitHub
2 changed files with 117 additions and 94 deletions

View File

@@ -498,6 +498,24 @@ public class VPlayerPanel extends FContainer {
} }
} }
@Override
protected void drawOverlay(Graphics g) {
if (Forge.isHorizontalTabLayout()) {
InfoTab infoTab = selectedTab;
if (infoTab != null) {
VDisplayArea selectedDisplayArea = infoTab.getDisplayArea();
if (selectedDisplayArea != null && selectedDisplayArea.getCount() > 0) {
float scale = avatarWidth / 2f;
float x = selectedDisplayArea.getLeft();
float y = selectedDisplayArea.getBottom() - scale;
g.fillRect(getAltDisplayAreaBackColor(), x, y, scale, scale);
infoTab.icon.draw(g, x, y, scale, scale);
}
}
}
super.drawOverlay(g);
}
@Override @Override
public void drawBackground(Graphics g) { public void drawBackground(Graphics g) {
float y; float y;
@@ -1069,6 +1087,11 @@ public class VPlayerPanel extends FContainer {
@Override @Override
public float getIdealWidth(float pref) { public float getIdealWidth(float pref) {
if (getDisplayArea() instanceof VCardDisplayArea vCardDisplayArea) {
float cardWidth = vCardDisplayArea.getCardWidth(vCardDisplayArea.getHeight());
float size = vCardDisplayArea.getCount();
return Math.min(cardWidth * size, pref);
}
return pref; return pref;
} }

View File

@@ -198,15 +198,12 @@ public final class FModel {
ForgePreferences.DEV_MODE = preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED); ForgePreferences.DEV_MODE = preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED);
ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN; ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN;
formats = new GameFormat.Collection(new GameFormat.Reader( new File(ForgeConstants.FORMATS_DATA_DIR), magicDb.setStandardPredicate(getFormats().getStandard().getFilterRules());
new File(ForgeConstants.USER_FORMATS_DIR), preferences.getPrefBoolean(FPref.LOAD_ARCHIVED_FORMATS))); magicDb.setPioneerPredicate(getFormats().getPioneer().getFilterRules());
magicDb.setModernPredicate(getFormats().getModern().getFilterRules());
magicDb.setStandardPredicate(formats.getStandard().getFilterRules()); magicDb.setCommanderPredicate(getFormats().get("Commander").getFilterRules());
magicDb.setPioneerPredicate(formats.getPioneer().getFilterRules()); magicDb.setOathbreakerPredicate(getFormats().get("Oathbreaker").getFilterRules());
magicDb.setModernPredicate(formats.getModern().getFilterRules()); magicDb.setBrawlPredicate(getFormats().get("Brawl").getFilterRules());
magicDb.setCommanderPredicate(formats.get("Commander").getFilterRules());
magicDb.setOathbreakerPredicate(formats.get("Oathbreaker").getFilterRules());
magicDb.setBrawlPredicate(formats.get("Brawl").getFilterRules());
magicDb.setFilteredHandsEnabled(preferences.getPrefBoolean(FPref.FILTERED_HANDS)); magicDb.setFilteredHandsEnabled(preferences.getPrefBoolean(FPref.FILTERED_HANDS));
try { try {
@@ -215,20 +212,6 @@ public final class FModel {
magicDb.setMulliganRule(MulliganDefs.MulliganRule.London); magicDb.setMulliganRule(MulliganDefs.MulliganRule.London);
} }
blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
// SetblockLands
for (final CardBlock b : blocks) {
magicDb.getBlockLands().add(b.getLandSet().getCode());
}
fantasyBlocks = new StorageBase<>("Custom blocks", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "fantasyblocks.txt", magicDb.getEditions()));
themedChaosDrafts = new StorageBase<>("Themed Chaos Drafts", new ThemedChaosDraft.Reader(ForgeConstants.BLOCK_DATA_DIR + "chaosdraftthemes.txt"));
planes = new StorageBase<>("Conquest planes", new ConquestPlane.Reader(ForgeConstants.CONQUEST_PLANES_DIR + "planes.txt"));
Map<String, QuestWorld> standardWorlds = new QuestWorld.Reader(ForgeConstants.QUEST_WORLD_DIR + "worlds.txt").readAll();
Map<String, QuestWorld> customWorlds = new QuestWorld.Reader(ForgeConstants.USER_QUEST_WORLD_DIR + "customworlds.txt").readAll();
customWorlds.values().forEach(world -> world.setCustom(true));
standardWorlds.putAll(customWorlds);
worlds = new StorageBase<>("Quest worlds", null, standardWorlds);
Spell.setPerformanceMode(preferences.getPrefBoolean(FPref.PERFORMANCE_MODE)); Spell.setPerformanceMode(preferences.getPrefBoolean(FPref.PERFORMANCE_MODE));
if (progressBar != null) { if (progressBar != null) {
@@ -239,15 +222,6 @@ public final class FModel {
DeckPreferences.load(); DeckPreferences.load();
ItemManagerConfig.load(); ItemManagerConfig.load();
achievements = Maps.newHashMap();
achievements.put(GameType.Constructed, new ConstructedAchievements());
achievements.put(GameType.Draft, new DraftAchievements());
achievements.put(GameType.Sealed, new SealedAchievements());
achievements.put(GameType.Quest, new QuestAchievements());
achievements.put(GameType.PlanarConquest, new PlanarConquestAchievements());
achievements.put(GameType.Puzzle, new PuzzleAchievements());
achievements.put(GameType.Adventure, new AdventureAchievements());
// Preload AI profiles // Preload AI profiles
AiProfileUtil.loadAllProfiles(ForgeConstants.AI_PROFILE_DIR); AiProfileUtil.loadAllProfiles(ForgeConstants.AI_PROFILE_DIR);
AiProfileUtil.setAiSideboardingMode(AiProfileUtil.AISideboardingMode.normalizedValueOf(FModel.getPreferences().getPref(FPref.MATCH_AI_SIDEBOARDING_MODE))); AiProfileUtil.setAiSideboardingMode(AiProfileUtil.AISideboardingMode.normalizedValueOf(FModel.getPreferences().getPref(FPref.MATCH_AI_SIDEBOARDING_MODE)));
@@ -265,21 +239,22 @@ public final class FModel {
return; // Don't preload ItemPool on mobile port with less than 5GB RAM return; // Don't preload ItemPool on mobile port with less than 5GB RAM
// Common ItemPool to preload // Common ItemPool to preload
allCardsNoAlt = getAllCardsNoAlt(); getAllCardsNoAlt();
archenemyCards = getArchenemyCards(); getArchenemyCards();
planechaseCards = getPlanechaseCards(); getPlanechaseCards();
attractionPool = getAttractionPool(); getAttractionPool();
contraptionPool = getContraptionPool(); getContraptionPool();
if (GuiBase.getInterface().isLibgdxPort()) { if (GuiBase.getInterface().isLibgdxPort()) {
// Preload mobile Itempool // Preload mobile Itempool
uniqueCardsNoAlt = getUniqueCardsNoAlt(); getUniqueCardsNoAlt();
} else { } else {
// Preload Desktop Itempool // Preload Desktop Itempool
commanderPool = getCommanderPool(); getCommanderPool();
brawlCommander = getBrawlCommander(); getOathbreakerCommander();
tinyLeadersCommander = getTinyLeadersCommander(); getBrawlCommander();
avatarPool = getAvatarPool(); getTinyLeadersCommander();
conspiracyPool = getConspiracyPool(); getAvatarPool();
getConspiracyPool();
} }
} }
@@ -303,89 +278,88 @@ public final class FModel {
public static ItemPool<PaperCard> getUniqueCardsNoAlt() { public static ItemPool<PaperCard> getUniqueCardsNoAlt() {
if (uniqueCardsNoAlt == null) if (uniqueCardsNoAlt == null)
return ItemPool.createFrom(getMagicDb().getCommonCards().getUniqueCardsNoAlt(), PaperCard.class); uniqueCardsNoAlt = ItemPool.createFrom(getMagicDb().getCommonCards().getUniqueCardsNoAlt(), PaperCard.class);
return uniqueCardsNoAlt; return uniqueCardsNoAlt;
} }
public static ItemPool<PaperCard> getAllCardsNoAlt() { public static ItemPool<PaperCard> getAllCardsNoAlt() {
if (allCardsNoAlt == null) if (allCardsNoAlt == null)
return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(), PaperCard.class); allCardsNoAlt = ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(), PaperCard.class);
return allCardsNoAlt; return allCardsNoAlt;
} }
public static ItemPool<PaperCard> getArchenemyCards() { public static ItemPool<PaperCard> getArchenemyCards() {
if (archenemyCards == null) if (archenemyCards == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_SCHEME)), PaperCard.class); archenemyCards = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_SCHEME)), PaperCard.class);
return archenemyCards; return archenemyCards;
} }
public static ItemPool<PaperCard> getPlanechaseCards() { public static ItemPool<PaperCard> getPlanechaseCards() {
if (planechaseCards == null) if (planechaseCards == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_PLANE_OR_PHENOMENON)), PaperCard.class); planechaseCards = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(CardRulesPredicates.IS_PLANE_OR_PHENOMENON)), PaperCard.class);
return planechaseCards; return planechaseCards;
} }
public static ItemPool<PaperCard> getBrawlCommander() { public static ItemPool<PaperCard> getBrawlCommander() {
if (brawlCommander == null) { if (brawlCommander == null) {
return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt( brawlCommander = ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(
FModel.getFormats().get("Brawl").getFilterPrinted() FModel.getFormats().get("Brawl").getFilterPrinted()
.and(PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER)) .and(PaperCardPredicates.fromRules(CardRulesPredicates.CAN_BE_BRAWL_COMMANDER))), PaperCard.class);
), PaperCard.class);
} }
return brawlCommander; return brawlCommander;
} }
public static ItemPool<PaperCard> getOathbreakerCommander() { public static ItemPool<PaperCard> getOathbreakerCommander() {
if (oathbreakerCommander == null) if (oathbreakerCommander == null)
return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules( oathbreakerCommander = ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules(
CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL))), PaperCard.class); CardRulesPredicates.CAN_BE_OATHBREAKER.or(CardRulesPredicates.CAN_BE_SIGNATURE_SPELL))), PaperCard.class);
return oathbreakerCommander; return oathbreakerCommander;
} }
public static ItemPool<PaperCard> getTinyLeadersCommander() { public static ItemPool<PaperCard> getTinyLeadersCommander() {
if (tinyLeadersCommander == null) if (tinyLeadersCommander == null)
return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules( tinyLeadersCommander = ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.fromRules(
CardRulesPredicates.CAN_BE_TINY_LEADERS_COMMANDER)), PaperCard.class); CardRulesPredicates.CAN_BE_TINY_LEADERS_COMMANDER)), PaperCard.class);
return tinyLeadersCommander; return tinyLeadersCommander;
} }
public static ItemPool<PaperCard> getCommanderPool() { public static ItemPool<PaperCard> getCommanderPool() {
if (commanderPool == null) if (commanderPool == null)
return ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.CAN_BE_COMMANDER), PaperCard.class); commanderPool = ItemPool.createFrom(getMagicDb().getCommonCards().getAllCardsNoAlt(PaperCardPredicates.CAN_BE_COMMANDER), PaperCard.class);
return commanderPool; return commanderPool;
} }
public static ItemPool<PaperCard> getAvatarPool() { public static ItemPool<PaperCard> getAvatarPool() {
if (avatarPool == null) if (avatarPool == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( avatarPool = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(
CardRulesPredicates.IS_VANGUARD)), PaperCard.class); CardRulesPredicates.IS_VANGUARD)), PaperCard.class);
return avatarPool; return avatarPool;
} }
public static ItemPool<PaperCard> getConspiracyPool() { public static ItemPool<PaperCard> getConspiracyPool() {
if (conspiracyPool == null) if (conspiracyPool == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( conspiracyPool = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(
CardRulesPredicates.IS_CONSPIRACY)), PaperCard.class); CardRulesPredicates.IS_CONSPIRACY)), PaperCard.class);
return conspiracyPool; return conspiracyPool;
} }
public static ItemPool<PaperCard> getDungeonPool() { public static ItemPool<PaperCard> getDungeonPool() {
if (dungeonPool == null) if (dungeonPool == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( dungeonPool = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(
CardRulesPredicates.IS_DUNGEON)), PaperCard.class); CardRulesPredicates.IS_DUNGEON)), PaperCard.class);
return dungeonPool; return dungeonPool;
} }
public static ItemPool<PaperCard> getAttractionPool() { public static ItemPool<PaperCard> getAttractionPool() {
if (attractionPool == null) if (attractionPool == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( attractionPool = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(
CardRulesPredicates.IS_ATTRACTION)), PaperCard.class); CardRulesPredicates.IS_ATTRACTION)), PaperCard.class);
return attractionPool; return attractionPool;
} }
public static ItemPool<PaperCard> getContraptionPool() { public static ItemPool<PaperCard> getContraptionPool() {
if (contraptionPool == null) if (contraptionPool == null)
return ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules( contraptionPool = ItemPool.createFrom(getMagicDb().getVariantCards().getAllCards(PaperCardPredicates.fromRules(
CardRulesPredicates.IS_CONTRAPTION)), PaperCard.class); CardRulesPredicates.IS_CONTRAPTION)), PaperCard.class);
return contraptionPool; return contraptionPool;
} }
@@ -435,29 +409,38 @@ public final class FModel {
} }
public static AchievementCollection getAchievements(GameType gameType) { public static AchievementCollection getAchievements(GameType gameType) {
switch (gameType) { // Translate gameType to appropriate type if needed if (achievements == null) {
case Constructed: achievements = Maps.newHashMap();
case Draft: achievements.put(GameType.Constructed, new ConstructedAchievements());
case Sealed: achievements.put(GameType.Draft, new DraftAchievements());
case Quest: achievements.put(GameType.Sealed, new SealedAchievements());
case PlanarConquest: achievements.put(GameType.Quest, new QuestAchievements());
case Puzzle: achievements.put(GameType.PlanarConquest, new PlanarConquestAchievements());
case Adventure: achievements.put(GameType.Puzzle, new PuzzleAchievements());
break; achievements.put(GameType.Adventure, new AdventureAchievements());
case AdventureEvent:
gameType = GameType.Adventure;
break;
case QuestDraft:
gameType = GameType.Quest;
break;
default:
gameType = GameType.Constructed;
break;
} }
return achievements.get(gameType);
// Translate gameType to appropriate type if needed
return switch (gameType) {
case Constructed, Draft, Sealed, Quest, PlanarConquest, Puzzle, Adventure -> achievements.get(gameType);
case AdventureEvent -> achievements.get(GameType.Adventure);
case QuestDraft -> achievements.get(GameType.Quest);
default -> achievements.get(GameType.Constructed);
};
} }
public static IStorage<CardBlock> getBlocks() { public static IStorage<CardBlock> getBlocks() {
if (blocks == null) {
blocks = new StorageBase<>("Block definitions", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "blocks.txt", magicDb.getEditions()));
// SetblockLands
for (final CardBlock b : blocks) {
try {
magicDb.getBlockLands().add(b.getLandSet().getCode());
} catch (Exception e) {
e.printStackTrace();
}
}
}
return blocks; return blocks;
} }
@@ -498,22 +481,39 @@ public final class FModel {
} }
public static IStorage<ConquestPlane> getPlanes() { public static IStorage<ConquestPlane> getPlanes() {
if (planes == null)
planes = new StorageBase<>("Conquest planes", new ConquestPlane.Reader(ForgeConstants.CONQUEST_PLANES_DIR + "planes.txt"));
return planes; return planes;
} }
public static IStorage<QuestWorld> getWorlds() { public static IStorage<QuestWorld> getWorlds() {
if (worlds == null) {
Map<String, QuestWorld> standardWorlds = new QuestWorld.Reader(ForgeConstants.QUEST_WORLD_DIR + "worlds.txt").readAll();
Map<String, QuestWorld> customWorlds = new QuestWorld.Reader(ForgeConstants.USER_QUEST_WORLD_DIR + "customworlds.txt").readAll();
customWorlds.values().forEach(world -> world.setCustom(true));
standardWorlds.putAll(customWorlds);
worlds = new StorageBase<>("Quest worlds", null, standardWorlds);
}
return worlds; return worlds;
} }
public static GameFormat.Collection getFormats() { public static GameFormat.Collection getFormats() {
if (formats == null) {
formats = new GameFormat.Collection(new GameFormat.Reader( new File(ForgeConstants.FORMATS_DATA_DIR),
new File(ForgeConstants.USER_FORMATS_DIR), preferences.getPrefBoolean(FPref.LOAD_ARCHIVED_FORMATS)));
}
return formats; return formats;
} }
public static IStorage<CardBlock> getFantasyBlocks() { public static IStorage<CardBlock> getFantasyBlocks() {
if (fantasyBlocks == null)
fantasyBlocks = new StorageBase<>("Custom blocks", new CardBlock.Reader(ForgeConstants.BLOCK_DATA_DIR + "fantasyblocks.txt", magicDb.getEditions()));
return fantasyBlocks; return fantasyBlocks;
} }
public static IStorage<ThemedChaosDraft> getThemedChaosDrafts() { public static IStorage<ThemedChaosDraft> getThemedChaosDrafts() {
if (themedChaosDrafts == null)
themedChaosDrafts = new StorageBase<>("Themed Chaos Drafts", new ThemedChaosDraft.Reader(ForgeConstants.BLOCK_DATA_DIR + "chaosdraftthemes.txt"));
return themedChaosDrafts; return themedChaosDrafts;
} }