Language selection.
Gulpfile
This commit is contained in:
parent
5b5f3d83c2
commit
5ed031cb6a
9 changed files with 135 additions and 32 deletions
62
Js/Main.js
62
Js/Main.js
|
@ -14,6 +14,7 @@ const languages = ["eng", "jpn"];
|
|||
let bodyLoaded = false;
|
||||
let utageLoaded = false;
|
||||
let selectedLang = "eng";
|
||||
let currentMission = undefined;
|
||||
let screenw = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
||||
let screenh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
||||
let screenSizeTimeout = undefined;
|
||||
|
@ -40,19 +41,7 @@ function onBodyLoaded() {
|
|||
(function checkIsLoaded() {
|
||||
if(bodyLoaded) {
|
||||
document.getElementById('loading-font').style.cssText = "display: none;";
|
||||
volume = localStorage.getItem('volume') || 0.5;
|
||||
volume = Number(volume);
|
||||
audio.changeVolume(volume);
|
||||
document.getElementById('volume-range').value = volume * 100;
|
||||
isMuted = localStorage.getItem('ismuted') || false;
|
||||
if(isMuted === "false") { isMuted = false; }
|
||||
else if(isMuted === "true") { isMuted = true; }
|
||||
audio.mute(isMuted);
|
||||
if(isMuted) {
|
||||
document.getElementById('mute-button').innerText = "🔇";
|
||||
} else {
|
||||
document.getElementById('mute-button').innerText = "🔊";
|
||||
}
|
||||
loadLocalStorage();
|
||||
}
|
||||
if(utageLoaded) {
|
||||
document.getElementById('loading-utage').style.cssText = "display: none;";
|
||||
|
@ -68,6 +57,7 @@ function onBodyLoaded() {
|
|||
function onAllLoaded(success) {
|
||||
textFunc.findTextElements();
|
||||
buildMissionSelectList();
|
||||
buildLanguageList();
|
||||
let appContainer = document.getElementById('app-container');
|
||||
appContainer.appendChild(pixiApp.app.view);
|
||||
setTimeout(() => {
|
||||
|
@ -77,6 +67,28 @@ function onAllLoaded(success) {
|
|||
}, 0);
|
||||
}
|
||||
|
||||
function loadLocalStorage() {
|
||||
//audio
|
||||
volume = localStorage.getItem('volume') || 0.5;
|
||||
volume = Number(volume);
|
||||
audio.changeVolume(volume);
|
||||
document.getElementById('volume-range').value = volume * 100;
|
||||
isMuted = localStorage.getItem('ismuted') || false;
|
||||
if(isMuted === "false") { isMuted = false; }
|
||||
else if(isMuted === "true") { isMuted = true; }
|
||||
audio.mute(isMuted);
|
||||
if(isMuted) {
|
||||
document.getElementById('mute-button').innerText = "🔇";
|
||||
} else {
|
||||
document.getElementById('mute-button').innerText = "🔊";
|
||||
}
|
||||
//language
|
||||
let lang = localStorage.getItem('language') || "eng";
|
||||
if(languages.includes(lang)) {
|
||||
selectedLang = lang;
|
||||
}
|
||||
}
|
||||
|
||||
function buildMissionSelectList() {
|
||||
let selectBox = document.getElementById('select-mission');
|
||||
selectBox.innerHTML = '';
|
||||
|
@ -97,13 +109,26 @@ function buildMissionSelectList() {
|
|||
}
|
||||
}
|
||||
|
||||
function buildLanguageList() {
|
||||
let selectBox = document.getElementById('select-language');
|
||||
selectBox.innerHTML = '';
|
||||
for(let i = 0; i < languages.length; ++i) {
|
||||
let opt = document.createElement('option');
|
||||
opt.setAttribute('value', languages[i]);
|
||||
opt.innerText = languages[i];
|
||||
selectBox.appendChild(opt);
|
||||
}
|
||||
selectBox.value = selectedLang;
|
||||
}
|
||||
|
||||
function missionChanged(event) {
|
||||
if(!event || !event.currentTarget || !event.currentTarget.value || event.currentTarget.value === '{Select}') { return; }
|
||||
|
||||
let newMission = utage.availableMissions[event.currentTarget.value.split('|')[0]];
|
||||
currentMission = newMission;
|
||||
let promises = [
|
||||
utage.parseMissionFile(`${utage.rootDirectory}XDUData/${newMission.Path.replace('Asset/', '').replace('.utage', '').replace('.tsv', '_t.tsv')}`),
|
||||
utage.loadMissionTranslation(`${utage.rootDirectory}XDUData/${newMission.Path.replace('Asset/', '').replace('.utage', '').replace('.tsv', `_translations_${selectedLang}.json`)}`),
|
||||
utage.loadMissionTranslation(`${utage.rootDirectory}XDUData/${newMission.Path.replace('Asset/', '').replace('.utage', '').replace('.tsv', `_translations_${selectedLang}.json`)}`, selectedLang),
|
||||
player.resetAll()
|
||||
];
|
||||
|
||||
|
@ -112,16 +137,25 @@ function missionChanged(event) {
|
|||
let res = player.playFile()
|
||||
.then((success) => {
|
||||
player.resetAll();
|
||||
currentMission = undefined;
|
||||
debugger;
|
||||
}, (failure) => {
|
||||
debugger;
|
||||
currentMission = undefined;
|
||||
console.log(failure);
|
||||
});
|
||||
}, (failure) => {
|
||||
currentMission = undefined;
|
||||
console.log(failure);
|
||||
});
|
||||
}
|
||||
|
||||
function languageChanged(event) {
|
||||
if(!event || !event.currentTarget || !event.currentTarget.value || event.currentTarget.value === '{Select}' || !languages.includes(event.currentTarget.value)) { return; }
|
||||
selectedLang = event.currentTarget.value;
|
||||
utage.loadMissionTranslation(`${utage.rootDirectory}XDUData/${currentMission.Path.replace('Asset/', '').replace('.utage', '').replace('.tsv', `_translations_${selectedLang}.json`)}`, selectedLang);
|
||||
}
|
||||
|
||||
function onMainClick(event) {
|
||||
player.onMainClick(event);
|
||||
}
|
||||
|
|
|
@ -284,7 +284,6 @@ class Player {
|
|||
default: {
|
||||
let newValue = commonFunctions.lerp(l.initV, l.finalV, pos, inter);
|
||||
let split = l.type.split(".");
|
||||
if(split[0] == 'scale') { debugger; }
|
||||
switch(split.length) {
|
||||
case 1:
|
||||
l.object[split[0]] = newValue;
|
||||
|
@ -805,6 +804,7 @@ class Player {
|
|||
this.playingVoice = undefined;
|
||||
this.text.resetAll();
|
||||
this.audio.resetAll();
|
||||
this.utage.resetTranslations();
|
||||
resolve();
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
|
|
|
@ -8,12 +8,13 @@ class TextFunctions {
|
|||
this.dialogBox = undefined;
|
||||
this.character = undefined;
|
||||
this.dialog = undefined;
|
||||
this.textScrollSpeedMs = 35;
|
||||
this.scrollControls = undefined;
|
||||
this.nextIndicator = undefined;
|
||||
this.dialogToDisplay = {timeout: undefined, fullText: "", text: "", curPos: 0};
|
||||
this.textScrollSpeedMs = 40;
|
||||
this.scrollingText = false;
|
||||
this.lineHeight = -1;
|
||||
this.textHistory = [];
|
||||
}
|
||||
|
||||
findTextElements() {
|
||||
|
@ -67,6 +68,7 @@ class TextFunctions {
|
|||
} else {
|
||||
this.dialogToDisplay.text = text;
|
||||
this.dialogToDisplay.fullText = text;
|
||||
this.textHistory.push({ character: this.character.innerHTML, text: text });
|
||||
this.dialogToDisplay.curPos = 0;
|
||||
this.dialogInner.innerHTML = "";
|
||||
//this.dialogInner.innerHTML = this.dialogToDisplay.text[0];
|
||||
|
@ -180,5 +182,12 @@ class TextFunctions {
|
|||
this.dialogBox.classList.add('hidden');
|
||||
this.scrollControls.classList.add('hidden');
|
||||
this.nextIndicator.classList.add('hidden');
|
||||
this.textHistory.length = 0;
|
||||
if(this.dialogToDisplay.timeout) {
|
||||
clearTimeout(this.dialogToDisplay.timeout);
|
||||
}
|
||||
this.dialogToDisplay = {timeout: undefined, fullText: "", text: "", curPos: 0};
|
||||
this.scrollingText = false;
|
||||
this.lineHeight = -1;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ class UtageInfo {
|
|||
this.paramInfo = {};
|
||||
this.soundInfo = {};
|
||||
this.textureInfo = {};
|
||||
this.translations = {};
|
||||
this.currentTranslation = {};
|
||||
this.bgmLoopData = {};
|
||||
}
|
||||
|
@ -77,16 +78,24 @@ class UtageInfo {
|
|||
});
|
||||
}
|
||||
|
||||
loadMissionTranslation(file) {
|
||||
loadMissionTranslation(file, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
commonFunctions.getFileJson(file)
|
||||
.then((success) => {
|
||||
this.currentTranslation = success;
|
||||
if(this.translations[key]) {
|
||||
debugger;
|
||||
this.currentTranslation = this.translations[key];
|
||||
resolve();
|
||||
}, (failure) => {
|
||||
this.currentTranslation = {};
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
commonFunctions.getFileJson(file)
|
||||
.then((success) => {
|
||||
debugger;
|
||||
this.translations[key] = success;
|
||||
this.currentTranslation = success;
|
||||
resolve();
|
||||
}, (failure) => {
|
||||
this.currentTranslation = {};
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -229,4 +238,9 @@ class UtageInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
resetTranslations() {
|
||||
this.translations = {};
|
||||
this.currentTranslation = {};
|
||||
}
|
||||
}
|
1
Js/XduPlayer.min.js
vendored
Normal file
1
Js/XduPlayer.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue