mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-11 15:45:05 +02:00
fix touch controls alpha; get default language on Android
This commit is contained in:
@@ -128,7 +128,7 @@ void osToggleVR(bool enable) {
|
|||||||
|
|
||||||
extern "C" {
|
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);
|
env->GetJavaVM(&jvm);
|
||||||
|
|
||||||
timeval t;
|
timeval t;
|
||||||
@@ -138,6 +138,7 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr
|
|||||||
const char* str;
|
const char* str;
|
||||||
|
|
||||||
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
cacheDir[0] = saveDir[0] = contentDir[0] = 0;
|
||||||
|
Core::defLang = langId;
|
||||||
|
|
||||||
str = env->GetStringUTFChars(jcontentDir, NULL);
|
str = env->GetStringUTFChars(jcontentDir, NULL);
|
||||||
strcat(contentDir, str);
|
strcat(contentDir, str);
|
||||||
@@ -147,7 +148,7 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring jcontentDir, jstr
|
|||||||
strcat(cacheDir, str);
|
strcat(cacheDir, str);
|
||||||
env->ReleaseStringUTFChars(jcacheDir, str);
|
env->ReleaseStringUTFChars(jcacheDir, str);
|
||||||
|
|
||||||
strcpy(saveDir, cacheDir);
|
strcpy(saveDir, contentDir);
|
||||||
|
|
||||||
sndInit();
|
sndInit();
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package org.xproger.openlara;
|
package org.xproger.openlara;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@@ -223,7 +225,7 @@ class Touch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Wrapper implements GvrView.StereoRenderer {
|
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 nativeFree();
|
||||||
public static native void nativeReset();
|
public static native void nativeReset();
|
||||||
public static native void nativeResize(int x, int y, int w, int h);
|
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);
|
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
|
@Override
|
||||||
public void onSurfaceCreated(EGLConfig config) {
|
public void onSurfaceCreated(EGLConfig config) {
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
nativeInit(contentDir, cacheDir);
|
nativeInit(contentDir, cacheDir, getLanguage());
|
||||||
nativeSoundState(true);
|
nativeSoundState(true);
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
3
src/ui.h
3
src/ui.h
@@ -342,7 +342,8 @@ namespace UI {
|
|||||||
m.translate(vec3(pos.x, pos.y, 0.0));
|
m.translate(vec3(pos.x, pos.y, 0.0));
|
||||||
m.scale(vec3(scale.x, scale.y, 1.0));
|
m.scale(vec3(scale.x, scale.y, 1.0));
|
||||||
Core::active.shader->setParam(uViewProj, m);
|
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();
|
game->getMesh()->renderCircle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user