diff --git a/Codes.xml b/Codes.xml index ec50375..d860fb8 100644 --- a/Codes.xml +++ b/Codes.xml @@ -751,6 +751,7 @@ timer standard,recommended,il + loader Shine Get Timer Shine Get Timer Chronomètre Shine Get diff --git a/scripts/inject_codes.js b/scripts/inject_codes.js index 2eee52c..b9ba465 100644 --- a/scripts/inject_codes.js +++ b/scripts/inject_codes.js @@ -287,6 +287,7 @@ const parseXml = (xmlString, gameVersion = null) => { source: readCode(code, 'source', gameVersion), presets: readPresetList(code, gameVersion), category: readTextNode(code, 'category'), + dependsOn: code.querySelector('depends-on')?.textContent ?? null, })) .filter((code) => code.source != null); }; diff --git a/site/.vuepress/components/CodeList.vue b/site/.vuepress/components/CodeList.vue index 05047c1..c9fabb5 100644 --- a/site/.vuepress/components/CodeList.vue +++ b/site/.vuepress/components/CodeList.vue @@ -87,8 +87,8 @@ export default { } this.unselectStageLoader(); - this.onSelectionChanged(this.availableCodes.filter((c) => c.selected)); this.refreshDisabledCodes(); + this.onSelectionChanged(this.availableCodes.filter((c) => c.selected)); this.generation++; }, getPresetPlaceholder() { @@ -117,23 +117,21 @@ export default { const newState = !this.stageLoaderSelected; this.stageLoaderSelected = newState; this.onStageLoaderToggle(newState); - this.onSelectionChanged(this.availableCodes.filter((c) => c.selected)); this.refreshDisabledCodes(); + this.onSelectionChanged(this.availableCodes.filter((c) => c.selected)); }, refreshDisabledCodes() { - for (const dependentCategory of codeCategories.filter((c) => c.dependsOn.length > 0)) { - for (const dependency of dependentCategory.dependsOn) { - const enableCodes = - (dependency === 'loader' && this.stageLoaderSelected) || - this.availableCodes.find((c) => c.selected && c.category === dependency); - - for (const code of this.availableCodes.filter( - (c) => c.category === dependentCategory.identifier && c.disabled !== !enableCodes, - )) { - code.disabled = !enableCodes; - if (code.disabled && code.selected) { - this.toggle(code); - } + for (const code of this.availableCodes) { + if (code.dependsOn) { + if (code.dependsOn === 'loader' && this.stageLoaderSelected) { + code.disabled = false; + } else if ( + !this.availableCodes.some((c) => c.selected && c.category === code.dependsOn) + ) { + code.disabled = true; + code.selected = false; + } else { + code.disabled = false; } } } @@ -153,8 +151,8 @@ export default { } code.selected = code.disabled ? false : !code.selected; - this.onSelectionChanged(this.availableCodes.filter((c) => c.selected)); this.refreshDisabledCodes(); + this.onSelectionChanged(this.availableCodes.filter((c) => c.selected)); }, populate() { this.availableCodes = this.codes.map((c) => ({ ...c, selected: false })); diff --git a/site/.vuepress/data/codeCategories.json b/site/.vuepress/data/codeCategories.json index 81903a9..3a401c3 100644 --- a/site/.vuepress/data/codeCategories.json +++ b/site/.vuepress/data/codeCategories.json @@ -2,37 +2,31 @@ { "identifier": "qol", "i18nKey": "generatorconfig.categories.qol", - "exclusive": false, - "dependsOn": [] + "exclusive": false }, { "identifier": "loader", "i18nKey": "generatorconfig.categories.loader", - "exclusive": true, - "dependsOn": [] + "exclusive": true }, { "identifier": "timer", "i18nKey": "generatorconfig.categories.timer", - "exclusive": false, - "dependsOn": ["loader"] + "exclusive": false }, { "identifier": "misc", "i18nKey": "generatorconfig.categories.misc", - "exclusive": false, - "dependsOn": [] + "exclusive": false }, { "identifier": "memcardpatch", "i18nKey": "generatorconfig.categories.memcardpatch", - "exclusive": true, - "dependsOn": [] + "exclusive": true }, { "identifier": "cosmetic", "i18nKey": "generatorconfig.categories.cosmetic", - "exclusive": false, - "dependsOn": [] + "exclusive": false } ]