diff --git a/core/src/cz/nic/tablexia/TablexiaSettings.java b/core/src/cz/nic/tablexia/TablexiaSettings.java index f4eaf6ef900e93994e084dff618a23293a9efaf3..87673c38d0a8e90f6bfdf6b533d60de558548218 100644 --- a/core/src/cz/nic/tablexia/TablexiaSettings.java +++ b/core/src/cz/nic/tablexia/TablexiaSettings.java @@ -2,6 +2,7 @@ package cz.nic.tablexia; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.Stage; import java.util.Locale; @@ -18,24 +19,26 @@ import cz.nic.tablexia.util.Log; public class TablexiaSettings { - private static final int DEFAULT_SCREEN_WIDTH = 1000; - private static final double MAXIMUM_RATIO = 9.0 / 16.0; - private static final int MIN_SCREEN_HEIGHT = (int) (DEFAULT_SCREEN_WIDTH * MAXIMUM_RATIO); + private static final int DEFAULT_SCREEN_WIDTH = 1000; + private static final double MAXIMUM_RATIO = 9.0 / 16.0; + private static final int MIN_SCREEN_HEIGHT = (int) (DEFAULT_SCREEN_WIDTH * MAXIMUM_RATIO); + private static final Color DEFAULT_BACKGROUND_COLOR = new Color(0.99f, 0.88f, 0.71f, 1); + private static final Color DEFAULT_FONT_COLOR = Color.BLACK; public static final Class<? extends AbstractTablexiaScreen<?>> LOADER_SCREEN = LoaderScreen.class; public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = GameMenuScreen.class; public static final Long GAMES_RANDOM_SEED = null; public static final int AVATAR_COUNT = 8; - private static final String PREFERENCES_KEY = "cz.nic.tablexia."; - public static final String LOCALE_KEY = "locale"; - private static final String SELECTED_USER = "selected_user"; + private static final String PREFERENCES_KEY = "cz.nic.tablexia."; + public static final String LOCALE_KEY = "locale"; + private static final String SELECTED_USER = "selected_user"; - public static final String DEV_VERSION_TYPE = "-SNAPSHOT-"; + public static final String DEV_VERSION_TYPE = "-SNAPSHOT-"; - private static final String APP_NAME = "Tablexia"; - private final String VERSION_NAME = TablexiaBuildConfig.VERSION_NAME; + private static final String APP_NAME = "Tablexia"; + private final String VERSION_NAME = TablexiaBuildConfig.VERSION_NAME; private final BuildType BUILD_TYPE; private Preferences preferences; @@ -53,14 +56,14 @@ public class TablexiaSettings { private final static BuildType FALLBACK_VARIANT = BuildType.DEVEL; - private final String key; - private boolean boundingBoxes; - private boolean applicationInfo; - private boolean screenInfo; - private boolean debugMenu; - private boolean showBuildTypeInName; - private boolean bugReport; - private final Log.TablexiaLogLevel logLevel; + private final String key; + private boolean boundingBoxes; + private boolean applicationInfo; + private boolean screenInfo; + private boolean debugMenu; + private boolean showBuildTypeInName; + private boolean bugReport; + private final Log.TablexiaLogLevel logLevel; BuildType(String key, boolean boundingBoxes, boolean applicationInfo, boolean screenInfo, boolean debugMenu, boolean showBuildTypeInName, boolean bugReport, Log.TablexiaLogLevel logLevel) { this.key = key; @@ -201,6 +204,13 @@ public class TablexiaSettings { return "GAME_DIFFICULTY_" + gameDefinition.name(); } + public static Color getDefaultBackgroundColor() { + return DEFAULT_BACKGROUND_COLOR; + } + + public static Color getDefaultFontColor() { + return DEFAULT_FONT_COLOR; + } //////////////////////////// USER SETTINGS diff --git a/core/src/cz/nic/tablexia/screen/about/AboutScreen.java b/core/src/cz/nic/tablexia/screen/about/AboutScreen.java index 96ff9c6baad03a2cca855ecaad48be522cb29b0d..aac5acaa32edd3376689292a11eb2eaaa0e5ffd4 100644 --- a/core/src/cz/nic/tablexia/screen/about/AboutScreen.java +++ b/core/src/cz/nic/tablexia/screen/about/AboutScreen.java @@ -10,81 +10,138 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.Table; -import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ExtendViewport; +import com.badlogic.gdx.utils.viewport.Viewport; import java.util.List; import java.util.Map; import cz.nic.tablexia.TablexiaSettings; +import cz.nic.tablexia.loader.application.ApplicationFontManager; import cz.nic.tablexia.screen.AbstractTablexiaScreen; import cz.nic.tablexia.screen.about.assets.AboutAssets; +import cz.nic.tablexia.util.ui.ClickListenerWithSound; public class AboutScreen extends AbstractTablexiaScreen<Void> { - private static final Color BACKGROUND_COLOR = new Color(0.972f, 0.972f, 0.972f, 1); - private static final Color DEFAULT_FONT_COLOR = Color.BLACK; - private static final boolean SHOW_BOUNDING_BOXES = TablexiaSettings.getInstance().isShowBoundingBoxes(); - private static final float DEFAULT_FONT_SCALE = 0.7f; - private static final float BIG_FONT_SCALE = 1.0f; - - private static final float CONTENT_RELATIVE_WIDTH = 0.9f; - private static final int LOGO_TABLEXIA_MAX_HEIGHT = 60; - private static final int LOGO_CZ_NIC_MAX_HEIGHT = 20; - private static final int CONTENT_PAD = 35; - private static final int IMAGE_PAD = 15; - private static final int BUTTON_PAD_BOTTOM = 25; + private static final Color DEFAULT_FONT_COLOR = TablexiaSettings.getDefaultFontColor(); + private static final Color DEFAULT_BACKGROUND_COLOR = TablexiaSettings.getDefaultBackgroundColor(); + private static final boolean SHOW_BOUNDING_BOXES = TablexiaSettings.getInstance().isShowBoundingBoxes(); + + private static final float CONTENT_RELATIVE_WIDTH = 0.9f; + private static final float CONTENT_RELATIVE_HEIGHT = 0.85f; + private static final int LOGO_TABLEXIA_MAX_HEIGHT = 60; + private static final int LOGO_CZ_NIC_MAX_HEIGHT = 20; + private static final int CONTENT_PAD = 10; + private static final int LABEL_PAD = 5; + private static final int IMAGE_PAD = 20; + private static final int CLOSE_BUTTON_PAD_BOTTOM = 25; + private static final int CLOSE_BUTTON_PAD_LEFT = 5; + private static final int CLOSE_BUTTON_SIZE = 35; - private static final int DEFAULT_FONT_PAD = 5; - private static final int BIG_FONT_PAD = 10; + private static final int DEFAULT_FONT_PAD = 5; + private static final int BIG_FONT_PAD = 10; + private final LabelStyle LABEL_STYLE_18 = new LabelStyle(getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_18), DEFAULT_FONT_COLOR); + private final LabelStyle BOLD_LABEL_STYLE_18 = new LabelStyle(getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_18), DEFAULT_FONT_COLOR); + private final LabelStyle BOLD_LABEL_STYLE_20 = new LabelStyle(getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_20), DEFAULT_FONT_COLOR); + private final LabelStyle BOLD_LABEL_STYLE_26 = new LabelStyle(getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_26), DEFAULT_FONT_COLOR); - private Table container; + private Table backgroundTable; + private Table contentStack; private Table content; + private Button closeButton; + private ScrollPane contentScrollPane; - private float contentWidth; - private LabelStyle labelStyle; - private LabelStyle boldLabelStyle; + private float contentWidth; + private float contentHeight; + private LabelClickListener labelClickListener; @Override - protected void screenLoaded(Map<String, String> screenState) { - contentWidth = CONTENT_RELATIVE_WIDTH * getStage().getWidth() - CONTENT_PAD; - container = new Table(); - container.setDebug(SHOW_BOUNDING_BOXES, SHOW_BOUNDING_BOXES); - container.setSize(getStage().getWidth(), getStage().getHeight() - CONTENT_PAD); - container.setBackground(new TextureRegionDrawable(getColorTextureRegion(BACKGROUND_COLOR))); + protected Viewport getViewport() { + return new ExtendViewport(TablexiaSettings.getWorldSize(), TablexiaSettings.getMinWorldHeight()); + } - getStage().addActor(container); - prepareContentLayout(); + @Override + protected void screenLoaded(Map<String, String> screenState) { + TextureRegionDrawable backgroundTexture = new TextureRegionDrawable(getColorTextureRegion(DEFAULT_BACKGROUND_COLOR)); + backgroundTable = new Table(); + contentStack = new Table(); + backgroundTable.background(backgroundTexture); + backgroundTable.setFillParent(true); + prepareScreenLayout(); } + /** * Prepare screen content layout */ - private void prepareContentLayout() { + private void prepareScreenLayout() { + contentWidth = CONTENT_RELATIVE_WIDTH * getViewportWidth(); + contentHeight = CONTENT_RELATIVE_HEIGHT * getViewportHeight(); + content = new Table(); +// content.setDebug(SHOW_BOUNDING_BOXES); + content.setSize(contentWidth, contentHeight); labelClickListener = new LabelClickListener(); - labelStyle = new LabelStyle(getDefaultRegularFont(), DEFAULT_FONT_COLOR); - boldLabelStyle = new LabelStyle(getDefaultBoldFont(), DEFAULT_FONT_COLOR); + + prepareContent(); + + closeButton = new Button(new TextureRegionDrawable(getScreenTextureRegion(AboutAssets.CLOSEBUTTON_UNPRESSED)), new TextureRegionDrawable(getScreenTextureRegion(AboutAssets.CLOSEBUTTON_PRESSED))); + closeButton.addListener(new ClickListenerWithSound() { + @Override + public void onClick(InputEvent event, float x, float y) { + super.onClick(event, x, y); + backToInitialScreen(); + } + }); + + contentScrollPane = new ScrollPane(content); + contentScrollPane.setScrollingDisabled(true, false); + contentScrollPane.setFillParent(true); + contentStack.add(closeButton).width(CLOSE_BUTTON_SIZE).height(CLOSE_BUTTON_SIZE).bottom().left().padLeft(CLOSE_BUTTON_SIZE + CLOSE_BUTTON_PAD_LEFT).padBottom(CLOSE_BUTTON_SIZE + CLOSE_BUTTON_PAD_BOTTOM); + + getStage().addActor(backgroundTable); + getStage().addActor(contentScrollPane); + getStage().addActor(contentStack); + } - addImageToContainer(AboutAssets.LOGO_TABLEXIA, LOGO_TABLEXIA_MAX_HEIGHT, Links.TABLEXIA); + private void prepareContent() { + Links nicWeb; + Links tablexiaWeb; + switch (TablexiaSettings.getInstance().getLocaleDefinition()) { + default: + tablexiaWeb = Links.TABLEXIA; + nicWeb = Links.NIC_CS; + break; + case de_DE: + tablexiaWeb = Links.TABLEXIA_DE; + nicWeb = Links.NIC_EN; + break; + case sk_SK: + tablexiaWeb = Links.TABLEXIA_SK; + nicWeb = Links.NIC_CS; + break; + } + addImageToContainer(AboutAssets.LOGO_TABLEXIA, LOGO_TABLEXIA_MAX_HEIGHT, tablexiaWeb); addDefaultTextToContainer(AboutAssets.ABOUT_INFO_1); //add cz.nic logo - addImageToContainer(AboutAssets.LOGO_NIC, LOGO_CZ_NIC_MAX_HEIGHT, Links.NIC_CZ); + addImageToContainer(AboutAssets.LOGO_NIC, LOGO_CZ_NIC_MAX_HEIGHT, nicWeb); //add text from properties addDefaultTextToContainer(AboutAssets.ABOUT_INFO_2); addDefaultTextToContainer(AboutAssets.ABOUT_INFO_3); - addBigBoldTextToContainer(AboutAssets.PARAGRAPH_1); + addParagraphName(AboutAssets.PARAGRAPH_1); addBoldTextToContainer(AboutAssets.PROJECT_MANAGERS); addDefaultTextToContainer(AboutAssets.PROJECT_MANAGERS_DETAILS); @@ -101,10 +158,10 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> { addBoldTextToContainer(AboutAssets.ILLUSTRATORS); addDefaultTextToContainer(AboutAssets.ILLUSTRATORS_DETAILS); - addBigBoldTextToContainer(AboutAssets.PARAGRAPH_2); + addParagraphName(AboutAssets.PARAGRAPH_2); addDefaultTextToContainer(AboutAssets.PARAGRAPH_2_DETAILS); - addBigBoldTextToContainer(AboutAssets.PARAGRAPH_3); + addParagraphName(AboutAssets.PARAGRAPH_3); addDefaultTextToContainer(AboutAssets.PARAGRAPH_3_DETAILS_1_1); addLabelLink(Links.TABLEXIA_GIT); @@ -112,69 +169,58 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> { addDefaultTextToContainer(AboutAssets.PARAGRAPH_3_DETAILS_1_2); addDefaultTextToContainer(AboutAssets.PARAGRAPH_3_DETAILS_2); - content.add(createTableWithLibrariesLinks()).width(contentWidth); + content.add(createTableWithLibrariesLinks()).width(contentWidth - LABEL_PAD); content.row(); - addBigBoldTextToContainer(AboutAssets.PARAGRAPH_4); + addParagraphName(AboutAssets.PARAGRAPH_4); addDefaultTextToContainer(AboutAssets.PARAGRAPH_4_DETAILS); addDefaultTextToContainer(AboutAssets.ABOUT_INFO_4); - addBigLabelLink(Links.TABLEXIA); - Button closeButton = new Button(new TextureRegionDrawable(getScreenTextureRegion(AboutAssets.CLOSEBUTTON_UNPRESSED)), new TextureRegionDrawable(getScreenTextureRegion(AboutAssets.CLOSEBUTTON_PRESSED))); - closeButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); - backToInitialScreen(); - } - }); - contentScrollPane = new ScrollPane(content); - contentScrollPane.setScrollingDisabled(true, false); - container.add(closeButton).width(CLOSE_BUTTON_SIZE).height(CLOSE_BUTTON_SIZE).bottom().padBottom(BUTTON_PAD_BOTTOM); - container.add(contentScrollPane); + addBigLabelLink(tablexiaWeb); + + content.pad(CONTENT_PAD); } + /** * Add default text * * @param textID */ private void addDefaultTextToContainer(String textID) { - addTextToContainer(textID, false, false); + addTextToContainer(textID, LABEL_STYLE_18, false); content.row(); } private void addBoldTextToContainer(String textID) { - addTextToContainer(textID, true, false); + addTextToContainer(textID, BOLD_LABEL_STYLE_18, false); + content.row(); + } + + private void addParagraphName(String textID) { + addTextToContainer(textID, BOLD_LABEL_STYLE_26, false); content.row(); } private void addBigBoldTextToContainer(String textID) { - addTextToContainer(textID, true, true); + addTextToContainer(textID, BOLD_LABEL_STYLE_20, true); content.row(); } /** - * Add custom label to container * - * @param textID labelID from properties file - * @param bold + * @param textID + * @param style * @param bigFont */ - private void addTextToContainer(String textID, boolean bold, boolean bigFont) { - LabelStyle style = labelStyle; - float fontScale = DEFAULT_FONT_SCALE; + private void addTextToContainer(String textID, LabelStyle style, boolean bigFont) { float labelPad = DEFAULT_FONT_PAD; - if (bold) { - style = boldLabelStyle; - } if (bigFont) { - fontScale = BIG_FONT_SCALE; labelPad = BIG_FONT_PAD; } - content.add(createStyledLabel(getText(textID), style, fontScale)).width(contentWidth).padTop(labelPad).padBottom(labelPad); + content.add(createStyledLabel(getText(textID), style)).width(contentWidth - LABEL_PAD).padTop(labelPad).padBottom(labelPad); } @@ -190,7 +236,6 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> { } - /** * Add image to content container * @@ -226,30 +271,19 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> { } private Label createLabelWithLink(Links link, boolean bigFont) { - float scale = DEFAULT_FONT_SCALE; + LabelStyle style = BOLD_LABEL_STYLE_18; if (bigFont) { - scale = BIG_FONT_SCALE; + style = BOLD_LABEL_STYLE_20; } - Label label = new Label(link.getLinkName(), boldLabelStyle); - - label.setFontScale(scale); + Label label = new Label(link.getLinkName(), style); label.setUserObject(link); label.addListener(labelClickListener); return label; } - /** - * Create Label with custom text and parameters - * - * @param text label text - * @param labelStyle label style - * @param scale text scale - * @return custom label - */ - private Label createStyledLabel(String text, LabelStyle labelStyle, float scale) { + private Label createStyledLabel(String text, LabelStyle labelStyle) { Label newLabel = new Label(text, labelStyle); - newLabel.setFontScale(scale); newLabel.setAlignment(Align.center); newLabel.setWrap(true); @@ -258,10 +292,9 @@ public class AboutScreen extends AbstractTablexiaScreen<Void> { } - private static class LabelClickListener extends ClickListener { - + private static class LabelClickListener extends ClickListenerWithSound { @Override - public void clicked(InputEvent event, float x, float y) { + public void onClick(InputEvent event, float x, float y) { String url = ((Links) event.getListenerActor().getUserObject()).getLinkAddress(); Gdx.net.openURI(url); } diff --git a/core/src/cz/nic/tablexia/screen/about/Links.java b/core/src/cz/nic/tablexia/screen/about/Links.java index c6ac9e9936b02c4f1b5f75c0d266452100f44bd4..f9a81bf4af14789409aa3111defc9ae52816958e 100644 --- a/core/src/cz/nic/tablexia/screen/about/Links.java +++ b/core/src/cz/nic/tablexia/screen/about/Links.java @@ -6,8 +6,11 @@ import java.util.List; public enum Links { - NIC_CZ("CZ.NIC", "http://www.nic.cz", LinkGroups.OTHER), - TABLEXIA("www.tablexia.cz", "http://tablexia.cz", LinkGroups.OTHER), + NIC_CS("CZ.NIC", "https://www.nic.cz/setlang/?language=cs", LinkGroups.OTHER), + NIC_EN("CZ.NIC", "https://www.nic.cz/setlang/?language=en", LinkGroups.OTHER), + TABLEXIA("www.tablexia.cz", "https://www.tablexia.cz/cs/", LinkGroups.OTHER), + TABLEXIA_SK("www.tablexia.cz", "https://www.tablexia.cz/sk/", LinkGroups.OTHER), + TABLEXIA_DE("www.tablexia.cz", "https://www.tablexia.cz/de/", LinkGroups.OTHER), TABLEXIA_GIT("GitLab CZ.NIC", "https://gitlab.labs.nic.cz/labs/tablexia/tree/master", LinkGroups.OTHER), AND_ENGINE("AndEngine,", "http://www.andengine.org/", LinkGroups.LIBRARY), ACTIVE_ANDROID("ActiveAndroid,", "http://www.activeandroid.com/", LinkGroups.LIBRARY), @@ -16,6 +19,7 @@ public enum Links { ROBO_GUICE("robo-guice,", "https://github.com/roboguice/roboguice", LinkGroups.LIBRARY), GOOGLE_GUICE("google-guice,", "http://code.google.com/p/google-guice/", LinkGroups.LIBRARY), SVG_ANDROID("svg-android", "http://code.google.com/p/svg-android/", LinkGroups.LIBRARY); + // TODO: 20.11.15 add fb & twitter private String linkName; private String linkAddress; diff --git a/core/src/cz/nic/tablexia/screen/encyclopedia/EncyclopediaScreen.java b/core/src/cz/nic/tablexia/screen/encyclopedia/EncyclopediaScreen.java index 5171ecf82efb43eeed28ea0b2680f491d2caa73d..6a28090bcabbdb1ccbec59cda981110bc2cf7024 100644 --- a/core/src/cz/nic/tablexia/screen/encyclopedia/EncyclopediaScreen.java +++ b/core/src/cz/nic/tablexia/screen/encyclopedia/EncyclopediaScreen.java @@ -51,7 +51,8 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> { private static final float RELATIVE_LEFT_PAD = 0.03f; - private static final Color BACKGROUND_COLOR = new Color(((float) 248 / (float) 255), ((float) 236 / (float) 255), ((float) 212 / (float) 255), 1); + + private static final Color BACKGROUND_COLOR = TablexiaSettings.getDefaultBackgroundColor(); private static final String FONT_PLUS_TEXT = "+A"; private static final String FONT_MINUS_TEXT = "-A"; private static final String MUSIC_EXTENSION = ".mp3"; diff --git a/core/src/cz/nic/tablexia/screen/encyclopedia/menu/MenuWidget.java b/core/src/cz/nic/tablexia/screen/encyclopedia/menu/MenuWidget.java index 1f903f7e523ccc0db69d7e61ffe57c5d6feefc3e..fe24e53c1b4fae2d3061f7d003b9f545f924d9eb 100644 --- a/core/src/cz/nic/tablexia/screen/encyclopedia/menu/MenuWidget.java +++ b/core/src/cz/nic/tablexia/screen/encyclopedia/menu/MenuWidget.java @@ -12,7 +12,6 @@ import com.badlogic.gdx.utils.Array; import java.util.HashMap; import java.util.Map; - import cz.nic.tablexia.loader.application.ApplicationFontManager; import cz.nic.tablexia.screen.AbstractTablexiaScreen; import cz.nic.tablexia.util.Point;