From d3db66a8af39a094bbd21b2972c1daa14ee80628 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 17 Dec 2016 17:13:27 +0000 Subject: [PATCH] Support multiple registry path prefixes. --- OpenRA.Mods.Common/ModContent.cs | 1 + .../Logic/Installation/InstallFromDiscLogic.cs | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/ModContent.cs b/OpenRA.Mods.Common/ModContent.cs index b3d5836f93..306647deec 100644 --- a/OpenRA.Mods.Common/ModContent.cs +++ b/OpenRA.Mods.Common/ModContent.cs @@ -43,6 +43,7 @@ namespace OpenRA public readonly SourceType Type = SourceType.Disc; // Used to find installation locations for SourceType.Install + public readonly string[] RegistryPrefixes = { string.Empty }; public readonly string RegistryKey; public readonly string RegistryValue; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs index 549f06ef58..6579952a74 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromDiscLogic.cs @@ -481,11 +481,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (Platform.CurrentPlatform != PlatformType.Windows) return null; - var path = Microsoft.Win32.Registry.GetValue(source.RegistryKey, source.RegistryValue, null) as string; - if (path == null) - return null; + foreach (var prefix in source.RegistryPrefixes) + { + var path = Microsoft.Win32.Registry.GetValue(prefix + source.RegistryKey, source.RegistryValue, null) as string; + if (path == null) + continue; - return IsValidSourcePath(path, source) ? path : null; + return IsValidSourcePath(path, source) ? path : null; + } + + return null; } if (source.Type == ModContent.SourceType.Disc)