mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #8748 from Ebola16/WAD
Android: Add Install WAD to menu_game_grid
This commit is contained in:
commit
b175e9e6ac
@ -447,6 +447,8 @@ public final class NativeLibrary
|
||||
|
||||
public static native void ReloadWiimoteConfig();
|
||||
|
||||
public static native boolean InstallWAD(String file);
|
||||
|
||||
private static boolean alertResult = false;
|
||||
|
||||
public static boolean displayAlertMsg(final String caption, final String text,
|
||||
@ -509,7 +511,7 @@ public final class NativeLibrary
|
||||
}
|
||||
|
||||
// Show the AlertDialog on the main thread.
|
||||
emulationActivity.runOnUiThread(() -> builder.show());
|
||||
emulationActivity.runOnUiThread(builder::show);
|
||||
|
||||
// Wait for the lock to notify that it is complete.
|
||||
synchronized (lock)
|
||||
|
@ -322,6 +322,9 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
||||
case MainPresenter.REQUEST_GAME_FILE:
|
||||
extensions = FileBrowserHelper.GAME_EXTENSIONS;
|
||||
break;
|
||||
case MainPresenter.REQUEST_WAD_FILE:
|
||||
extensions = FileBrowserHelper.WAD_EXTENSION;
|
||||
break;
|
||||
default:
|
||||
throw new InvalidParameterException("Unhandled request code");
|
||||
}
|
||||
|
@ -262,7 +262,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
}
|
||||
|
||||
private final String[] mGamePaths;
|
||||
private Thread mEmulationThread;
|
||||
private State state;
|
||||
private Surface mSurface;
|
||||
private boolean mRunWhenSurfaceIsValid;
|
||||
@ -399,7 +398,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
mRunWhenSurfaceIsValid = false;
|
||||
if (state == State.STOPPED)
|
||||
{
|
||||
mEmulationThread = new Thread(() ->
|
||||
Thread emulationThread = new Thread(() ->
|
||||
{
|
||||
NativeLibrary.SurfaceChanged(mSurface);
|
||||
if (loadPreviousTemporaryState)
|
||||
@ -413,8 +412,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
NativeLibrary.Run(mGamePaths);
|
||||
}
|
||||
}, "NativeEmulation");
|
||||
mEmulationThread.start();
|
||||
|
||||
emulationThread.start();
|
||||
}
|
||||
else if (state == State.PAUSED)
|
||||
{
|
||||
|
@ -155,6 +155,13 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||
FileBrowserHelper.GAME_EXTENSIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchInstallWAD()
|
||||
{
|
||||
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_WAD_FILE, false,
|
||||
FileBrowserHelper.WAD_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requestCode An int describing whether the Activity that is returning did so successfully.
|
||||
* @param resultCode An int describing what Activity is giving us this callback.
|
||||
@ -181,6 +188,14 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
||||
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
||||
}
|
||||
break;
|
||||
|
||||
case MainPresenter.REQUEST_WAD_FILE:
|
||||
// If the user picked a file, as opposed to just backing out.
|
||||
if (resultCode == MainActivity.RESULT_OK)
|
||||
{
|
||||
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,17 @@
|
||||
package org.dolphinemu.dolphinemu.ui.main;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import org.dolphinemu.dolphinemu.BuildConfig;
|
||||
import org.dolphinemu.dolphinemu.NativeLibrary;
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
||||
@ -18,6 +22,7 @@ public final class MainPresenter
|
||||
public static final int REQUEST_DIRECTORY = 1;
|
||||
public static final int REQUEST_GAME_FILE = 2;
|
||||
public static final int REQUEST_SD_FILE = 3;
|
||||
public static final int REQUEST_WAD_FILE = 4;
|
||||
|
||||
private final MainView mView;
|
||||
private final Context mContext;
|
||||
@ -92,6 +97,10 @@ public final class MainPresenter
|
||||
case R.id.menu_open_file:
|
||||
mView.launchOpenFileActivity();
|
||||
return true;
|
||||
|
||||
case R.id.menu_install_wad:
|
||||
mView.launchInstallWAD();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -111,4 +120,33 @@ public final class MainPresenter
|
||||
{
|
||||
mDirToAdd = dir;
|
||||
}
|
||||
|
||||
public void installWAD(String file)
|
||||
{
|
||||
final Activity mainPresenterActivity = (Activity) mContext;
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase).create();
|
||||
dialog.setTitle("Installing WAD");
|
||||
dialog.setMessage("Installing...");
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
|
||||
Thread installWADThread = new Thread(() ->
|
||||
{
|
||||
if (NativeLibrary.InstallWAD(file))
|
||||
{
|
||||
mainPresenterActivity.runOnUiThread(
|
||||
() -> Toast.makeText(mContext, R.string.wad_install_success, Toast.LENGTH_SHORT)
|
||||
.show());
|
||||
}
|
||||
else
|
||||
{
|
||||
mainPresenterActivity.runOnUiThread(
|
||||
() -> Toast.makeText(mContext, R.string.wad_install_failure, Toast.LENGTH_SHORT)
|
||||
.show());
|
||||
}
|
||||
mainPresenterActivity.runOnUiThread(dialog::dismiss);
|
||||
}, "InstallWAD");
|
||||
installWADThread.start();
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ public interface MainView
|
||||
|
||||
void launchOpenFileActivity();
|
||||
|
||||
void launchInstallWAD();
|
||||
|
||||
/**
|
||||
* To be called when the game file cache is updated.
|
||||
*/
|
||||
|
@ -150,6 +150,13 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||
FileBrowserHelper.GAME_EXTENSIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchInstallWAD()
|
||||
{
|
||||
FileBrowserHelper.openFilePicker(this, MainPresenter.REQUEST_WAD_FILE, false,
|
||||
FileBrowserHelper.WAD_EXTENSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showGames()
|
||||
{
|
||||
@ -187,6 +194,14 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
||||
EmulationActivity.launchFile(this, FileBrowserHelper.getSelectedFiles(result));
|
||||
}
|
||||
break;
|
||||
|
||||
case MainPresenter.REQUEST_WAD_FILE:
|
||||
// If the user picked a file, as opposed to just backing out.
|
||||
if (resultCode == MainActivity.RESULT_OK)
|
||||
{
|
||||
mPresenter.installWAD(FileBrowserHelper.getSelectedPath(result));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,9 @@ public final class FileBrowserHelper
|
||||
public static final HashSet<String> RAW_EXTENSION = new HashSet<>(Collections.singletonList(
|
||||
"raw"));
|
||||
|
||||
public static final HashSet<String> WAD_EXTENSION = new HashSet<>(Collections.singletonList(
|
||||
"wad"));
|
||||
|
||||
public static void openDirectoryPicker(FragmentActivity activity, HashSet<String> extensions)
|
||||
{
|
||||
Intent i = new Intent(activity, CustomFilePickerActivity.class);
|
||||
|
@ -31,10 +31,16 @@
|
||||
android:title="@string/grid_menu_refresh"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_open_file"
|
||||
android:icon="@android:drawable/ic_media_play"
|
||||
android:title="Open File"
|
||||
app:showAsAction="ifRoom" />
|
||||
android:title="@string/grid_menu_open_file"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_install_wad"
|
||||
android:title="@string/grid_menu_install_wad"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
@ -288,6 +288,10 @@
|
||||
<string name="grid_menu_gcpad_settings">GameCube Input</string>
|
||||
<string name="grid_menu_wiimote_settings">Wii Input</string>
|
||||
<string name="grid_menu_refresh">Refresh Library</string>
|
||||
<string name="grid_menu_open_file">Open File</string>
|
||||
<string name="grid_menu_install_wad">Install WAD</string>
|
||||
<string name="wad_install_success">Successfully installed this title to the NAND.</string>
|
||||
<string name="wad_install_failure">Failed to install this title to the NAND.</string>
|
||||
|
||||
<!-- Add Directory Screen-->
|
||||
<string name="add_directory_title">Add Folder to Library</string>
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/PowerPC/Profiler.h"
|
||||
#include "Core/State.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
@ -733,6 +734,14 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(J
|
||||
Core::RunAsCPUThread([&path] { DVDInterface::ChangeDisc(path); });
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallWAD(JNIEnv* env,
|
||||
jobject obj,
|
||||
jstring jFile)
|
||||
{
|
||||
const std::string path = GetJString(env, jFile);
|
||||
return static_cast<jboolean>(WiiUtils::InstallWAD(path));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user