Explain how to initialize missing MPC-HC settings
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-10-19 15:51:25 +02:00
parent 8accc26b43
commit 2ddd18bdd4
7 changed files with 44 additions and 3 deletions

View File

@ -142,3 +142,4 @@ open until it is run on disposable machines with the required account setups.
- [x] Reduce Ontime countdown/message sizing by 30%, enlarge the clock, and bottom-align fullscreen messages; preview both layouts in Firefox.
- [x] Verify the shared MPC-HC x86/x64 registry target and block apply while either player is running to prevent settings being overwritten on exit.
- [x] Hide Ontime clock seconds and slow background blink to a three-second fade with a steady reduced-motion fallback.
- [x] Explain first-launch/registry-mode steps for missing MPC-HC capture settings and key-creation failures without suppressing the underlying error.

View File

@ -28,6 +28,11 @@ views; do not add a speculative Wow6432Node or "MPC-HC x64" target.
See [MPC-HC's settings store](https://github.com/clsid2/mpc-hc/blob/develop/src/mpc-hc/Profile.cpp)
and [Windows registry sharing rules](https://learn.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys).
Apply attempts to create missing registry keys automatically. If Windows rejects
key creation, launch MPC-HC once, save settings in Windows registry mode, close
it, and retry; the error also retains the Windows diagnostic. Capture cannot
export settings that do not exist and gives the same first-launch guidance.
Close **both** `mpc-hc.exe` and `mpc-hc64.exe` before applying. The adapter refuses
writes while either process is running, to prevent an open player from saving
stale settings over the new values. If the two players still differ, check each

View File

@ -198,7 +198,12 @@ function Set-RegistryDeclaration {
}
foreach ($entry in $Declaration.values) {
$path = if ([string]::IsNullOrWhiteSpace([string]$entry.path)) { $Root } else { Join-Path $Root $entry.path }
if (-not (Test-Path -LiteralPath $path)) { [void](New-Item -Path $path -ErrorAction Stop) }
if (-not (Test-Path -LiteralPath $path)) {
try { [void](New-Item -Path $path -ErrorAction Stop) }
catch {
throw "Could not create MPC-HC settings key '$path'. Launch MPC-HC once, save its settings in Windows registry mode, then close both MPC-HC versions and retry. Check permissions if it still fails. Windows reported: $($_.Exception.Message)"
}
}
$value = switch ($entry.type) {
'DWord' { if ($entry.value -lt 0) { [int32]$entry.value } else { [uint32]$entry.value } }
'QWord' { if ($entry.value -lt 0) { [int64]$entry.value } else { [uint64]$entry.value } }

View File

@ -145,7 +145,10 @@ function Export-ConfigCapture {
foreach ($config in $selectedConfigs) {
$location = $locations | Where-Object name -eq $config.name | Select-Object -First 1
if (-not $location.targetExists) {
$operations.Add([pscustomobject]@{ kind = 'config'; name = $config.name; status = 'Missing'; message = "Computer source is absent: $($location.target)" })
$missingMessage = if ($config.name -eq 'mpc-hc-settings' -and $config.mode -eq 'registry') {
'MPC-HC has no registry settings to capture. Launch MPC-HC, save its settings in Windows registry mode, close both MPC-HC versions, then rerun cc capture.'
} else { "Computer source is absent: $($location.target)" }
$operations.Add([pscustomobject]@{ kind = 'config'; name = $config.name; status = 'Missing'; message = $missingMessage })
continue
}
if ($config.mode -eq 'copy') {

View File

@ -138,3 +138,19 @@ Describe 'MPC-HC running player protection' {
}
}
}
Describe 'Missing MPC-HC settings guidance' {
It 'explains first launch and retains the key-creation error' {
InModuleScope Adapters {
Mock Get-Process { $null }
Mock Test-Path { $false }
Mock New-Item { throw 'Access denied' }
Mock New-ItemProperty {}
$declaration = [pscustomobject]@{ values = @(
[pscustomobject]@{ path = ''; name = 'Volume'; type = 'DWord'; value = 80 }
) }
{ Set-RegistryDeclaration -Root 'TestRoot' -Declaration $declaration } | Should -Throw '*Launch MPC-HC once*Access denied*'
Should -Invoke New-ItemProperty -Times 0
}
}
}

View File

@ -120,6 +120,17 @@ Describe 'Configuration deployment' {
$result.message | Should -Be 'Registry access denied'
}
It 'explains how to initialize missing MPC-HC settings for capture' {
Mock Get-RepositoryRevision { 'abc123' } -ModuleName Configs
Mock Get-ConfigLocations {
[pscustomobject]@{ name = 'mpc-hc-settings'; targetExists = $false; target = 'HKCU:\Software\MPC-HC\MPC-HC' }
} -ModuleName Configs
$config = [pscustomobject]@{ name = 'mpc-hc-settings'; mode = 'registry' }
$result = Export-ConfigCapture -Configs @($config) -RepositoryRoot $repo -Settings $settings -Machine test -OutputPath (Join-Path $caseRoot 'missing-capture')
$result.operations[0].status | Should -Be 'Missing'
$result.operations[0].message | Should -Match 'Launch MPC-HC.*close both MPC-HC versions'
}
It 'refuses unsafe automatic restoration of registry and hosts backups' {
$registryState = @{ configs = @{ 'mpc-hc-settings' = @{ mode = 'registry'; target = 'HKCU:\Software\MPC-HC\MPC-HC' } } }
{ Restore-ConfigBackup -Name mpc-hc-settings -Paths $paths -State $registryState } | Should -Throw '*not supported for registry*'

View File

@ -33,7 +33,7 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$rootPath = 'HKCU:\Software\MPC-HC\MPC-HC'
if (-not (Test-Path -LiteralPath $rootPath)) { throw "MPC-HC registry settings were not found at '$rootPath'. Start MPC-HC and save its settings first." }
if (-not (Test-Path -LiteralPath $rootPath)) { throw "MPC-HC registry settings were not found at '$rootPath'. Launch MPC-HC, save its settings in Windows registry mode, close both MPC-HC versions, then retry capture." }
function Test-PrivateMpcHcSetting {
param([string]$RelativePath, [string]$Name, $Value)