diff --git a/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java b/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java index 0fd7261af9affbd6ba54a89e620bb4101b8bea4d..7d0f746debd029e7bdf3f78f22432c9b91e43ef9 100644 --- a/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java +++ b/core/src/cz/nic/tablexia/game/AbstractTablexiaGame.java @@ -543,14 +543,14 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T> for (ITrophyDefinition trophy : trophies) { if ((!hasTrophies.containsKey(trophy) || hasTrophies.get(trophy) == false) && trophy.hasTrophy(getSelectedUser()) == true) { - Log.debug(VictoryDialog.class, "has new trophy: " + trophy.getTrophyName()); + Log.debug(VictoryDialog.class, "has new trophy: " + trophy.getTrophyNameKey()); received.add(trophy); } } int i = 1; for (ITrophyDefinition trophy : received) { - TrophyReceivedDialog dialog = new TrophyReceivedDialog(this, trophy, getGameGlobalTextureRegion(TrophyHelper.getFullPath(trophy.getTrophyName(), TrophyHelper.TrophyType.SMALL)), i, received.size()); + TrophyReceivedDialog dialog = new TrophyReceivedDialog(this, trophy, getGameGlobalTextureRegion(TrophyHelper.getFullPath(trophy.getTrophyNameKey(), TrophyHelper.TrophyType.SMALL)), i, received.size()); addChildDialog(dialog); i++; } diff --git a/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java b/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java index 60188ee5664f2d15438021a7dd851cb294d89d03..50b5753e989dd027c1bfd4f354b517fabd29bef6 100644 --- a/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java +++ b/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java @@ -21,6 +21,7 @@ package cz.nic.tablexia.game.trophy; import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.game.difficulty.GameDifficulty; +import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.shared.model.User; import cz.nic.tablexia.model.game.GameTrophy; @@ -93,15 +94,25 @@ public enum GameTrophyDefinition implements ITrophyDefinition { } @Override - public String getTrophyName() { + public String getTrophyNameKey() { return trophyName; } @Override - public String getTrophyDescription() { + public String getTrophyName() { + return ApplicationTextManager.getInstance().getText(getTrophyNameKey()); + } + + @Override + public String getTrophyDescriptionKey() { return trophyDescription; } + @Override + public String getTrophyDescription() { + return String.format("%s %s", ApplicationTextManager.getInstance().getText(getTrophyDescriptionKey()), getGameDefinition().getTitle()); + } + public int getLimit() { return limit; } diff --git a/core/src/cz/nic/tablexia/game/trophy/ITrophyDefinition.java b/core/src/cz/nic/tablexia/game/trophy/ITrophyDefinition.java index a73024f38a4877babdeb4e8f55e39abaa2daeccb..6dce88a3e521f2a17092540dc88cd19710310117 100644 --- a/core/src/cz/nic/tablexia/game/trophy/ITrophyDefinition.java +++ b/core/src/cz/nic/tablexia/game/trophy/ITrophyDefinition.java @@ -22,7 +22,9 @@ import cz.nic.tablexia.shared.model.User; public interface ITrophyDefinition { + String getTrophyNameKey(); String getTrophyName(); + String getTrophyDescriptionKey(); String getTrophyDescription(); boolean hasTrophy(User user); String name(); diff --git a/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java b/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java index a386a8cb638c712d8c35a3c95cbd9ea34dcc3585..0e0a27c6efbe0b5289e944ebbd925c5fc343372e 100644 --- a/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java +++ b/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java @@ -55,8 +55,8 @@ public class TrophyReceivedDialog extends TablexiaDialog { this.disableOverlay(); this.setModal(false); - String name = ApplicationTextManager.getInstance().getText(trophy.getTrophyName()); - String desc = ApplicationTextManager.getInstance().getText(trophy.getTrophyDescription()); + String name = trophy.getTrophyName(); + String desc = trophy.getTrophyDescription(); String title = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_NEW_TROPHY); this.addLabel(title, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center); diff --git a/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java b/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java index 96cf927513b97cda95057e7a93afcbba88103859..6d7ba5d619275023b0aa6514a12ee67c1e65ad93 100644 --- a/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java +++ b/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java @@ -23,8 +23,9 @@ import java.util.ArrayList; import java.util.List; import cz.nic.tablexia.game.difficulty.GameDifficulty; +import cz.nic.tablexia.loader.application.ApplicationTextManager; +import cz.nic.tablexia.model.game.UserTrophy; import cz.nic.tablexia.shared.model.User; -import cz.nic.tablexia.model.game.*; /** * Definitions of user trophies @@ -47,7 +48,7 @@ public enum UserTrophyDefinition implements ITrophyDefinition { private int limit; private UserTrophy.UserTrophyResolver userTrophyResolver; - private UserTrophyDefinition(UserTrophyTypeDefinition trophyTypeDefinition, String dbFieldName, String trophyName, String trophyDescription, int limit, UserTrophy.UserTrophyResolver userTrophyResolver) { + UserTrophyDefinition(UserTrophyTypeDefinition trophyTypeDefinition, String dbFieldName, String trophyName, String trophyDescription, int limit, UserTrophy.UserTrophyResolver userTrophyResolver) { this.trophyTypeDefinition = trophyTypeDefinition; this.dbFieldName = dbFieldName; @@ -66,15 +67,25 @@ public enum UserTrophyDefinition implements ITrophyDefinition { } @Override - public String getTrophyName() { + public String getTrophyNameKey() { return trophyName; } @Override - public String getTrophyDescription() { + public String getTrophyName() { + return ApplicationTextManager.getInstance().getText(getTrophyNameKey()); + } + + @Override + public String getTrophyDescriptionKey() { return trophyDescription; } + @Override + public String getTrophyDescription() { + return ApplicationTextManager.getInstance().getText(getTrophyDescriptionKey()); + } + public int getLimit() { return limit; } diff --git a/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java b/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java index eec1a118ff0d00f04effea2c68414494ab4d0a13..a00c86b5de25bbc334ca7fc9507ca46fd40114a0 100644 --- a/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java +++ b/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java @@ -32,7 +32,6 @@ import cz.nic.tablexia.game.trophy.GameTrophyDefinition; import cz.nic.tablexia.game.trophy.ITrophyDefinition; import cz.nic.tablexia.game.trophy.UserTrophyDefinition; import cz.nic.tablexia.loader.application.ApplicationFontManager; -import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.model.game.UserTrophy; import cz.nic.tablexia.screen.AbstractTablexiaScreen; import cz.nic.tablexia.screen.halloffame.assets.HallOfFameAssets; @@ -245,7 +244,7 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti for (final ITrophyDefinition trophy : trophies) { TrophyHelper.TrophyType trophyType = getData().get(trophy) ? TrophyHelper.TrophyType.FULL : TrophyHelper.TrophyType.EMPTY; - final TextureRegion texture = getScreenTextureRegion(TrophyHelper.getFullPath(trophy.getTrophyName(), trophyType)); + final TextureRegion texture = getScreenTextureRegion(TrophyHelper.getFullPath(trophy.getTrophyNameKey(), trophyType)); final Image trophyImage = new Image(texture); trophyImage.addListener(new ClickListener() { @@ -254,13 +253,11 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti Log.info(getClass(), "TROPHY CLICKED: " + trophy.getTrophyName()); TextureRegion banner = getScreenTextureRegion(HallOfFameAssets.HALL_OF_FAME_DIALOG_BANNER); - TextureRegion texture = getTextureRegionForAtlas(AbstractTablexiaGame.GLOBAL_ATLAS_NAME, TrophyHelper.getFullPath(trophy.getTrophyName(), TrophyHelper.TrophyType.SMALL)); + TextureRegion texture = getTextureRegionForAtlas(AbstractTablexiaGame.GLOBAL_ATLAS_NAME, TrophyHelper.getFullPath(trophy.getTrophyNameKey(), TrophyHelper.TrophyType.SMALL)); TextureRegion[] textures = new TextureRegion[] {banner, texture}; - String name = ApplicationTextManager.getInstance().getText(trophy.getTrophyName()); - String desc = ApplicationTextManager.getInstance().getText(trophy.getTrophyDescription()); - - if (trophy instanceof GameTrophyDefinition) desc += " " + ((GameTrophyDefinition) trophy).getGameDefinition().getTitle(); + String name = trophy.getTrophyName(); + String desc = trophy.getTrophyDescription(); final TrophyDialog trophyDialog = new TrophyDialog(TablexiaSettings.getSceneWidth(getStage()) / 2 - TROPHY_DIALOG_WIDTH / 2, SCREEN_SIZE.y / 2 - TROPHY_DIALOG_HEIGHT / 2, TROPHY_DIALOG_WIDTH, TROPHY_DIALOG_HEIGHT, TablexiaDialog.BackGroundType.DIALOG_SQUARE_BORDERLINES, new DialogTextContent(name, desc), textures); trophyDialog.show(getStage()); @@ -350,7 +347,7 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti Trio<Float, Float, Float> position = TrophyHelper.trophiesProperties.get(trophyDefinition); int trophyX = (int) (position.getFirst() * SCREEN_SIZE.x); - final TextureRegion texture = getScreenTextureRegion(TrophyHelper.getFullPath(trophyDefinition.getTrophyName(), TrophyHelper.TrophyType.FULL)); + final TextureRegion texture = getScreenTextureRegion(TrophyHelper.getFullPath(trophyDefinition.getTrophyNameKey(), TrophyHelper.TrophyType.FULL)); float trophyWidth = texture.getRegionWidth() * position.getThird(); scrollPane.layout(); diff --git a/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyHelper.java b/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyHelper.java index 5332dc55ed63bcbc09e6f27f30921be4af3d9d78..05b6debbd04723b7839206593cae9138833c8fdc 100644 --- a/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyHelper.java +++ b/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyHelper.java @@ -133,13 +133,13 @@ public class TrophyHelper { //common trophies for(GameTrophyDefinition trophyDefinition: GameTrophyDefinition.values()){ for(TrophyType trophyType : TrophyType.values()){ - trophyNamesToBeLoaded.add(getFullPath(trophyDefinition.getTrophyName(),trophyType)); + trophyNamesToBeLoaded.add(getFullPath(trophyDefinition.getTrophyNameKey(),trophyType)); } } //user trophies for(UserTrophyDefinition trophyDefinition: UserTrophyDefinition.values()){ for(TrophyType trophyType : TrophyType.values()){ - trophyNamesToBeLoaded.add(getFullPath(trophyDefinition.getTrophyName(),trophyType)); + trophyNamesToBeLoaded.add(getFullPath(trophyDefinition.getTrophyNameKey(),trophyType)); } } return trophyNamesToBeLoaded;