Changed dialoges to ConfirmDialog
This commit is contained in:
@ -24,9 +24,9 @@ public enum PlayerShape {
|
||||
SMILEY(R.string.playershape_name_smiley, R.string.playershape_description_smiley,
|
||||
R.drawable.playershapes_smiley, new CollectStarTask(30)),
|
||||
WHEEL(R.string.playershape_name_wheel, R.string.playershape_description_wheel,
|
||||
R.drawable.playershapes_wheel, new CollectStarTask(48)),
|
||||
R.drawable.playershapes_wheel, new CollectStarTask(45)),
|
||||
SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
|
||||
R.drawable.playershapes_sun, new CollectEnergyTask(16));
|
||||
R.drawable.playershapes_sun, new CollectEnergyTask(10));
|
||||
|
||||
@StringRes
|
||||
private int nameId;
|
||||
|
@ -242,6 +242,7 @@ public class GameActivity extends Activity implements ExceptionHandler, User.LvU
|
||||
type.reset();
|
||||
database.writeToolData();
|
||||
database.close();
|
||||
checkForAlreadyUnlockedPlayerShapes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,20 +7,22 @@ import android.widget.ToggleButton;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.views.ResetConfirmDialog;
|
||||
import de.frajul.endlessroll.views.ConfirmDialog;
|
||||
import de.frajul.endlessroll.views.TopBar;
|
||||
|
||||
/**
|
||||
* Created by Julian on 10.09.2017.
|
||||
*/
|
||||
|
||||
public class SettingsScreen extends Screen<LinearLayout> implements View.OnClickListener {
|
||||
public class SettingsScreen extends Screen<LinearLayout> implements View.OnClickListener, ConfirmDialog.ConfirmDialogListener {
|
||||
|
||||
private final int CALL_ID_CONFIRM_RESET = 1;
|
||||
|
||||
private TopBar topBar;
|
||||
private ToggleButton soundToggle;
|
||||
private Button resetButton;
|
||||
|
||||
private ResetConfirmDialog resetConfirmDialog;
|
||||
private ConfirmDialog resetConfirmDialog;
|
||||
|
||||
public SettingsScreen(GameActivity gameActivity) {
|
||||
super(ScreenType.SETTINGS, gameActivity, R.layout.settings);
|
||||
@ -30,7 +32,7 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
|
||||
resetButton = (Button) layout.findViewById(R.id.settings_reset);
|
||||
resetButton.setOnClickListener(this);
|
||||
|
||||
resetConfirmDialog = new ResetConfirmDialog(gameActivity, this);
|
||||
resetConfirmDialog = new ConfirmDialog(gameActivity, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,7 +56,15 @@ public class SettingsScreen extends Screen<LinearLayout> implements View.OnClick
|
||||
if (v.equals(soundToggle)) {
|
||||
gameActivity.getSoundManager().setSoundOn(soundToggle.isChecked());
|
||||
} else if (v.equals(resetButton)) {
|
||||
resetConfirmDialog.show();
|
||||
resetConfirmDialog.show(CALL_ID_CONFIRM_RESET, R.string.confirm_dialog_reset);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmed(int callId) {
|
||||
if (callId == CALL_ID_CONFIRM_RESET) {
|
||||
gameActivity.resetData();
|
||||
prepareToBeShown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,15 @@ import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.MyGlSurfaceView;
|
||||
import de.frajul.endlessroll.rendering.Rendering;
|
||||
import de.frajul.endlessroll.sqlDatabase.MyDatabase;
|
||||
import de.frajul.endlessroll.views.ExitConfirmDialog;
|
||||
import de.frajul.endlessroll.views.ConfirmDialog;
|
||||
|
||||
/**
|
||||
* Created by Julian on 07.07.2016.
|
||||
*/
|
||||
public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClickListener {
|
||||
public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClickListener, ConfirmDialog.ConfirmDialogListener {
|
||||
|
||||
private final int CALL_ID_CONFIRM_EXIT = 1;
|
||||
private final int CALL_ID_CONFIRM_FINISH_WORLD = 2;
|
||||
|
||||
private Rendering rendering;
|
||||
|
||||
@ -28,7 +31,7 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
|
||||
private Button toGlTestScreen;
|
||||
private Button settings;
|
||||
|
||||
private ExitConfirmDialog exitConfirmDialog;
|
||||
private ConfirmDialog confirmDialog;
|
||||
|
||||
public StartScreen(GameActivity gameActivity, MyGlSurfaceView glSurfaceView) throws Exception {
|
||||
super(ScreenType.START, gameActivity, R.layout.start_screen, glSurfaceView);
|
||||
@ -43,7 +46,7 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
|
||||
settings = (Button) layout.findViewById(R.id.startscreen_settings);
|
||||
settings.setOnClickListener(this);
|
||||
|
||||
exitConfirmDialog = new ExitConfirmDialog(gameActivity);
|
||||
confirmDialog = new ConfirmDialog(gameActivity, this);
|
||||
|
||||
rendering = new StartScreenRendering(gameActivity);
|
||||
glView.addRendering(rendering);
|
||||
@ -63,7 +66,7 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
|
||||
|
||||
@Override
|
||||
public void onBackKeyDown() {
|
||||
exitConfirmDialog.show();
|
||||
confirmDialog.show(CALL_ID_CONFIRM_EXIT, R.string.confirm_dialog_exit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,6 +87,18 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
|
||||
database.writeAllLevelAndPackStatus(gameActivity.getLevelManager());
|
||||
database.close();
|
||||
} else if (v.equals(finishFirstWorld)) {
|
||||
confirmDialog
|
||||
.show(CALL_ID_CONFIRM_FINISH_WORLD, R.string.confirm_dialog_finish_world_1);
|
||||
} else if (v.equals(toGlTestScreen))
|
||||
gameActivity.flipToScreen(ScreenType.GL_TEST);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onConfirmed(int callId) {
|
||||
if (callId == CALL_ID_CONFIRM_EXIT) {
|
||||
gameActivity.exitGame();
|
||||
} else if (callId == CALL_ID_CONFIRM_FINISH_WORLD) {
|
||||
gameActivity.resetData();
|
||||
gameActivity.getUser().gainEp(320, false);
|
||||
gameActivity.getLevelManager().finishFirstPack();
|
||||
@ -96,9 +111,6 @@ public class StartScreen extends GLScreen<RelativeLayout> implements View.OnClic
|
||||
database.open();
|
||||
database.writeAllLevelAndPackStatus(gameActivity.getLevelManager());
|
||||
database.close();
|
||||
} else if (v.equals(toGlTestScreen))
|
||||
gameActivity.flipToScreen(ScreenType.GL_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package de.frajul.endlessroll.views;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
@ -14,36 +15,54 @@ import de.frajul.endlessroll.main.GameActivity;
|
||||
* Created by Julian on 31.10.2017.
|
||||
*/
|
||||
|
||||
public class ExitConfirmDialog extends Dialog implements View.OnClickListener {
|
||||
public class ConfirmDialog extends Dialog implements View.OnClickListener {
|
||||
|
||||
public interface ConfirmDialogListener {
|
||||
void onConfirmed(int callId);
|
||||
}
|
||||
|
||||
private GameActivity gameActivity;
|
||||
private int callId = -1;
|
||||
@StringRes
|
||||
private int text = -1;
|
||||
private ConfirmDialogListener listener;
|
||||
|
||||
private TextView textView;
|
||||
private Button yesButton;
|
||||
private Button noButton;
|
||||
|
||||
public ExitConfirmDialog(GameActivity gameActivity) {
|
||||
public ConfirmDialog(GameActivity gameActivity, ConfirmDialogListener listener) {
|
||||
super(gameActivity);
|
||||
this.gameActivity = gameActivity;
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.exit_confirm_dialog);
|
||||
TextView textView = (TextView) findViewById(R.id.exit_confirm_dialog_textview);
|
||||
setContentView(R.layout.confirm_dialog);
|
||||
textView = (TextView) findViewById(R.id.confirm_dialog_textview);
|
||||
textView.setTypeface(gameActivity.getTypeface());
|
||||
noButton = (Button) findViewById(R.id.exit_confirm_dialog_no_button);
|
||||
noButton = (Button) findViewById(R.id.confirm_dialog_no_button);
|
||||
noButton.setTypeface(gameActivity.getTypeface());
|
||||
noButton.setOnClickListener(this);
|
||||
yesButton = (Button) findViewById(R.id.exit_confirm_dialog_yes_button);
|
||||
yesButton = (Button) findViewById(R.id.confirm_dialog_yes_button);
|
||||
yesButton.setTypeface(gameActivity.getTypeface());
|
||||
yesButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
public void show(int callId, @StringRes int text) {
|
||||
this.callId = callId;
|
||||
this.text = text;
|
||||
super.show();
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
if (v.equals(yesButton))
|
||||
gameActivity.exitGame();
|
||||
listener.onConfirmed(callId);
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package de.frajul.endlessroll.views;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.screens.SettingsScreen;
|
||||
|
||||
/**
|
||||
* Created by Julian on 31.10.2017.
|
||||
*/
|
||||
|
||||
public class ResetConfirmDialog extends Dialog implements View.OnClickListener {
|
||||
|
||||
private GameActivity gameActivity;
|
||||
private SettingsScreen settingsScreen;
|
||||
private Button yesButton;
|
||||
private Button noButton;
|
||||
|
||||
public ResetConfirmDialog(GameActivity gameActivity, SettingsScreen settingsScreen) {
|
||||
super(gameActivity);
|
||||
this.gameActivity = gameActivity;
|
||||
this.settingsScreen = settingsScreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.exit_confirm_dialog);
|
||||
TextView textView = (TextView) findViewById(R.id.exit_confirm_dialog_textview);
|
||||
textView.setTypeface(gameActivity.getTypeface());
|
||||
textView.setText(R.string.reset_dialog_question);
|
||||
noButton = (Button) findViewById(R.id.exit_confirm_dialog_no_button);
|
||||
noButton.setTypeface(gameActivity.getTypeface());
|
||||
noButton.setOnClickListener(this);
|
||||
yesButton = (Button) findViewById(R.id.exit_confirm_dialog_yes_button);
|
||||
yesButton.setTypeface(gameActivity.getTypeface());
|
||||
yesButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
if (v.equals(yesButton)) {
|
||||
gameActivity.resetData();
|
||||
settingsScreen.prepareToBeShown();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@
|
||||
android:background="@drawable/xml_background_exit_confirm_dialog">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/exit_confirm_dialog_textview"
|
||||
android:id="@+id/confirm_dialog_textview"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/exit_confirm_dialog_question"
|
||||
android:text="@string/confirm_dialog_placeholder"
|
||||
android:textSize="20sp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
@ -20,22 +20,22 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/exit_confirm_dialog_yes_button"
|
||||
android:id="@+id/confirm_dialog_yes_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginRight="1dp"
|
||||
style="@style/DialogButton"
|
||||
android:text="@string/exit_confirm_dialog_yes"/>
|
||||
android:text="@string/confirm_dialog_button_yes"/>
|
||||
<Button
|
||||
android:id="@+id/exit_confirm_dialog_no_button"
|
||||
android:id="@+id/confirm_dialog_no_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAlignment="center"
|
||||
style="@style/DialogButton"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/exit_confirm_dialog_no"/>
|
||||
android:text="@string/confirm_dialog_button_no"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -95,10 +95,12 @@
|
||||
<string name="tool_upgrade_force">Force</string>
|
||||
<string name="tool_upgrade_value_max">Max.</string>
|
||||
|
||||
<string name="exit_confirm_dialog_yes">Yes</string>
|
||||
<string name="exit_confirm_dialog_no">No</string>
|
||||
<string name="exit_confirm_dialog_question">Do you really want to exit the game?</string>
|
||||
<string name="reset_dialog_question">Do you really want to reset ALL your progress?</string>
|
||||
<string name="confirm_dialog_button_yes">Yes</string>
|
||||
<string name="confirm_dialog_button_no">No</string>
|
||||
<string name="confirm_dialog_placeholder">This is a beautiful ConfirmDialog placeholder!</string>
|
||||
<string name="confirm_dialog_exit">Do you really want to exit the game?</string>
|
||||
<string name="confirm_dialog_reset">Do you really want to reset ALL your progress?</string>
|
||||
<string name="confirm_dialog_finish_world_1">Do you really want to finish the first world?\nYour old progress will be DELETED!</string>
|
||||
|
||||
<string name="tutorial_placeholder">This is a multiline placeholder\nfor all the tutorials I made!!!\nAwesome! - Isn\'t it?</string>
|
||||
<string name="tutorial_welcome">Welcome to Endless Roll!\nHave fun!</string>
|
||||
|
Reference in New Issue
Block a user