add Display Shop Item names option

- closes #3639
This commit is contained in:
Anthony Calosa
2023-09-22 13:31:40 +08:00
parent 1e116be3b0
commit d073bb94a5
15 changed files with 95 additions and 8 deletions

View File

@@ -20,4 +20,5 @@ public class SettingData {
public Float cardTooltipAdjLandscape; public Float cardTooltipAdjLandscape;
public boolean dayNightBG; public boolean dayNightBG;
public boolean disableWinLose; public boolean disableWinLose;
public boolean showShopOverlay;
} }

View File

@@ -477,7 +477,7 @@ public class RewardScene extends UIScene {
lastRowXAdjust = ((numberOfColumns * cardWidth) - (lastRowCount * cardWidth)) / 2; lastRowXAdjust = ((numberOfColumns * cardWidth) - (lastRowCount * cardWidth)) / 2;
} }
RewardActor actor = new RewardActor(reward, type == Type.Loot || type == Type.QuestReward, type); RewardActor actor = new RewardActor(reward, type == Type.Loot || type == Type.QuestReward, type, type == Type.Shop && (numberOfRows > 2 || numberOfColumns > 2));
actor.setBounds(lastRowXAdjust + xOff + cardWidth * (i % numberOfColumns) + spacing, yOff + cardHeight * currentRow + spacing, cardWidth - spacing * 2, cardHeight - spacing * 2); actor.setBounds(lastRowXAdjust + xOff + cardWidth * (i % numberOfColumns) + spacing, yOff + cardHeight * currentRow + spacing, cardWidth - spacing * 2, cardHeight - spacing * 2);

View File

@@ -213,6 +213,13 @@ public class SettingsScene extends UIScene {
Config.instance().saveSettings(); Config.instance().saveSettings();
} }
}); });
addSettingField(Forge.getLocalizer().getMessage("lblShowShopOverlay"), Config.instance().getSettingData().showShopOverlay, new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Config.instance().getSettingData().showShopOverlay = ((CheckBox) actor).isChecked();
Config.instance().saveSettings();
}
});
addCheckBox(Forge.getLocalizer().getMessage("lblCardName"), ForgePreferences.FPref.UI_OVERLAY_CARD_NAME); addCheckBox(Forge.getLocalizer().getMessage("lblCardName"), ForgePreferences.FPref.UI_OVERLAY_CARD_NAME);
addSettingSlider(Forge.getLocalizer().getMessage("cbAdjustMusicVolume"), ForgePreferences.FPref.UI_VOL_MUSIC, 0, 100); addSettingSlider(Forge.getLocalizer().getMessage("cbAdjustMusicVolume"), ForgePreferences.FPref.UI_VOL_MUSIC, 0, 100);
addSettingSlider(Forge.getLocalizer().getMessage("cbAdjustSoundsVolume"), ForgePreferences.FPref.UI_VOL_SOUNDS, 0, 100); addSettingSlider(Forge.getLocalizer().getMessage("cbAdjustSoundsVolume"), ForgePreferences.FPref.UI_VOL_SOUNDS, 0, 100);

View File

@@ -392,7 +392,7 @@ public class SpellSmithScene extends UIScene {
if (Current.player().getGold() < currentPrice) pullUsingGold.setDisabled(true); if (Current.player().getGold() < currentPrice) pullUsingGold.setDisabled(true);
if (Current.player().getShards() < currentShardPrice) pullUsingShards.setDisabled(true); if (Current.player().getShards() < currentShardPrice) pullUsingShards.setDisabled(true);
if (rewardActor != null) rewardActor.remove(); if (rewardActor != null) rewardActor.remove();
rewardActor = new RewardActor(R, true, null); rewardActor = new RewardActor(R, true, null, true);
rewardActor.flip(); //Make it flip so it draws visual attention, why not. rewardActor.flip(); //Make it flip so it draws visual attention, why not.
rewardActor.setBounds(rewardDummy.getX(), rewardDummy.getY(), rewardDummy.getWidth(), rewardDummy.getHeight()); rewardActor.setBounds(rewardDummy.getX(), rewardDummy.getY(), rewardDummy.getWidth(), rewardDummy.getHeight());
stage.addActor(rewardActor); stage.addActor(rewardActor);

View File

@@ -380,6 +380,10 @@ public class Controls {
return newTextraLabel(name, getTextraFont()); return newTextraLabel(name, getTextraFont());
} }
public static TextraLabel newRewardLabel(String name) {
return newTextraLabel(name, getRewardHeaderFont());
}
public static String colorIdToTypingString(ColorSet color) { public static String colorIdToTypingString(ColorSet color) {
return colorIdToTypingString(color, false); return colorIdToTypingString(color, false);
} }
@@ -425,6 +429,10 @@ public class Controls {
return Forge.getAssets().getTextraFont(getSkin().getFont("default"), Config.instance().getAtlas(Paths.ITEMS_ATLAS), Config.instance().getAtlas(Paths.PIXELMANA_ATLAS)); return Forge.getAssets().getTextraFont(getSkin().getFont("default"), Config.instance().getAtlas(Paths.ITEMS_ATLAS), Config.instance().getAtlas(Paths.PIXELMANA_ATLAS));
} }
static public Font getRewardHeaderFont() {
return Forge.getAssets().getGenericHeaderFont(getSkin().getFont("default"));
}
static public Font getTextraFont(String name) { static public Font getTextraFont(String name) {
return Forge.getAssets().getTextraFont(name, getSkin().getFont(name), Config.instance().getAtlas(Paths.ITEMS_ATLAS)); return Forge.getAssets().getTextraFont(name, getSkin().getFont(name), Config.instance().getAtlas(Paths.ITEMS_ATLAS));
} }

