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

Merge branch 'feature-about-devel' into 'devel'

Feature about devel

Zmenil jsem velikost screenu podle novych viewportu. Taky jsem tam pridal nove fonty. Do TablexiaSetting jsem pridal dve promenne: barvu pozadi a barvu fontu + jejich getry. 

See merge request !112
parents f3f30178 3d8bb886
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -14,8 +14,6 @@ import java.util.List;
import java.util.Map;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Point;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.encyclopedia.assets.EncyclopediaAssets;
import cz.nic.tablexia.screen.encyclopedia.content.ContentParser;
......@@ -24,25 +22,27 @@ import cz.nic.tablexia.screen.encyclopedia.menu.MenuItem;
import cz.nic.tablexia.screen.encyclopedia.menu.MenuWidget;
import cz.nic.tablexia.screen.encyclopedia.widget.ResizableScrollPane;
import cz.nic.tablexia.screen.encyclopedia.widget.ResizableWidgetGroup;
import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.Point;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
import cz.nic.tablexia.util.ui.TablexiaButton;
public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
private static final String SOURCE_FILE_EXTENSION = ".json";
private static final Point SCREEN_SIZE = new Point(TablexiaSettings.getWorldSize(), TablexiaSettings.getMinWorldHeight());
private static final float FONT_BUTTON_WIDTH = 70;
private static final float BUTTONS_MARGIN_LEFT = 30;
private static final float BUTTONS_GAP = 20;
private static final float CONTENT_RELATIVE_WIDTH = 0.70f;
private static final float MENU_RELATIVE_HEIGHT = 0.85f;
private static final int CLOSE_BUTTON_WIDTH = 35;
private static final int CLOSE_BUTTON_HEIGHT = 35;
private static final int CLOSE_BUTTON_PAD_TOP = 0;
private static final int CLOSE_BUTTON_PAD_RIGHT = 20;
private static final int CLOSE_BUTTON_PAD_LEFT = 5;
private static final int CLOSE_BUTTON_PAD_BOTTOM = 25;
private static final String SOURCE_FILE_EXTENSION = ".json";
private static final Point SCREEN_SIZE = new Point(TablexiaSettings.getWorldSize(), TablexiaSettings.getMinWorldHeight());
private static final float FONT_BUTTON_WIDTH = 70;
private static final float BUTTONS_MARGIN_LEFT = 30;
private static final float BUTTONS_GAP = 20;
private static final float CONTENT_RELATIVE_WIDTH = 0.70f;
private static final float MENU_RELATIVE_HEIGHT = 0.85f;
private static final int CLOSE_BUTTON_WIDTH = 35;
private static final int CLOSE_BUTTON_HEIGHT = 35;
private static final int CLOSE_BUTTON_PAD_TOP = 0;
private static final int CLOSE_BUTTON_PAD_RIGHT = 20;
private static final int CLOSE_BUTTON_PAD_LEFT = 5;
private static final int CLOSE_BUTTON_PAD_BOTTOM = 25;
private static final Color BACKGROUND_COLOR = new Color(((float) 248 / (float) 255), ((float) 236 / (float) 255), ((float) 212 / (float) 255), 1);
private static final String FONT_PLUS_TEXT = "+A";
......
......@@ -13,8 +13,8 @@ import com.badlogic.gdx.utils.Array;
import java.util.HashMap;
import java.util.Map;
import cz.nic.tablexia.util.Point;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.util.Point;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
/**
......
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