mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-11 15:45:05 +02:00
fix automatic language detector for Web version
This commit is contained in:
@@ -112,28 +112,30 @@
|
|||||||
proc.connect(audioContext.destination);
|
proc.connect(audioContext.destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLanguage() {
|
function getLanguage() {
|
||||||
var lang = navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage;
|
var lang = navigator.languages && navigator.languages[0] || navigator.language || navigator.userLanguage;
|
||||||
var id = 0;
|
if (!lang) return;
|
||||||
if (lang == "fr") {
|
var id = 0;
|
||||||
id = 1;
|
lang = lang.substring(0, 2);
|
||||||
} else if (lang == "de") {
|
if (lang == "fr") {
|
||||||
id = 2;
|
id = 1;
|
||||||
} else if (lang == "es") {
|
} else if (lang == "de") {
|
||||||
id = 3;
|
id = 2;
|
||||||
} else if (lang == "it") {
|
} else if (lang == "es") {
|
||||||
id = 4;
|
id = 3;
|
||||||
} else if (lang == "pl") {
|
} else if (lang == "it") {
|
||||||
id = 5;
|
id = 4;
|
||||||
} else if (lang == "pt") {
|
} else if (lang == "pl") {
|
||||||
id = 6;
|
id = 5;
|
||||||
} else if (lang == "ru" || lang == "be" || lang == "uk") {
|
} else if (lang == "pt") {
|
||||||
id = 7;
|
id = 6;
|
||||||
} else if (lang == "ja") {
|
} else if (lang == "ru" || lang == "be" || lang == "uk") {
|
||||||
id = 8;
|
id = 7;
|
||||||
}
|
} else if (lang == "ja") {
|
||||||
Module.ccall('set_def_lang', 'null', ['number'], [id]);
|
id = 8;
|
||||||
}
|
}
|
||||||
|
Module.ccall('set_def_lang', 'null', ['number'], [id]);
|
||||||
|
}
|
||||||
|
|
||||||
// unlock audio context after user interaction
|
// unlock audio context after user interaction
|
||||||
var userAction = function() {
|
var userAction = function() {
|
||||||
@@ -142,7 +144,7 @@
|
|||||||
window.removeEventListener('touchstart', userAction, false);
|
window.removeEventListener('touchstart', userAction, false);
|
||||||
window.removeEventListener('click', userAction, false);
|
window.removeEventListener('click', userAction, false);
|
||||||
console.log("resume playback");
|
console.log("resume playback");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('touchstart', userAction, false);
|
window.addEventListener('touchstart', userAction, false);
|
||||||
@@ -248,9 +250,9 @@
|
|||||||
};
|
};
|
||||||
reader.readAsArrayBuffer(event.target.files[0]);
|
reader.readAsArrayBuffer(event.target.files[0]);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
var db;
|
var db;
|
||||||
var request = indexedDB.open("db");
|
var request = indexedDB.open("db");
|
||||||
request.onupgradeneeded = function() {
|
request.onupgradeneeded = function() {
|
||||||
console.log("!!!!!!!! NO DB!");
|
console.log("!!!!!!!! NO DB!");
|
||||||
};
|
};
|
||||||
@@ -262,32 +264,32 @@ request.onsuccess = function() {
|
|||||||
|
|
||||||
function logTimestamps(timestamps) {
|
function logTimestamps(timestamps) {
|
||||||
console.log('There are ' + timestamps.length +
|
console.log('There are ' + timestamps.length +
|
||||||
' timestamp(s) saved in IndexedDB: ' + timestamps.join(', '));
|
' timestamp(s) saved in IndexedDB: ' + timestamps.join(', '));
|
||||||
}
|
}
|
||||||
|
|
||||||
function backupSaves() {
|
function backupSaves() {
|
||||||
|
|
||||||
var transaction = db.transaction("FILE_DATA", 'readonly');
|
var transaction = db.transaction("FILE_DATA", 'readonly');
|
||||||
var store = transaction.objectStore("FILE_DATA");
|
var store = transaction.objectStore("FILE_DATA");
|
||||||
store.get("level/1/GYMLOAD.PNG").onsuccess = function(e) {
|
store.get("level/1/GYMLOAD.PNG").onsuccess = function(e) {
|
||||||
var value = e.target.result;
|
var value = e.target.result;
|
||||||
// value will be: { zip: {}, foo: { bar: { baz: 1 } } }
|
// value will be: { zip: {}, foo: { bar: { baz: 1 } } }
|
||||||
console.log(value);
|
console.log(value);
|
||||||
var data = value;
|
var data = value;
|
||||||
var a = document.createElement("a");
|
var a = document.createElement("a");
|
||||||
|
|
||||||
a.href = URL.createObjectURL(new Blob([data]));
|
a.href = URL.createObjectURL(new Blob([data]));
|
||||||
a.download = "savegame.dat";
|
a.download = "savegame.dat";
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
function restoreSaves() {
|
function restoreSaves() {
|
||||||
alert('restore');
|
alert('restore');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-60009035-1', 'auto');ga('send', 'pageview');</script>
|
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-60009035-1', 'auto');ga('send', 'pageview');</script>
|
||||||
|
Reference in New Issue
Block a user