View File

@@ -15,6 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Tooltip; import com.badlogic.gdx.scenes.scene2d.ui.Tooltip;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener; import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
@@ -44,6 +45,7 @@ import forge.item.SealedProduct;
import forge.sound.SoundEffectType; import forge.sound.SoundEffectType;
import forge.sound.SoundSystem; import forge.sound.SoundSystem;
import forge.util.Aggregates; import forge.util.Aggregates;
import forge.util.CardTranslation;
import forge.util.ImageFetcher; import forge.util.ImageFetcher;
import forge.util.ImageUtil; import forge.util.ImageUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -75,6 +77,8 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
private boolean hover, hasbackface; private boolean hover, hasbackface;
boolean loaded = true; boolean loaded = true;
boolean alternate = false, shown = false; boolean alternate = false, shown = false;
boolean isRewardShop, showOverlay;
TextraLabel overlayLabel;
public int renderedCount = 0; //Counter for cards that require rendering a preview. public int renderedCount = 0; //Counter for cards that require rendering a preview.
static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher(); static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher();
@@ -173,9 +177,11 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
Gdx.graphics.requestRendering(); Gdx.graphics.requestRendering();
} }
public RewardActor(Reward reward, boolean flippable, RewardScene.Type type) { public RewardActor(Reward reward, boolean flippable, RewardScene.Type type, boolean showOverlay) {
this.flipOnClick = flippable; this.flipOnClick = flippable;
this.reward = reward; this.reward = reward;
this.isRewardShop = RewardScene.Type.Shop.equals(type);
this.showOverlay = showOverlay;
if (backTexture == null) { if (backTexture == null) {
backTexture = FSkin.getSleeves().get(0); backTexture = FSkin.getSleeves().get(0);
} }
@@ -351,9 +357,8 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
Sprite backSprite = Config.instance().getItemSprite("CardBack"); Sprite backSprite = Config.instance().getItemSprite("CardBack");
Sprite item = Config.instance().getItemSprite(reward.type.toString()); Sprite item = Config.instance().getItemSprite(reward.type.toString());
setItemTooltips(item, backSprite, false); setItemTooltips(item, backSprite, false);
boolean isShop = RewardScene.Type.Shop.equals(type); processSprite(backSprite, item, isRewardShop ? null :
processSprite(backSprite, item, isShop ? null : Controls.newTextraLabel("[%200]" + reward.getCount() + " " + reward.type), 0, isRewardShop ? 0 : -10, false);
Controls.newTextraLabel("[%200]" + reward.getCount() + " " + reward.type), 0, isShop ? 0 : -10, false);
needsToBeDisposed = true; needsToBeDisposed = true;
break; break;
} }
@@ -752,11 +757,9 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
oldProjectionTransform.set(batch.getProjectionMatrix()); oldProjectionTransform.set(batch.getProjectionMatrix());
applyProjectionMatrix(batch); applyProjectionMatrix(batch);
if (hover | hasKeyboardFocus()) if (hover | hasKeyboardFocus())
batch.setColor(0.5f, 0.5f, 0.5f, 1); batch.setColor(0.5f, 0.5f, 0.5f, 1);
if (!frontSideUp()) { if (!frontSideUp()) {
if (flipOnClick) { if (flipOnClick) {
batch.draw(backTexture, -getWidth() / 2, -getHeight() / 2, getWidth(), getHeight()); batch.draw(backTexture, -getWidth() / 2, -getHeight() / 2, getWidth(), getHeight());
@@ -766,9 +769,58 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} else { } else {
drawFrontSide(batch); drawFrontSide(batch);
} }
batch.setColor(1, 1, 1, 1); batch.setColor(1, 1, 1, 1);
resetTransform(batch); resetTransform(batch);
batch.setProjectionMatrix(oldProjectionTransform); batch.setProjectionMatrix(oldProjectionTransform);
if (showOverlay && Config.instance().getSettingData().showShopOverlay) {
if (overlayLabel == null) {
setOverlayLabel();
}
if (overlayLabel != null) {
overlayLabel.draw(batch, parentAlpha);
}
}
}
private void setOverlayLabel() {
String display = "";
int alignment = Align.top;
String labelStyle = "background";
if (reward == null)
return;
Reward.Type rewardType = reward.getType();
switch (rewardType) {
case Card:
display = reward.getCard() != null ? CardTranslation.getTranslatedName(reward.getCard().getName()) : "";
//alignment = Align.topLeft;
labelStyle = "dialog";
break;
case Life:
case Gold:
case Shards:
display = reward.type.toString();
break;
case Item:
display = reward.getItem() != null ? reward.getItem().name : "";
break;
case CardPack:
display = reward.getDeck() != null ? "Card Pack (" + reward.getDeck().getComment() + ")" : "";
break;
default:
break;
}
overlayLabel = Controls.newRewardLabel("[%98]" + display);
overlayLabel.setWidth(this.getWidth());
overlayLabel.setWrap(true);
overlayLabel.setAlignment(alignment);
overlayLabel.style = (Controls.getSkin().get(labelStyle, Label.LabelStyle.class));
//compute layout
overlayLabel.layout();
//get the layout values and apply
overlayLabel.setHeight(overlayLabel.layout.getHeight());
overlayLabel.setPosition(this.getX(), (this.getY(Align.top) - overlayLabel.layout.getHeight()));
} }
private void drawFrontSide(Batch batch) { private void drawFrontSide(Batch batch) {

View File

@@ -383,6 +383,17 @@ public class Assets implements Disposable {
return textrafonts.get(name); return textrafonts.get(name);
} }
public Font getGenericHeaderFont(BitmapFont bitmapFont) {
if (textrafonts == null)
textrafonts = new ObjectMap<>();
if (!textrafonts.containsKey("GenericHeaderFont")) {
Font font = new Font(bitmapFont, 0f, -0.5f, 0f, -2.5f);
font.integerPosition = false;
textrafonts.put("GenericHeaderFont", font);
}
return textrafonts.get("GenericHeaderFont");
}
public Music getMusic(FileHandle file) { public Music getMusic(FileHandle file) {
if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) { if (file == null || !file.exists() || !FileType.Absolute.equals(file.type())) {
System.err.println("Failed to load: " + file + "!."); System.err.println("Failed to load: " + file + "!.");

View File

@@ -2984,6 +2984,7 @@ lblChangelog=Änderungen
lblToken=Spielstein lblToken=Spielstein
lblBackToAdventure=Zurück zum Abenteuer lblBackToAdventure=Zurück zum Abenteuer
lblDisableWinLose=Deaktivieren Sie Winslose Overlay lblDisableWinLose=Deaktivieren Sie Winslose Overlay
lblShowShopOverlay=Shop -Artikelname anzeigen
lblExitToWoldMap=Zurück zur Weltkarte? lblExitToWoldMap=Zurück zur Weltkarte?
lblStartArena=Willst du in die Arena gehen? lblStartArena=Willst du in die Arena gehen?
lblWouldYouLikeDestroy=Möchten Sie {0} zerstören? lblWouldYouLikeDestroy=Möchten Sie {0} zerstören?

View File

@@ -2996,6 +2996,7 @@ lblBackToAdventure=Back to Adventure
lblQuitAdventureEventMatch=Quit Match (will count as a loss) lblQuitAdventureEventMatch=Quit Match (will count as a loss)
lblQuitAdventureEvent=You have matches left to play!\nLeaving the event early will forfeit your potential future winnings.\nYou will still receive winnings as if you conceded your remaining matches.\n\nWould you still like to quit the event? lblQuitAdventureEvent=You have matches left to play!\nLeaving the event early will forfeit your potential future winnings.\nYou will still receive winnings as if you conceded your remaining matches.\n\nWould you still like to quit the event?
lblDisableWinLose=Disable WinLose Overlay lblDisableWinLose=Disable WinLose Overlay
lblShowShopOverlay=Display Shop Item names
lblExitToWoldMap=Exit to the World Map? lblExitToWoldMap=Exit to the World Map?
lblStartArena=Do you want to go into the Arena? lblStartArena=Do you want to go into the Arena?
lblWouldYouLikeDestroy=Would you like to destroy {0}? lblWouldYouLikeDestroy=Would you like to destroy {0}?

View File

@@ -2987,6 +2987,7 @@ lblChangelog=Cambios
lblToken=Simbólico lblToken=Simbólico
lblBackToAdventure=Volver a la aventura lblBackToAdventure=Volver a la aventura
lblDisableWinLose=Desactivar WinLose Overlay lblDisableWinLose=Desactivar WinLose Overlay
lblShowShopOverlay=Nombre del artículo de la tienda de exhibición
lblExitToWoldMap=Salir al mapa del mundo? lblExitToWoldMap=Salir al mapa del mundo?
lblStartArena=¿Quieres ir a la arena? lblStartArena=¿Quieres ir a la arena?
lblWouldYouLikeDestroy=¿Le gustaría destruir {0}? lblWouldYouLikeDestroy=¿Le gustaría destruir {0}?

View File

@@ -2991,6 +2991,7 @@ lblChangelog=Changements
lblToken=Jeton lblToken=Jeton
lblBackToAdventure=Retour à l'aventure lblBackToAdventure=Retour à l'aventure
lblDisableWinLose=Désactiver la superposition Winlose lblDisableWinLose=Désactiver la superposition Winlose
lblShowShopOverlay=Nom de l'article de la boutique d'affichage
lblExitToWoldMap=Sortir sur la carte du monde? lblExitToWoldMap=Sortir sur la carte du monde?
lblStartArena=Voulez-vous entrer dans l''arène? lblStartArena=Voulez-vous entrer dans l''arène?
lblWouldYouLikeDestroy=Souhaitez-vous détruire {0}? lblWouldYouLikeDestroy=Souhaitez-vous détruire {0}?

View File

@@ -2990,6 +2990,7 @@ lblChangelog=I cambiamenti
lblToken=Gettone lblToken=Gettone
lblBackToAdventure=Torna all'avventura lblBackToAdventure=Torna all'avventura
lblDisableWinLose=Disabilita overlay winlose lblDisableWinLose=Disabilita overlay winlose
lblShowShopOverlay=Visualizza il nome dell'articolo del negozio
lblExitToWoldMap=Esci alla mappa del mondo? lblExitToWoldMap=Esci alla mappa del mondo?
lblStartArena=Vuoi andare nell''arena? lblStartArena=Vuoi andare nell''arena?
lblWouldYouLikeDestroy=Vorresti distruggere {0}? lblWouldYouLikeDestroy=Vorresti distruggere {0}?

View File

@@ -2986,6 +2986,7 @@ lblChangelog=変更
lblToken=トークン lblToken=トークン
lblBackToAdventure=冒険に戻ります lblBackToAdventure=冒険に戻ります
lblDisableWinLose=Winloseオーバーレイを無効にします lblDisableWinLose=Winloseオーバーレイを無効にします
lblShowShopOverlay=ショップアイテム名を表示します
lblExitToWoldMap=世界地図に終了しますか? lblExitToWoldMap=世界地図に終了しますか?
lblStartArena=アリーナに行きたいですか? lblStartArena=アリーナに行きたいですか?
lblWouldYouLikeDestroy={0}を破壊しますか? lblWouldYouLikeDestroy={0}を破壊しますか?

View File

@@ -3076,6 +3076,7 @@ lblChangelog=Mudanças
lblToken=Símbolo lblToken=Símbolo
lblBackToAdventure=De volta à aventura lblBackToAdventure=De volta à aventura
lblDisableWinLose=Desative a sobreposição de Winlose lblDisableWinLose=Desative a sobreposição de Winlose
lblShowShopOverlay=Nome do item da loja de exibição
lblExitToWoldMap=Sair para o mapa do mundo? lblExitToWoldMap=Sair para o mapa do mundo?
lblStartArena=Você quer entrar na arena? lblStartArena=Você quer entrar na arena?
lblWouldYouLikeDestroy=Você gostaria de destruir {0}? lblWouldYouLikeDestroy=Você gostaria de destruir {0}?

View File

@@ -2974,6 +2974,7 @@ lblChangelog=变化
lblToken=令牌 lblToken=令牌
lblBackToAdventure=回到冒险 lblBackToAdventure=回到冒险
lblDisableWinLose=禁用Winlose覆盖 lblDisableWinLose=禁用Winlose覆盖
lblShowShopOverlay=展示商店项目名称
lblExitToWoldMap=退出世界地图? lblExitToWoldMap=退出世界地图?
lblStartArena=您想进入竞技场吗? lblStartArena=您想进入竞技场吗?
lblWouldYouLikeDestroy=您想销毁{0}吗? lblWouldYouLikeDestroy=您想销毁{0}吗?