mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
Merge branch 'main' of github.com:geode-sdk/geode
This commit is contained in:
commit
79e14e4be3
1 changed files with 31 additions and 10 deletions
|
@ -44,20 +44,41 @@ CCPoint cocos::getMousePos() {
|
|||
return CCPoint(0, 0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
void clearJNIException() {
|
||||
// this is a silly workaround to not crash when the method is not found.
|
||||
// cocos figured this out half a year later...
|
||||
auto vm = JniHelper::getJavaVM();
|
||||
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) == JNI_OK) {
|
||||
env->ExceptionClear();
|
||||
}
|
||||
}
|
||||
|
||||
ghc::filesystem::path getBaseDir() {
|
||||
JniMethodInfo t;
|
||||
std::string path = "/storage/emulated/0/Android/data/com.geode.launcher/files";
|
||||
|
||||
if (JniHelper::getStaticMethodInfo(t, "com/geode/launcher/utils/GeodeUtils", "getBaseDirectory", "()Ljava/lang/String;")) {
|
||||
jstring str = reinterpret_cast<jstring>(t.env->CallStaticObjectMethod(t.classID, t.methodID));
|
||||
t.env->DeleteLocalRef(t.classID);
|
||||
path = JniHelper::jstring2string(str);
|
||||
t.env->DeleteLocalRef(str);
|
||||
} else {
|
||||
clearJNIException();
|
||||
}
|
||||
|
||||
return ghc::filesystem::path(path);
|
||||
}
|
||||
}
|
||||
|
||||
ghc::filesystem::path dirs::getGameDir() {
|
||||
return ghc::filesystem::path(
|
||||
"/storage/emulated/0/Android/data/com.geode.launcher/files/game"
|
||||
// "/data/user/0/com.geode.launcher/files/"
|
||||
/*CCFileUtils::sharedFileUtils()->getWritablePath().c_str()*/
|
||||
);
|
||||
return getBaseDir() / "game";
|
||||
}
|
||||
|
||||
ghc::filesystem::path dirs::getSaveDir() {
|
||||
return ghc::filesystem::path(
|
||||
"/storage/emulated/0/Android/data/com.geode.launcher/files/save"
|
||||
// "/data/user/0/com.geode.launcher/files/"
|
||||
/*CCFileUtils::sharedFileUtils()->getWritablePath().c_str()*/
|
||||
);
|
||||
return getBaseDir() / "save";
|
||||
}
|
||||
|
||||
ghc::filesystem::path dirs::getModRuntimeDir() {
|
||||
|
|
Loading…
Reference in a new issue