From cf96bfc2be70c69b8196ab8c054441832e3b9315 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 29 Aug 2013 22:52:09 -0400 Subject: [PATCH] [Android] Add a button in the emulation view that allows a person to exit emulation and go back to the game list. However, this does not work correctly yet. It will stop correctly. But the SurfaceView will not render the next game selected. --- Source/Android/res/menu/emuwindow_overlay.xml | 6 +++ Source/Android/res/values-ja/strings.xml | 1 + Source/Android/res/values/strings.xml | 2 + .../dolphinemu/EmulationActivity.java | 39 +++++++++++++++++++ .../dolphinemu/gamelist/GameListFragment.java | 1 - 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Source/Android/res/menu/emuwindow_overlay.xml b/Source/Android/res/menu/emuwindow_overlay.xml index 04c7161699..4acfb5b087 100644 --- a/Source/Android/res/menu/emuwindow_overlay.xml +++ b/Source/Android/res/menu/emuwindow_overlay.xml @@ -42,4 +42,10 @@ android:title="@string/overlay_slot5"/> + + + diff --git a/Source/Android/res/values-ja/strings.xml b/Source/Android/res/values-ja/strings.xml index 71cdcd47b3..707f70e29c 100644 --- a/Source/Android/res/values-ja/strings.xml +++ b/Source/Android/res/values-ja/strings.xml @@ -33,6 +33,7 @@ ステートセーブ ステートロード + 終了 スロット 1 スロット 2 スロット 3 diff --git a/Source/Android/res/values/strings.xml b/Source/Android/res/values/strings.xml index 99522f5f00..f598d9d17f 100644 --- a/Source/Android/res/values/strings.xml +++ b/Source/Android/res/values/strings.xml @@ -33,6 +33,8 @@ Save State Load State + Exit + Are you sure you wish to exit this game? Slot 1 Slot 2 Slot 3 diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/EmulationActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/EmulationActivity.java index 7a81306468..aab01ad1ce 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/EmulationActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/EmulationActivity.java @@ -5,7 +5,10 @@ import java.util.List; import org.dolphinemu.dolphinemu.settings.InputConfigFragment; import android.app.Activity; +import android.app.AlertDialog; +import android.app.AlertDialog.Builder; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; @@ -77,6 +80,7 @@ public final class EmulationActivity extends Activity public void onStop() { super.onStop(); + if (Running) NativeLibrary.StopEmulation(); } @@ -85,6 +89,7 @@ public final class EmulationActivity extends Activity public void onPause() { super.onPause(); + if (Running) NativeLibrary.PauseEmulation(); } @@ -93,10 +98,23 @@ public final class EmulationActivity extends Activity public void onResume() { super.onResume(); + if (Running) NativeLibrary.UnPauseEmulation(); } + @Override + public void onDestroy() + { + super.onDestroy(); + + if (Running) + { + NativeLibrary.StopEmulation(); + Running = false; + } + } + @Override public boolean onTouchEvent(MotionEvent event) { @@ -185,6 +203,27 @@ public final class EmulationActivity extends Activity NativeLibrary.LoadState(4); return true; + case R.id.exitEmulation: + { + // Create a confirmation method for quitting the current emulation instance. + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(getString(R.string.overlay_exit_emulation)); + builder.setMessage(R.string.overlay_exit_emulation_confirm); + builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) + { + finish(); + } + }); + builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) + { + // Do nothing. Just makes the No button appear. + } + }); + builder.show(); + } + default: return super.onOptionsItemSelected( item ); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java index d5739d68ed..e0aefa153a 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java @@ -136,7 +136,6 @@ public final class GameListFragment extends Fragment Intent intent = new Intent(mMe, EmulationActivity.class); intent.putExtra("SelectedGame", o); mMe.startActivity(intent); - mMe.finish(); } @Override