Android: Add Install WAD to menu_game_grid
This commit is contained in:
parent
c9aab4f809
commit
2d6d0c86cc
|
@ -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,
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.widget.Toast;
|
||||
|
||||
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 +20,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 +95,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 +118,16 @@ public final class MainPresenter
|
|||
{
|
||||
mDirToAdd = dir;
|
||||
}
|
||||
|
||||
public void installWAD(String file)
|
||||
{
|
||||
if (NativeLibrary.InstallWAD(file))
|
||||
{
|
||||
Toast.makeText(mContext, R.string.wad_install_success, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(mContext, R.string.wad_install_failure, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"/>
|
||||
|
||||
</menu>
|
||||
<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