mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2026-05-06 07:56:46 -04:00
Android: Expose asset prefix path to Java via JNI
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package io.openrct2;
|
||||
|
||||
/**
|
||||
* Platform constants exposed from C++ via JNI.
|
||||
* These constants are defined in the native code and exposed to Java to ensure
|
||||
* the same definitions are used in both languages.
|
||||
*/
|
||||
public class PlatformConstants {
|
||||
static {
|
||||
System.loadLibrary("openrct2");
|
||||
}
|
||||
|
||||
/**
|
||||
* Android asset path prefix.
|
||||
* This constant is retrieved from the native C++ code to ensure consistency.
|
||||
*/
|
||||
public static final String ANDROID_ASSET_PATH_PREFIX = getAndroidAssetPathPrefix();
|
||||
|
||||
/**
|
||||
* Native method to get the Android asset path prefix from C++.
|
||||
* Defined in src/openrct2/platform/Platform.Android.cpp
|
||||
*/
|
||||
private static native String getAndroidAssetPathPrefix();
|
||||
}
|
||||
@@ -487,6 +487,16 @@ namespace OpenRCT2::Platform
|
||||
}
|
||||
} // namespace OpenRCT2::Platform
|
||||
|
||||
/**
|
||||
* JNI function to expose the Android asset path prefix constant to Java.
|
||||
* Called from io.openrct2.PlatformConstants.getAndroidAssetPathPrefix()
|
||||
*/
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_io_openrct2_PlatformConstants_getAndroidAssetPathPrefix(JNIEnv* env, jclass /* clazz */)
|
||||
{
|
||||
return env->NewStringUTF(std::string(OpenRCT2::Platform::kAndroidAssetPathPrefix).c_str());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* pjvm, void* reserved)
|
||||
{
|
||||
// Due to an issue where JNI_OnLoad could be called multiple times, we need
|
||||
|
||||
Reference in New Issue
Block a user