Skip to content

Commit

Permalink
Reimplement UI_CLONE_MODE_SOURCE (Card-Forge#3984)
Browse files Browse the repository at this point in the history
* Reimplement UI_CLONE_MODE_SOURCE
  • Loading branch information
tool4ever authored Jan 19, 2024
1 parent 03a9325 commit e733b8f
Showing 15 changed files with 48 additions and 1 deletion.
9 changes: 9 additions & 0 deletions forge-core/src/main/java/forge/StaticData.java
Original file line number Diff line number Diff line change
@@ -49,6 +49,8 @@ public class StaticData {
private boolean enableSmartCardArtSelection;
private boolean loadNonLegalCards;

private boolean sourceImageForClone;

// Loaded lazily:
private IStorage<SealedProduct.Template> boosters;
private IStorage<SealedProduct.Template> specialBoosters;
@@ -900,6 +902,13 @@ public void setEnableSmartCardArtSelection(boolean isEnabled) {
this.enableSmartCardArtSelection = isEnabled;
}

public boolean useSourceImageForClone() {
return sourceImageForClone;
}
public void setSourceImageForClone(final boolean b) {
this.sourceImageForClone = b;
}

public boolean isRebalanced(String name)
{
if (!name.startsWith("A-")) {
6 changes: 5 additions & 1 deletion forge-game/src/main/java/forge/game/card/CardView.java
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.google.common.collect.Sets;

import forge.ImageKeys;
import forge.StaticData;
import forge.card.CardEdition;
import forge.card.CardRarity;
import forge.card.CardRules;
@@ -936,7 +937,7 @@ void updateState(Card c) {
updateIntensity(c);
}

if (getBackup() == null && !c.isFaceDown() && (c.isDoubleFaced()||c.isFlipCard()||c.isAdventureCard())) {
if (getBackup() == null && !c.isFaceDown() && (c.isDoubleFaced() || c.isFlipCard() || c.isAdventureCard() || c.isCloned())) {
set(TrackableProperty.PaperCardBackup, c.getPaperCard());
}

@@ -1234,6 +1235,9 @@ public String getImageKey(Iterable<PlayerView> viewers) {
: getType().getCreatureTypes().toString().toLowerCase().replace(" ", "_").replace("[", "").replace("]",""));
}
if (canBeShownToAny(viewers)) {
if (isCloned() && StaticData.instance().useSourceImageForClone()) {
return getBackup().getCurrentState().getImageKey(viewers);
}
return get(TrackableProperty.ImageKey);
}
return ImageKeys.getTokenKey(ImageKeys.HIDDEN_CARD);
Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@ public void itemStateChanged(final ItemEvent arg0) {
lstControls.add(Pair.of(view.getCbPerformanceMode(), FPref.PERFORMANCE_MODE));
lstControls.add(Pair.of(view.getCbSideboardForAI(), FPref.MATCH_SIDEBOARD_FOR_AI));
lstControls.add(Pair.of(view.getCbFilteredHands(), FPref.FILTERED_HANDS));
lstControls.add(Pair.of(view.getCbCloneImgSource(), FPref.UI_CLONE_MODE_SOURCE));
lstControls.add(Pair.of(view.getCbRemoveSmall(), FPref.DECKGEN_NOSMALL));
lstControls.add(Pair.of(view.getCbCardBased(), FPref.DECKGEN_CARDBASED));
lstControls.add(Pair.of(view.getCbRemoveArtifacts(), FPref.DECKGEN_ARTIFACTS));
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbFilteredHands = new OptionsCheckBox(localizer.getMessage("cbFilteredHands"));
private final JCheckBox cbImageFetcher = new OptionsCheckBox(localizer.getMessage("cbImageFetcher"));
private final JCheckBox cbDisableCardImages = new OptionsCheckBox(localizer.getMessage("lblDisableCardImages"));
private final JCheckBox cbCloneImgSource = new OptionsCheckBox(localizer.getMessage("cbCloneImgSource"));
private final JCheckBox cbScaleLarger = new OptionsCheckBox(localizer.getMessage("cbScaleLarger"));
private final JCheckBox cbRenderBlackCardBorders = new OptionsCheckBox(localizer.getMessage("cbRenderBlackCardBorders"));
private final JCheckBox cbLargeCardViewers = new OptionsCheckBox(localizer.getMessage("cbLargeCardViewers"));
@@ -235,6 +236,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbFilteredHands, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlFilteredHands")), descriptionConstraints);

pnlPrefs.add(cbCloneImgSource, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlCloneImgSource")), descriptionConstraints);

pnlPrefs.add(cbPromptFreeBlocks, titleConstraints);
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlPromptFreeBlocks")), descriptionConstraints);

@@ -842,6 +846,11 @@ public JCheckBox getCbFilteredHands() {
return cbFilteredHands;
}

/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbCloneImgSource() {
return cbCloneImgSource;
}

/** @return {@link javax.swing.JCheckBox} */
public JCheckBox getCbPromptFreeBlocks() {
return cbPromptFreeBlocks;
4 changes: 4 additions & 0 deletions forge-gui-mobile/src/forge/screens/settings/SettingsPage.java
Original file line number Diff line number Diff line change
@@ -233,6 +233,10 @@ public void valueChanged(String newValue) {
Forge.getLocalizer().getMessage("cbFilteredHands"),
Forge.getLocalizer().getMessage("nlFilteredHands")),
1);
lstSettings.addItem(new BooleanSetting(FPref.UI_CLONE_MODE_SOURCE,
Forge.getLocalizer().getMessage("cbCloneImgSource"),
Forge.getLocalizer().getMessage("nlCloneImgSource")),
1);
lstSettings.addItem(new BooleanSetting(FPref.MATCHPREF_PROMPT_FREE_BLOCKS,
Forge.getLocalizer().getMessage("cbPromptFreeBlocks"),
Forge.getLocalizer().getMessage("nlPromptFreeBlocks")),
2 changes: 2 additions & 0 deletions forge-gui/res/languages/de-DE.properties
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ cbSideboardForAI=Sideboard für Mensch/KI
cbPerformanceMode=Performance-Modus
cbFilteredHands=Alternative Starthand
cbImageFetcher=Lade automatisch fehlende Kartenbilder
cbCloneImgSource=Klone zeigen eigenes Kartenbild
cbScaleLarger=Skaliere Bilder größer
cbRenderBlackCardBorders=Zeige schwarzen Rand
cbLargeCardViewers=Nutze große Kartenansicht
@@ -158,6 +159,7 @@ nlEnforceDeckLegality=Erzwingt eine Deck-Konformität zum gewählten Format (min
nlSideboardForAI=Erlaubt Spielern das Nutzen des Sideboards von KI-Decks und in Constructed-Formaten.
nlPerformanceMode=Schalten zusätzlich Prüfungen auf statische Fähigkeiten ab, um das Spiel zu beschleunigen. Warnung: Kann Probleme mit 'Aufblitzen' bei Karten von KI-Gegner verursachen!
nlFilteredHands=Erzeugt zwei Starthände, und behält die, welche am nächsten an der durchschnittlichen Länderanzahl im Deck ist. (Erfordert Neustart)
nlCloneImgSource=Zeige das originale Kartenbild des Klones statt der geklonten Karte.
nlPromptFreeBlocks=Wenn ein neuer Block nichts kosten würde, dann wird er automatisch bezahlt.
nlPauseWhileMinimized=Wenn aktiviert, pausiert Forge im minimierten Zustand (betrifft hauptsächlich KI gegen KI).
nlEscapeEndsTurn=Wenn aktiviert, funktioniert ESCape als Alternative um den Zug zu beenden.
2 changes: 2 additions & 0 deletions forge-gui/res/languages/en-US.properties
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ cbSideboardForAI=Human Sideboard for AI
cbPerformanceMode=Performance Mode
cbFilteredHands=Filtered Hands
cbImageFetcher=Automatically Download Missing Card Art
cbCloneImgSource=Clones Use Original Card Art
cbScaleLarger=Scale Image Larger
cbRenderBlackCardBorders=Render Black Card Borders
cbLargeCardViewers=Use Large Card Viewers
@@ -158,6 +159,7 @@ nlEnforceDeckLegality=Enforces deck legality relevant to each environment (minim
nlSideboardForAI=Allows users to sideboard with the AIs deck and sideboard in constructed game formats.
nlPerformanceMode=Disables additional static abilities checks to speed up the game engine. (Warning: breaks some ''as if had flash'' scenarios when casting cards owned by opponents).
nlFilteredHands=Generates two starting hands and keeps the one with the closest to average land count for the deck. (REQUIRES RESTART)
nlCloneImgSource=When enabled clones will use their original art instead of the cloned card''s art.
nlPromptFreeBlocks=When enabled, if you would have to pay 0 to block, pay automatically without prompt.
nlPauseWhileMinimized=When enabled, Forge pauses when minimized (primarily for AI vs AI).
nlEscapeEndsTurn=When enabled, Escape key functions as an alternative shortcut to end the current turn.
2 changes: 2 additions & 0 deletions forge-gui/res/languages/es-ES.properties
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ cbSideboardForAI=Banquillo humano para la IA
cbPerformanceMode=Modo de desempeño
cbFilteredHands=Manos filtradas
cbImageFetcher=Descargar automáticamente el arte de la carta si no existe
cbCloneImgSource=Clones usan el arte original de la carta
cbScaleLarger=Imagen de escala más grande
cbRenderBlackCardBorders=Renderizar bordes de cartas negras
cbLargeCardViewers=Usar visores de cartas grandes
@@ -158,6 +159,7 @@ nlEnforceDeckLegality=Aplica la legalidad del mazo correspondiente a cada entorn
nlSideboardForAI=Permite a los usuarios sideboard con el mazo de la IA y el sideboard en formatos de juego construidos.
nlPerformanceMode=Desactiva las comprobaciones de habilidades estáticas adicionales para acelerar el motor del juego. (Advertencia: rompe algunos escenarios ''como si tuviera flash'' cuando se lanzan cartas de propiedad de los oponentes).
nlFilteredHands=Genera dos manos iniciales y mantiene la que tiene el recuento de tierras más cercano al promedio del mazo (Requiere reinicio)
nlCloneImgSource=Cuando se habilita, los clones usarán su arte original en lugar del arte de la carta clonada.
nlPromptFreeBlocks=Cuando está habilitado, si tuvieses que pagar 0 para bloquear, paga automáticamente sin aviso.
nlPauseWhileMinimized=Cuando está habilitado, Forge hace una pausa cuando está minimizado (principalmente para IA contra IA).
nlEscapeEndsTurn=Cuando está habilitada, la tecla Escape funciona como un atajo alternativo para finalizar el turno actual.
2 changes: 2 additions & 0 deletions forge-gui/res/languages/fr-FR.properties
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ cbSideboardForAI=Réserve humain pour l''IA
cbPerformanceMode=Mode Performances
cbFilteredHands=Mains filtrées
cbImageFetcher=Télécharger automatiquement l''illustration de la carte manquante
cbCloneImgSource=Les clones utilisent l''illustration originale de la carte
cbScaleLarger=Agrandir l''image
cbRenderBlackCardBorders=Rendre les bordures noires de la carte
cbLargeCardViewers=Utiliser les visionneuses de grandes cartes
@@ -158,6 +159,7 @@ nlEnforceDeckLegality=Applique la légalité du deck en fonction de chaque envir
nlSideboardForAI=Permet aux utilisateurs de se sideboarder avec le deck IA et le sideboard dans des formats de jeu construits.
nlPerformanceMode=Désactive les vérifications supplémentaires des capacités statiques pour accélérer le moteur de jeu. (Attention : casse certains scénarios ''comme si c''était flash'' lors du lancement de cartes appartenant à des adversaires).
nlFilteredHands=Génère deux mains de départ et conserve celle dont le nombre de terrains est le plus proche de la moyenne pour le deck. (NÉCESSITE UN REDÉMARRAGE)
nlCloneImgSource=Lorsqu''il est activé, les clones utiliseront leur art original au lieu de l''art de la carte clonée.
nlPromptFreeBlocks=Lorsqu''il est activé, si vous deviez payer 0 pour bloquer, payez automatiquement sans invite.
nlPauseWhileMinimized=Lorsqu''il est activé, Forge s''arrête lorsqu''il est réduit (principalement pour l''IA par rapport à l''IA).
nlEscapeEndsTurn=Lorsqu''elle est activée, la touche Échap fonctionne comme un raccourci alternatif pour terminer le tour en cours.
2 changes: 2 additions & 0 deletions forge-gui/res/languages/it-IT.properties
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@ cbSideboardForAI=Sideboard umana per IA
cbPerformanceMode=Modalità alte prestazioni
cbFilteredHands=Mani Filtrate
cbImageFetcher=Scarica automaticamente l''arte delle carte mancanti
cbCloneImgSource=I cloni usano l''arte della carta originale
cbScaleLarger=Ingrandisci l''immagine
cbRenderBlackCardBorders=Disegna i bordi neri delle carte
cbLargeCardViewers=Usa visualizzatori di carte di grandi dimensioni
@@ -157,6 +158,7 @@ nlEnforceDeckLegality=Fa rispettare la legalità del mazzo relativa a ciascun am
nlSideboardForAI=Consente agli utenti di gestire la sideboard con il mazzo dell''IA e la propria nei formati di gioco constructed.
nlPerformanceMode=Disabilita delle verifiche aggiuntive delle abilità statiche per velocizzare il motore di gioco. (Attenzione: non fa funzionare correttamente il giocare carte di proprietà di un avversario in contesti "come se avesse lampo").
nlFilteredHands=Genera due mani iniziali e mantiene quella con il numero di terre più vicino alla media del mazzo. (RIAVVIO NECESSARIO)
nlCloneImgSource=Se abilitato, i cloni useranno la loro arte originale invece di quella della carta clonata.
nlPromptFreeBlocks=Se abilitato, quando è richiesto un pagamento di 0 per bloccare, paga automaticamente senza chiedere conferma.
nlPauseWhileMinimized=Se abilitato, mette in pausa Forge quando è ridotto a icona (principalmente per IA vs IA).
nlEscapeEndsTurn=Se abilitato, il tasto Esc funziona come scorciatoia alternativa per terminare il turno in corso.
2 changes: 2 additions & 0 deletions forge-gui/res/languages/ja-JP.properties
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ cbSideboardForAI=人間が AI の代わりにサイドボードする
cbPerformanceMode=パフォーマンスモード
cbFilteredHands=初期ハンド補正
cbImageFetcher=欠落したカード画像を自動的にダウンロードする
cbCloneImgSource=コピーカードは元のカード画像を使用します
cbScaleLarger=画像を拡大する
cbRenderBlackCardBorders=黒枠のレンダリング
cbLargeCardViewers=大きなカードビューアーを使用する
@@ -158,6 +159,7 @@ nlEnforceDeckLegality=各環境に使えるデッキの合法性を強制しま
nlSideboardForAI=人間が構築戦の時、AI の替わりに AI のデッキのサイドボードをします。
nlPerformanceMode=常在型能力の追加チェックを無効にして、ゲームエンジンを高速化します。 (警告:対戦相手が所有するカードをキャストするときに、「あたかもフラッシュがあるかのように」の能力が無効になるかもしれません。)
nlFilteredHands=2つのハンドを生成し、デッキの平均土地数に最も近いハンドをキープします。
nlCloneImgSource=有効にすると、クローンはクローン先のカードのアートの代わりに元のアートを使用します。
nlPromptFreeBlocks=有効にすると、ブロックするために0を支払う必要がある場合、プロンプトなしで自動的に支払います。
nlPauseWhileMinimized=有効にすると、Forge は最小化すると一時停止します(主に AI 対 AI)。
nlEscapeEndsTurn=有効にすると、エスケープキーは現在のターンを終了するための代替ショートカットとして機能します。
2 changes: 2 additions & 0 deletions forge-gui/res/languages/pt-BR.properties
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ cbSideboardForAI=Humano e a Reserva de IA
cbPerformanceMode=Modo de Desempenho
cbFilteredHands=Mãos Filtradas
cbImageFetcher=Baixar Automaticamente a Arte de Cartas Ausentes
cbCloneImgSource=Clones Usam a Arte da Carta Origem
cbScaleLarger=Expandir Imagem
cbRenderBlackCardBorders=Renderizar Bordas Pretas de Carta
cbLargeCardViewers=Usar Visualizadores de Cartas Grande
@@ -159,6 +160,7 @@ nlEnforceDeckLegality=Força a legalidade do deck relevante para cada ambiente (
nlSideboardForAI=Permite os usuários trocarem cartas com decks IA e a reserva em formatos de jogo construídos.
nlPerformanceMode=Desabilita verificações adicionais de habilidades estáticas para acelerar o jogo. (Aviso\: quebra alguns cenários 'como se tivesse lampejo' ao conjurar cartas pertencentes a adversários).
nlFilteredHands=Gera duas mãos iniciais e mantém a mão mais próxima da média da contagem de terreno do deck. (REQUER REINÍCIO)
nlCloneImgSource=Quando ativado os clones usarão sua arte original em vez da arte da carta clonada.
nlPromptFreeBlocks=Quando ativado, se você tiver que pagar 0 para bloquear, pague automaticamente sem solicitação.
nlPauseWhileMinimized=Quando ativado, o Forge pausa quando minimizado (principalmente para IA vs IA).
nlEscapeEndsTurn=Quando ativado, a tecla Escape funciona como um atalho alternativo para o final do turno atual.
2 changes: 2 additions & 0 deletions forge-gui/res/languages/zh-CN.properties
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ cbSideboardForAI=玩家为AI换备
cbPerformanceMode=性能模式
cbFilteredHands=手牌过滤
cbImageFetcher=自动下载缺失的图片
cbCloneImgSource=复制使用原始的图片
cbScaleLarger=将图像缩放的更大
cbRenderBlackCardBorders=渲染黑卡边框
cbLargeCardViewers=使用大图查看器
@@ -158,6 +159,7 @@ nlEnforceDeckLegality=强制每个与环境相关的套牌合法性(最小单
nlSideboardForAI=允许用户在构筑赛制中为AI换备牌。
nlPerformanceMode=禁止其他静态能力检查以加速游戏引擎(警告:对手手牌有闪现单卡能使用时可能会跳过)。
nlFilteredHands=生成两个起手并发给你最接近套牌地比例的起手(需要重启)
nlCloneImgSource=启用克隆的时候将使用原画而不是克隆牌的画
nlPromptFreeBlocks=启用后如果你需要支付0来阻挡,则不会提示自动支付0。
nlPauseWhileMinimized=启用后,Forge将在暂停时最小化(主要用于AI VS AI)。
nlEscapeEndsTurn=启用后,空格键可以用于结束当前回合的替代按键。
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import com.google.common.eventbus.Subscribe;

import forge.LobbyPlayer;
import forge.StaticData;
import forge.game.Game;
import forge.game.GameRules;
import forge.game.GameType;
@@ -156,6 +157,8 @@ public void startGame() {

game = match.createGame();

StaticData.instance().setSourceImageForClone(FModel.getPreferences().getPrefBoolean(FPref.UI_CLONE_MODE_SOURCE));

if (game.getRules().getGameType() == GameType.Quest) {
final QuestController qc = FModel.getQuest();
// Reset new list when the Match round starts, not when each game starts
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ public enum FPref {
UI_CURRENT_SOUND_SET("Default"),
UI_CURRENT_MUSIC_SET("Default"),
UI_CURRENT_AI_PROFILE ("Default"),
UI_CLONE_MODE_SOURCE ("false"),
UI_MATCH_IMAGE_VISIBLE ("true"),
UI_THEMED_COMBOBOX ("true"), // Now applies to all theme settings, not just Combo.
UI_LOCK_TITLE_BAR ("false"),

0 comments on commit e733b8f

Please sign in to comment.