Merge branch 'fix_translation_loading' into 'master'

Fix an edge case where translation txt file is loaded before csv file

See merge request 
This commit is contained in:
Da'Inihlus 2025-04-12 17:04:01 +00:00
commit 9b38c69f73
2 changed files with 28 additions and 14 deletions
BondageClub
Screens/Online/Game
Scripts

View file

@ -2,6 +2,9 @@
/** @type {null | string[][]} */
let OnlineGameDictionary = null;
/** @type { ()=>void | undefined } */
let OnlineGameTranslateResolve = undefined;
/**
* Loads the online game dictionary that will be used throughout the game to output messages
* @returns {void} - Nothing
@ -21,6 +24,7 @@ function OnlneGameDictionaryLoad() {
if (this.status == 200) {
CommonCSVCache[FullPath] = CommonParseCSV(this.responseText);
OnlineGameDictionary = CommonCSVCache[FullPath];
OnlineGameTranslateResolve?.();
}
});
@ -39,15 +43,18 @@ function OnlneGameDictionaryLoad() {
}
function OnlineGameTranslate(CachePath) {
if (!Array.isArray(TranslationCache[CachePath])) return;
for (let T = 0; T < OnlineGameDictionary.length; T++) {
if (OnlineGameDictionary[T][1]) {
let indexText = TranslationCache[CachePath].indexOf(OnlineGameDictionary[T][1].trim());
if (indexText >= 0) {
OnlineGameDictionary[T][1] = TranslationCache[CachePath][indexText + 1];
const DoTranslate = () => {
for (let T = 0; T < OnlineGameDictionary.length; T++) {
if (OnlineGameDictionary[T][1]) {
let indexText = TranslationCache[CachePath].indexOf(OnlineGameDictionary[T][1].trim());
if (indexText >= 0) {
OnlineGameDictionary[T][1] = TranslationCache[CachePath][indexText + 1];
}
}
}
}
};
if(OnlineGameDictionary) DoTranslate();
else OnlineGameTranslateResolve = DoTranslate;
}
/**
* Searches in the dictionary for a specific keyword and returns the message linked to it

View file

@ -10,6 +10,9 @@ var ActivityOrgasmGameTimer = 0;
var ActivityOrgasmResistLabel = "";
var ActivityOrgasmRuined = false; // If set to true, the orgasm will be ruined right before it happens
/** @type { ()=>void | undefined } */
let ActivityTranslateResolve = undefined;
/**
* Checks if the current room allows for activities. (They can only be done in certain rooms)
* @returns {boolean} - Whether or not activities can be done
@ -36,6 +39,7 @@ function ActivityDictionaryLoad() {
if (this.status == 200) {
CommonCSVCache[FullPath] = CommonParseCSV(this.responseText);
ActivityDictionary = CommonCloneDeep(CommonCSVCache[FullPath]);
ActivityTranslateResolve?.();
}
});
}
@ -56,15 +60,18 @@ function ActivityDictionaryLoad() {
*/
function ActivityTranslate(CachePath) {
if (!Array.isArray(TranslationCache[CachePath])) return;
for (let T = 0; T < ActivityDictionary.length; T++) {
if (ActivityDictionary[T][1]) {
let indexText = TranslationCache[CachePath].indexOf(ActivityDictionary[T][1].trim());
if (indexText >= 0) {
ActivityDictionary[T][1] = TranslationCache[CachePath][indexText + 1];
const DoTranslate = () => {
for (let T = 0; T < ActivityDictionary.length; T++) {
if (ActivityDictionary[T][1]) {
let indexText = TranslationCache[CachePath].indexOf(ActivityDictionary[T][1].trim());
if (indexText >= 0) {
ActivityDictionary[T][1] = TranslationCache[CachePath][indexText + 1];
}
}
}
}
};
if(ActivityDictionary) DoTranslate();
else ActivityTranslateResolve = DoTranslate;
}
/**