mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-02-17 07:56:24 +00:00
Refactor code structure for improved readability and maintainability (#473)
* Add ToolTips to Tweaks
This commit is contained in:
31
Scripts/FileIO/LoadSettings.ps1
Normal file
31
Scripts/FileIO/LoadSettings.ps1
Normal file
@@ -0,0 +1,31 @@
|
||||
# Loads settings from a JSON file and adds them to script params
|
||||
function LoadSettings {
|
||||
param (
|
||||
[string]$filePath,
|
||||
[string]$expectedVersion = "1.0"
|
||||
)
|
||||
|
||||
$settingsJson = LoadJsonFile -filePath $filePath -expectedVersion $expectedVersion
|
||||
|
||||
if (-not $settingsJson -or -not $settingsJson.Settings) {
|
||||
throw "Failed to load settings from $(Split-Path $filePath -Leaf)"
|
||||
}
|
||||
|
||||
# Get current Windows build version
|
||||
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
|
||||
|
||||
foreach ($setting in $settingsJson.Settings) {
|
||||
if ($setting.Value -eq $false) {
|
||||
continue
|
||||
}
|
||||
|
||||
$feature = $script:Features[$setting.Name]
|
||||
|
||||
# Check version and feature compatibility using Features.json
|
||||
if (($feature.MinVersion -and $WinVersion -lt $feature.MinVersion) -or ($feature.MaxVersion -and $WinVersion -gt $feature.MaxVersion) -or ($feature.FeatureId -eq 'DisableModernStandbyNetworking' -and (-not $script:ModernStandbySupported))) {
|
||||
continue
|
||||
}
|
||||
|
||||
AddParameter $setting.Name $setting.Value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user