WiiUtils: Add function to convert UpdateResult to jint

This commit is contained in:
OatmealDome 2022-01-09 15:50:23 -05:00
parent 7c86baee50
commit 19e1809cdf
3 changed files with 42 additions and 0 deletions

View File

@ -10,6 +10,16 @@ public final class WiiUtils
public static final int RESULT_CORRUPTED_SOURCE = 3;
public static final int RESULT_TITLE_MISSING = 4;
public static final int UPDATE_RESULT_SUCCESS = 0;
public static final int UPDATE_RESULT_ALREADY_UP_TO_DATE = 1;
public static final int UPDATE_RESULT_REGION_MISMATCH = 2;
public static final int UPDATE_RESULT_MISSING_UPDATE_PARTITION = 3;
public static final int UPDATE_RESULT_DISC_READ_FAILED = 4;
public static final int UPDATE_RESULT_SERVER_FAILED = 5;
public static final int UPDATE_RESULT_DOWNLOAD_FAILED = 6;
public static final int UPDATE_RESULT_IMPORT_FAILED = 7;
public static final int UPDATE_RESULT_CANCELLED = 8;
public static native boolean installWAD(String file);
public static native int importWiiSave(String file, BooleanSupplier canOverwrite);

View File

@ -35,6 +35,36 @@ static jint ConvertCopyResult(WiiSave::CopyResult result)
static_assert(static_cast<int>(WiiSave::CopyResult::NumberOfEntries) == 5);
}
static jint ConvertUpdateResult(WiiUtils::UpdateResult result)
{
switch (result)
{
case WiiUtils::UpdateResult::Succeeded:
return 0;
case WiiUtils::UpdateResult::AlreadyUpToDate:
return 1;
case WiiUtils::UpdateResult::RegionMismatch:
return 2;
case WiiUtils::UpdateResult::MissingUpdatePartition:
return 3;
case WiiUtils::UpdateResult::DiscReadFailed:
return 4;
case WiiUtils::UpdateResult::ServerFailed:
return 5;
case WiiUtils::UpdateResult::DownloadFailed:
return 6;
case WiiUtils::UpdateResult::ImportFailed:
return 7;
case WiiUtils::UpdateResult::Cancelled:
return 8;
default:
ASSERT(false);
return 1;
}
static_assert(static_cast<int>(WiiUtils::UpdateResult::NumberOfEntries) == 9);
}
extern "C" {
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_installWAD(JNIEnv* env,

View File

@ -82,6 +82,8 @@ enum class UpdateResult
ImportFailed,
// Update was cancelled.
Cancelled,
NumberOfEntries,
};
// Return false to cancel the update as soon as the current title has finished updating.