mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-12 02:51:16 +10:00
Make MPO tweak a three-state control (#4897)
* refactor: make MPO tweak a three-state control * docs: explain MPO tweak states * docs: address code review comments * refactor: make Multiplane Overlay config-driven
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
function Get-WinUtilRegistryComboState {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Finds the configured combo-box state matching the current registry values.
|
||||
|
||||
.PARAMETER Registry
|
||||
Registry settings containing a value mapping for each supported state.
|
||||
|
||||
.OUTPUTS
|
||||
The name of the matching state.
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
$Registry
|
||||
)
|
||||
|
||||
foreach ($state in $Registry[0].Values.PSObject.Properties) {
|
||||
$stateMatches = $true
|
||||
foreach ($setting in @($Registry)) {
|
||||
$currentValue = Get-WinUtilRegistryComboValue -Setting $setting
|
||||
$actualValue = if ($currentValue.Exists -and $null -ne $currentValue.Value) { $currentValue.Value } else { $setting.DefaultValue }
|
||||
$configuredValue = $setting.Values.PSObject.Properties[$state.Name].Value
|
||||
# Removal represents the effective Windows default when matching the current state.
|
||||
$expectedValue = if ($configuredValue -eq "<RemoveEntry>") { $setting.DefaultValue } else { $configuredValue }
|
||||
if ([string]$actualValue -ne [string]$expectedValue) {
|
||||
$stateMatches = $false
|
||||
break
|
||||
}
|
||||
}
|
||||
if ($stateMatches) {
|
||||
return $state.Name
|
||||
}
|
||||
}
|
||||
|
||||
throw "Registry values do not match a supported state."
|
||||
}
|
||||
Reference in New Issue
Block a user