Changed overall style

Now one can change directly between Screens from TopBar
Fixed bugs
This commit is contained in:
=
2018-01-21 17:40:25 +01:00
parent 2c19e3dcb5
commit 5302ac0d00
19 changed files with 181 additions and 154 deletions

View File

@ -138,6 +138,21 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
super.finish();
}
public boolean isShortMenuInGameActive() {
return gameScreen.getGameViewManager().isShortMenuVisible();
}
public void flipToScreen(final Screen.ScreenType screen, final Screen.ScreenType caller) {
if (screen != Screen.ScreenType.NONE && flipper.getCurrentScreen().getType() != screen) {
runOnUiThread(new Runnable() {
@Override
public void run() {
flipper.showScreen(screen, caller);
}
});
}
}
public void flipToScreen(final Screen.ScreenType screen) {
if (screen != Screen.ScreenType.NONE && flipper.getCurrentScreen().getType() != screen) {
runOnUiThread(new Runnable() {

View File

@ -13,6 +13,7 @@ import de.frajul.endlessroll.main.MyGlSurfaceView;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.main.game.GameState;
import de.frajul.endlessroll.main.tutorial.BreakPoint;
import de.frajul.endlessroll.views.ViewManager;
/**
* Created by Julian on 08.02.2016.
@ -51,6 +52,10 @@ public class GameScreen extends GLScreen<RelativeLayout> {
return game.getGameState() == GameState.LEVEL_FINISHED;
}
public ViewManager getGameViewManager(){
return game.getViewManager();
}
@Override
public void onBackKeyDown() {
game.tryToPause();

View File

@ -67,6 +67,7 @@ public class PlayerShapeShopScreen extends Screen<RelativeLayout> implements Pla
createViews();
topBar.update();
topBar.setCustomCallerForScreenSwitch(super.caller);
}
@Override

View File

@ -22,7 +22,6 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
private ToggleButton musicToggle;
private ToggleButton soundToggle;
private Button resetButton;
private boolean resetPressed = false;
private ConfirmDialog resetConfirmDialog;
@ -44,10 +43,12 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
gameActivity.getSoundManager().menuMusic.start();
topBar.update();
topBar.setCustomCallerForScreenSwitch(super.caller);
topBar.setShopsEnabled(!gameActivity.isShortMenuInGameActive());
musicToggle.setChecked(!gameActivity.getSoundManager().isMusicMuted());
soundToggle.setChecked(!gameActivity.getSoundManager().isSoundsMuted());
resetButton.setEnabled(super.caller != ScreenType.GAME);
resetPressed = false;
}
@Override
@ -56,10 +57,7 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
.writeSoundsMuted(gameActivity.getSoundManager().isSoundsMuted());
gameActivity.getDataStorageHandler()
.writeMusicMuted(gameActivity.getSoundManager().isMusicMuted());
//ResetButton is disabled if caller is GAME, because shortMenu or GoalMessage would still be visible on next level start
if (resetPressed && (super.caller == ScreenType.LEVELS || super.caller == ScreenType.GAME)) {
super.caller = ScreenType.WORLDS;
}
flipToCaller();
}
@ -79,7 +77,11 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
if (callId == CALL_ID_CONFIRM_RESET) {
gameActivity.resetData();
prepareToBeShown();
resetPressed = true;
//ResetButton is disabled if caller is GAME, because shortMenu or GoalMessage would still be visible on next level start
if (super.caller == ScreenType.LEVELS || super.caller == ScreenType.GAME) {
super.caller = ScreenType.WORLDS;
topBar.setCustomCallerForScreenSwitch(super.caller);
}
}
}
}

View File

@ -29,7 +29,6 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
private Button gain90EP;
private Button finishFirstWorld;
private Button toGlTestScreen;
private Button settings;
private ConfirmDialog confirmDialog;
@ -43,8 +42,6 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
gain90EP = createButton(R.id.startscreen_gain_90_ep, typeface);
finishFirstWorld = createButton(R.id.startscreen_finish_world_1, typeface);
toGlTestScreen = createButton(R.id.startscreen_to_gl_test_screen, typeface);
settings = (Button) layout.findViewById(R.id.startscreen_settings);
settings.setOnClickListener(this);
confirmDialog = new ConfirmDialog(gameActivity, this);
@ -63,9 +60,9 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
public void prepareToBeShown() {
gameActivity.getSoundManager().menuMusic.start();
glView.setCurrentRendering(rendering);
((StartScene) rendering.getScene()).randomizeWorld();
((StartScene) rendering.getScene()).loadTexturesForCurrentWorld();
glView.setCurrentRendering(rendering);
}
@Override
@ -78,9 +75,6 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
if (v.equals(play)) {
gameActivity.flipToScreen(ScreenType.WORLDS);
glView.setCurrentRendering(null);
} else if (v.equals(settings)) {
gameActivity.flipToScreen(ScreenType.SETTINGS);
glView.setCurrentRendering(null);
} else if (v.equals(gain90EP)) {
gameActivity.getUser().gainEp(90, true);
} else if (v.equals(unlockLevels)) {

View File

@ -90,6 +90,7 @@ public class ToolShopScreen extends Screen<RelativeLayout> implements View.OnCli
gameActivity.getSoundManager().menuMusic.start();
topBar.update();
topBar.setCustomCallerForScreenSwitch(super.caller);
slotSettings.unlockSlotsIfLevelReached(gameActivity.getUser().getLevelUpBounties());
onToolOfferSlotSelected(toolOfferSlots.get(0));

View File

@ -21,6 +21,7 @@ public class TopBar implements View.OnClickListener {
private GameActivity gameActivity;
private View layout;
private Screen.ScreenType parent;
private Screen.ScreenType customCallerForScreenSwitch = Screen.ScreenType.NONE;
private Animation starDecreaseAnimation;
private Animation energyDecreaseAnimation;
@ -59,11 +60,12 @@ public class TopBar implements View.OnClickListener {
toolshopButton.setOnClickListener(this);
shapeshopButton = (Button) layout.findViewById(R.id.topbar_shapeshop);
shapeshopButton.setOnClickListener(this);
if (parent == Screen.ScreenType.TOOL_SHOP || parent == Screen.ScreenType.SHAPE_SHOP || parent == Screen.ScreenType.SETTINGS) {
toolshopButton.setEnabled(false);
shapeshopButton.setEnabled(false);
if(parent == Screen.ScreenType.SETTINGS)
settingsButton.setEnabled(false);
}
if(parent == Screen.ScreenType.TOOL_SHOP)
toolshopButton.setEnabled(false);
if(parent == Screen.ScreenType.SHAPE_SHOP)
shapeshopButton.setEnabled(false);
if (parent == Screen.ScreenType.GAME) {
toolshopButton.setEnabled(false);
shapeshopButton.setEnabled(false);
@ -96,7 +98,7 @@ public class TopBar implements View.OnClickListener {
gameActivity.getTutorialManager().onTopBarUpdate(this);
}
public void startToolShopButtonPulse(){
public void startToolShopButtonPulse() {
toolshopButton.startAnimation(toolShopPulse);
}
@ -110,22 +112,32 @@ public class TopBar implements View.OnClickListener {
energyCountDecrease.startAnimation(energyDecreaseAnimation);
}
public void setCustomCallerForScreenSwitch(Screen.ScreenType customCallerForScreenSwitch) {
this.customCallerForScreenSwitch = customCallerForScreenSwitch;
}
@Override
public void onClick(View v) {
if (v.equals(toolshopButton)) {
gameActivity.flipToScreen(Screen.ScreenType.TOOL_SHOP);
flipToScreen(Screen.ScreenType.TOOL_SHOP);
} else if (v.equals(shapeshopButton)) {
gameActivity.flipToScreen(Screen.ScreenType.SHAPE_SHOP);
flipToScreen(Screen.ScreenType.SHAPE_SHOP);
} else if (v.equals(settingsButton)) {
gameActivity.flipToScreen(Screen.ScreenType.SETTINGS);
flipToScreen(Screen.ScreenType.SETTINGS);
}
}
private void flipToScreen(Screen.ScreenType screenType) {
if (customCallerForScreenSwitch != Screen.ScreenType.NONE)
gameActivity.flipToScreen(screenType, customCallerForScreenSwitch);
gameActivity.flipToScreen(screenType);
}
public Screen.ScreenType getParent() {
return parent;
}
public boolean isToolShopButtonEnabled(){
public boolean isToolShopButtonEnabled() {
return toolshopButton.isEnabled();
}
}

View File

@ -150,4 +150,8 @@ public class ViewManager implements View.OnClickListener {
return ((int) (value * 20)) / 10f;
}
public boolean isShortMenuVisible(){
return shortMenu.isVisible();
}
}

View File

@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="47dp" />
<solid android:color="#FF97A0F0" />
<solid android:color="#a997f0" />
<padding
android:bottom="10dp"
android:left="15dp"

View File

@ -5,8 +5,8 @@
<gradient
android:centerX="0%"
android:centerY="0%"
android:endColor="#ff71a5"
android:startColor="#d7fd00"
android:endColor="#fd9400"
android:startColor="#f0fd00"
android:angle="315"
android:type="linear" />
<padding
@ -16,5 +16,5 @@
android:top="10dp" />
<stroke
android:width="4dp"
android:color="#74ff71d0" />
android:color="#74ff8800" />
</shape>

View File

@ -2,29 +2,26 @@
<selector xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" tools:context=".main.GameActivity">
<item android:state_pressed="true" android:state_enabled="true">
<shape>
<corners android:radius="20dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
<stroke android:width="1dp" android:color="#992f2f" />
<solid android:color="#ef4444" />
<gradient android:type="linear" android:angle="90" android:startColor="#ca5f47" android:endColor="#f15841" />
<corners android:radius="7dp"/>
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/>
<stroke android:width="1dp" android:color="#992f2f"/>
</shape>
</item>
<item android:state_pressed="false" android:state_enabled="true">
<shape>
<corners android:radius="20dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
<stroke android:width="1dp" android:color="#992f2f" />
<gradient android:angle="270" android:endColor="#992f2f" android:startColor="#ef4444" />
<gradient android:type="linear" android:angle="90" android:startColor="#d63e1c" android:endColor="#f53619" />
<corners android:radius="7dp"/>
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/>
<stroke android:width="1dp" android:color="#992f2f"/>
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:radius="20dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
<stroke android:width="1dp" android:color="#992f2f" />
<gradient android:angle="270" android:endColor="#a15d5d" android:startColor="#b73d3d" />
<gradient android:type="linear" android:angle="90" android:startColor="#ac5441" android:endColor="#ae5243" />
<corners android:radius="7dp"/>
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp"/>
<stroke android:width="1dp" android:color="#992f2f"/>
</shape>
</item>
</selector>

View File

@ -2,14 +2,13 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ef78">
android:background="#41a6d1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/pre_start_screen_loading"
android:textAllCaps="false"
android:textSize="30sp"
android:textStyle="bold"/>
</RelativeLayout>

View File

@ -3,22 +3,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/startscreen_settings"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:background="@drawable/xml_selector_settingsbutton"
android:layout_marginBottom="15dp"/>
<Button
android:id="@+id/startscreen_play"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="38dp"
android:layout_centerInParent="true"
android:background="@drawable/playershapes_ball"
android:gravity="center"
android:text="@string/start_screen_play"
@ -31,8 +20,11 @@
style="@style/GameButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/startscreen_play"
android:layout_alignParentStart="true"
android:layout_below="@+id/startscreen_gain_90_ep"
android:layout_marginBottom="2dp"
android:layout_marginStart="10dp"
android:layout_marginTop="2dp"
android:text="@string/start_screen_unlock_all_levels"
android:visibility="visible"/>
@ -42,8 +34,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/startscreen_play"
android:layout_below="@+id/startscreen_to_gl_test_screen"
android:layout_marginBottom="2dp"
android:layout_marginStart="10dp"
android:layout_marginTop="2dp"
android:text="@string/start_screen_gain_90_ep"
android:visibility="visible"/>
@ -64,8 +58,10 @@
style="@style/GameButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:text="@string/start_screen_to_gl_test_screen"
android:visibility="visible"/>

View File

@ -3,7 +3,7 @@
android:id="@+id/topbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#a600f9">
android:background="@color/topbar">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topbar_levellayout"
@ -72,9 +72,9 @@
android:id="@+id/topbar_settings"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_alignParentEnd="true"
android:background="@drawable/xml_selector_settingsbutton"/>
<Button
@ -83,8 +83,8 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/topbar_settings"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/topbar_settings"
android:background="@drawable/xml_selector_toolshopbutton"/>
<Button
@ -92,9 +92,9 @@
style="@style/GameButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_toLeftOf="@+id/topbar_toolshop"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/topbar_toolshop"
android:background="@drawable/xml_selector_shapeshopbutton"/>
<TextView

View File

@ -20,4 +20,5 @@
<color name="background_levelup_message">#9d000000</color>
<color name="background_short_menu">#5b000000</color>
<color name="background_tutorial">#3d000000</color>
<color name="topbar">#cf664c</color>
</resources>

View File

@ -29,8 +29,8 @@
<string name="short_menu_restart">Restart</string>
<string name="short_menu_exit">Exit</string>
<string name="start_screen_play">Play</string>
<string name="start_screen_unlock_all_levels" translatable="false">Unlock all levels (Yes! It\'s magic!)</string>
<string name="start_screen_gain_90_ep" translatable="false">Gain 90 ep (Nope! No magic at all!)</string>
<string name="start_screen_unlock_all_levels" translatable="false">Unlock all levels</string>
<string name="start_screen_gain_90_ep" translatable="false">Gain 90 ep</string>
<string name="start_screen_finish_world_1">Finish the first world!</string>
<string name="start_screen_to_gl_test_screen" translatable="false">Test GL Stuff!!!</string>
<string name="tool_upgrade_title_placeholder">Time (Lv12)</string>