Commit 6b82852e authored by Matyáš Latner's avatar Matyáš Latner

Merge branch 'devel' into feature-abstractgame

parents 00b63482 196c7acc
......@@ -70,3 +70,6 @@ ios/robovm.properties
## core
core/gen
temp/
\ No newline at end of file
......@@ -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;
......@@ -9,7 +10,6 @@ import java.util.Locale;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.kidnapping.KidnappingGame;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
......@@ -19,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;
......@@ -54,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;
......@@ -202,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
......
......@@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.actions.DelayAction;
import com.badlogic.gdx.scenes.scene2d.actions.RunnableAction;
......@@ -20,6 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import cz.nic.tablexia.TablexiaSettings;
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;
......@@ -105,7 +107,7 @@ public class GameScreen extends AbstractRobberyScreen {
}
}
public static void init(Group infoItemLayer, Group colorInfoLayer, SceneBackground sceneBackground, AbstractRobberyScreen abstractRobberyScreen) {
public static void init(Stage stage, Group infoItemLayer, Group colorInfoLayer, SceneBackground sceneBackground, AbstractRobberyScreen abstractRobberyScreen) {
for (InfoItem container : InfoItem.values()) {
container.init(abstractRobberyScreen);
container.infoItemGroup.setVisible(false);
......@@ -115,7 +117,7 @@ public class GameScreen extends AbstractRobberyScreen {
colorInfoLayer.addActor(container.infoBanner);
}
}
calculateDimensions(infoItemLayer.getStage().getWidth(), infoItemLayer.getStage().getHeight(), sceneBackground);
calculateDimensions(TablexiaSettings.getSceneWidth(stage), TablexiaSettings.getSceneOuterHeight(stage), sceneBackground);
}
public static void calculateDimensions(float width, float height, SceneBackground sceneBackground) {
......@@ -139,9 +141,9 @@ public class GameScreen extends AbstractRobberyScreen {
private enum SceneBackground {
NEWSSTAND (GameDifficulty.EASY, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND_BOTTOM, 11f/36, 2f/7),
JEWELLERY (GameDifficulty.MEDIUM, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY_BOTTOM, 59f/160, 2f/7),
BANK (GameDifficulty.HARD, RobberyAssets.SCREEN_BACKGROUND_BANK, RobberyAssets.SCREEN_BACKGROUND_BANK_BOTTOM, 23f/72, 9f/28);
NEWSSTAND (GameDifficulty.EASY, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND_BOTTOM, 11f/36, 1f/6),
JEWELLERY (GameDifficulty.MEDIUM, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY_BOTTOM, 59f/160, 1f/6),
BANK (GameDifficulty.HARD, RobberyAssets.SCREEN_BACKGROUND_BANK, RobberyAssets.SCREEN_BACKGROUND_BANK_BOTTOM, 23f/72, 1f/5);
private final GameDifficulty gameDifficulty;
private final String sceneBackground;
......@@ -228,7 +230,7 @@ public class GameScreen extends AbstractRobberyScreen {
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 float PERSON_COUNTER_POSITION_Y_RATIO = 1f/8;
private static final Color PERSON_COUNTER_TEXT_COLOR = Color.WHITE;
private static final ApplicationFontManager.FontType PERSON_COUNTER_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_20;
......@@ -307,12 +309,12 @@ public class GameScreen extends AbstractRobberyScreen {
sceneBackground = new Image(getScreenTextureRegion(sceneBackgroundDefinition.getSceneBackground()));
sceneBackgroundBottom = new Image(getScreenTextureRegion(sceneBackgroundDefinition.getSceneBackgroundBottom(), false));
float width = getStage().getWidth();
float height = getStage().getHeight();
float width = getSceneWidth();
float height = getSceneOuterHeight();
setActorToFullScene(sceneBackground);
sceneBackground.setTouchable(Touchable.disabled);
doorBackground.setBounds(getSceneLeftX(), getSceneInnerBottomY(), width, height);
doorBackground.setBounds(getSceneLeftX(), getSceneOuterBottomY(), width, height);
sceneBackgroundBottom.setBounds(getSceneLeftX() + BACKGROUND_BOTTOM_POSITION_X_CORRECTION_OFFSET,
getSceneOuterBottomY(),
getSceneWidth() + BACKGROUND_BOTTOM_WIDTH_CORRECTION_OFFSET,
......@@ -329,7 +331,7 @@ public class GameScreen extends AbstractRobberyScreen {
getStage().addActor(infoItemLayer);
getStage().addActor(personCounter);
InfoItem.init(infoItemLayer, colorInfoLayer, sceneBackgroundDefinition, this);
InfoItem.init(getStage(), infoItemLayer, colorInfoLayer, sceneBackgroundDefinition, this);
prepareCreaturePositions(getSceneWidth(), getSceneInnerHeight());
}
......
......@@ -12,7 +12,7 @@ public class ShootingRangeResultResolver implements GameDefinition.GameResultRes
@Override
public AbstractTablexiaGame.GameResult getGameResult(Game game) {
int[][] CUPS = {Properties.CUPS_EASY, Properties.CUPS_MEDIUM, Properties.CUPS_HARD};
int gameScore = Integer.valueOf(game.getGameScore(Properties.SCORE_TOTAL));
int gameScore = Integer.valueOf(game.getGameScore(Properties.SCORE_TOTAL, "0"));
int gameDificultyOrdinal = game.getDifficulty().getDifficultyNumber() -1;
if (gameScore > CUPS[gameDificultyOrdinal][2]) {
......
package cz.nic.tablexia.game.trophy;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -9,7 +10,6 @@ import com.badlogic.gdx.utils.Align;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaApplication;
......@@ -30,9 +30,9 @@ public class TrophyReceivedDialog extends TablexiaDialog {
private static final int DIALOG_OFFSET = 20;
private static final int DIALOG_WIDTH = 200;
private static final int DIALOG_HEIGHT = 150;
private static final float TITLE_FONT_SCALE = 0.7f;
private static final float CONTENT_FONT_SCALE = 0.5f;
private static final int MAX_NUMBER_OF_TROPHIES_TO_DISPLAY = 4;
private static final BitmapFont DIALOG_BIGGER_FONT = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_14);
private static final BitmapFont DIALOG_NORMAL_FONT = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_12);
private ITrophyDefinition trophy;
private TextureRegion trophyTexture;
......@@ -58,15 +58,15 @@ public class TrophyReceivedDialog extends TablexiaDialog {
String desc = ApplicationTextManager.getInstance().getText(trophy.getTrophyDescription());
String title = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_NEW_TROPHY);
this.addLabel(title, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.BLACK), Align.center, TITLE_FONT_SCALE);
this.addLabel(title, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center);
this.getContentTable().row();
this.addImage(trophyTexture, 1);
this.getContentTable().row();
this.addLabel(name, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.BLACK), Align.center, TITLE_FONT_SCALE);
this.addLabel(name, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center);
this.getContentTable().row();
this.addLabel(desc, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.GRAY), Align.center, CONTENT_FONT_SCALE);
this.addLabel(desc, new Label.LabelStyle(DIALOG_NORMAL_FONT, Color.GRAY), Align.center);
super.prepareContent();
}
......@@ -165,13 +165,15 @@ public class TrophyReceivedDialog extends TablexiaDialog {
final Placeholder other = ((Placeholder) otherObj);
return Objects.equals(getTotal(), other.getTotal())
&& Objects.equals(getActual(), other.getActual());
return (getTotal() == other.getTotal() && getActual() == other.getActual());
}
@Override
public int hashCode() {
return Objects.hash(getTotal(), getActual());
int code = 0;
code += getTotal() * 13;
code += getActual() * 53;
return code;
}
}
}
......@@ -60,15 +60,30 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp
public static final String DIALOG_PATH = "dialog/";
public static final String DIALOG_BUBBLE_CLASSIC = DIALOG_PATH + "bubble_classic";
public static final String DIALOG_BUBBLE_CLASSIC_PURE = DIALOG_PATH + "bubble_classic_pure";
public static final String DIALOG_BUBBLE_CLASSIC_BOTTOM = DIALOG_PATH + "bubble_classic_bottom";
public static final String DIALOG_BUBBLE_CLASSIC_ROUND = DIALOG_PATH + "bubble_classic_round";
public static final String DIALOG_BUBBLE_CLASSIC_SQUARE = DIALOG_PATH + "bubble_classic_square";
public static final String DIALOG_BUBBLE_ARROW_DOWN = DIALOG_PATH + "bubble_arrow_down";
public static final String DIALOG_BUBBLE_ARROW_LEFT = DIALOG_PATH + "bubble_arrow_left";
public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT = DIALOG_PATH + "bubble_arrow_bend_left";
public static final String DIALOG_BUBBLE_CLASSIC_CONTINUE_BUTTON = DIALOG_PATH + "bubble_classic_continue_button";
public static final String DIALOG_RECTANGLE = DIALOG_PATH + "dialog_rectangle";
public static final String DIALOG_SQUARE = DIALOG_PATH + "dialog_square";
public static final String DIALOG_SQUARE_BORDER_LINES = DIALOG_PATH + "dialog_square_borderlines";
public static final String DIALOG_BUBBLE_ARROW_BOTTOM = DIALOG_PATH + "bubble_arrow_bottom";
public static final String DIALOG_BUBBLE_ARROW_TOP = DIALOG_PATH + "bubble_arrow_top";
public static final String DIALOG_BUBBLE_ARROW_LEFT = DIALOG_PATH + "bubble_arrow_left";
public static final String DIALOG_BUBBLE_ARROW_RIGHT = DIALOG_PATH + "bubble_arrow_right";
public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_BOTTOM = DIALOG_PATH + "bubble_arrow_bend_left_bottom";
public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_TOP = DIALOG_PATH + "bubble_arrow_bend_left_top";
public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_LEFT = DIALOG_PATH + "bubble_arrow_bend_left_left";
public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_RIGHT = DIALOG_PATH + "bubble_arrow_bend_left_right";
public static final String DIALOG_BUBBLE_CLASSIC_BOTTOM = DIALOG_PATH + "bubble_classic_bottom";
public static final String DIALOG_BUBBLE_CLASSIC_TOP = DIALOG_PATH + "bubble_classic_top";
public static final String DIALOG_BUBBLE_CLASSIC_LEFT = DIALOG_PATH + "bubble_classic_left";
public static final String DIALOG_BUBBLE_CLASSIC_RIGHT = DIALOG_PATH + "bubble_classic_right";
public static final String BUTTON_PATH = "button/";
public static final String BUTTON_BLUE_PART = "tablexiabutton_blank_blue";
public static final String BUTTON_GREEN_PART = "tablexiabutton_blank_green";
......
......@@ -238,6 +238,7 @@ public class User implements IMenuItem {
updateStatement.setInt(1, user.isHelp() ? 1 : 0);
updateStatement.setInt(2, user.isIntro() ? 1 : 0);
updateStatement.setInt(3, user.isDeleted() ? 1 : 0);
updateStatement.setLong(4, user.getId());
updateStatement.executeUpdate();
updateStatement.close();
return true;
......
......@@ -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;
......
......@@ -180,8 +180,11 @@ public class FormScreen extends AbstractTablexiaScreen<Void> {
});
// signature pen needs to be below pen and stamp
group.addActor(signaturePane = new SignaturePane());
signaturePane.setBounds(600, getStage().getHeight() * 0.1f, 300, getStage().getHeight() * 0.2f);
signaturePane = new SignaturePane();
group.addActor(signaturePane);
signaturePane.setBounds(getSceneWidth() / 2, getSceneInnerHeight() * 0.1f, getSceneInnerHeight() / 2, getSceneInnerHeight() * 0.1f);
signaturePane.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes());
// pencil and stamp layers
group.addActor(pen = ScaleUtil.createImageWidthPosition(getScreenTextureRegion(GFX_PATH + "pencil_dropped", false), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.85f, getStage().getWidth() * -0.13f));
......
......@@ -104,7 +104,7 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> {
private Actor prepareBalcony() {
final Group group = new Group();
ScaleUtil.setFullScreen(group, getStage());
boolean isWinter = true;
boolean isWinter = false;
Image balcony = new TablexiaNoBlendingImage(getScreenTextureRegion(isWinter ? BALCONY_WINTER : BALCONY));
setActorToFullScene(balcony);
......
......@@ -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