Android: Add option to pause when menu is open
This commit is contained in:
parent
0c9c66bf81
commit
f88fca8817
|
@ -156,6 +156,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
mApplySettingsOnSurfaceRestored = false;
|
mApplySettingsOnSurfaceRestored = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AndroidHostInterface.getInstance().isEmulationThreadPaused())
|
||||||
|
AndroidHostInterface.getInstance().pauseEmulationThread(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,19 +295,34 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
private static final int REQUEST_CODE_SETTINGS = 0;
|
private static final int REQUEST_CODE_SETTINGS = 0;
|
||||||
private static final int REQUEST_IMPORT_PATCH_CODES = 1;
|
private static final int REQUEST_IMPORT_PATCH_CODES = 1;
|
||||||
|
|
||||||
|
private void onMenuClosed() {
|
||||||
|
enableFullscreenImmersive();
|
||||||
|
|
||||||
|
if (AndroidHostInterface.getInstance().isEmulationThreadPaused())
|
||||||
|
AndroidHostInterface.getInstance().pauseEmulationThread(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void showMenu() {
|
private void showMenu() {
|
||||||
|
if (getBooleanSetting("Main/PauseOnMenu", false) &&
|
||||||
|
!AndroidHostInterface.getInstance().isEmulationThreadPaused())
|
||||||
|
{
|
||||||
|
AndroidHostInterface.getInstance().pauseEmulationThread(true);
|
||||||
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setItems(R.array.emulation_menu, (dialogInterface, i) -> {
|
builder.setItems(R.array.emulation_menu, (dialogInterface, i) -> {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: // Quick Load
|
case 0: // Quick Load
|
||||||
{
|
{
|
||||||
AndroidHostInterface.getInstance().loadState(false, mSaveStateSlot);
|
AndroidHostInterface.getInstance().loadState(false, mSaveStateSlot);
|
||||||
|
onMenuClosed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1: // Quick Save
|
case 1: // Quick Save
|
||||||
{
|
{
|
||||||
AndroidHostInterface.getInstance().saveState(false, mSaveStateSlot);
|
AndroidHostInterface.getInstance().saveState(false, mSaveStateSlot);
|
||||||
|
onMenuClosed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +335,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
case 3: // Toggle Fast Forward
|
case 3: // Toggle Fast Forward
|
||||||
{
|
{
|
||||||
AndroidHostInterface.getInstance().setFastForwardEnabled(!AndroidHostInterface.getInstance().isFastForwardEnabled());
|
AndroidHostInterface.getInstance().setFastForwardEnabled(!AndroidHostInterface.getInstance().isFastForwardEnabled());
|
||||||
|
onMenuClosed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +353,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnDismissListener(dialogInterface -> enableFullscreenImmersive());
|
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +362,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
builder.setSingleChoiceItems(R.array.emulation_save_state_slot_menu, mSaveStateSlot, (dialogInterface, i) -> {
|
builder.setSingleChoiceItems(R.array.emulation_save_state_slot_menu, mSaveStateSlot, (dialogInterface, i) -> {
|
||||||
mSaveStateSlot = i;
|
mSaveStateSlot = i;
|
||||||
dialogInterface.dismiss();
|
dialogInterface.dismiss();
|
||||||
|
onMenuClosed();
|
||||||
});
|
});
|
||||||
builder.setOnDismissListener(dialogInterface -> enableFullscreenImmersive());
|
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +378,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
case 0: // Reset
|
case 0: // Reset
|
||||||
{
|
{
|
||||||
AndroidHostInterface.getInstance().resetSystem();
|
AndroidHostInterface.getInstance().resetSystem();
|
||||||
|
onMenuClosed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,12 +390,14 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
|
|
||||||
case 2: // Change Disc
|
case 2: // Change Disc
|
||||||
{
|
{
|
||||||
|
onMenuClosed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3: // Change Touchscreen Controller
|
case 3: // Change Touchscreen Controller
|
||||||
{
|
{
|
||||||
showTouchscreenControllerMenu();
|
showTouchscreenControllerMenu();
|
||||||
|
onMenuClosed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +410,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnDismissListener(dialogInterface -> enableFullscreenImmersive());
|
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,8 +420,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
String[] values = getResources().getStringArray(R.array.settings_touchscreen_controller_view_values);
|
String[] values = getResources().getStringArray(R.array.settings_touchscreen_controller_view_values);
|
||||||
setStringSetting("Controller1/TouchscreenControllerView", values[i]);
|
setStringSetting("Controller1/TouchscreenControllerView", values[i]);
|
||||||
updateControllers();
|
updateControllers();
|
||||||
|
onMenuClosed();
|
||||||
});
|
});
|
||||||
builder.setOnDismissListener(dialogInterface -> enableFullscreenImmersive());
|
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +443,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
builder.setItems(items, (dialogInterface, i) -> {
|
builder.setItems(items, (dialogInterface, i) -> {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
AndroidHostInterface.getInstance().setPatchCodeEnabled(i - 1, !codes[i - 1].isEnabled());
|
AndroidHostInterface.getInstance().setPatchCodeEnabled(i - 1, !codes[i - 1].isEnabled());
|
||||||
enableFullscreenImmersive();
|
onMenuClosed();
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
@ -428,7 +452,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||||
startActivityForResult(Intent.createChooser(intent, "Choose Patch Code File"), REQUEST_IMPORT_PATCH_CODES);
|
startActivityForResult(Intent.createChooser(intent, "Choose Patch Code File"), REQUEST_IMPORT_PATCH_CODES);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setOnCancelListener(dialogInterface -> enableFullscreenImmersive());
|
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,12 @@
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:summary="Automatically saves the emulator state when powering down or exiting. You can then resume directly from where you left off next time."
|
app:summary="Automatically saves the emulator state when powering down or exiting. You can then resume directly from where you left off next time."
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:key="Main/PauseOnMenu"
|
||||||
|
app:title="Pause When Menu Opened"
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:summary="Pauses emulation when ingame and the menu is opened."
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:key="Main/AutoLoadCheats"
|
app:key="Main/AutoLoadCheats"
|
||||||
app:title="Load Patch Codes"
|
app:title="Load Patch Codes"
|
||||||
|
|
Loading…
Reference in New Issue