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

#11 Difficulty description from enum

parent b3028745
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@
package cz.nic.tablexia.game.difficulty;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
/**
* Game difficulty types
*
......@@ -26,34 +28,28 @@ package cz.nic.tablexia.game.difficulty;
*/
public enum GameDifficulty {
// TODO use string resources
EASY("gamedifficulty_easy"),
MEDIUM("gamedifficulty_medium"),
HARD("gamedifficulty_hard");
EASY ("gamedifficulty_easy"),
MEDIUM ("gamedifficulty_medium"),
HARD ("gamedifficulty_hard");
private String descriptionResourceId;
private String descriptionResourceKey;
private GameDifficulty(String descriptionResourceId) {
this.descriptionResourceId = descriptionResourceId;
private GameDifficulty(String descriptionResourceKey) {
this.descriptionResourceKey = descriptionResourceKey;
}
/**
* Returns id of description for current difficulty
*
* @return id of description string resource
*/
public String getDescriptionResourceId() {
return descriptionResourceId;
public String getTextDescription() {
return ApplicationTextManager.getInstance().getText(getDescriptionResourceKey());
}
/**
* Returns string key for intent extra
* Returns key of description for current difficulty
*
* @return string key for intent extra
* @return key of description string resource
*/
public static String getIntentKey() {
return GameDifficulty.class.getName();
public String getDescriptionResourceKey() {
return descriptionResourceKey;
}
/**
......
......@@ -124,9 +124,9 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener {
font.setScale(0.5f);
Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.BLACK);
Label easy = new Label(ApplicationTextManager.getInstance().getText(GameDifficulty.EASY.getDescriptionResourceId()), labelStyle);
Label medium = new Label(ApplicationTextManager.getInstance().getText(GameDifficulty.MEDIUM.getDescriptionResourceId()), labelStyle);
Label hard = new Label(ApplicationTextManager.getInstance().getText(GameDifficulty.HARD.getDescriptionResourceId()), labelStyle);
Label easy = new Label(GameDifficulty.EASY.getTextDescription(), labelStyle);
Label medium = new Label(GameDifficulty.MEDIUM.getTextDescription(), labelStyle);
Label hard = new Label(GameDifficulty.HARD.getTextDescription(), labelStyle);
float labelY = screen.getStage().getHeight() * 0.06f;
float labelAddX = diffWidth / 2;
......
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