From: Oskar Wiksten Date: Sun, 21 Oct 2012 16:26:43 +0000 (+0200) Subject: Provide setting to disable confirmation dialog box when overwriting a savegame slot. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=32be42531b8041e2ec4181ffdabc2dbeb80de0c4;p=users%2Fmchehab%2Fandors-trail.git Provide setting to disable confirmation dialog box when overwriting a savegame slot. --- diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml index e03f53f..a826bf0 100644 --- a/AndorsTrail/res/values/strings.xml +++ b/AndorsTrail/res/values/strings.xml @@ -339,7 +339,7 @@ Virtual d-pad - Enables a virtual on-screen directional pad to guide movement + Enables a virtual on-screen directional pad to guide movement. Minimizable d-pad If the virtual d-pad is enabled, this setting allows the d-pad to be minimized by pressing its center. @@ -542,5 +542,18 @@ Lowers AP cost of equipping items in combat by %1$d AP Are you sure you want to overwrite this savegame? - + + Always show confirmation dialog box + Only show when overwriting a different playername + Never display confirmation dialog box + + + 0 + 1 + 2 + + Confirm overwriting savegames + Gives a question about whether you want to overwrite when saving to a savegame slot that already contains a savegame. + + diff --git a/AndorsTrail/res/xml/preferences.xml b/AndorsTrail/res/xml/preferences.xml index 656df7d..8605f26 100644 --- a/AndorsTrail/res/xml/preferences.xml +++ b/AndorsTrail/res/xml/preferences.xml @@ -39,6 +39,13 @@ android:defaultValue="0" android:entries="@array/preferences_display_loot" android:entryValues="@array/preferences_display_loot_values" /> + diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java index a593c79..e3dfdef 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailApplication.java @@ -16,7 +16,7 @@ public final class AndorsTrailApplication extends Application { public static final boolean DEVELOPMENT_DEBUGRESOURCES = false; public static final boolean DEVELOPMENT_FORCE_STARTNEWGAME = false; public static final boolean DEVELOPMENT_FORCE_CONTINUEGAME = false; - public static final boolean DEVELOPMENT_DEBUGBUTTONS = true; + public static final boolean DEVELOPMENT_DEBUGBUTTONS = false; public static final boolean DEVELOPMENT_VALIDATEDATA = false; public static final boolean DEVELOPMENT_DEBUGMESSAGES = false; public static final boolean DEVELOPMENT_INCOMPATIBLE_SAVEGAMES = DEVELOPMENT_DEBUGRESOURCES; diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailPreferences.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailPreferences.java index 3993bb7..1daefb2 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailPreferences.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/AndorsTrailPreferences.java @@ -22,6 +22,9 @@ public class AndorsTrailPreferences { public static final int DPAD_POSITION_UPPER_LEFT = 6; public static final int DPAD_POSITION_UPPER_RIGHT = 7; public static final int DPAD_POSITION_UPPER_CENTER = 8; + public static final int CONFIRM_OVERWRITE_SAVEGAME_ALWAYS = 0; + public static final int CONFIRM_OVERWRITE_SAVEGAME_WHEN_PLAYERNAME_DIFFERS = 1; + public static final int CONFIRM_OVERWRITE_SAVEGAME_NEVER = 2; public boolean confirmRest = true; public boolean confirmAttack = true; @@ -35,6 +38,7 @@ public class AndorsTrailPreferences { public boolean dpadMinimizeable = true; public boolean optimizedDrawing = false; public boolean enableUiAnimations = true; + public int displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS; public static void read(final Context androidContext, AndorsTrailPreferences dest) { try { @@ -50,6 +54,7 @@ public class AndorsTrailPreferences { dest.dpadMinimizeable = prefs.getBoolean("dpadMinimizeable", true); dest.optimizedDrawing = prefs.getBoolean("optimized_drawing", false); dest.enableUiAnimations = prefs.getBoolean("enableUiAnimations", true); + dest.displayOverwriteSavegame = Integer.parseInt(prefs.getString("display_overwrite_savegame", Integer.toString(CONFIRM_OVERWRITE_SAVEGAME_ALWAYS))); // This might be implemented as a skill in the future. //dest.movementAggressiveness = Integer.parseInt(prefs.getString("movementaggressiveness", Integer.toString(MOVEMENTAGGRESSIVENESS_NORMAL))); @@ -66,6 +71,7 @@ public class AndorsTrailPreferences { dest.dpadMinimizeable = true; dest.optimizedDrawing = false; dest.enableUiAnimations = true; + dest.displayOverwriteSavegame = CONFIRM_OVERWRITE_SAVEGAME_ALWAYS; } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java index 79c9365..ca1adb9 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/LoadSaveActivity.java @@ -16,6 +16,7 @@ import android.widget.Button; import android.widget.TextView; import com.gpl.rpg.AndorsTrail.AndorsTrailApplication; +import com.gpl.rpg.AndorsTrail.AndorsTrailPreferences; import com.gpl.rpg.AndorsTrail.R; import com.gpl.rpg.AndorsTrail.Savegames; import com.gpl.rpg.AndorsTrail.Savegames.FileHeader; @@ -26,7 +27,7 @@ public final class LoadSaveActivity extends Activity implements OnClickListener private static final int SLOT_NUMBER_CREATE_NEW_SLOT = -1; private static final int SLOT_NUMBER_FIRST_SLOT = 1; private ModelContainer model; - + private AndorsTrailPreferences preferences; @Override public void onCreate(Bundle savedInstanceState) { @@ -35,6 +36,7 @@ public final class LoadSaveActivity extends Activity implements OnClickListener final AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this); AndorsTrailApplication.setWindowParameters(this, app.preferences); this.model = app.world.model; + this.preferences = app.preferences; String loadsave = getIntent().getData().getLastPathSegment().toString(); isLoading = (loadsave.equalsIgnoreCase("load")); @@ -97,20 +99,36 @@ public final class LoadSaveActivity extends Activity implements OnClickListener LoadSaveActivity.this.finish(); } - private boolean requiresConfirmation(int slot) { - if (isLoading) return false; - if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) return false; // if we're creating a new slot - return true; + private String getConfirmOverwriteQuestion(int slot) { + if (isLoading) return null; + if (slot == SLOT_NUMBER_CREATE_NEW_SLOT) return null; // if we're creating a new slot + + if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_ALWAYS) { + return getString(R.string.loadsave_save_overwrite_confirmation_all); + } else if (preferences.displayOverwriteSavegame == AndorsTrailPreferences.CONFIRM_OVERWRITE_SAVEGAME_NEVER) { + return null; + } + + final String currentPlayerName = model.player.actorTraits.name; + final FileHeader header = Savegames.quickload(this, slot); + if (header == null) return null; + + final String savedPlayerName = header.playerName; + if (currentPlayerName.equals(savedPlayerName)) return null; // if the names match + + return getString(R.string.loadsave_save_overwrite_confirmation, savedPlayerName, currentPlayerName); } @Override public void onClick(View view) { final int slot = (Integer) view.getTag(); - if (requiresConfirmation(slot)) { + final String message = getConfirmOverwriteQuestion(slot); + + if (message != null) { new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.loadsave_save_overwrite_confirmation_title) - .setMessage(getString(R.string.loadsave_save_overwrite_confirmation_all)) + .setMessage(message) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {