Commit 3a9be8b4 authored by Luboš Horáček's avatar Luboš Horáček

#125 orientace statistik bankovni loupeze

parent c6afac5e
......@@ -40,22 +40,24 @@ import cz.nic.tablexia.menu.mainmenu.screen.gamemenu.BaseGameMenuFragment;
public enum GamesDefinition implements MenuEnum {
BANKOVNILOUPEZ(0, R.string.game_bankovniloupez, R.string.game_bankovniloupez_description, new int[] { R.drawable.screen_gamemenu_bankovniloupez_back, R.drawable.screen_gamemenu_bankovniloupez_mid, R.drawable.screen_gamemenu_bankovniloupez_fore }, R.drawable.screen_gamemenu_bankovniloupez_startbutton, R.drawable.screen_gamemenu_bankovniloupez_title, R.layout.game_bankovniloupez_loading,
SpeechSounds.LOADING_BANKOVNILOUPEZ, false, R.string.game_bankovniloupez_score, R.string.game_bankovniloupez_averagescore, "menu/sfx/gamemenu_bankovniloupez_intro.mp3", cz.nic.tablexia.game.games.bankovniloupez.BankovniloupezActivity.class, BaseGameMenuFragment.class),
SpeechSounds.LOADING_BANKOVNILOUPEZ, false, R.string.game_bankovniloupez_score, R.string.game_bankovniloupez_averagescore, "menu/sfx/gamemenu_bankovniloupez_intro.mp3", cz.nic.tablexia.game.games.bankovniloupez.BankovniloupezActivity.class, BaseGameMenuFragment.class, 1),
PRONASLEDOVANI(1, R.string.game_pronasledovani, R.string.game_pronasledovani_description, new int[] { R.drawable.screen_gamemenu_pronasledovani_back, R.drawable.screen_gamemenu_pronasledovani_mid, R.drawable.screen_gamemenu_pronasledovani_fore }, R.drawable.screen_gamemenu_pronasledovani_startbutton, R.drawable.screen_gamemenu_pronasledovani_title, R.layout.game_pronasledovani_loading,
SpeechSounds.LOADING_PRONASLEDOVANI, true, R.string.game_score_duration, R.string.game_averagescore_duration, "menu/sfx/gamemenu_pronasledovani_intro.mp3", cz.nic.tablexia.game.games.pronasledovani.PronasledovaniActivity.class, BaseGameMenuFragment.class),
PRONASLEDOVANI(1, R.string.game_pronasledovani, R.string.game_pronasledovani_description, new int[] { R.drawable.screen_gamemenu_pronasledovani_back, R.drawable.screen_gamemenu_pronasledovani_mid, R.drawable.screen_gamemenu_pronasledovani_fore }, R.drawable.screen_gamemenu_pronasledovani_startbutton, R.drawable.screen_gamemenu_pronasledovani_title, R.layout.game_pronasledovani_loading,
SpeechSounds.LOADING_PRONASLEDOVANI, true, R.string.game_score_duration, R.string.game_averagescore_duration, "menu/sfx/gamemenu_pronasledovani_intro.mp3", cz.nic.tablexia.game.games.pronasledovani.PronasledovaniActivity.class, BaseGameMenuFragment.class),
UNOS(2, R.string.game_unos, R.string.game_unos_description, new int[] { R.drawable.screen_gamemenu_unos_back, R.drawable.screen_gamemenu_unos_mid, R.drawable.screen_gamemenu_unos_fore }, R.drawable.screen_gamemenu_unos_startbutton, R.drawable.screen_gamemenu_unos_title, R.layout.game_unos_loading, SpeechSounds.LOADING__UNOS, false, R.string.game_score_error, R.string.game_averagescore_error,
"menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.unos.UnosActivity.class, BaseGameMenuFragment.class),
UNOS(2, R.string.game_unos, R.string.game_unos_description, new int[] { R.drawable.screen_gamemenu_unos_back, R.drawable.screen_gamemenu_unos_mid, R.drawable.screen_gamemenu_unos_fore }, R.drawable.screen_gamemenu_unos_startbutton, R.drawable.screen_gamemenu_unos_title, R.layout.game_unos_loading, SpeechSounds.LOADING__UNOS, false, R.string.game_score_error, R.string.game_averagescore_error,
"menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.unos.UnosActivity.class, BaseGameMenuFragment.class),
NOCNISLEDOVANI(3, R.string.game_nocnisledovani, R.string.game_nocnisledovani_description, new int[] { R.drawable.screen_gamemenu_nocnisledovani_back, R.drawable.screen_gamemenu_nocnisledovani_mid, R.drawable.screen_gamemenu_nocnisledovani_fore }, R.drawable.screen_gamemenu_sledovani_startbutton, R.drawable.screen_gamemenu_nocnisledovani_title, R.layout.game_nocnisledovani_loading, null,
false, R.string.game_score_error, R.string.game_averagescore_error, "menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.nocnisledovani.NocniSledovaniActivity.class, BaseGameMenuFragment.class),
NOCNISLEDOVANI(3, R.string.game_nocnisledovani, R.string.game_nocnisledovani_description, new int[] { R.drawable.screen_gamemenu_nocnisledovani_back, R.drawable.screen_gamemenu_nocnisledovani_mid, R.drawable.screen_gamemenu_nocnisledovani_fore }, R.drawable.screen_gamemenu_sledovani_startbutton, R.drawable.screen_gamemenu_nocnisledovani_title, R.layout.game_nocnisledovani_loading, null,
false, R.string.game_score_error, R.string.game_averagescore_error, "menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.nocnisledovani.NocniSledovaniActivity.class, BaseGameMenuFragment.class),
STRELNICE(4, R.string.game_strelnice, R.string.game_strelnice_description, new int[] { R.drawable.screen_gamemenu_strelnice_back, R.drawable.screen_gamemenu_strelnice_mid, R.drawable.screen_gamemenu_strelnice_fore }, R.drawable.screen_gamemenu_unos_startbutton, R.drawable.screen_gamemenu_strelnice_title, R.layout.game_strelnice_loading, null, false, R.string.game_score_error,
R.string.game_averagescore_error, "menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.strelnice.StrelniceActivity.class, BaseGameMenuFragment.class),
STRELNICE(4, R.string.game_strelnice, R.string.game_strelnice_description, new int[] { R.drawable.screen_gamemenu_strelnice_back, R.drawable.screen_gamemenu_strelnice_mid, R.drawable.screen_gamemenu_strelnice_fore }, R.drawable.screen_gamemenu_unos_startbutton, R.drawable.screen_gamemenu_strelnice_title, R.layout.game_strelnice_loading, null, false, R.string.game_score_error,
R.string.game_averagescore_error, "menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.strelnice.StrelniceActivity.class, BaseGameMenuFragment.class),
POTME(5, R.string.game_potme, R.string.game_potme_description, new int[] { R.drawable.screen_gamemenu_unos_back, R.drawable.screen_gamemenu_strelnice_mid, R.drawable.screen_gamemenu_strelnice_fore }, R.drawable.screen_gamemenu_unos_startbutton, R.drawable.screen_gamemenu_potme_title, R.layout.game_unos_loading, null, false, R.string.game_score_error, R.string.game_averagescore_error,
"menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.potme.PotmeActivity.class, BaseGameMenuFragment.class);
POTME(5, R.string.game_potme, R.string.game_potme_description, new int[] { R.drawable.screen_gamemenu_unos_back, R.drawable.screen_gamemenu_strelnice_mid, R.drawable.screen_gamemenu_strelnice_fore }, R.drawable.screen_gamemenu_unos_startbutton, R.drawable.screen_gamemenu_potme_title, R.layout.game_unos_loading, null, false, R.string.game_score_error, R.string.game_averagescore_error,
"menu/sfx/gamemenu_unos_intro.mp3", cz.nic.tablexia.game.games.potme.PotmeActivity.class, BaseGameMenuFragment.class);
private static final int DEFAULT_CHART_ORIENTATION = -1;
private int position;
private int gameNameResourceId;
......@@ -71,6 +73,7 @@ public enum GamesDefinition implements MenuEnum {
private int scoreTextResourceId;
private int averagescoreTextResourceId;
private String introSoundPath;
private int chartOrientation;
/**
* Creates new game menu item
......@@ -84,6 +87,11 @@ public enum GamesDefinition implements MenuEnum {
*/
private GamesDefinition(int position, int gameNameResourceId, int gameDescriptionResourceId, int[] gameImageResourceId, int gameStartImageResourceId, int gameTitleImageResourceId, int gameLoadingLayoutResourceId, String gameLoadingSoundPath, boolean isScoreDuration, int scoreTextResourceId, int averagescoreTextResourceId, String introSoundPath, Class<? extends GameActivity> gameClass,
Class<? extends Fragment> gameMenuFragmentClass) {
this(position, gameNameResourceId, gameDescriptionResourceId, gameImageResourceId, gameStartImageResourceId, gameTitleImageResourceId, gameLoadingLayoutResourceId, gameLoadingSoundPath, isScoreDuration, scoreTextResourceId, averagescoreTextResourceId, introSoundPath, gameClass, gameMenuFragmentClass, DEFAULT_CHART_ORIENTATION);
}
private GamesDefinition(int position, int gameNameResourceId, int gameDescriptionResourceId, int[] gameImageResourceId, int gameStartImageResourceId, int gameTitleImageResourceId, int gameLoadingLayoutResourceId, String gameLoadingSoundPath, boolean isScoreDuration, int scoreTextResourceId, int averagescoreTextResourceId, String introSoundPath, Class<? extends GameActivity> gameClass,
Class<? extends Fragment> gameMenuFragmentClass, int chartOrientation) {
this.position = position;
this.gameNameResourceId = gameNameResourceId;
......@@ -99,6 +107,7 @@ public enum GamesDefinition implements MenuEnum {
this.introSoundPath = introSoundPath;
this.gameClass = gameClass;
this.gameMenuFragmentClass = gameMenuFragmentClass;
this.chartOrientation = chartOrientation;
}
/**
......@@ -110,6 +119,10 @@ public enum GamesDefinition implements MenuEnum {
return gameClass;
}
public int getChartOrientation() {
return chartOrientation;
}
/**
* Returns game name resource id
*
......
/*******************************************************************************
* Tablexia
* Tablexia
*
* Copyright (C) 2013 CZ NIC z.s.p.o. <podpora at nic dot cz>
*
......@@ -81,7 +81,6 @@ public class Statistics extends AbstractMenuFragment {
private static final int DETAIL_INFO_PANEL_DELAY = 2000;
private static final int MILISECOUNDS = 1000;
private static final int CHART_VALUE_POLARITY = -1;
private static final int ONE_POINT_CHART_OFFSET = 1;
private static final GameDifficulty INITIALLY_SELECTED_DIFFICULTY = GameDifficulty.EASY;
private static final GamesDefinition INITIALLY_SELECTED_GAME = GamesDefinition.BANKOVNILOUPEZ;
......@@ -191,17 +190,17 @@ public class Statistics extends AbstractMenuFragment {
private void prepareCloseButton(View fragmentLayout) {
View closeButton = fragmentLayout.findViewById(R.id.screen_statistics_closebutton);
if (closeButton != null) {
if (closeButton != null) {
final ImageButton closeButtonImage = (ImageButton) fragmentLayout.findViewById(R.id.screen_statistics_closebutton_image);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
playSound(PermanentSounds.BUTTON_SOUND, false);
closeButtonImage.setPressed(true);
getTablexiaContext().prepareMainMenu().changeMenuItem(MainMenuDefinition.START, true, false);
}
});
}
}
......@@ -288,20 +287,20 @@ public class Statistics extends AbstractMenuFragment {
private void refreshGameListBackgroundState() {
for (GamesDefinition gameDefinition : GamesDefinition.values()) {
ImageButton gameListItem = gameListItems.get(gameDefinition);
if (gameListItem != null) {
if (gameDefinition == selectedGameDefinition) {
Integer selectedGameResourceId = GAMELIST_ACTIVEBACKGROUND_MAPPING.get(gameDefinition);
if (selectedGameResourceId != null) {
gameListItem.setBackgroundResource(selectedGameResourceId);
gameListItem.setImageResource(selectedGameResourceId);
}
} else {
Integer unselectGameResourceId = GAMELIST_INACTIVEBACKGROUND_MAPPING.get(gameDefinition);
if (unselectGameResourceId != null) {
gameListItem.setBackgroundResource(unselectGameResourceId);
gameListItem.setImageResource(unselectGameResourceId);
}
}
if (gameListItem != null) {
if (gameDefinition == selectedGameDefinition) {
Integer selectedGameResourceId = GAMELIST_ACTIVEBACKGROUND_MAPPING.get(gameDefinition);
if (selectedGameResourceId != null) {
gameListItem.setBackgroundResource(selectedGameResourceId);
gameListItem.setImageResource(selectedGameResourceId);
}
} else {
Integer unselectGameResourceId = GAMELIST_INACTIVEBACKGROUND_MAPPING.get(gameDefinition);
if (unselectGameResourceId != null) {
gameListItem.setBackgroundResource(unselectGameResourceId);
gameListItem.setImageResource(unselectGameResourceId);
}
}
}
}
}
......@@ -339,7 +338,7 @@ public class Statistics extends AbstractMenuFragment {
difficultyButtonsContainer.addView(difficultyButton);
}
private void setDifficultyButtonText(TextView difficultyText, Spanned text) {
if (Utility.isScreenSize(getActivity(), Configuration.SCREENLAYOUT_SIZE_XLARGE) || Utility.isScreenSize(getActivity(), Configuration.SCREENLAYOUT_SIZE_LARGE)) {
difficultyText.setText(text);
......@@ -442,14 +441,14 @@ public class Statistics extends AbstractMenuFragment {
@Override
public void run() {
FragmentActivity activity = getActivity();
if (activity != null) {
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
hideDetailInfoPanelAnim();
}
});
}
}
......@@ -488,11 +487,11 @@ public class Statistics extends AbstractMenuFragment {
double x = selectedSerie.getX(seriesSelection.getPointIndex());
double y = selectedSerie.getY(seriesSelection.getPointIndex());
double[] screenPoint = lineChart.toScreenPoint(new double[]{x, y}, 0);
int chartPadding = getActivity().findViewById(R.id.screen_statistics_chart).getPaddingTop();
detailInfoPanel.setX((float) screenPoint[0] - (detailInfoPanel.getMeasuredWidth() / 2) + chartPadding);
detailInfoPanel.setY((float) screenPoint[1] - (detailInfoPanel.getMeasuredHeight() - (detailInfoPanel.getMeasuredHeight() / 9)) + chartPadding);
detailInfoPanel.setX(((float) screenPoint[0] - (detailInfoPanel.getMeasuredWidth() / 2)) + chartPadding);
detailInfoPanel.setY(((float) screenPoint[1] - (detailInfoPanel.getMeasuredHeight() - (detailInfoPanel.getMeasuredHeight() / 9))) + chartPadding);
}
......@@ -536,9 +535,9 @@ public class Statistics extends AbstractMenuFragment {
private String getScoreValue(GamesDefinition gameDefinition, int scoreTextResourceId, double scoreValue) {
String result = getActivity().getString(scoreTextResourceId);
if (gameDefinition.isScoreDuration()) {
result = result + " " + DurationFormatUtils.formatDuration((long)scoreValue * MILISECOUNDS * CHART_VALUE_POLARITY, "HH:mm:ss");
result = result + " " + DurationFormatUtils.formatDuration((long) scoreValue * MILISECOUNDS * selectedGameDefinition.getChartOrientation(), "HH:mm:ss");
} else {
result = result + " " + String.format("%.0f", scoreValue * CHART_VALUE_POLARITY);
result = result + " " + String.format("%.0f", scoreValue * selectedGameDefinition.getChartOrientation());
}
return result;
}
......@@ -598,7 +597,7 @@ public class Statistics extends AbstractMenuFragment {
xySeries.clear();
if (gameLogs != null) {
for (int i = 0; i < gameLogs.size(); i++) {
xySeries.add(i, gameLogs.get(i).getCounter() * CHART_VALUE_POLARITY);
xySeries.add(i, gameLogs.get(i).getCounter() * selectedGameDefinition.getChartOrientation());
}
}
}
......@@ -612,31 +611,31 @@ public class Statistics extends AbstractMenuFragment {
chartRenderer.clearXTextLabels();
chartRenderer.clearYTextLabels();
ViewGroup selectedDifficultyButton = null;
for (ViewGroup difficultyButton : difficultyButtons) {
if (((ImageView)difficultyButton.findViewById(R.id.screen_statistics_difficultybutton_image)).isSelected()) {
selectedDifficultyButton = difficultyButton;
}
}
if (selectedDifficultyButton != null) {
selectedDifficulty = GameDifficulty.values()[(Integer)selectedDifficultyButton.getTag()];
XYSeries selectedSerie = difficultySeries.get(selectedDifficulty);
prepareNewSerie(selectedDifficulty, selectedSerie);
int starNumber = 0;
if (selectedSerie != null && selectedSerie.getItemCount() > 0) {
if ((selectedSerie != null) && (selectedSerie.getItemCount() > 0)) {
double minX = selectedSerie.getMinX();
double maxX = selectedSerie.getMaxX();
double minY = selectedSerie.getMinY();
double maxY = selectedSerie.getMaxY();
double itemsLimitedCount = Math.min(selectedSerie.getItemCount(), CHART_SERIE_MAXIMUM_INCREASE_POINT) - 1;
if (minY == maxY) {
minY = selectedSerie.getY(0) - ONE_POINT_CHART_OFFSET;
maxY = selectedSerie.getY(0) + ONE_POINT_CHART_OFFSET;
......@@ -645,23 +644,23 @@ public class Statistics extends AbstractMenuFragment {
itemsLimitedCount = 1;
maxX = selectedSerie.getX(0) + ONE_POINT_CHART_OFFSET;
}
double offset = CHART_SERIE_MAXIMUM_INCREASE_POINT - itemsLimitedCount;
chartRenderer.setYAxisMin(minY - ((maxY - minY) * (1 / CHART_SERIE_PADDING_RATIO)));
chartRenderer.setYAxisMax(maxY + ((maxY - minY) * (1 / CHART_SERIE_PADDING_RATIO)));
chartRenderer.setXAxisMin(minX - ((maxX - minX) / itemsLimitedCount));
chartRenderer.setXAxisMax(maxX + (offset * ((maxX - minX) / itemsLimitedCount)));
starNumber = GameManager.getStarNumberForUserGameAndDifficulty(getTablexiaContext().getSelectedUser(),
selectedGameDefinition,
selectedDifficulty);
}
int allStarsNumber = GameManager.getStarNumberForUser(getTablexiaContext().getSelectedUser().getId());
showStarNumber(starNumber, allStarsNumber);
mChartView.repaint();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment