Android: Implement reading country value from game files.

This commit is contained in:
Eder Bastos 2015-05-16 19:02:46 -04:00
parent 12493c332c
commit 4c786cb70c
8 changed files with 74 additions and 11 deletions

View file

@ -132,6 +132,8 @@ public final class NativeLibrary
public static native String GetDescription(String filename);
public static native String GetGameId(String filename);
public static native int GetCountry(String filename);
public static native String GetDate(String filename);
public static native long GetFilesize(String filename);
public static native boolean IsWiiTitle(String filename);

View file

@ -181,8 +181,7 @@ public final class GameGridActivity extends Activity
{
GcGame game = new GcGame(NativeLibrary.GetTitle(entry.getAbsolutePath()),
NativeLibrary.GetDescription(entry.getAbsolutePath()).replace("\n", " "),
// TODO Some games might actually not be from this region, believe it or not.
"United States",
NativeLibrary.GetCountry(entry.getAbsolutePath()),
entry.getAbsolutePath(),
NativeLibrary.GetGameId(entry.getAbsolutePath()),
NativeLibrary.GetDate(entry.getAbsolutePath()));

View file

@ -38,7 +38,7 @@ public class GameDetailsDialog extends DialogFragment
Bundle arguments = new Bundle();
arguments.putString(ARGUMENT_GAME_TITLE, game.getTitle());
arguments.putString(ARGUMENT_GAME_DESCRIPTION, game.getDescription());
arguments.putString(ARGUMENT_GAME_COUNTRY, game.getCountry());
arguments.putInt(ARGUMENT_GAME_COUNTRY, game.getCountry());
arguments.putString(ARGUMENT_GAME_DATE, game.getDate());
arguments.putString(ARGUMENT_GAME_PATH, game.getPath());
arguments.putString(ARGUMENT_GAME_SCREENSHOT_PATH, game.getScreenPath());
@ -64,9 +64,12 @@ public class GameDetailsDialog extends DialogFragment
ImageButton buttonLaunch = (ImageButton) contents.findViewById(R.id.button_launch);
int countryIndex = getArguments().getInt(ARGUMENT_GAME_COUNTRY);
String country = getResources().getStringArray(R.array.country_names)[countryIndex];
textTitle.setText(getArguments().getString(ARGUMENT_GAME_TITLE));
textDescription.setText(getArguments().getString(ARGUMENT_GAME_DESCRIPTION));
textCountry.setText(getArguments().getString(ARGUMENT_GAME_COUNTRY));
textCountry.setText(country);
textDate.setText(getArguments().getString(ARGUMENT_GAME_DATE));
buttonLaunch.setOnClickListener(new View.OnClickListener()
{

View file

@ -4,6 +4,23 @@ public interface Game
{
public static final int PLATFORM_GC = 0;
public static final int PLATFORM_WII = 1;
public static final int PLATFORM_WII_WARE = 2;
// Copied from IVolume::ECountry. Update these if that is ever modified.
public static final int COUNTRY_EUROPE = 0;
public static final int COUNTRY_JAPAN = 1;
public static final int COUNTRY_USA = 2;
public static final int COUNTRY_AUSTRALIA = 3;
public static final int COUNTRY_FRANCE = 4;
public static final int COUNTRY_GERMANY = 5;
public static final int COUNTRY_ITALY = 6;
public static final int COUNTRY_KOREA = 7;
public static final int COUNTRY_NETHERLANDS = 8;
public static final int COUNTRY_RUSSIA = 9;
public static final int COUNTRY_SPAIN = 10;
public static final int COUNTRY_TAIWAN = 11;
public static final int COUNTRY_WORLD = 12;
public static final int COUNTRY_UNKNOWN = 13;
public int getPlatform();
@ -13,7 +30,7 @@ public interface Game
public String getDescription();
public String getCountry();
public int getCountry();
public String getPath();

View file

@ -7,18 +7,18 @@ public final class GcGame implements Game
{
private String mTitle;
private String mDescription;
private String mCountry;
private String mPath;
private String mGameId;
private String mScreenshotFolderPath;
private String mDate;
private int mCountry;
private int mPlatform = PLATFORM_GC;
private static final String PATH_SCREENSHOT_FOLDER = "file:///sdcard/dolphin-emu/ScreenShots/";
public GcGame(String title, String description, String country, String path, String gameId, String date)
public GcGame(String title, String description, int country, String path, String gameId, String date)
{
mTitle = title;
mDescription = description;
@ -54,7 +54,7 @@ public final class GcGame implements Game
}
@Override
public String getCountry()
public int getCountry()
{
return mCountry;
}

View file

@ -28,9 +28,9 @@ public final class WiiGame implements Game
}
@Override
public String getCountry()
public int getCountry()
{
return null;
return 13;
}
@Override

View file

@ -190,4 +190,20 @@
<item>2</item>
<item>3</item>
</string-array>
<string-array name="country_names">
<item>Europe</item>
<item>Japan</item>
<item>USA</item>
<item>Australia</item>
<item>France</item>
<item>Germany</item>
<item>Italy</item>
<item>Korea</item>
<item>Netherlands</item>
<item>Russia</item>
<item>Spain</item>
<item>Taiwan</item>
<item>Unknown</item>
</string-array>
</resources>

View file

@ -43,6 +43,7 @@
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoBackendBase.h"
#include "../DiscIO/Volume.h"
ANativeWindow* surf;
std::string g_filename;
@ -178,6 +179,23 @@ static bool IsWiiTitle(std::string filename)
return false;
}
static int GetCountry(std::string filename)
{
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(filename));
if (pVolume != nullptr)
{
DiscIO::IVolume::ECountry country = pVolume->GetCountry();
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Country Code: %i", country);
return country;
}
// Technically correct.
return 13;
}
static std::string GetTitle(std::string filename)
{
__android_log_print(ANDROID_LOG_WARN, DOLPHIN_TAG, "Getting Title for file: %s", filename.c_str());
@ -330,6 +348,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_onGamePadMov
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetBanner(JNIEnv *env, jobject obj, jstring jFile);JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetTitle(JNIEnv *env, jobject obj, jstring jFilename);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDescription(JNIEnv *env, jobject obj, jstring jFilename);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameId(JNIEnv *env, jobject obj, jstring jFilename);
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCountry(JNIEnv *env, jobject obj, jstring jFilename);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDate(JNIEnv *env, jobject obj, jstring jFilename);
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetFilesize(JNIEnv *env, jobject obj, jstring jFilename);
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsWiiTitle(JNIEnv *env, jobject obj, jstring jFilename);
@ -411,6 +430,13 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetDate(J
return env->NewStringUTF(date.c_str());
}
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetCountry(JNIEnv *env, jobject obj, jstring jFilename)
{
std::string filename = GetJString(env, jFilename);
int country = GetCountry(filename);
return country;
}
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetFilesize(JNIEnv *env, jobject obj, jstring jFilename)
{
std::string filename = GetJString(env, jFilename);