Merge pull request #5104 from mahdihijazi/master

Fix saving/loading screenshots for Android
This commit is contained in:
Markus Wick 2017-03-19 01:29:29 +01:00 committed by GitHub
commit 553e8fae4c
6 changed files with 309 additions and 222 deletions

View file

@ -13,7 +13,9 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.IntDef;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.SparseIntArray;
import android.view.InputDevice; import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -44,8 +46,11 @@ import org.dolphinemu.dolphinemu.utils.Java_GCAdapter;
import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter; import org.dolphinemu.dolphinemu.utils.Java_WiimoteAdapter;
import org.dolphinemu.dolphinemu.utils.Log; import org.dolphinemu.dolphinemu.utils.Log;
import java.lang.annotation.Retention;
import java.util.List; import java.util.List;
import static java.lang.annotation.RetentionPolicy.SOURCE;
public final class EmulationActivity extends AppCompatActivity public final class EmulationActivity extends AppCompatActivity
{ {
private View mDecorView; private View mDecorView;
@ -84,6 +89,71 @@ public final class EmulationActivity extends AppCompatActivity
private FrameLayout mFrameContent; private FrameLayout mFrameContent;
private String mSelectedTitle; private String mSelectedTitle;
@Retention(SOURCE)
@IntDef({MENU_ACTION_EDIT_CONTROLS_PLACEMENT, MENU_ACTION_TOGGLE_CONTROLS, MENU_ACTION_ADJUST_SCALE,
MENU_ACTION_CHOOSE_CONTROLLER, MENU_ACTION_REFRESH_WIIMOTES, MENU_ACTION_TAKE_SCREENSHOT,
MENU_ACTION_QUICK_SAVE, MENU_ACTION_QUICK_LOAD, MENU_ACTION_SAVE_ROOT,
MENU_ACTION_LOAD_ROOT, MENU_ACTION_SAVE_SLOT1, MENU_ACTION_SAVE_SLOT2,
MENU_ACTION_SAVE_SLOT3, MENU_ACTION_SAVE_SLOT4, MENU_ACTION_SAVE_SLOT5,
MENU_ACTION_SAVE_SLOT6, MENU_ACTION_LOAD_SLOT1, MENU_ACTION_LOAD_SLOT2,
MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5,
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT})
public @interface MenuAction {
}
public static final int MENU_ACTION_EDIT_CONTROLS_PLACEMENT = 0;
public static final int MENU_ACTION_TOGGLE_CONTROLS = 1;
public static final int MENU_ACTION_ADJUST_SCALE = 2;
public static final int MENU_ACTION_CHOOSE_CONTROLLER = 3;
public static final int MENU_ACTION_REFRESH_WIIMOTES = 4;
public static final int MENU_ACTION_TAKE_SCREENSHOT = 5;
public static final int MENU_ACTION_QUICK_SAVE = 6;
public static final int MENU_ACTION_QUICK_LOAD = 7;
public static final int MENU_ACTION_SAVE_ROOT = 8;
public static final int MENU_ACTION_LOAD_ROOT = 9;
public static final int MENU_ACTION_SAVE_SLOT1 = 10;
public static final int MENU_ACTION_SAVE_SLOT2 = 11;
public static final int MENU_ACTION_SAVE_SLOT3 = 12;
public static final int MENU_ACTION_SAVE_SLOT4 = 13;
public static final int MENU_ACTION_SAVE_SLOT5 = 14;
public static final int MENU_ACTION_SAVE_SLOT6 = 15;
public static final int MENU_ACTION_LOAD_SLOT1 = 16;
public static final int MENU_ACTION_LOAD_SLOT2 = 17;
public static final int MENU_ACTION_LOAD_SLOT3 = 18;
public static final int MENU_ACTION_LOAD_SLOT4 = 19;
public static final int MENU_ACTION_LOAD_SLOT5 = 20;
public static final int MENU_ACTION_LOAD_SLOT6 = 21;
public static final int MENU_ACTION_EXIT = 22;
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_emulation_edit_layout, EmulationActivity.MENU_ACTION_EDIT_CONTROLS_PLACEMENT);
buttonsActionsMap.append(R.id.menu_emulation_toggle_controls, EmulationActivity.MENU_ACTION_TOGGLE_CONTROLS);
buttonsActionsMap.append(R.id.menu_emulation_adjust_scale, EmulationActivity.MENU_ACTION_ADJUST_SCALE);
buttonsActionsMap.append(R.id.menu_emulation_choose_controller, EmulationActivity.MENU_ACTION_CHOOSE_CONTROLLER);
buttonsActionsMap.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES);
buttonsActionsMap.append(R.id.menu_emulation_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT);
buttonsActionsMap.append(R.id.menu_quicksave, EmulationActivity.MENU_ACTION_QUICK_SAVE);
buttonsActionsMap.append(R.id.menu_quickload, EmulationActivity.MENU_ACTION_QUICK_LOAD);
buttonsActionsMap.append(R.id.menu_emulation_save_root, EmulationActivity.MENU_ACTION_SAVE_ROOT);
buttonsActionsMap.append(R.id.menu_emulation_load_root, EmulationActivity.MENU_ACTION_LOAD_ROOT);
buttonsActionsMap.append(R.id.menu_emulation_save_1, EmulationActivity.MENU_ACTION_SAVE_SLOT1);
buttonsActionsMap.append(R.id.menu_emulation_save_2, EmulationActivity.MENU_ACTION_SAVE_SLOT2);
buttonsActionsMap.append(R.id.menu_emulation_save_3, EmulationActivity.MENU_ACTION_SAVE_SLOT3);
buttonsActionsMap.append(R.id.menu_emulation_save_4, EmulationActivity.MENU_ACTION_SAVE_SLOT4);
buttonsActionsMap.append(R.id.menu_emulation_save_5, EmulationActivity.MENU_ACTION_SAVE_SLOT5);
buttonsActionsMap.append(R.id.menu_emulation_load_1, EmulationActivity.MENU_ACTION_LOAD_SLOT1);
buttonsActionsMap.append(R.id.menu_emulation_load_2, EmulationActivity.MENU_ACTION_LOAD_SLOT2);
buttonsActionsMap.append(R.id.menu_emulation_load_3, EmulationActivity.MENU_ACTION_LOAD_SLOT3);
buttonsActionsMap.append(R.id.menu_emulation_load_4, EmulationActivity.MENU_ACTION_LOAD_SLOT4);
buttonsActionsMap.append(R.id.menu_emulation_load_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
{ {
@ -394,249 +464,65 @@ public final class EmulationActivity extends AppCompatActivity
return true; return true;
} }
@SuppressWarnings("WrongConstant")
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) public boolean onOptionsItemSelected(MenuItem item)
{ {
onMenuItemClicked(item.getItemId()); handleMenuAction(buttonsActionsMap.get(item.getItemId()));
return true; return true;
} }
public void onMenuItemClicked(int id) public void handleMenuAction(@MenuAction int menuAction)
{ {
switch (id) switch (menuAction)
{ {
// Edit the placement of the controls // Edit the placement of the controls
case R.id.menu_emulation_edit_layout: case MENU_ACTION_EDIT_CONTROLS_PLACEMENT:
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager() editControlsPlacement();
.findFragmentById(R.id.frame_emulation_fragment);
if (emulationFragment.isConfiguringControls())
{
emulationFragment.stopConfiguringControls();
}
else
{
emulationFragment.startConfiguringControls();
}
break; break;
// Enable/Disable specific buttons or the entire input overlay. // Enable/Disable specific buttons or the entire input overlay.
case R.id.menu_emulation_toggle_controls: case MENU_ACTION_TOGGLE_CONTROLS:
{ toggleControls();
final SharedPreferences.Editor editor = mPreferences.edit();
boolean[] enabledButtons = new boolean[14];
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_toggle_controls);
if (mIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0)
{
for (int i = 0; i < enabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
}
builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener()
{
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked)
{
editor.putBoolean("buttonToggleGc" + indexSelected, isChecked);
}
});
}
else if (mPreferences.getInt("wiiController", 3) == 4)
{
for (int i = 0; i < enabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleClassic" + i, true);
}
builder.setMultiChoiceItems(R.array.classicButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener()
{
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked)
{
editor.putBoolean("buttonToggleClassic" + indexSelected, isChecked);
}
});
}
else
{
for (int i = 0; i < enabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true);
}
if (mPreferences.getInt("wiiController", 3) == 3)
{
builder.setMultiChoiceItems(R.array.nunchukButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener()
{
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked)
{
editor.putBoolean("buttonToggleWii" + indexSelected, isChecked);
}
});
}
else
{
builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener()
{
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked)
{
editor.putBoolean("buttonToggleWii" + indexSelected, isChecked);
}
});
}
}
builder.setNeutralButton(getString(R.string.emulation_toggle_all), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.toggleInputOverlayVisibility();
}
});
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
editor.apply();
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.refreshInputOverlay();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
return; return;
}
// Adjust the scale of the overlay controls. // Adjust the scale of the overlay controls.
case R.id.menu_emulation_adjust_scale: case MENU_ACTION_ADJUST_SCALE:
{ adjustScale();
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_seekbar, null);
final SeekBar seekbar = (SeekBar) view.findViewById(R.id.seekbar);
final TextView value = (TextView) view.findViewById(R.id.text_value);
final TextView units = (TextView) view.findViewById(R.id.text_units);
seekbar.setMax(150);
seekbar.setProgress(mPreferences.getInt("controlScale", 50));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
public void onStartTrackingTouch(SeekBar seekBar)
{
// Do nothing
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
value.setText(String.valueOf(progress + 50));
}
public void onStopTrackingTouch(SeekBar seekBar)
{
// Do nothing
}
});
value.setText(String.valueOf(seekbar.getProgress() + 50));
units.setText("%");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_control_scale);
builder.setView(view);
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt("controlScale", seekbar.getProgress());
editor.apply();
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.refreshInputOverlay();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
return; return;
}
// (Wii games only) Change the controller for the input overlay. // (Wii games only) Change the controller for the input overlay.
case R.id.menu_emulation_choose_controller: case MENU_ACTION_CHOOSE_CONTROLLER:
final SharedPreferences.Editor editor = mPreferences.edit(); chooseController();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_choose_controller);
builder.setSingleChoiceItems(R.array.controllersEntries, mPreferences.getInt("wiiController", 3),
new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int indexSelected)
{
editor.putInt("wiiController", indexSelected);
NativeLibrary.SetConfig("WiimoteNew.ini", "Wiimote1", "Extension",
getResources().getStringArray(R.array.controllersValues)[indexSelected]);
}
});
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
editor.apply();
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.refreshInputOverlay();
Toast.makeText(getApplication(), R.string.emulation_controller_changed, Toast.LENGTH_SHORT).show();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
return; return;
case R.id.menu_refresh_wiimotes: case MENU_ACTION_REFRESH_WIIMOTES:
NativeLibrary.RefreshWiimotes(); NativeLibrary.RefreshWiimotes();
return; return;
// Screenshot capturing // Screenshot capturing
case R.id.menu_emulation_screenshot: case MENU_ACTION_TAKE_SCREENSHOT:
NativeLibrary.SaveScreenShot(); NativeLibrary.SaveScreenShot();
return; return;
// Quick save / load // Quick save / load
case R.id.menu_quicksave: case MENU_ACTION_QUICK_SAVE:
NativeLibrary.SaveState(9); NativeLibrary.SaveState(9);
return; return;
case R.id.menu_quickload: case MENU_ACTION_QUICK_LOAD:
NativeLibrary.LoadState(9); NativeLibrary.LoadState(9);
return; return;
// TV Menu only // TV Menu only
case R.id.menu_emulation_save_root: case MENU_ACTION_SAVE_ROOT:
if (!mDeviceHasTouchScreen) if (!mDeviceHasTouchScreen)
{ {
showMenu(SaveStateFragment.FRAGMENT_ID); showMenu(SaveStateFragment.FRAGMENT_ID);
} }
return; return;
case R.id.menu_emulation_load_root: case MENU_ACTION_LOAD_ROOT:
if (!mDeviceHasTouchScreen) if (!mDeviceHasTouchScreen)
{ {
showMenu(LoadStateFragment.FRAGMENT_ID); showMenu(LoadStateFragment.FRAGMENT_ID);
@ -644,54 +530,73 @@ public final class EmulationActivity extends AppCompatActivity
return; return;
// Save state slots // Save state slots
case R.id.menu_emulation_save_1: case MENU_ACTION_SAVE_SLOT1:
NativeLibrary.SaveState(0); NativeLibrary.SaveState(0);
return; return;
case R.id.menu_emulation_save_2: case MENU_ACTION_SAVE_SLOT2:
NativeLibrary.SaveState(1); NativeLibrary.SaveState(1);
return; return;
case R.id.menu_emulation_save_3: case MENU_ACTION_SAVE_SLOT3:
NativeLibrary.SaveState(2); NativeLibrary.SaveState(2);
return; return;
case R.id.menu_emulation_save_4: case MENU_ACTION_SAVE_SLOT4:
NativeLibrary.SaveState(3); NativeLibrary.SaveState(3);
return; return;
case R.id.menu_emulation_save_5: case MENU_ACTION_SAVE_SLOT5:
NativeLibrary.SaveState(4); NativeLibrary.SaveState(4);
return; return;
case MENU_ACTION_SAVE_SLOT6:
NativeLibrary.SaveState(5);
return;
// Load state slots // Load state slots
case R.id.menu_emulation_load_1: case MENU_ACTION_LOAD_SLOT1:
NativeLibrary.LoadState(0); NativeLibrary.LoadState(0);
return; return;
case R.id.menu_emulation_load_2: case MENU_ACTION_LOAD_SLOT2:
NativeLibrary.LoadState(1); NativeLibrary.LoadState(1);
return; return;
case R.id.menu_emulation_load_3: case MENU_ACTION_LOAD_SLOT3:
NativeLibrary.LoadState(2); NativeLibrary.LoadState(2);
return; return;
case R.id.menu_emulation_load_4: case MENU_ACTION_LOAD_SLOT4:
NativeLibrary.LoadState(3); NativeLibrary.LoadState(3);
return; return;
case R.id.menu_emulation_load_5: case MENU_ACTION_LOAD_SLOT5:
NativeLibrary.LoadState(4); NativeLibrary.LoadState(4);
return; return;
case R.id.menu_exit: case MENU_ACTION_LOAD_SLOT6:
NativeLibrary.LoadState(5);
return;
case MENU_ACTION_EXIT:
toggleMenu(); toggleMenu();
stopEmulation(); stopEmulation();
return; return;
} }
} }
private void editControlsPlacement() {
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentById(R.id.frame_emulation_fragment);
if (emulationFragment.isConfiguringControls()) {
emulationFragment.stopConfiguringControls();
} else {
emulationFragment.startConfiguringControls();
}
}
// Gets button presses // Gets button presses
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) public boolean dispatchKeyEvent(KeyEvent event)
@ -726,6 +631,157 @@ public final class EmulationActivity extends AppCompatActivity
return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action); return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action);
} }
private void toggleControls() {
final SharedPreferences.Editor editor = mPreferences.edit();
boolean[] enabledButtons = new boolean[14];
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_toggle_controls);
if (mIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0) {
for (int i = 0; i < enabledButtons.length; i++) {
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
}
builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
editor.putBoolean("buttonToggleGc" + indexSelected, isChecked);
}
});
} else if (mPreferences.getInt("wiiController", 3) == 4) {
for (int i = 0; i < enabledButtons.length; i++) {
enabledButtons[i] = mPreferences.getBoolean("buttonToggleClassic" + i, true);
}
builder.setMultiChoiceItems(R.array.classicButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
editor.putBoolean("buttonToggleClassic" + indexSelected, isChecked);
}
});
} else {
for (int i = 0; i < enabledButtons.length; i++) {
enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true);
}
if (mPreferences.getInt("wiiController", 3) == 3) {
builder.setMultiChoiceItems(R.array.nunchukButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
editor.putBoolean("buttonToggleWii" + indexSelected, isChecked);
}
});
} else {
builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
editor.putBoolean("buttonToggleWii" + indexSelected, isChecked);
}
});
}
}
builder.setNeutralButton(getString(R.string.emulation_toggle_all), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.toggleInputOverlayVisibility();
}
});
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
editor.apply();
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.refreshInputOverlay();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
private void adjustScale() {
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_seekbar, null);
final SeekBar seekbar = (SeekBar) view.findViewById(R.id.seekbar);
final TextView value = (TextView) view.findViewById(R.id.text_value);
final TextView units = (TextView) view.findViewById(R.id.text_units);
seekbar.setMax(150);
seekbar.setProgress(mPreferences.getInt("controlScale", 50));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
value.setText(String.valueOf(progress + 50));
}
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
value.setText(String.valueOf(seekbar.getProgress() + 50));
units.setText("%");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_control_scale);
builder.setView(view);
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt("controlScale", seekbar.getProgress());
editor.apply();
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.refreshInputOverlay();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
private void chooseController() {
final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.emulation_choose_controller);
builder.setSingleChoiceItems(R.array.controllersEntries, mPreferences.getInt("wiiController", 3),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected) {
editor.putInt("wiiController", indexSelected);
NativeLibrary.SetConfig("WiimoteNew.ini", "Wiimote1", "Extension",
getResources().getStringArray(R.array.controllersValues)[indexSelected]);
}
});
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
editor.apply();
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
.findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
emulationFragment.refreshInputOverlay();
Toast.makeText(getApplication(), R.string.emulation_controller_changed, Toast.LENGTH_SHORT).show();
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
@Override @Override
public boolean dispatchGenericMotionEvent(MotionEvent event) public boolean dispatchGenericMotionEvent(MotionEvent event)
{ {

View file

@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.fragments;
import android.app.Fragment; import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.SparseIntArray;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -18,6 +19,16 @@ public final class LoadStateFragment extends Fragment implements View.OnClickLis
public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".load_state"; public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".load_state";
public static final int FRAGMENT_ID = R.layout.fragment_state_load; public static final int FRAGMENT_ID = R.layout.fragment_state_load;
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_emulation_load_1, EmulationActivity.MENU_ACTION_LOAD_SLOT1);
buttonsActionsMap.append(R.id.menu_emulation_load_2, EmulationActivity.MENU_ACTION_LOAD_SLOT2);
buttonsActionsMap.append(R.id.menu_emulation_load_3, EmulationActivity.MENU_ACTION_LOAD_SLOT3);
buttonsActionsMap.append(R.id.menu_emulation_load_4, EmulationActivity.MENU_ACTION_LOAD_SLOT4);
buttonsActionsMap.append(R.id.menu_emulation_load_5, EmulationActivity.MENU_ACTION_LOAD_SLOT5);
buttonsActionsMap.append(R.id.menu_emulation_load_6, EmulationActivity.MENU_ACTION_LOAD_SLOT6);
}
public static LoadStateFragment newInstance() public static LoadStateFragment newInstance()
{ {
LoadStateFragment fragment = new LoadStateFragment(); LoadStateFragment fragment = new LoadStateFragment();
@ -47,9 +58,10 @@ public final class LoadStateFragment extends Fragment implements View.OnClickLis
return rootView; return rootView;
} }
@SuppressWarnings("WrongConstant")
@Override @Override
public void onClick(View button) public void onClick(View button)
{ {
((EmulationActivity) getActivity()).onMenuItemClicked(button.getId()); ((EmulationActivity) getActivity()).handleMenuAction(buttonsActionsMap.get(button.getId()));
} }
} }

