Added settings screen, even if the look has to be polished and new items have to be added

The toolshop-button and the settings-button in the topBar now consist of icons (no text). Bad thing is, that the 'disabled' state doesn't look that good
Every screen is given its caller when flipped to. At OnBackKeyDown you can now either 'flipToCaller()' or 'flipToPreviousScreenInTree()' or as you wish...
This commit is contained in:
=
2017-09-10 15:10:40 +02:00
parent 74b73bb143
commit bd38883299
22 changed files with 1080 additions and 964 deletions

View File

@ -24,7 +24,7 @@ public class GLTestScreen extends GLScreen<RelativeLayout> {
@Override
public void prepareToBeShown() {
glView.setCurrentRendering(rendering);
flipToCaller();
}
@Override

View File

@ -0,0 +1,51 @@
package de.frajul.endlessroll.main.screens;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ToggleButton;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.views.TopBar;
/**
* Created by Julian on 10.09.2017.
*/
public class SettingsScreen extends Screen<LinearLayout> implements View.OnClickListener {
private TopBar topBar;
private ToggleButton soundToggle;
private Button resetButton;
public SettingsScreen(GameActivity gameActivity) {
super(ScreenType.SETTINGS, gameActivity, R.layout.settings);
topBar = super.createTopBar(R.id.settings_topbar);
soundToggle = (ToggleButton) layout.findViewById(R.id.settings_soundtoggle);
soundToggle.setOnClickListener(this);
resetButton = (Button) layout.findViewById(R.id.settings_reset);
resetButton.setOnClickListener(this);
}
@Override
public void prepareToBeShown() {
topBar.update();
soundToggle.setChecked(gameActivity.getSoundManager().isSoundOn());
resetButton.setEnabled(super.caller != ScreenType.GAME);
}
@Override
public void onBackKeyDown() {
flipToCaller();
}
@Override
public void onClick(View v) {
if (v.equals(soundToggle)) {
gameActivity.getSoundManager().setSoundOn(soundToggle.isChecked());
} else if (v.equals(resetButton)) {
gameActivity.resetData();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".main.GameActivity">
<item android:state_enabled="true">
<bitmap android:src="@drawable/settings_enabled"/>
</item>
<item android:state_enabled="false">
<bitmap android:src="@drawable/settings_disabled"/>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".main.GameActivity">
<item android:state_enabled="true">
<bitmap android:src="@drawable/shop_enabled"/>
</item>
<item android:state_enabled="false">
<bitmap android:src="@drawable/shop_disabled"/>
</item>
</selector>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backgrounds_menu_grass"
android:orientation="vertical">
<include
android:id="@+id/settings_topbar"
layout="@layout/topbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
android:layout_marginLeft="20dp">
<ToggleButton
android:id="@+id/settings_soundtoggle"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/xml_selector_sound"
android:textOff=""
android:textOn=""/>
<Button
android:id="@+id/settings_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
style="@style/GameButton"
android:text="@string/settings_reset"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@ -3,16 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ToggleButton
android:id="@+id/startscreen_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/startscreen_play"
<Button
android:id="@+id/startscreen_settings"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/startscreen_play"
android:background="@drawable/xml_selector_sound"
android:textOff=""
android:textOn=""/>
android:background="@drawable/xml_selector_settingsbutton"
android:layout_marginBottom="15dp"/>
<Button
android:id="@+id/startscreen_play"

View File

@ -14,8 +14,8 @@
android:layout_centerVertical="true"
android:layout_marginEnd="20dp"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:clipChildren="false">
android:clipChildren="false"
android:orientation="vertical">
<TextView
android:id="@+id/topbar_leveldisplay"
@ -42,15 +42,15 @@
android:background="@drawable/currency_star"/>
<ImageView
android:id="@+id/topbar_energyview"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/currency_energy"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/topbar_starcount"
android:layout_toEndOf="@+id/topbar_starcount"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:id="@+id/topbar_energyview"/>
android:layout_toEndOf="@+id/topbar_starcount"
android:layout_toRightOf="@+id/topbar_starcount"
android:background="@drawable/currency_energy"/>
<TextView
android:id="@+id/topbar_starcount"
@ -70,59 +70,44 @@
android:text="@string/number_placeholder"
android:textSize="25sp"/>
<ToggleButton
android:id="@+id/topbar_soundtoggle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentTop="true"
<Button
android:id="@+id/topbar_settings"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/topbar_toolshop"
android:layout_toStartOf="@+id/topbar_toolshop"
android:background="@drawable/xml_selector_sound"
android:textOff=""
android:textOn=""/>
android:background="@drawable/xml_selector_settingsbutton"/>
<Button
android:id="@+id/topbar_toolshop"
style="@style/GameButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:text="@string/topbar_toolshop"/>
android:background="@drawable/xml_selector_shopbutton"/>
<TextView
android:id="@+id/topbar_starcount_decrease"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/number_placeholder"
android:visibility="invisible"
android:textSize="20sp"
android:layout_alignEnd="@+id/topbar_starcount"
android:layout_centerVertical="true"
android:layout_alignEnd="@+id/topbar_starcount"/>
android:text="@string/number_placeholder"
android:textSize="20sp"
android:visibility="invisible"/>
<TextView
android:id="@+id/topbar_energycount_decrease"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/number_placeholder"
android:visibility="invisible"
android:textSize="20sp"
android:layout_alignEnd="@+id/topbar_energycount"
android:layout_centerVertical="true"
android:layout_alignEnd="@+id/topbar_energycount"/>
<Button
android:id="@+id/topbar_resetButton"
style="@style/GameButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/topbar_reset"
android:layout_marginLeft="64dp"
android:layout_marginStart="64dp"
android:layout_alignBaseline="@+id/topbar_soundtoggle"
android:layout_alignBottom="@+id/topbar_soundtoggle"
android:layout_toRightOf="@+id/topbar_energycount"
android:layout_toEndOf="@+id/topbar_energycount"/>
android:text="@string/number_placeholder"
android:textSize="20sp"
android:visibility="invisible"/>
</RelativeLayout>

View File

@ -31,7 +31,7 @@
<string name="tool_upgrade_title_placeholder">Time (Lv12)</string>
<string name="topbar_level_placeholder">Level: 24</string>
<string name="topbar_level_format_d">Level: %d</string>
<string name="topbar_reset">Reset</string>
<string name="settings_reset">Reset</string>
<string name="topbar_toolshop">Toolshop</string>
<string name="unlock_message_placeholder">Ramp unlocked</string>
<string name="world_button_title_placeholder">Great world</string>