Skip to content
Snippets Groups Projects
Commit 0b1d34a8 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#41 VictoryDialog text -> victory text for game result

parent 1f7da724
No related branches found
No related tags found
No related merge requests found
Showing
with 94 additions and 10 deletions
......@@ -4,7 +4,7 @@ game_robbery_loadingtext=Na začátku hry si přečti pravidlo, podle kterého p
game_robbery_victorytext_threestars=S takovouhle ostrahou nepotřebuje banka ani trezor.
game_robbery_victorytext_twostar=Tvoje jméno si už začínají štěbetat\ni straky na střechách.
game_robbery_victorytext_onestar=Otázka je, jestli zůstal trezor poloplný,\nnebo poloprázdný.
game_robbery_victorytext_gameover=U lupičů jsi rozhodně nejoblíbenější hlídač.\nKdyž budeš trénovat, určitě se tě budou brzy bát.
game_robbery_victorytext_nostar=U lupičů jsi rozhodně nejoblíbenější hlídač.\nKdyž budeš trénovat, určitě se tě budou brzy bát.
game_robbery_victorytext_stats=Správně jsi {0} <b>{1}/{2}</b> návštěvníků.
game_robbery_victorytext_stats_identification=identifikoval/a
game_robbery_victorytext_stats_identification_male=identifikoval
......
......@@ -4,7 +4,7 @@ game_robbery_loadingtext=Lies dir zu Beginn des Spiels durch, wie du den Räuber
game_robbery_victorytext_threestars=Mit einer solchen Wache braucht die Bank nicht einmal einen Tresor.
game_robbery_victorytext_twostar=Deinen Namen pfeifen langsam schon \ndie Elstern von den Dächern.
game_robbery_victorytext_onestar=Die Frage ist, ob der Tresor halb voll, \noder halb leer geblieben ist.
game_robbery_victorytext_gameover=Du bist bei den Räubern eindeutig der beliebteste Wächter.\nWenn du trainierst, werden sie bald Angst vor dir haben.
game_robbery_victorytext_nostar=Du bist bei den Räubern eindeutig der beliebteste Wächter.\nWenn du trainierst, werden sie bald Angst vor dir haben.
game_robbery_victorytext_stats=Du hast {0} Besucher richtig <b>{1}/{2}</b>.
game_robbery_victorytext_stats_identification=identifiziert
game_robbery_victorytext_stats_identification_male=identifiziert
......
......@@ -5,7 +5,7 @@ game_robbery_loadingtext=Na začiatku hry si prečítaj pravidlo, podľa ktoréh
game_robbery_victorytext_threestars=S takouto ostrahou nepotrebuje banka ani trezor.
game_robbery_victorytext_twostar=Tvoje meno si začínajú štebotať aj straky na strechách.
game_robbery_victorytext_onestar=Otázka je, či ostal trezor poloplný alebo poloprázdný.
game_robbery_victorytext_gameover=U lupičov si rozhodne najobľúbenejší strážca. Ak budeš trénovať, určite sa ťa budú skoro báť.
game_robbery_victorytext_nostar=U lupičov si rozhodne najobľúbenejší strážca. Ak budeš trénovať, určite sa ťa budú skoro báť.
game_robbery_victorytext_stats=Správne si {0} <b>{1}/{2}</b> návštevníkov.
game_robbery_victorytext_stats_identification=identifikoval/a
game_robbery_victorytext_stats_identification_male=identifikoval
......
package cz.nic.tablexia.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Cell;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.utils.Align;
import net.engio.mbassy.listener.Handler;
......@@ -305,16 +308,17 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
public static final float RESULTSBANNER_WIDTH_RATIO = 2f / 3;
public static final float RESULTSBANNER_TOPPADDING_RATIO = 1f / 30;
public static final float RATINGSTAR_HEIGHT_RATIO = 1f / 8;
public static final float TEXT_TOP_PADDING_RATIO = 1f / 15;
Image[] ratingStarsEnabled;
public VictoryDialog() {
public VictoryDialog(String text) {
super(DIALOG_POSITION_X,
DIALOG_POSITION_Y,
DIALOG_WIDTH,
DIALOG_HEIGHT,
BackGroundType.DIALOG_SQUARE_BORDERLINES,
new DialogTextContent("TEXT"),
new DialogTextContent(text),
TablexiaButton.ButtonType.BLUE,
TablexiaButton.ButtonType.GREEN,
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_BUTTON_CHANGEGAME),
......@@ -323,6 +327,18 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
setModal(true);
}
@Override
protected int getTextAlignment() {
return Align.center;
}
@Override
protected Cell<Label> addLabel(String text, BitmapFont font) {
Cell<Label> labelCell = super.addLabel(text, font);
labelCell.padTop(getHeight() * TEXT_TOP_PADDING_RATIO);
return labelCell;
}
@Override
protected void prepareContent() {
// RESULTS BANNER
......@@ -401,7 +417,9 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
gamePhase = GamePhase.FINISHED;
game.endGame();
Log.info(getClass(), "[DB] Ended game: " + game);
(new VictoryDialog()).show(getStage());
String gameResultKey = getTextKeyForGameResult(game.getGameResult());
(new VictoryDialog(gameResultKey != null ? getText(gameResultKey) : "")).show(getStage());
}
public void startNewGame() {
......@@ -416,6 +434,8 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
});
}
protected abstract String getTextKeyForGameResult(GameResult gameResult);
//////////////////////////// HIDE/SHOW TRANSACTIONS
......
......@@ -6,4 +6,9 @@ import cz.nic.tablexia.game.AbstractTablexiaGame;
* Created by Václav Tarantík on 6.3.15.
*/
public class InTheDarknessGame extends AbstractTablexiaGame<Void> {
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
return null;
}
}
......@@ -194,4 +194,9 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
}
return 0;
}
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
return null;
}
}
\ No newline at end of file
......@@ -344,4 +344,9 @@ public class NightWatchGame extends AbstractTablexiaGame<int[][]> {
int clickY = clickmap.getRegionHeight() - (int) (y / SCREEN_MIN_HEIGHT * clickmap.getRegionHeight());
return new Color(getData()[clickX][clickY]);
}
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
return null;
}
}
......@@ -206,9 +206,13 @@ public class PursuitGame extends AbstractTablexiaGame<int[][]> {
Point vehiclePositonConsideringMapRotation =ArithmeticsHelper.translatePositionAccordingToRotation(vehiclePosition, grid.getRotation(), gridRotationCenter);
vehicle.setPosition(vehiclePositonConsideringMapRotation.x, vehiclePositonConsideringMapRotation.y);
vehicle.setRotation(grid.getRotation());
Log.info(getClass(),"Vehicle: "+vehiclePositonConsideringMapRotation+", Flag: "+flagPositonConsideringMapRotation);
Log.info(getClass(), "Vehicle: " + vehiclePositonConsideringMapRotation + ", Flag: " + flagPositonConsideringMapRotation);
vehicle.setVisible(true);
finishFlag.setVisible(true);
}
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
return null;
}
}
......@@ -16,11 +16,45 @@ import cz.nic.tablexia.screen.AbstractTablexiaScreen;
public class RobberyGame extends AbstractTablexiaGame<GameRule> {
private enum ResultTextMapping {
NO_STAR_TEXT (GameResult.NO_STAR, VICTORYTEXT_NOSTAR),
ONE_STAR_TEXT (GameResult.ONE_STAR, VICTORYTEXT_ONESTAR),
TWO_STAR_TEXT (GameResult.TWO_STAR, VICTORYTEXT_TWOSTAR),
THREE_STAR_TEXT (GameResult.THREE_STAR, VICTORYTEXT_THREESTARS);
private final GameResult gameResult;
private final String textKey;
ResultTextMapping(GameResult gameResult, String textKey) {
this.gameResult = gameResult;
this.textKey = textKey;
}
public String getTextKey() {
return textKey;
}
public static ResultTextMapping getResultTextMappingForGameResult(GameResult gameResult) {
for (ResultTextMapping resultTextMapping : ResultTextMapping.values()) {
if (resultTextMapping.gameResult.equals(gameResult)) {
return resultTextMapping;
}
}
return null;
}
}
public static int CREATURES_COUNT = 50;
public static int THIEVES_COUNT = 8;
public static int CREATURES_WIDTH = 193;
public static int CREATURES_HEIGHT = 480;
private static final String VICTORYTEXT_NOSTAR = "game_robbery_victorytext_nostar";
private static final String VICTORYTEXT_ONESTAR = "game_robbery_victorytext_onestar";
private static final String VICTORYTEXT_TWOSTAR = "game_robbery_victorytext_twostar";
private static final String VICTORYTEXT_THREESTARS = "game_robbery_victorytext_threestars";
private InputMultiplexer inputMultiplexer;
private AbstractTablexiaScreen<Void> actualScreen;
......@@ -118,8 +152,16 @@ public class RobberyGame extends AbstractTablexiaGame<GameRule> {
actualScreen.dispose();
CreatureFactory.getInstance().dispose();
}
//////////////////////////// ABSTRACT TABLEXIA GAME
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
return ResultTextMapping.getResultTextMappingForGameResult(gameResult).getTextKey();
}
//////////////////////////// COMPONENT SCREENS
private void showScreen(final AbstractTablexiaScreen newScreen, boolean transaction) {
......
......@@ -273,5 +273,8 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
return Properties.RESULT_SOUNDS[progress];
}
@Override
protected String getTextKeyForGameResult(GameResult gameResult) {
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment