1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-09 22:56:53 +02:00

fix touch controls alpha; get default language on Android

This commit is contained in:
XProger
2019-02-19 04:57:40 +03:00
parent 5f5b495613
commit b1897e630b
3 changed files with 32 additions and 5 deletions

View File

@@ -128,7 +128,7 @@ void osToggleVR(bool enable) {
extern "C" {
JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstring jcacheDir) {
JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstring jcacheDir, jint langId) {
env->GetJavaVM(&jvm);
timeval t;
@@ -138,6 +138,7 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr
const char* str;
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
Core::defLang = langId;
str = env->GetStringUTFChars(jcontentDir, NULL);
strcat(contentDir, str);
@@ -147,7 +148,7 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr
strcat(cacheDir, str);
env->ReleaseStringUTFChars(jcacheDir, str);
strcpy(saveDir, cacheDir);
strcpy(saveDir, contentDir);
sndInit();

View File

@@ -1,6 +1,8 @@
package org.xproger.openlara;
import java.util.ArrayList;
import java.util.Locale;
import javax.microedition.khronos.egl.EGLConfig;
import android.os.Bundle;
import android.os.Environment;
@@ -223,7 +225,7 @@ class Touch {
}
class Wrapper implements GvrView.StereoRenderer {
public static native void nativeInit(String contentDir, String cacheDir);
public static native void nativeInit(String contentDir, String cacheDir, int langId);
public static native void nativeFree();
public static native void nativeReset();
public static native void nativeResize(int x, int y, int w, int h);
@@ -272,10 +274,33 @@ class Wrapper implements GvrView.StereoRenderer {
nativeResize(0, 0, width, height);
}
int getLanguage() {
String lang = Locale.getDefault().getLanguage();
int id = 0;
if (lang.startsWith("fr")) {
id = 1;
} else if (lang.startsWith("de")) {
id = 2;
} else if (lang.startsWith("es")) {
id = 3;
} else if (lang.startsWith("it")) {
id = 4;
} else if (lang.startsWith("pl")) {
id = 5;
} else if (lang.startsWith("pt")) {
id = 6;
} else if (lang.startsWith("ru") || lang.startsWith("be") || lang.startsWith("uk")) {
id = 7;
} else if (lang.startsWith("ja")) {
id = 8;
}
return id;
}
@Override
public void onSurfaceCreated(EGLConfig config) {
if (!ready) {
nativeInit(contentDir, cacheDir);
nativeInit(contentDir, cacheDir, getLanguage());
nativeSoundState(true);
ready = true;
}

View File

@@ -342,7 +342,8 @@ namespace UI {
m.translate(vec3(pos.x, pos.y, 0.0));
m.scale(vec3(scale.x, scale.y, 1.0));
Core::active.shader->setParam(uViewProj, m);
Core::setMaterial(1.0f, 1.0f, 1.0f, active ? 0.7f : 0.5f);
float a = active ? 0.7f : 0.5f;
Core::setMaterial(a, a, a, a);
game->getMesh()->renderCircle();
}