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`.
This commit is contained in:
Sandro642 2024-10-24 18:00:00 +02:00
parent ae9e7b54b0
commit fc5a2d4b8d
3 changed files with 29 additions and 5 deletions

View File

@ -22,7 +22,7 @@ class AthenaShield {
} }
// Récupérer la visibilité du menu // Récupérer la visibilité du menu
get view() { get type() {
return this.config.menuVisibility return this.config.menuVisibility
} }
} }

View File

@ -31,7 +31,6 @@ const {
const DiscordWrapper = require('./assets/js/discordwrapper') const DiscordWrapper = require('./assets/js/discordwrapper')
const ProcessBuilder = require('./assets/js/processbuilder') const ProcessBuilder = require('./assets/js/processbuilder')
const dataPath = require('./assets/js/configmanager') const dataPath = require('./assets/js/configmanager')
const athShield = require('./assets/athshield/parserAthShield')
const fs = require('fs') const fs = require('fs')
// Launch Elements // Launch Elements

View File

@ -1,8 +1,9 @@
// Requirements // Requirements
const os = require('os') const os = require('os')
const semver = require('semver') 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 { MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR } = require('./assets/js/ipcconstants')
const settingsState = { const settingsState = {
@ -707,6 +708,29 @@ document.getElementById('settingsGameHeight').addEventListener('keydown', (e) =>
const settingsModsContainer = document.getElementById('settingsModsContainer') 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. * Resolve and update the mods on the UI.
*/ */
@ -1130,6 +1154,7 @@ function animateSettingsTabRefresh(){
* Prepare the Mods tab for display. * Prepare the Mods tab for display.
*/ */
async function prepareModsTab(first){ async function prepareModsTab(first){
manageModCategory()
await resolveModsForUI() await resolveModsForUI()
await resolveDropinModsForUI() await resolveDropinModsForUI()
await resolveShaderpacksForUI() await resolveShaderpacksForUI()