From fc5a2d4b8d04cd29e52cbeb8da77602229ac268f Mon Sep 17 00:00:00 2001 From: Sandro642 Date: Thu, 24 Oct 2024 18:00:00 +0200 Subject: [PATCH] Rename view method to type and integrate athShield in settings Renamed the `view` method to `type` in parserAthShield.js to better reflect its purpose. Removed unused `athShield` import from landing.js and added it to settings.js. Added a manageModCategory function in settings.js to manage the display and interaction state of the Mods tab based on the type of `athShield`. --- app/assets/athshield/parserAthShield.js | 2 +- app/assets/js/scripts/landing.js | 1 - app/assets/js/scripts/settings.js | 31 ++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/assets/athshield/parserAthShield.js b/app/assets/athshield/parserAthShield.js index 8a166733..de3c9a6c 100644 --- a/app/assets/athshield/parserAthShield.js +++ b/app/assets/athshield/parserAthShield.js @@ -22,7 +22,7 @@ class AthenaShield { } // Récupérer la visibilité du menu - get view() { + get type() { return this.config.menuVisibility } } diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index 058d1bd8..e23b0c43 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -31,7 +31,6 @@ const { const DiscordWrapper = require('./assets/js/discordwrapper') const ProcessBuilder = require('./assets/js/processbuilder') const dataPath = require('./assets/js/configmanager') -const athShield = require('./assets/athshield/parserAthShield') const fs = require('fs') // Launch Elements diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 81a65a70..96d956f9 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -1,8 +1,9 @@ // Requirements -const os = require('os') -const semver = require('semver') +const os = require('os') +const semver = require('semver') -const DropinModUtil = require('./assets/js/dropinmodutil') +const DropinModUtil = require('./assets/js/dropinmodutil') +const athShield = require('./assets/athshield/parserAthShield') const { MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR } = require('./assets/js/ipcconstants') const settingsState = { @@ -707,6 +708,29 @@ document.getElementById('settingsGameHeight').addEventListener('keydown', (e) => const settingsModsContainer = document.getElementById('settingsModsContainer') +/** + * Manages the display and interaction state of the Mods tab and its buttons based on the type of `athShield`. + * + * The function performs the following: + * - If `athShield.type` is 'hidden': hides the Mods button entirely. + * - If `athShield.type` is 'blocked': shows the Mods button, displays the Mods tab, and disables all buttons within the Mods tab. + * - Otherwise: shows and enables all components (Mods button and buttons within the Mods tab) normally. + * + * @return {void} + */ +function manageModCategory() { + const modsButton = document.querySelector('button[rSc="settingsTabMods"]') + const dropInMods = document.getElementById('settingsDropinModsContainer') + + if (athShield.type === 'hidden') { + // Hide the Mods navigation button + modsButton.style.display = 'none' + } else if (athShield.type === 'blocked') { + // Hide the drop-in mods elements + dropInMods.style.display = 'none' + } +} + /** * Resolve and update the mods on the UI. */ @@ -1130,6 +1154,7 @@ function animateSettingsTabRefresh(){ * Prepare the Mods tab for display. */ async function prepareModsTab(first){ + manageModCategory() await resolveModsForUI() await resolveDropinModsForUI() await resolveShaderpacksForUI()