Generally make the Android UI better.

This commit is contained in:
Ryan Houdek
2013-04-23 14:21:48 -05:00
parent 453fdff4bd
commit bd72e13dd4
17 changed files with 704 additions and 160 deletions

View File

@ -35,6 +35,11 @@
#include "BootManager.h"
#include "OnScreenDisplay.h"
// Banner loading
#include "Filesystem.h"
#include "BannerLoader.h"
#include "VolumeCreator.h"
#include "Android/ButtonManager.h"
#include <jni.h>
@ -140,6 +145,57 @@ void OSDCallbacks(u32 UserData)
}
}
#define DVD_BANNER_WIDTH 96
#define DVD_BANNER_HEIGHT 32
std::vector<std::string> m_volume_names;
std::vector<std::string> m_names;
bool LoadBanner(std::string filename, u32 *Banner)
{
DiscIO::IVolume* pVolume = DiscIO::CreateVolumeFromFilename(filename);
if (pVolume != NULL)
{
bool bIsWad = false;
if (DiscIO::IsVolumeWadFile(pVolume))
bIsWad = true;
m_volume_names = pVolume->GetNames();
// check if we can get some info from the banner file too
DiscIO::IFileSystem* pFileSystem = DiscIO::CreateFileSystem(pVolume);
if (pFileSystem != NULL || bIsWad)
{
DiscIO::IBannerLoader* pBannerLoader = DiscIO::CreateBannerLoader(*pFileSystem, pVolume);
if (pBannerLoader != NULL)
if (pBannerLoader->IsValid())
{
m_names = pBannerLoader->GetNames();
if (pBannerLoader->GetBanner(Banner))
return true;
}
}
}
return false;
}
std::string GetName(std::string filename)
{
if (!m_names.empty())
return m_names[0];
if (!m_volume_names.empty())
return m_volume_names[0];
// No usable name, return filename (better than nothing)
std::string name;
SplitPath(filename, NULL, &name, NULL);
return name;
}
#ifdef __cplusplus
extern "C"
{
@ -162,6 +218,63 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_DolphinEmulator_onTouchEve
ButtonManager::TouchEvent(Action, X, Y);
}
JNIEXPORT jintArray JNICALL Java_org_dolphinemu_dolphinemu_GameListItem_GetBanner(JNIEnv *env, jobject obj, jstring jFile)
{
const char *File = env->GetStringUTFChars(jFile, NULL);
jintArray Banner = env->NewIntArray(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT);
u32 uBanner[DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT];
if (LoadBanner(File, uBanner))
{
env->SetIntArrayRegion(Banner, 0, DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT, (jint*)uBanner);
}
env->ReleaseStringUTFChars(jFile, File);
return Banner;
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_GameListItem_GetTitle(JNIEnv *env, jobject obj, jstring jFile)
{
const char *File = env->GetStringUTFChars(jFile, NULL);
std::string Name = GetName(File);
m_names.clear();
m_volume_names.clear();
env->ReleaseStringUTFChars(jFile, File);
return env->NewStringUTF(Name.c_str());
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_GameListView_GetConfig(JNIEnv *env, jobject obj, jstring jKey, jstring jValue, jstring jDefault)
{
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
const char *Key = env->GetStringUTFChars(jKey, NULL);
const char *Value = env->GetStringUTFChars(jValue, NULL);
const char *Default = env->GetStringUTFChars(jDefault, NULL);
std::string value;
ini.Get(Key, Value, &value, Default);
env->ReleaseStringUTFChars(jKey, Key);
env->ReleaseStringUTFChars(jValue, Value);
env->ReleaseStringUTFChars(jDefault, Default);
return env->NewStringUTF(value.c_str());
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_GameListView_SetConfig(JNIEnv *env, jobject obj, jstring jKey, jstring jValue, jstring jDefault)
{
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
const char *Key = env->GetStringUTFChars(jKey, NULL);
const char *Value = env->GetStringUTFChars(jValue, NULL);
const char *Default = env->GetStringUTFChars(jDefault, NULL);
ini.Set(Key, Value, Default);
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
env->ReleaseStringUTFChars(jKey, Key);
env->ReleaseStringUTFChars(jValue, Value);
env->ReleaseStringUTFChars(jDefault, Default);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(JNIEnv *env, jobject obj, jstring jFile, jobject _surf, jint _width, jint _height)
{
surf = ANativeWindow_fromSurface(env, _surf);
@ -178,7 +291,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeGLSurfaceView_main(J
VideoBackend::PopulateList();
VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);
WiimoteReal::LoadSettings();
const char *File = env->GetStringUTFChars(jFile, NULL);
// No use running the loop when booting fails
if ( BootManager::BootCore( File ) )