View file

@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.fragments;
import android.app.Fragment; import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.SparseIntArray;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -19,6 +20,16 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".ingame_menu"; public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".ingame_menu";
public static final int FRAGMENT_ID = R.layout.fragment_ingame_menu; public static final int FRAGMENT_ID = R.layout.fragment_ingame_menu;
private TextView mTitleText; private TextView mTitleText;
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_take_screenshot, EmulationActivity.MENU_ACTION_TAKE_SCREENSHOT);
buttonsActionsMap.append(R.id.menu_quicksave, EmulationActivity.MENU_ACTION_QUICK_SAVE);
buttonsActionsMap.append(R.id.menu_quickload, EmulationActivity.MENU_ACTION_QUICK_LOAD);
buttonsActionsMap.append(R.id.menu_emulation_save_root, EmulationActivity.MENU_ACTION_SAVE_ROOT);
buttonsActionsMap.append(R.id.menu_emulation_load_root, EmulationActivity.MENU_ACTION_LOAD_ROOT);
buttonsActionsMap.append(R.id.menu_refresh_wiimotes, EmulationActivity.MENU_ACTION_REFRESH_WIIMOTES);
buttonsActionsMap.append(R.id.menu_exit, EmulationActivity.MENU_ACTION_EXIT);
}
@Nullable @Nullable
@Override @Override
@ -39,10 +50,11 @@ public final class MenuFragment extends Fragment implements View.OnClickListener
return rootView; return rootView;
} }
@SuppressWarnings("WrongConstant")
@Override @Override
public void onClick(View button) public void onClick(View button)
{ {
((EmulationActivity) getActivity()).onMenuItemClicked(button.getId()); ((EmulationActivity) getActivity()).handleMenuAction(buttonsActionsMap.get(button.getId()));
} }
public void setTitleText(String title) public void setTitleText(String title)

