Added back-arrow on topBar
This commit is contained in:
@ -341,4 +341,8 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
|
||||
public TutorialManager getTutorialManager() {
|
||||
return tutorialManager;
|
||||
}
|
||||
|
||||
public GameScreen getGameScreen() {
|
||||
return gameScreen;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.GameHandler;
|
||||
import de.frajul.endlessroll.main.GameLog;
|
||||
import de.frajul.endlessroll.main.physics.Physics;
|
||||
import de.frajul.endlessroll.main.screens.GameScreen;
|
||||
import de.frajul.endlessroll.main.screens.Screen;
|
||||
import de.frajul.endlessroll.rendering.Rendering;
|
||||
import de.frajul.endlessroll.sqlDatabase.MyDatabase;
|
||||
@ -52,14 +53,14 @@ public class Game extends Rendering<GameScene> {
|
||||
private List<Integer> collectedStars = new ArrayList<>();
|
||||
private boolean energyCollected;
|
||||
|
||||
public Game(GameHandler handler, GameActivity gameActivity) throws Exception {
|
||||
public Game(GameHandler handler, GameScreen gameScreen, GameActivity gameActivity) throws Exception {
|
||||
super(gameActivity);
|
||||
this.handler = handler;
|
||||
this.gameActivity = gameActivity;
|
||||
physics = new Physics();
|
||||
collisionManager = new CollisionManager(this);
|
||||
particleSystem = new ParticleSystem(getContext());
|
||||
viewManager = new ViewManager(this, handler, gameActivity);
|
||||
viewManager = new ViewManager(this, gameScreen, handler, gameActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ public class GameScreen extends GLScreen<RelativeLayout> {
|
||||
|
||||
public GameScreen(GameActivity gameActivity, MyGlSurfaceView glSurfaceView) throws Exception {
|
||||
super(ScreenType.GAME, gameActivity, R.layout.game, glSurfaceView);
|
||||
game = new Game(gameViewHandler, gameActivity);
|
||||
game = new Game(gameViewHandler, this, gameActivity);
|
||||
glView.addRendering(game);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public abstract class Screen<V extends ViewGroup> {
|
||||
}
|
||||
|
||||
protected TopBar createTopBar(@IdRes int id) {
|
||||
return new TopBar(gameActivity, type, layout.findViewById(id));
|
||||
return new TopBar(gameActivity, this, layout.findViewById(id));
|
||||
}
|
||||
|
||||
public void setCaller(ScreenType caller) {
|
||||
|
@ -34,7 +34,7 @@ public class ToolShopTutorial {
|
||||
|
||||
public void onTopBarUpdate(TopBar topBar) {
|
||||
if (!finished && isSpringUnlocked()) {
|
||||
boolean notOnToolShopScreen = topBar.getParent() != Screen.ScreenType.TOOL_SHOP;
|
||||
boolean notOnToolShopScreen = topBar.getParentType() != Screen.ScreenType.TOOL_SHOP;
|
||||
if (notOnToolShopScreen && topBar.isToolShopButtonEnabled())
|
||||
topBar.startToolShopButtonPulse();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import android.widget.TextView;
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.game.Game;
|
||||
import de.frajul.endlessroll.main.screens.GameScreen;
|
||||
import de.frajul.endlessroll.main.screens.Screen;
|
||||
|
||||
/**
|
||||
@ -26,14 +27,14 @@ public class GameOverMessage implements View.OnClickListener {
|
||||
private Button tryAgain;
|
||||
private Button toMenu;
|
||||
|
||||
public GameOverMessage(Game game, GameActivity gameActivity, View layout) {
|
||||
public GameOverMessage(Game game, GameScreen gameScreen, GameActivity gameActivity, View layout) {
|
||||
this.game = game;
|
||||
this.gameActivity = gameActivity;
|
||||
this.layout = layout;
|
||||
layout.setVisibility(View.GONE);
|
||||
Typeface typeface = gameActivity.getTypeface();
|
||||
fadeIn = AnimationUtils.loadAnimation(gameActivity, R.anim.fade_in);
|
||||
topBar = new TopBar(gameActivity, Screen.ScreenType.GAME,
|
||||
topBar = new TopBar(gameActivity, gameScreen,
|
||||
layout.findViewById(R.id.game_over_message_topbar));
|
||||
topBar.setShopsEnabled(true);
|
||||
TextView title = (TextView) layout.findViewById(R.id.game_over_message_title);
|
||||
|
@ -12,6 +12,7 @@ import de.frajul.endlessroll.levels.Level;
|
||||
import de.frajul.endlessroll.levels.LevelPack;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.game.Game;
|
||||
import de.frajul.endlessroll.main.screens.GameScreen;
|
||||
import de.frajul.endlessroll.main.screens.Screen;
|
||||
|
||||
/**
|
||||
@ -30,7 +31,7 @@ public class GoalMessage implements GoalMessageLevelButtonOnClickListener, View.
|
||||
private GoalMessageLevelButton nextLevel;
|
||||
private Button toMenu;
|
||||
|
||||
public GoalMessage(Game game, GameActivity gameActivity, View layout) {
|
||||
public GoalMessage(Game game, GameScreen gameScreen, GameActivity gameActivity, View layout) {
|
||||
this.game = game;
|
||||
this.gameActivity = gameActivity;
|
||||
this.layout = layout;
|
||||
@ -38,7 +39,7 @@ public class GoalMessage implements GoalMessageLevelButtonOnClickListener, View.
|
||||
Typeface typeface = gameActivity.getTypeface();
|
||||
fadeIn = AnimationUtils.loadAnimation(gameActivity, R.anim.fade_in);
|
||||
|
||||
topBar = new TopBar(gameActivity, Screen.ScreenType.GAME,
|
||||
topBar = new TopBar(gameActivity, gameScreen,
|
||||
layout.findViewById(R.id.goal_message_topbar));
|
||||
topBar.setShopsEnabled(true);
|
||||
TextView title = (TextView) layout.findViewById(R.id.goal_message_title);
|
||||
|
@ -12,6 +12,7 @@ import java.util.Random;
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.game.Game;
|
||||
import de.frajul.endlessroll.main.screens.GameScreen;
|
||||
import de.frajul.endlessroll.main.screens.Screen;
|
||||
|
||||
/**
|
||||
@ -31,11 +32,11 @@ public class ShortMenu implements View.OnClickListener {
|
||||
private TextView restartView;
|
||||
private TextView exitView;
|
||||
|
||||
public ShortMenu(final Game game, GameActivity gameActivity, View layout) {
|
||||
public ShortMenu(final Game game, GameScreen gameScreen, GameActivity gameActivity, View layout) {
|
||||
this.game = game;
|
||||
this.layout = layout;
|
||||
Typeface typeface = gameActivity.getTypeface();
|
||||
topBar = new TopBar(gameActivity, Screen.ScreenType.GAME,
|
||||
topBar = new TopBar(gameActivity, gameScreen,
|
||||
layout.findViewById(R.id.shortmenu_topbar));
|
||||
continueView = (TextView) layout.findViewById(R.id.shortmenu_continue);
|
||||
continueView.setTypeface(typeface);
|
||||
|
@ -20,7 +20,7 @@ public class TopBar implements View.OnClickListener {
|
||||
|
||||
private GameActivity gameActivity;
|
||||
private View layout;
|
||||
private Screen.ScreenType parent;
|
||||
private Screen parent;
|
||||
private Screen.ScreenType customCallerForScreenSwitch = Screen.ScreenType.NONE;
|
||||
|
||||
private Animation starDecreaseAnimation;
|
||||
@ -31,13 +31,14 @@ public class TopBar implements View.OnClickListener {
|
||||
private ProgressBar levelProgress;
|
||||
private TextView starCount;
|
||||
private TextView energyCount;
|
||||
private Button backButton;
|
||||
private Button settingsButton;
|
||||
private Button toolshopButton;
|
||||
private Button shapeshopButton;
|
||||
private TextView starCountDecrease;
|
||||
private TextView energyCountDecrease;
|
||||
|
||||
public TopBar(GameActivity gameActivity, Screen.ScreenType parent, View layout) {
|
||||
public TopBar(GameActivity gameActivity, Screen parent, View layout) {
|
||||
this.gameActivity = gameActivity;
|
||||
this.parent = parent;
|
||||
this.layout = layout;
|
||||
@ -54,19 +55,22 @@ public class TopBar implements View.OnClickListener {
|
||||
starCount.setTypeface(typeface);
|
||||
energyCount = (TextView) layout.findViewById(R.id.topbar_energycount);
|
||||
energyCount.setTypeface(typeface);
|
||||
backButton = (Button) layout.findViewById(R.id.topbar_back_button);
|
||||
backButton.setOnClickListener(this);
|
||||
settingsButton = (Button) layout.findViewById(R.id.topbar_settings);
|
||||
settingsButton.setOnClickListener(this);
|
||||
toolshopButton = (Button) layout.findViewById(R.id.topbar_toolshop);
|
||||
toolshopButton.setOnClickListener(this);
|
||||
shapeshopButton = (Button) layout.findViewById(R.id.topbar_shapeshop);
|
||||
shapeshopButton.setOnClickListener(this);
|
||||
if(parent == Screen.ScreenType.SETTINGS)
|
||||
if (parent.getType() == Screen.ScreenType.SETTINGS)
|
||||
settingsButton.setEnabled(false);
|
||||
if(parent == Screen.ScreenType.TOOL_SHOP)
|
||||
if (parent.getType() == Screen.ScreenType.TOOL_SHOP)
|
||||
toolshopButton.setEnabled(false);
|
||||
if(parent == Screen.ScreenType.SHAPE_SHOP)
|
||||
if (parent.getType() == Screen.ScreenType.SHAPE_SHOP)
|
||||
shapeshopButton.setEnabled(false);
|
||||
if (parent == Screen.ScreenType.GAME) {
|
||||
if (parent.getType() == Screen.ScreenType.GAME) {
|
||||
backButton.setEnabled(false);
|
||||
toolshopButton.setEnabled(false);
|
||||
shapeshopButton.setEnabled(false);
|
||||
}
|
||||
@ -118,6 +122,9 @@ public class TopBar implements View.OnClickListener {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.equals(backButton)) {
|
||||
parent.onBackKeyDown();
|
||||
}
|
||||
if (v.equals(toolshopButton)) {
|
||||
flipToScreen(Screen.ScreenType.TOOL_SHOP);
|
||||
} else if (v.equals(shapeshopButton)) {
|
||||
@ -133,8 +140,8 @@ public class TopBar implements View.OnClickListener {
|
||||
gameActivity.flipToScreen(screenType);
|
||||
}
|
||||
|
||||
public Screen.ScreenType getParent() {
|
||||
return parent;
|
||||
public Screen.ScreenType getParentType() {
|
||||
return parent.getType();
|
||||
}
|
||||
|
||||
public boolean isToolShopButtonEnabled() {
|
||||
|
@ -13,6 +13,7 @@ import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.GameHandler;
|
||||
import de.frajul.endlessroll.main.game.Game;
|
||||
import de.frajul.endlessroll.main.game.Timer;
|
||||
import de.frajul.endlessroll.main.screens.GameScreen;
|
||||
import de.frajul.endlessroll.user.User;
|
||||
|
||||
/**
|
||||
@ -35,7 +36,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
|
||||
private String fpsFormat, playerProgressFormat, playerSpeedFormat;
|
||||
|
||||
public ViewManager(final Game game, final GameHandler gameViewHandler, final GameActivity gameActivity) {
|
||||
public ViewManager(final Game game, final GameScreen gameScreen, final GameHandler gameViewHandler, final GameActivity gameActivity) {
|
||||
this.game = game;
|
||||
this.gameViewHandler = gameViewHandler;
|
||||
|
||||
@ -46,12 +47,14 @@ public class ViewManager implements View.OnClickListener {
|
||||
toolButtonBar = new ToolButtonBar(game,
|
||||
gameActivity.getUser().getToolSlotSettings(),
|
||||
(LinearLayout) layout.findViewById(R.id.game_toolbuttonbar));
|
||||
shortMenu = new ShortMenu(game, gameActivity,
|
||||
shortMenu = new ShortMenu(game, gameScreen, gameActivity,
|
||||
layout.findViewById(R.id.game_shortmenu));
|
||||
gameOverMessage = new GameOverMessage(game, gameActivity,
|
||||
gameOverMessage = new GameOverMessage(game, gameScreen, gameActivity,
|
||||
layout.findViewById(R.id.game_game_over_message));
|
||||
goalMessage = new GoalMessage(game, gameActivity, layout.findViewById(R.id.game_goal_message));
|
||||
countdown = new Countdown(game, gameActivity.getSoundManager(), gameActivity.getTypeface(),
|
||||
goalMessage = new GoalMessage(game, gameScreen, gameActivity,
|
||||
layout.findViewById(R.id.game_goal_message));
|
||||
countdown = new Countdown(game, gameActivity.getSoundManager(),
|
||||
gameActivity.getTypeface(),
|
||||
(TextView) layout.findViewById(R.id.game_countdown));
|
||||
}
|
||||
});
|
||||
@ -66,12 +69,12 @@ public class ViewManager implements View.OnClickListener {
|
||||
playerSpeedFormat = game.getContext().getString(R.string.game_playerspeed_format_f);
|
||||
}
|
||||
|
||||
public void prepareToBeShown(){
|
||||
if(shortMenu.isVisible())
|
||||
public void prepareToBeShown() {
|
||||
if (shortMenu.isVisible())
|
||||
shortMenu.prepareToBeShown();
|
||||
if(gameOverMessage.isVisible())
|
||||
if (gameOverMessage.isVisible())
|
||||
gameOverMessage.prepareToBeShown();
|
||||
if(goalMessage.isVisible())
|
||||
if (goalMessage.isVisible())
|
||||
goalMessage.prepareToBeShown();
|
||||
}
|
||||
|
||||
@ -92,7 +95,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
});
|
||||
}
|
||||
|
||||
public void onGoalMessageKeyBack(){
|
||||
public void onGoalMessageKeyBack() {
|
||||
goalMessage.onKeyBack();
|
||||
}
|
||||
|
||||
@ -105,7 +108,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
});
|
||||
}
|
||||
|
||||
public void showGoalMessage(final LevelPack levelPack, final Level level){
|
||||
public void showGoalMessage(final LevelPack levelPack, final Level level) {
|
||||
gameViewHandler.startInUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -150,7 +153,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
return ((int) (value * 20)) / 10f;
|
||||
}
|
||||
|
||||
public boolean isShortMenuVisible(){
|
||||
public boolean isShortMenuVisible() {
|
||||
return shortMenu.isVisible();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user