From d6ac86ed8ca5e914dace44cb5760038d41f94b2a Mon Sep 17 00:00:00 2001 From: louis Date: Tue, 11 Aug 2020 11:52:45 -0400 Subject: [PATCH] load name variants global stinx --- CHANGELOG.md | 6 +++++- Js/Main.js | 2 +- Js/Player.js | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f696757..d5b8181 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,4 +43,8 @@ Fix MoveCamera macro ## V1.4.0 (2019-09-29) -Updated Pixi.js to v5 \ No newline at end of file +Updated Pixi.js to v5 + +## V1.5.0 (2020-07-31) + +XDU Global support diff --git a/Js/Main.js b/Js/Main.js index 9c491ee..0a8804e 100644 --- a/Js/Main.js +++ b/Js/Main.js @@ -11,7 +11,7 @@ const textFunc = new TextFunctions(); let audio = undefined; //Cant create a audio context without user input. const player = new Player(pixiApp, utage, textFunc, audio, shaders); const languages = ["eng", "jpn", "rus", "enm", "kor", "zho"]; -const version = "YameteTomete XDUPlayer V1.4.0"; +const version = "YameteTomete XDUPlayer V1.5.0"; let bodyLoaded = false; let utageLoaded = false; let languagesLoaded = false; diff --git a/Js/Player.js b/Js/Player.js index 99ab45e..5f9d29b 100644 --- a/Js/Player.js +++ b/Js/Player.js @@ -960,7 +960,12 @@ class Player { let text = cur.English ? (this.utage.translations ? (this.utage.translations[cur.English] || cur.Text) : cur.Text) : cur.Text; text = commonFunctions.convertUtageTextTags(text); if(cur.Arg2 && cur.Arg2.toLowerCase() === "") { - this.text.characterName(true, this.utage.charTranslations[cur.Arg1] || cur.Arg1); + let nameFullWidth = cur.Arg1.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) + 0xFEE0);}); + let nameHalfWidth = cur.Arg1.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)}); + this.text.characterName(true, this.utage.charTranslations[cur.Arg1] + || this.utage.charTranslations[nameFullWidth] + || this.utage.charTranslations[nameHalfWidth] + || cur.Arg1); this.text.dialogText(true, commonFunctions.convertUtageTextTags(text)); } else { let found = false; @@ -975,7 +980,12 @@ class Player { if(cur.Character) { nameToUse = cur.Arg1; } - this.text.characterName(true, this.utage.charTranslations[nameToUse] || nameToUse); + let nameFullWidth = nameToUse.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) + 0xFEE0);}); + let nameHalfWidth = nameToUse.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)}); + this.text.characterName(true, this.utage.charTranslations[nameToUse] + || this.utage.charTranslations[nameFullWidth] + || this.utage.charTranslations[nameHalfWidth] + || nameToUse); this.text.dialogText(true, text); //restoreTint is set from a colorTo command. //We want to maintain the tint change from colorTo during speaking still. @@ -1013,7 +1023,12 @@ class Player { } //If we didnt find the character just dump the text anyways with Arg1 as the name if(!found) { - this.text.characterName(true, this.utage.charTranslations[cur.Arg1] || cur.Arg1); + let nameFullWidth = cur.Arg1.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) + 0xFEE0);}); + let nameHalfWidth = cur.Arg1.replace(/[A-Za-z0-9]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)}); + this.text.characterName(true, this.utage.charTranslations[cur.Arg1] + || this.utage.charTranslations[nameFullWidth] + || this.utage.charTranslations[nameHalfWidth] + || cur.Arg1); this.text.dialogText(true, text); } }