diff --git a/core/src/cz/nic/tablexia/screen/statistics/StatisticsScreen.java b/core/src/cz/nic/tablexia/screen/statistics/StatisticsScreen.java index 696828050e7f380160843245bd3d572dfc546093..32d8d008065b80eec8727573b0ef338eed1c4db9 100644 --- a/core/src/cz/nic/tablexia/screen/statistics/StatisticsScreen.java +++ b/core/src/cz/nic/tablexia/screen/statistics/StatisticsScreen.java @@ -35,15 +35,15 @@ import cz.nic.tablexia.game.difficulty.GameDifficulty; import cz.nic.tablexia.loader.application.ApplicationAtlasManager; import cz.nic.tablexia.loader.application.ApplicationFontManager; import cz.nic.tablexia.loader.application.ApplicationTextManager; -import cz.nic.tablexia.model.game.GameDAO; -import cz.nic.tablexia.shared.model.Game; import cz.nic.tablexia.menu.game.GameMenuDefinition; +import cz.nic.tablexia.model.game.GameDAO; import cz.nic.tablexia.screen.AbstractTablexiaScreen; import cz.nic.tablexia.screen.statistics.enums.GraphStyle; import cz.nic.tablexia.screen.statistics.interfaces.GameClickListener; import cz.nic.tablexia.screen.statistics.views.BookmarkButton; import cz.nic.tablexia.screen.statistics.views.GraphPane; import cz.nic.tablexia.screen.statistics.views.StatisticsScoreDialog; +import cz.nic.tablexia.shared.model.Game; import cz.nic.tablexia.util.Log; import cz.nic.tablexia.util.ScaleUtil; import cz.nic.tablexia.util.ui.ClickListenerWithSound; @@ -58,11 +58,10 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { private static final float COMPONENTS_PADDING = 10f, TITLE_PADDING = 50f; private static final float CLOSE_BUTTON_POSITION = 25f, CLOSE_BUTTON_SIZE = 35f; private static final float DRAWER_SCALE = 0.6f; - private static final float SWITCH_GRAPH_POSITION_X_SCALE = 0.4f, SWITCH_GRAPH_POSITION_Y_SCALE = 0.88f, SWITCH_GRAPH_PADDING = 30f; - private static final float DIFFICULTIES_SCALE = 0.8f, DIFFICULTIES_POSITION_X_SCALE = 0.65f, DIFFICULTIES_POSITION_Y_SCALE = 0.9f; + private static final float SWITCH_GRAPH_POSITION_X_SCALE = 0.33f, SWITCH_GRAPH_POSITION_Y_SCALE = 0.88f, SWITCH_GRAPH_PADDING = 48f; + private static final float DIFFICULTIES_SCALE = 0.8f, DIFFICULTIES_POSITION_X_SCALE = 0.63f, DIFFICULTIES_POSITION_Y_SCALE = 0.9f; private static final float NOTEBOOK_POSITION_SCALE = 0.3f, NOTEBOOK_WIDTH_SCALE = 0.7f, NOTEBOOK_HEIGHT_SCALE = 0.85f; private static final float BOOKMARK_SIZE_SCALE = 0.6f, BOOKMARKS_POSITION_X_SCALE = 0.24f, BOOKMARKS_POSITION_Y_SCALE = 0.7f; - private static final float SMALL_FONT_SCALE = 0.7f; public static final String GFX_PATH = "gfx/", BUTTON_PATH = "button/"; private static final String[] BOOKMARKS_TEXTURES = {"1", "2", "3", "2", "1", "3"}; @@ -90,14 +89,10 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { private Table graphPaneHolder; private GraphPane graphPane; private Map<GameDifficulty, Button> difficultyButtons; - private BitmapFont defaultFont, defaultBoldFont; - - public StatisticsScreen() { - } + private BitmapFont defaultBoldFont; @Override protected void screenPaused(Map<String, String> screenState) { - screenState.put(DIFFICULTY_EASY_KEY, String.valueOf(selectedGameDifficulties.contains(GameDifficulty.EASY))); screenState.put(DIFFICULTY_MEDIUM_KEY, String.valueOf(selectedGameDifficulties.contains(GameDifficulty.MEDIUM))); screenState.put(DIFFICULTY_HARD_KEY, String.valueOf(selectedGameDifficulties.contains(GameDifficulty.HARD))); @@ -113,7 +108,7 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { content = new Group(); content.addActor(background = new TablexiaNoBlendingImage(getApplicationTextureRegion(ApplicationAtlasManager.BACKGROUND_WOODEN))); - content.addActor(titleLabel = new Label(getText("statistics_label"), new Label.LabelStyle(defaultFont, Color.BLACK))); + content.addActor(titleLabel = new Label(getText("statistics_label"), new Label.LabelStyle(defaultBoldFont, Color.BLACK))); content.addActor(buttonClose = new Button(new TextureRegionDrawable(getApplicationTextureRegion(BUTTON_PATH + "closebutton_unpressed")), new TextureRegionDrawable(getApplicationTextureRegion(BUTTON_PATH + "closebutton_pressed")))); content.addListener(onScreenTouchListener); buttonClose.addListener(closeClickListener); @@ -131,8 +126,8 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { switchGraph.setSwitchSelectedListener(switchListener); switchGraph.setDisabledStep(1); switchGraphType = new WidgetGroup(); - Label left = setSmallFont(new Label(getText("statistics_games"), new Label.LabelStyle(defaultFont, Color.BLACK))); - Label right = setSmallFont(new Label(getText("statistics_average"), new Label.LabelStyle(defaultFont, Color.BLACK))); + Label left = new Label(getText("statistics_games"), new Label.LabelStyle(defaultBoldFont, Color.BLACK)); + Label right = new Label(getText("statistics_average"), new Label.LabelStyle(defaultBoldFont, Color.BLACK)); left.addListener(leftButtonListener); right.addListener(rightButtonListener); switchGraphType.addActor(left); @@ -150,7 +145,7 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { for (GameDifficulty gameDifficulty : GameDifficulty.getVisibleGameDifficultyList()) { String diffString = gameDifficulty.name().toLowerCase(); Button diffButton = new Button(new TextureRegionDrawable(getScreenTextureRegion(GFX_PATH + "difficultyradio_" + diffString + "_unpressed", false)), new TextureRegionDrawable(getScreenTextureRegion(GFX_PATH + "difficultyradio_" + diffString + "_pressed", false)), new TextureRegionDrawable(getScreenTextureRegion(GFX_PATH + "difficultyradio_" + diffString + "_pressed", false))); - Label diffLabel = setSmallFont(new Label(ApplicationTextManager.getInstance().getText("gamedifficulty_" + diffString), new Label.LabelStyle(defaultFont, Color.BLACK))); + Label diffLabel = new Label(ApplicationTextManager.getInstance().getText("gamedifficulty_" + diffString), new Label.LabelStyle(defaultBoldFont, Color.BLACK)); difficulties.addActor(diffButton); difficulties.addActor(diffLabel); diffButton.setUserObject(gameDifficulty); @@ -173,7 +168,7 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { boolean gameFromDBLoaded = false; for (int i = 0; i < GameMenuDefinition.values().length; i++) { GameMenuDefinition gameMenuDefinition = GameMenuDefinition.values()[i]; - Button button = new BookmarkButton(gameMenuDefinition.getTitle(), getScreenTextureRegion(GFX_PATH + "gamelist_listitem_background" + BOOKMARKS_TEXTURES[i] + "_inactive", false), getScreenTextureRegion(GFX_PATH + "gamelist_listitem_background" + BOOKMARKS_TEXTURES[i] + "_active", false), defaultFont); + Button button = new BookmarkButton(gameMenuDefinition.getTitle(), getScreenTextureRegion(GFX_PATH + "gamelist_listitem_background" + BOOKMARKS_TEXTURES[i] + "_inactive", false), getScreenTextureRegion(GFX_PATH + "gamelist_listitem_background" + BOOKMARKS_TEXTURES[i] + "_active", false), defaultBoldFont); button.setUserObject(gameMenuDefinition); button.addListener(bookmarkClickListener); bookmarks.addActor(button); @@ -197,7 +192,6 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { } private void loadFonts() { - defaultFont = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_20); defaultBoldFont = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_20); } @@ -523,10 +517,6 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> { return graphPane; } - private Label setSmallFont(Label label) { - label.setFontScale(SMALL_FONT_SCALE); - return label; - } public void position() { titleLabel.setPosition(TITLE_PADDING, getStage().getHeight() - TITLE_PADDING); diff --git a/core/src/cz/nic/tablexia/screen/statistics/views/GraphPane.java b/core/src/cz/nic/tablexia/screen/statistics/views/GraphPane.java index d80b3d941b42ff648b39768723c521d7fccb66b5..37d865ae0d55d5fd29a17316fc280082ff7f7c6b 100644 --- a/core/src/cz/nic/tablexia/screen/statistics/views/GraphPane.java +++ b/core/src/cz/nic/tablexia/screen/statistics/views/GraphPane.java @@ -29,22 +29,24 @@ import static com.badlogic.gdx.scenes.scene2d.actions.Actions.moveTo; * Created by danilov on 11/6/15. */ public class GraphPane extends WidgetGroup { - private List<Game> allGames, easyGames, mediumGames, hardGames; - private List<Float> easyAverageScores, mediumAverageScores, hardAverageScores; + + public static final float POINT_SIZE = 20f, MIN_GRAPH_WIDTH = 593f; + private static final float LINE_SIZE = 5.5f, EFFECTS_SPEED = 0.4f, CLICK_AREA_SIZE = 50f; + + private float maxScore, minScore; + private boolean screenResized, initialResize; + private GameDefinition selectedGameDefinition; + private StatisticsGameScoreResolver statisticsGameScoreResolver; + private GameDifficulty lastSelectedGameDifficulty; + private GameClickListener gameClickListener; private GraphStyle graphStyle; private StatisticsScreen statisticsScreen; private TextureRegion lineTextureRegion, pointTextureRegion; - private GameDefinition selectedGameDefinition; - public static final float POINT_SIZE = 20f, MIN_GRAPH_WIDTH = 593f; - private static final float LINE_SIZE = 8f, EFFECTS_SPEED = 0.4f, CLICK_AREA_SIZE = 50f; + private List<Game> allGames, easyGames, mediumGames, hardGames; + private List<Float> easyAverageScores, mediumAverageScores, hardAverageScores; private List<Image> easyPoints, mediumPoints, hardPoints; - private StatisticsGameScoreResolver statisticsGameScoreResolver; - private GameDifficulty lastSelectedGameDifficulty; private Set<GameDifficulty> selectedDifficulties; - private GameClickListener gameClickListener; - private float maxScore, minScore; private List<Actor> clickAreas; - private boolean screenResized, initialResize; public GraphPane(List<Game> allGames, GraphStyle graphStyle, StatisticsScreen screen, GameDefinition selectedGameDefinition, Set<GameDifficulty> selectedDifficulties, GameDifficulty lastSelectedGameDifficulty, GameClickListener gameClickListener) { this.allGames = allGames; diff --git a/core/src/cz/nic/tablexia/screen/statistics/views/StatisticsScoreDialog.java b/core/src/cz/nic/tablexia/screen/statistics/views/StatisticsScoreDialog.java index 36f9b59e7add07e6879b232099cdd70e29e6de09..21365c6f47f1ca84c9d4c56945df9e78f785fef4 100644 --- a/core/src/cz/nic/tablexia/screen/statistics/views/StatisticsScoreDialog.java +++ b/core/src/cz/nic/tablexia/screen/statistics/views/StatisticsScoreDialog.java @@ -14,7 +14,7 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent; public class StatisticsScoreDialog extends DynamicBubbleDialog { public static final float DIALOG_PADDING = 20f, DIALOG_PADDING_BOTTOM = DIALOG_PADDING /2; - private static final float GRAPH_DIALOG_HEIGHT = 150f; + private static final float GRAPH_DIALOG_HEIGHT = 120f; private TextureRegion[] ratingStarsTextures; private ArrowType arrowType; private Label label;