View file

@ -3,6 +3,7 @@ package org.dolphinemu.dolphinemu.fragments;
import android.app.Fragment; import android.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.SparseIntArray;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -18,6 +19,16 @@ public final class SaveStateFragment extends Fragment implements View.OnClickLis
public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".save_state"; public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".save_state";
public static final int FRAGMENT_ID = R.layout.fragment_state_save; public static final int FRAGMENT_ID = R.layout.fragment_state_save;
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
static {
buttonsActionsMap.append(R.id.menu_emulation_save_1, EmulationActivity.MENU_ACTION_SAVE_SLOT1);
buttonsActionsMap.append(R.id.menu_emulation_save_2, EmulationActivity.MENU_ACTION_SAVE_SLOT2);
buttonsActionsMap.append(R.id.menu_emulation_save_3, EmulationActivity.MENU_ACTION_SAVE_SLOT3);
buttonsActionsMap.append(R.id.menu_emulation_save_4, EmulationActivity.MENU_ACTION_SAVE_SLOT4);
buttonsActionsMap.append(R.id.menu_emulation_save_5, EmulationActivity.MENU_ACTION_SAVE_SLOT5);
buttonsActionsMap.append(R.id.menu_emulation_save_6, EmulationActivity.MENU_ACTION_SAVE_SLOT6);
}
public static SaveStateFragment newInstance() public static SaveStateFragment newInstance()
{ {
SaveStateFragment fragment = new SaveStateFragment(); SaveStateFragment fragment = new SaveStateFragment();
@ -47,9 +58,10 @@ public final class SaveStateFragment extends Fragment implements View.OnClickLis
return rootView; return rootView;
} }
@SuppressWarnings("WrongConstant")
@Override @Override
public void onClick(View button) public void onClick(View button)
{ {
((EmulationActivity) getActivity()).onMenuItemClicked(button.getId()); ((EmulationActivity) getActivity()).handleMenuAction(buttonsActionsMap.get(button.getId()));
} }
} }

View file

@ -95,7 +95,7 @@ public final class Game
{ {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
String screenPath = PATH_SCREENSHOT_FOLDER + gameId + "/thumb.png"; String screenPath = PATH_SCREENSHOT_FOLDER + gameId + "/" + gameId + "-1.png";
values.put(GameDatabase.KEY_GAME_PLATFORM, platform); values.put(GameDatabase.KEY_GAME_PLATFORM, platform);
values.put(GameDatabase.KEY_GAME_TITLE, title); values.put(GameDatabase.KEY_GAME_TITLE, title);

View file

@ -52,11 +52,6 @@
android:text="@string/emulation_loadstate" android:text="@string/emulation_loadstate"
style="@style/InGameMenuOption"/> style="@style/InGameMenuOption"/>
<Button
android:id="@+id/menu_ingame_settings"
android:text="@string/preferences_settings"
style="@style/InGameMenuOption"/>
<Button <Button
android:id="@+id/menu_refresh_wiimotes" android:id="@+id/menu_refresh_wiimotes"
android:text="@string/emulation_refresh_wiimotes" android:text="@string/emulation_refresh_wiimotes"