Commit 568c1b3b authored by Matyáš Latner's avatar Matyáš Latner

Merge branch 'feature-fonts' into 'devel'

Feature fonts



See merge request !111
parents 51dcdfa2 08fd294d
......@@ -118,17 +118,13 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
public static final String VICTORY_DIALOG_SUMMARY_ICON_TIME = "time";
private static final String VICTORY_DIALOG_TUTORIAL_TEXT = "victoryscreen_text_tutorial";
private static final float VICTORY_DIALOG_BUTTON_TEXT_SCALE = 0.7f;
private static final String VICTORY_DIALOG_BUTTON_TEXT_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD;
private static final Color VICTORY_DIALOG_BUTTON_TEXT_FONT_COLOR = Color.BLACK;
private static final Color VICTORY_DIALOG_BUTTON_TEXT_FONT_COLOR = Color.BLACK;
private static final ApplicationFontManager.FontType VICTORY_DIALOG_BUTTON_TEXT_FONT_TYPE = ApplicationFontManager.FontType.ROBOTO_BOLD_14;
private static final int VICTORY_DIALOG_SHOW_SOUND_DELAY = 2;
private static final String VICTORY_DIALOG_TEXT_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR;
private static final float VICTORY_DIALOG_SUMMARY_IMAGE_SIZE = 0.7f;
private static final Color VICTORY_DIALOG_SUMMARY_FONT_COLOR = Color.GRAY;
private static final String VICTORY_DIALOG_SUMMARY_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR;
private static final float VICTORY_DIALOG_SUMMARY_TEXT_SIZE = 0.7f;
public static final String RANDOM_SEED_SCREEN_INFO_LABEL = "Random Seed";
public static final String GAME_DIFFICULTY_SCREEN_INFO_LABEL = "Game Difficulty";
......@@ -423,13 +419,18 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
private class VictoryDialog extends TwoButtonDialog {
public static final int RATINGSTARS_COUNT = 3;
public static final float RATINGSTAR_DELAY = 0.5f;
public static final int RATINGSTARS_COUNT = 3;
public static final float RATINGSTAR_DELAY = 0.5f;
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;
public static final float RESULTSBANNER_WIDTH_RATIO = 2f / 3;
public static final float CONTENT_ITEMS_TOPPADDING_RATIO = 1f / 30;
public static final float RATINGSTAR_HEIGHT_RATIO = 1f / 8;
public static final float TEXT_TOP_PADDING_RATIO = 1f / 15;
private static final int SUMMARY_TEXT_BOTTOM_PADDING = 10;
private final ApplicationFontManager.FontType SUMMARY_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_14;
private final ApplicationFontManager.FontType RESULT_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_16;
private final Color DIALOG_FONTS_COLOR = Color.BLACK;
private Image[] ratingStarsEnabled;
private Music victorySpeech;
......@@ -457,7 +458,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
@Override
public Cell<Label> addLabel(String text, BitmapFont font) {
Cell<Label> labelCell = super.addLabel(text, font);
Cell<Label> labelCell = addLabel(text, new Label.LabelStyle(font, DIALOG_FONTS_COLOR), getTextAlignment(), 1);
labelCell.padTop(getHeight() * TEXT_TOP_PADDING_RATIO);
return labelCell;
}
......@@ -468,7 +469,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
Image resultsBanner = new Image(getGameGlobalTextureRegion(VICTORY_DIALOG_RESULTSBANNER));
float resultBannerWidth = getWidth() * RESULTSBANNER_WIDTH_RATIO;
float resultsBannerSizeRatio = resultBannerWidth / resultsBanner.getWidth();
addImage(resultsBanner, resultsBannerSizeRatio).center().colspan(3);
addImage(resultsBanner, resultsBannerSizeRatio).center().colspan(3).padTop(getHeight() * CONTENT_ITEMS_TOPPADDING_RATIO);
// RATING STARS
getContentTable().row();
......@@ -477,7 +478,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
for (int i = 0; i < RATINGSTARS_COUNT; i++) {
createRatingStar(i, ratingStarTable);
}
getContentTable().add(ratingStarTable).center();
getContentTable().add(ratingStarTable).center().padTop(getHeight() * CONTENT_ITEMS_TOPPADDING_RATIO);
getContentTable().row();
// MAIN TEXT
......@@ -490,7 +491,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
}
getContentTable().row();
addLabel(victoryDialogText, ApplicationFontManager.getInstance().getFont(VICTORY_DIALOG_TEXT_FONT_TYPE));
addLabel(victoryDialogText, getFont(RESULT_TEXT_FONT));
getContentTable().row();
// SUMMARY TEXT
......@@ -501,7 +502,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
horizontalGroup.addActor(createSummaryGroup(summaryMessage));
}
}
getContentTable().add(horizontalGroup).padBottom(15).center();
getContentTable().add(horizontalGroup).padBottom(SUMMARY_TEXT_BOTTOM_PADDING).padTop(getHeight() * CONTENT_ITEMS_TOPPADDING_RATIO).center();
getContentTable().row();
showTrophies();
......@@ -539,10 +540,9 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
}
if (summaryMessage.getText() != null) {
BitmapFont font = ApplicationFontManager.getInstance().getFont(VICTORY_DIALOG_SUMMARY_FONT_TYPE);
BitmapFont font = getFont(SUMMARY_TEXT_FONT);
font.getData().markupEnabled = true;
Label summaryText = new Label(summaryMessage.getText(), new Label.LabelStyle(font, VICTORY_DIALOG_SUMMARY_FONT_COLOR));
summaryText.setFontScale(VICTORY_DIALOG_SUMMARY_TEXT_SIZE);
horizontalGroup.addActor(summaryText);
}
......@@ -610,7 +610,6 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
@Override
public void createButton(TablexiaButton textButton, ClickListener clickListener) {
textButton.getLabel().setStyle(new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(VICTORY_DIALOG_BUTTON_TEXT_FONT_TYPE), VICTORY_DIALOG_BUTTON_TEXT_FONT_COLOR));
textButton.getLabel().setFontScale(VICTORY_DIALOG_BUTTON_TEXT_SCALE);
super.createButton(textButton, clickListener);
}
......
......@@ -45,7 +45,7 @@ import static com.badlogic.gdx.scenes.scene2d.actions.Actions.parallel;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.run;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.scaleTo;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence;
import static cz.nic.tablexia.util.ui.TablexiaButton.*;
import static cz.nic.tablexia.util.ui.TablexiaButton.ButtonType;
/**
* Created by Matyáš Latner on 7.9.15.
......@@ -142,12 +142,11 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
private static final double KEY_ICON_TILE_SIZE_RATION_X = 0.7;
private static final double KEY_ICON_TILE_SIZE_RATION_Y = 0.4;
private static final float START_BUTTON_FONT_SCALE = 0.8f;
private static final int START_BUTTON_WIDTH = 135;
private static final int START_BUTTON_HEIGHT = 72;
private static final float START_BUTTON_X_OFFSET_RATIO = 1f / 4;
private static final float START_BUTTON_Y_OFFSET_RATIO = 1f / 4;
private static final ButtonType START_BUTTON_TYPE = ButtonType.GREEN;
private static final ButtonType START_BUTTON_TYPE = ButtonType.GREEN;
private static final String START_BUTTON_TEXT_KEY = "complete";
public static final float ANIMATION_DURATION = 0.4f;
......@@ -531,7 +530,6 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
setTouchable(isDisabled ? Touchable.disabled : Touchable.enabled);
}
};
startButton.getLabel().setFontScale(START_BUTTON_FONT_SCALE);
startButton.setSize(START_BUTTON_WIDTH, START_BUTTON_HEIGHT);
startButton.setPosition(MAP_START_POSITION_X + (MAP_X_SIZE * TILE_SIZE) + (startButton.getWidth() * START_BUTTON_X_OFFSET_RATIO),
MAP_START_POSITION_Y - (startButton.getHeight() * START_BUTTON_Y_OFFSET_RATIO));
......
......@@ -39,13 +39,13 @@ import cz.nic.tablexia.util.ui.ClickListenerWithSound;
public class MapWidget extends Group {
private static final float BOOKMARKBUTTON_TILE_SIZE_RATIO_HEIGHT = 0.3f;
private static final float BOOKMARKBUTTON_TILE_SIZE_RATIO_WIDTH = 1.5f;
public static final Color BOOKMARKBUTTON_BACKGROUND_COLOR_CHECKED = new Color(0.428f, 0.369f, 0.350f, 1f);
public static final Color BOOKMARKBUTTON_BACKGROUND_COLOR_UP = new Color(0.588f, 0.529f, 0.510f, 1f);
private static final Color BOOKMARKBUTTON_TEXT_COLOR = Color.BLACK;
private static final float BOOKMARKBUTTON_TEXT_SCALE = 0.8f;
private static final float BOOKMARKBUTTON_PADDING_RATIO = 1f / 20;
private static final float BOOKMARKBUTTON_TILE_SIZE_RATIO_HEIGHT = 0.3f;
private static final float BOOKMARKBUTTON_TILE_SIZE_RATIO_WIDTH = 1.5f;
public static final Color BOOKMARKBUTTON_BACKGROUND_COLOR_CHECKED = new Color(0.428f, 0.369f, 0.350f, 1f);
public static final Color BOOKMARKBUTTON_BACKGROUND_COLOR_UP = new Color(0.588f, 0.529f, 0.510f, 1f);
private static final Color BOOKMARKBUTTON_TEXT_COLOR = Color.BLACK;
private static final float BOOKMARKBUTTON_PADDING_RATIO = 1f / 20;
private static final ApplicationFontManager.FontType BOOKMARK_TITLE_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_16;
private Group mapLayer;
private Group backgroundLayer;
......@@ -88,21 +88,12 @@ public class MapWidget extends Group {
return this;
}
// public void setClickable(boolean clickable) {
// if (bookmarkButton != null) {
// bookmarkButton.setTouchable(clickable ? Touchable.enabled : Touchable.disabled);
// }
// }
public TileMap getTileMap() {
return tileMap;
}
public void setClickable(TileMapClickListener tileMapClickListener) {
this.tileMapClickListener = tileMapClickListener;
// if (bookmarkButton != null) {
// scene.registerTouchArea(bookmarkButton);
// }
}
public void setInFront() {
......@@ -124,13 +115,12 @@ public class MapWidget extends Group {
float bookmarkHeight = InTheDarknessGame.TILE_SIZE * BOOKMARKBUTTON_TILE_SIZE_RATIO_HEIGHT;
TextButton.TextButtonStyle bookmarkButtonStyle = new TextButton.TextButtonStyle();
bookmarkButtonStyle.font = ApplicationFontManager.getInstance().getDefaultApplicationRegularFont();
bookmarkButtonStyle.font = ApplicationFontManager.getInstance().getFont(BOOKMARK_TITLE_TEXT_FONT);
bookmarkButtonStyle.fontColor = BOOKMARKBUTTON_TEXT_COLOR;
bookmarkButtonStyle.checked = new SpriteDrawable(new Sprite(ApplicationAtlasManager.getInstance().getColorTextureRegion(BOOKMARKBUTTON_BACKGROUND_COLOR_CHECKED)));
bookmarkButtonStyle.up = new SpriteDrawable(new Sprite(ApplicationAtlasManager.getInstance().getColorTextureRegion(BOOKMARKBUTTON_BACKGROUND_COLOR_UP)));
bookmarkButton = new TextButton((floorNumber + 1) + ". " + buttonText, bookmarkButtonStyle);
bookmarkButton.getLabel().setFontScale(BOOKMARKBUTTON_TEXT_SCALE);
bookmarkButton.setBounds(floorNumber * (bookmarkWidth + (bookmarkWidth * BOOKMARKBUTTON_PADDING_RATIO)),
-(bookmarkHeight + 2),
bookmarkWidth,
......
......@@ -2,26 +2,28 @@ package cz.nic.tablexia.game.games.kidnapping.actors;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
/**
* Created by lhoracek on 5/19/15.
*/
public class EarOverlay extends Group {
private static final ApplicationFontManager.FontType FONT_TYPE = ApplicationFontManager.FontType.ROBOTO_REGULAR_30;
private static final Color FONT_COLOR = Color.WHITE;
private Image ear, overlay;
private Label text;
public EarOverlay(String text, Texture overlayTexture, TextureRegion earTexture) {
this.addActor(overlay = new Image(overlayTexture));
this.addActor(ear = new Image(earTexture));
BitmapFont bf = new BitmapFont(); // TODO change font
bf.getData().setScale(3);
this.addActor(this.text = new Label(text, new Label.LabelStyle(bf, Color.WHITE)));
this.addActor(this.text = new Label(text, new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(FONT_TYPE), FONT_COLOR)));
}
@Override
......@@ -32,10 +34,6 @@ public class EarOverlay extends Group {
text.setPosition(getWidth() / 2 - text.getWidth() / 2, getHeight() / 5 - text.getHeight() / 2);
}
public Image getEar() {
return ear;
}
public Label getText() {
return text;
}
......
......@@ -9,10 +9,13 @@ import cz.nic.tablexia.util.ui.TablexiaButton;
*/
public class ReplayButton extends TablexiaButton {
private static final String REPLAY_BUTTON_TEXT_KEY = "game_kidnapping_replay";
private static final int WIDTH = 200;
private static final int HEIGHT = 80;
public ReplayButton(KidnappingGame screen) {
// TODO fix getting text through screen
super(screen.getText("game_kidnapping_replay"), ButtonType.GREEN);
setSize(150, 80);
super(screen.getText(REPLAY_BUTTON_TEXT_KEY), ButtonType.GREEN);
setSize(WIDTH, HEIGHT);
setDisabled(true);
}
}
......
......@@ -23,6 +23,7 @@ import java.util.Random;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.robbery.assets.RobberyAssets;
import cz.nic.tablexia.game.games.robbery.creature.CreatureRoot;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.ui.TablexiaNoBlendingImage;
import static com.badlogic.gdx.scenes.scene2d.actions.Actions.alpha;
......@@ -226,9 +227,10 @@ public class GameScreen extends AbstractRobberyScreen {
private static final float COLORBANNER_X_POSITION_RATIO = 1f/2;
private static final float COLORBANNER_WIDTH_RATIO = 1f/3;
private static final float PERSON_COUNTER_POSITION_X_RATIO = 5f/6;
private static final float PERSON_COUNTER_POSITION_Y_RATIO = 1f/4;
private static final Color PERSON_COUNTER_TEXT_COLOR = Color.WHITE;
private static final float PERSON_COUNTER_POSITION_X_RATIO = 5f/6;
private static final float PERSON_COUNTER_POSITION_Y_RATIO = 1f/4;
private static final Color PERSON_COUNTER_TEXT_COLOR = Color.WHITE;
private static final ApplicationFontManager.FontType PERSON_COUNTER_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_20;
private static final Interpolation INFOITEM_HIDE_INTERPOLATION = Interpolation.pow4In;
private static final Interpolation INFOITEM_SHOW_ALPHA_INTERPOLATION = Interpolation.pow4Out;
......@@ -316,7 +318,7 @@ public class GameScreen extends AbstractRobberyScreen {
getSceneWidth() + BACKGROUND_BOTTOM_WIDTH_CORRECTION_OFFSET,
getSceneOuterHeight());
personCounter = new Label("", new Label.LabelStyle(getDefaultBoldFont(), PERSON_COUNTER_TEXT_COLOR));
personCounter = new Label("", new Label.LabelStyle(getFont(PERSON_COUNTER_FONT), PERSON_COUNTER_TEXT_COLOR));
personCounter.setPosition(width * PERSON_COUNTER_POSITION_X_RATIO, height * PERSON_COUNTER_POSITION_Y_RATIO);
getStage().addActor(doorBackground);
......
......@@ -14,6 +14,7 @@ import java.util.Map;
import cz.nic.tablexia.game.games.robbery.assets.RobberyAssets;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.TablexiaNoBlendingImage;
......@@ -23,7 +24,6 @@ public class RuleScreen extends AbstractRobberyScreen {
private static final float LABEL_Y_POSITION_RATIO = 23f/40;
private static final Color LABEL_TEXT_COLOR = Color.GRAY;
private static final float LABEL_FONT_SCALE = 0.8f;
private static final float TITLE_PAPER_POSITION_X_OFFSET = 1f/20;
private static final float TITLE_PAPER_Y_POSITION_RATIO = 3f/5;
......@@ -103,10 +103,9 @@ public class RuleScreen extends AbstractRobberyScreen {
float labelWidth = paperWidth * TITLE_WIDTH_RATIO;
float labelHeight = paperHeight * TITLE_HEIGHT_RATIO;
BitmapFont font = getDefaultRegularFont();
BitmapFont font = getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_18);
font.getData().markupEnabled = true;
Label label = new Label(getData().getRuleMessageText(this), new LabelStyle(font, LABEL_TEXT_COLOR));
label.setFontScale(LABEL_FONT_SCALE);
label.setWrap(true);
label.setBounds(paperX + (paperWidth / 2) - (labelWidth / 2),
paperY + (paperHeight * LABEL_Y_POSITION_RATIO) - labelHeight,
......
......@@ -31,6 +31,7 @@ import cz.nic.tablexia.game.games.shooting_range.tools.HitEvaluator;
import cz.nic.tablexia.game.games.shooting_range.tools.PixelPerfectHitEvaluator;
import cz.nic.tablexia.game.games.shooting_range.tools.TargetGenerator;
import cz.nic.tablexia.game.games.shooting_range.tools.TargetPositionController;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.model.game.Game;
/**
......@@ -38,6 +39,9 @@ import cz.nic.tablexia.model.game.Game;
*/
public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
private static final ApplicationFontManager.FontType SCORE_COUNTER_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_20;
private static final Color SCORE_COUNTER_TEXT_COLOR = Color.WHITE;
private GfxLibrary gfxLibrary = new GfxLibrary(this, TextureType.values());
private SfxLibrary sfxLibrary = new SfxLibrary(this, SoundType.values());
......@@ -254,7 +258,7 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
watch.setScale(0.4f);
getStage().addActor(carousel = new Carousel(gfxLibrary));
carousel.setScale(0.6f);
Label.LabelStyle labelStyle = new Label.LabelStyle(getDefaultBoldFont(), Color.WHITE);
Label.LabelStyle labelStyle = new Label.LabelStyle(getFont(SCORE_COUNTER_TEXT_FONT), SCORE_COUNTER_TEXT_COLOR);
getStage().addActor(score = new Label("0", labelStyle));
screenResized((int) getStage().getWidth(), (int) getStage().getHeight());
......
......@@ -21,6 +21,50 @@ import cz.nic.tablexia.loader.IApplicationLoader;
*/
public class ApplicationFontManager extends AssetManager implements IApplicationLoader {
public enum FontType {
ROBOTO_REGULAR_10 ("Roboto-Regular_10.ttf", 10, true),
ROBOTO_REGULAR_12 ("Roboto-Regular_12.ttf", 12, true),
ROBOTO_REGULAR_14 ("Roboto-Regular_14.ttf", 14, true),
ROBOTO_REGULAR_14_NOFILTER ("Roboto-Regular_14_nofilter.ttf", 14, false),
ROBOTO_REGULAR_16 ("Roboto-Regular_16.ttf", 16, true),
ROBOTO_REGULAR_18 ("Roboto-Regular_18.ttf", 18, true),
ROBOTO_REGULAR_20 ("Roboto-Regular_20.ttf", 20, true),
ROBOTO_REGULAR_26 ("Roboto-Regular_26.ttf", 26, true),
ROBOTO_REGULAR_30 ("Roboto-Regular_30.ttf", 30, true),
ROBOTO_BOLD_10 ("Roboto-Bold_10.ttf", 10, true),
ROBOTO_BOLD_12 ("Roboto-Bold_12.ttf", 12, true),
ROBOTO_BOLD_14 ("Roboto-Bold_14.ttf", 14, true),
ROBOTO_BOLD_16 ("Roboto-Bold_16.ttf", 16, true),
ROBOTO_BOLD_18 ("Roboto-Bold_18.ttf", 18, true),
ROBOTO_BOLD_20 ("Roboto-Bold_20.ttf", 20, true),
ROBOTO_BOLD_20_NOFILTER ("Roboto-Bold_20_nofilter.ttf", 20, false),
ROBOTO_BOLD_26 ("Roboto-Bold_26.ttf", 26, true),
ROBOTO_BOLD_30 ("Roboto-Bold_30.ttf", 30, true);
private String fontName;
private int size;
private boolean filtering;
FontType(String fontName, int size, boolean filtering) {
this.fontName = fontName;
this.size = size;
this.filtering = filtering;
}
public String getFontName() {
return FONT_PATH + fontName;
}
public int getSize() {
return size;
}
public boolean isFiltering() {
return filtering;
}
}
private static final int FONT_SIZE = 20;
private static final String FONT_PATH = "font/";
public static final String FONT_ROBOTO_REGULAR = FONT_PATH + "Roboto-Regular.ttf";
......@@ -53,6 +97,22 @@ public class ApplicationFontManager extends AssetManager implements IApplication
public void load() {
loadFont(FONT_ROBOTO_REGULAR);
loadFont(FONT_ROBOTO_BOLD);
for (FontType fontType: FontType.values()) {
loadFont(fontType);
}
}
private void loadFont(FontType fontType) {
FreeTypeFontLoaderParameter fontParams = new FreeTypeFontLoaderParameter();
fontParams.fontFileName = fontType.getFontName();
fontParams.fontParameters.size = fontType.getSize();
fontParams.fontParameters.characters = FreeTypeFontGenerator.DEFAULT_CHARS + TablexiaSettings.LocaleDefinition.getAllSpecialCharacters();
if (fontType.isFiltering()) {
fontParams.fontParameters.minFilter = TextureFilter.Linear;
fontParams.fontParameters.magFilter = TextureFilter.Linear;
}
load(fontType.getFontName(), BitmapFont.class, fontParams);
}
private void loadFont(String fontFile) {
......@@ -65,14 +125,21 @@ public class ApplicationFontManager extends AssetManager implements IApplication
load(fontFile, BitmapFont.class, fontParams);
}
public BitmapFont getFont(FontType fontType) {
return get(fontType.getFontName(), BitmapFont.class);
}
@Deprecated
public BitmapFont getFont(String fontName) {
return get(fontName, BitmapFont.class);
}
@Deprecated
public BitmapFont getDefaultApplicationRegularFont() {
return getFont(APPLICATION_DEFAULT_FONT_REGULAR);
}
@Deprecated
public BitmapFont getDefaultApplicationBoldFont() {
return getFont(APPLICATION_DEFAULT_FONT_BOLD);
}
......
......@@ -32,13 +32,11 @@ public class GameMenuItemGroup extends Container<Table> {
private static final Color HIGHLITED_COLOR = new Color(0.780f, 0.698f, 0.600f, 1);
private static final String TITLE_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD;
private static final Color TITLE_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
private static final float TITLE_FONT_SCALE = 0.9f;
private static final ApplicationFontManager.FontType TITLE_FONT_TYPE = ApplicationFontManager.FontType.ROBOTO_BOLD_18;
private static final Color TITLE_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
private static final String DESCRIPTION_FONT_TYPE = ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR;
private static final Color DESCRIPTION_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
private static final float DESCRIPTION_FONT_SCALE = 0.6f;
private static final ApplicationFontManager.FontType DESCRIPTION_FONT_TYPE = ApplicationFontManager.FontType.ROBOTO_REGULAR_12;
private static final Color DESCRIPTION_FONT_COLOR = new Color(0.325f, 0.278f, 0.255f, 1);
private static final float LABLES_PADDING_LEFT_RATIO = 1f / 40;
private static final float LABELS_PADDING_DEFAULT = 5f;
......@@ -96,10 +94,8 @@ public class GameMenuItemGroup extends Container<Table> {
// texts
Label titleLabel = new Label(menuItem.getTitle(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(TITLE_FONT_TYPE), TITLE_FONT_COLOR));
titleLabel.setWrap(true);
titleLabel.setFontScale(TITLE_FONT_SCALE);
Label descritopnLabel = new Label(menuItem.getDescription(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(DESCRIPTION_FONT_TYPE), DESCRIPTION_FONT_COLOR));
descritopnLabel.setWrap(true);
descritopnLabel.setFontScale(DESCRIPTION_FONT_SCALE);
Table labelsContainer = new Table();
labelsContainer.add(titleLabel).align(Align.left);
labelsContainer.row();
......
......@@ -34,20 +34,19 @@ import cz.nic.tablexia.menu.main.user.UserSelectBox;
*/
public class MainMenu extends AbstractMenu {
private static final MenuControlType MENU_CONTROL_TYPE = MenuControlType.MANUAL;
private static final boolean MENU_SCREEN_PAUSE = true;
private static final float MAINMENU_PADDING = 10f;
private static final float SCROLLBAR_PADDING_BOTTOM = 10f;
private static final float SCROLLBAR_PADDING_TOP = 10f;
private static final int SELECTBOX_USER_HEIGHT = 70;
private static final int SELECTBOX_LOCALE_HEIGHT = 40;
private static final float SELECTBOX_LOCALE_TEXT_SCALE = 0.65f;
private static final float SELECTBOX_LOCALE_WIDTH_RATIO = 2f/5;
private static final int APP_NAME_TEXT_ALIGN = Align.left;
private static final float APP_NAME_TEXT_SCALE = 0.5f;
private static final float APP_NAME_TEXT_PADDING_LEFT = 10f;
private static final float APP_NAME_WIDTH_RATIO = 3f/5;
private static final MenuControlType MENU_CONTROL_TYPE = MenuControlType.MANUAL;
private static final boolean MENU_SCREEN_PAUSE = true;
private static final float MAINMENU_PADDING = 10f;
private static final float SCROLLBAR_PADDING_BOTTOM = 10f;
private static final float SCROLLBAR_PADDING_TOP = 10f;
private static final int SELECTBOX_USER_HEIGHT = 70;
private static final int SELECTBOX_LOCALE_HEIGHT = 40;
private static final float SELECTBOX_LOCALE_WIDTH_RATIO = 2f/5;
private static final ApplicationFontManager.FontType APP_NAME_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_10;
private static final int APP_NAME_TEXT_ALIGN = Align.left;
private static final float APP_NAME_TEXT_PADDING_LEFT = 10f;
private static final float APP_NAME_WIDTH_RATIO = 3f/5;
private Map<IMenuItem, Group> subMenus = new HashMap<IMenuItem, Group>();
private VerticalGroup menuItemsLayout;
......@@ -92,10 +91,10 @@ public class MainMenu extends AbstractMenu {
// Locale SelectBox and App name
Table footerTable = new Table();
float footerContentWidth = getBackground().getDrawable().getMinWidth() - (2 * MAINMENU_PADDING) - APP_NAME_TEXT_PADDING_LEFT;
footerTable.add(new LocaleSelectBox(SELECTBOX_LOCALE_HEIGHT, SELECTBOX_LOCALE_TEXT_SCALE)).width(footerContentWidth * SELECTBOX_LOCALE_WIDTH_RATIO);
Label appName = new Label(TablexiaSettings.getInstance().getAppName() + System.lineSeparator() + TablexiaSettings.getInstance().getVersionName(), new Label.LabelStyle(font, Color.BLACK));
footerTable.add(new LocaleSelectBox(SELECTBOX_LOCALE_HEIGHT)).width(footerContentWidth * SELECTBOX_LOCALE_WIDTH_RATIO);
Label appName = new Label(TablexiaSettings.getInstance().getAppName() + System.lineSeparator() + TablexiaSettings.getInstance().getVersionName(),
new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(APP_NAME_TEXT_FONT), Color.BLACK));
appName.setAlignment(APP_NAME_TEXT_ALIGN);
appName.setFontScale(APP_NAME_TEXT_SCALE);
appName.setWrap(true);
footerTable.add(appName).width(footerContentWidth * APP_NAME_WIDTH_RATIO).padLeft(APP_NAME_TEXT_PADDING_LEFT);
layoutTable.add(footerTable).fillX();
......
......@@ -24,10 +24,9 @@ import cz.nic.tablexia.util.ui.AbstractTablexiaSelectBox;
*/
public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.LocaleItem> {
private static final Color LOCALE_TEXT_COLOR = new Color(0.098f, 0.086f, 0.075f, 1f);
private static final int LOCALE_TEXT_ALIGN = Align.center;
private final float textSize;
private static final ApplicationFontManager.FontType LOCALE_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_14_NOFILTER;
private static final Color LOCALE_TEXT_COLOR = new Color(0.098f, 0.086f, 0.075f, 1f);
private static final int LOCALE_TEXT_ALIGN = Align.center;
public class LocaleItem extends Actor {
......@@ -41,7 +40,7 @@ public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.L
this.localeDefinition = localeDefinition;
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUITEM_BACKGROUND);
font = ApplicationFontManager.getInstance().getDefaultApplicationRegularFont();
font = ApplicationFontManager.getInstance().getFont(LOCALE_TEXT_FONT);
text = ApplicationTextManager.getInstance().getText(localeDefinition.getDescriptionKey());
glyphLayout = new GlyphLayout();
}
......@@ -57,10 +56,8 @@ public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.L
background.draw(batch, getX(), getY(), getWidth(), getHeight());
font.getData().setScale(textSize);
glyphLayout.setText(font, text, LOCALE_TEXT_COLOR, getWidth(), LOCALE_TEXT_ALIGN, false);
font.draw(batch, glyphLayout, getX(), getY() + getHeight() / 2 + font.getLineHeight() / 3);
font.getData().setScale(1f);
}
}
......@@ -71,9 +68,8 @@ public class LocaleSelectBox extends AbstractTablexiaSelectBox<LocaleSelectBox.L
}
};
public LocaleSelectBox(float itemHeight, float textSize) {
public LocaleSelectBox(float itemHeight) {
super(itemHeight);
this.textSize = textSize;
ApplicationBus.getInstance().subscribe(this);
prepareLocales();
}
......
......@@ -18,8 +18,9 @@ import cz.nic.tablexia.menu.main.user.UserSelectBox;
*/
public abstract class UserMenuNewSelectBoxItemGroup extends Actor implements UserSelectBox.UserSelectBoxItem {
private static final Color NEWUSER_TEXT_COLOR = new Color(0.098f, 0.086f, 0.075f, 1f);
private static final int NEWUSER_TEXT_ALIGN = Align.center;
private static final ApplicationFontManager.FontType NEWUSER_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_20_NOFILTER;
private static final Color NEWUSER_TEXT_COLOR = new Color(0.098f, 0.086f, 0.075f, 1f);
private static final int NEWUSER_TEXT_ALIGN = Align.center;
private final NinePatch background;
private final BitmapFont font;
......@@ -27,9 +28,9 @@ public abstract class UserMenuNewSelectBoxItemGroup extends Actor implements Use
private final GlyphLayout glyphLayout;
public UserMenuNewSelectBoxItemGroup() {
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUBUTTON_BACKGROUND);
font = ApplicationFontManager.getInstance().getDefaultApplicationBoldFont();
text = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_NEWUSER);
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUBUTTON_BACKGROUND);
font = ApplicationFontManager.getInstance().getFont(NEWUSER_TEXT_FONT);
text = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_NEWUSER);
glyphLayout = new GlyphLayout();
}
......
......@@ -18,21 +18,22 @@ import cz.nic.tablexia.model.User;
*/
public class UserMenuSelectBoxItemGroup extends Group implements UserSelectBox.UserSelectBoxItem {
private static final int TEXT_LEFT_OFFSET = 20;
private static final int IMAGE_BORDER_OFFSET = 4;
private static final Color FOREGROUND_COLOR = new Color(0.322f, 0.278f, 0.255f, 1f);
private static final ApplicationFontManager.FontType TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_20;
private static final int TEXT_LEFT_OFFSET = 20;
private static final int IMAGE_BORDER_OFFSET = 4;
private static final Color FOREGROUND_COLOR = new Color(0.322f, 0.278f, 0.255f, 1f);
private final NinePatch background;
private final BitmapFont font;
private final NinePatch background;
private final BitmapFont font;
private final TextureRegionDrawable image;
private final User user;
private final User user;
public UserMenuSelectBoxItemGroup(IMenuItem menuItem, float width) {
this.user = (User) menuItem;
this.user = (User) menuItem;
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUITEM_BACKGROUND);
font = ApplicationFontManager.getInstance().getDefaultApplicationRegularFont();
image = new TextureRegionDrawable(ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.USERMENU_MENUITEM_SAMPLE));
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUITEM_BACKGROUND);
font = ApplicationFontManager.getInstance().getFont(TEXT_FONT);
image = new TextureRegionDrawable(ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.USERMENU_MENUITEM_SAMPLE));
}
public void performAction() {
......
......@@ -655,10 +655,12 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {