Skip to content
Snippets Groups Projects
Commit 6c50b21d authored by Drahomír Karchňák's avatar Drahomír Karchňák Committed by Matyáš Latner
Browse files

#140 Clicking new trophy at victory screen opens up hall of fame for you

parent 989ba2e6
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ import cz.nic.tablexia.game.common.TablexiaRandom;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.trophy.ITrophyDefinition;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationSoundManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.main.MainMenu;
......@@ -42,6 +43,7 @@ import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.model.game.GameDAO;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.gamemenu.GameMenuScreen;
import cz.nic.tablexia.screen.halloffame.HallOfFameScreen;
import cz.nic.tablexia.screen.halloffame.trophy.TrophyHelper;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.util.Log;
......@@ -58,6 +60,7 @@ import cz.nic.tablexia.util.ui.dialog.components.ImageContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.ResizableSpaceContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.TablexiaDialogComponentAdapter;
import cz.nic.tablexia.util.ui.dialog.components.TextContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.TouchCloseDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.TwoButtonContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.ViewportMaximumSizeComponent;
......@@ -153,6 +156,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
private boolean playAgainButtonClicked = false;
private ArrayList<TablexiaComponentDialog> receivedTrophyDialogs;
private TablexiaComponentDialog victoryDialog;
public AbstractTablexiaGame() {
inGameLoading = false;
......@@ -737,7 +741,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
adapters.add(new AdaptiveSizeDialogComponent());
//Create the dialog
TablexiaComponentDialog victoryDialog = TablexiaComponentDialogFactory.getInstance().createDialog(
victoryDialog = TablexiaComponentDialogFactory.getInstance().createDialog(
adapters.toArray(new TablexiaDialogComponentAdapter[]{}));
handleTrophies();
......@@ -839,7 +843,7 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
}
}
private void addReceivedTrophyDialog(ITrophyDefinition trophyDefinition) {
private void addReceivedTrophyDialog(final ITrophyDefinition trophyDefinition) {
TextureRegion trophyTexture = getGameGlobalTextureRegion(TrophyHelper.getFullPath(trophyDefinition.getTrophyName(), TrophyHelper.TrophyType.SMALL));
String title = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_NEW_TROPHY);
......@@ -848,6 +852,28 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
ArrayList<TablexiaDialogComponentAdapter> components = new ArrayList<TablexiaDialogComponentAdapter>();
components.add(new AdaptiveSizeDialogComponent());
components.add(new TouchCloseDialogComponent(new TouchCloseDialogComponent.TouchListener() {
@Override
public boolean dialogTouched(float x, float y, TablexiaComponentDialog dialog) {
//AABB intersect test - WhetherA or not user clicked on the dialog
if( x > dialog.getInnerLeftX() &&
x < dialog.getInnerLeftX() + dialog.getInnerWidth() &&
y > dialog.getInnerBottomY() &&
y < dialog.getInnerBottomY() + dialog.getInnerHeight()
) {
//TODO - Use invisible TablexiaButton ???
ApplicationSoundManager.getInstance().getSound(ApplicationSoundManager.MAINMENU_BUTTON).play();
HashMap<String, String> screenState = new HashMap<String, String>();
screenState.put(HallOfFameScreen.SCROLL_TO_TROPHY_KEY, trophyDefinition.name());
ApplicationBus.getInstance().post(new Tablexia.ChangeScreenEvent(HallOfFameScreen.class, TablexiaApplication.ScreenTransaction.FADE, screenState)).asynchronously();
victoryDialog.hide();
clearReceivedTrophyDialogs();
}
return false;
}
}));
components.add(new FixedSpaceContentDialogComponent());
components.add(new TextContentDialogComponent(title, ApplicationFontManager.FontType.ROBOTO_BOLD_14, true, true));
......
......@@ -461,7 +461,7 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> {
components.add(new DimmerDialogComponent(NEWSPAPER_DETAIL_DIALOG_DIMMER));
components.add(new TouchCloseDialogComponent(new TouchCloseDialogComponent.TouchListener() {
@Override
public boolean dialogTouched(float x, float y) {
public boolean dialogTouched(float x, float y, TablexiaComponentDialog dialog) {
if(dialogIndex == 4 && clickedOnDialog(x, y)) {
for (Actor a : getStage().getActors()) {
a.setTouchable(Touchable.disabled);
......@@ -546,7 +546,7 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> {
components.add(new TouchCloseDialogComponent(new TouchCloseDialogComponent.TouchListener() {
@Override
public boolean dialogTouched(float x, float y) {
public boolean dialogTouched(float x, float y, TablexiaComponentDialog dialog) {
stopMusic();
if (num == NUMBER_OF_OFFICE_DIALOGS) {
......
......@@ -357,7 +357,7 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti
ArrayList<TablexiaDialogComponentAdapter> components = new ArrayList<TablexiaDialogComponentAdapter>();
components.add(new TouchCloseDialogComponent(new TouchCloseDialogComponent.TouchListener() {
@Override
public boolean dialogTouched(float x, float y) {
public boolean dialogTouched(float x, float y, TablexiaComponentDialog dialog) {
mouseImage.setDrawable(new SpriteDrawable(new Sprite(mouseTexture)));
mouseImage.setTouchable(Touchable.enabled);
return true;
......
package cz.nic.tablexia.util.ui.dialog.components;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog;
/**
* Created by Matyáš Latner.
*/
......@@ -12,7 +14,7 @@ public class TouchCloseDialogComponent extends TablexiaDialogComponentAdapter {
* @param y posY of touch
* @return true if u want to hide the dialog, false if u dont.
*/
boolean dialogTouched(float x, float y);
boolean dialogTouched(float x, float y, TablexiaComponentDialog dialog);
}
private TouchListener touchListener;
......@@ -30,7 +32,7 @@ public class TouchCloseDialogComponent extends TablexiaDialogComponentAdapter {
boolean result = true;
if(touchListener != null)
result = touchListener.dialogTouched(x, y);
result = touchListener.dialogTouched(x, y, getDialog());
if(result)
getDialog().hide();
......
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