Open SadPencil opened 6 months ago
The following lines show an example to write game registries. I suggest run this code every single time the map editor (from Steam) starts. This is because there might be multiple game installation instances, as a result, we have to register the game every single time to tell the map editor the right InstallPath
. -- yeah registry is a bad design
using var HKLM_32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
using var ra2Key = HKLM_32.CreateSubKey(@"SOFTWARE\Westwood\Red Alert 2");
// ra2Key.SetValue("Serial", sn);
// ra2Key.SetValue("Name", "Red Alert 2");
ra2Key.SetValue("InstallPath", Path.Combine(p.GameDir, "RA2.EXE"));
// ra2Key.SetValue("SKU", 8448);
// ra2Key.SetValue("Version", 65542);
using var yrKey = HKLM_32.CreateSubKey(@"SOFTWARE\Westwood\Yuri's Revenge");
// yrKey.SetValue("Serial", sn);
// yrKey.SetValue("Name", "Yuri's Revenge");
yrKey.SetValue("InstallPath", Path.Combine(p.GameDir, "RA2MD.EXE"));
// yrKey.SetValue("SKU", 10496);
// yrKey.SetValue("Version", 65537);
Updating the game registry requires admin privilege so it's probably not a good idea. I think we can just make FinalSunSettings.WriteFinalSunIni()
optional -- it's only meaningful for legacy map editors
I summarized the changes below.
FinalSun.ini
andFinalAlert.ini
now uses UTF-8 encoding instead of the old ANSI (note: ANSI does not refer to any specific encoding! )FinalSun.ini
andFinalAlert.ini
now resides in both map editor folder and%localappdata%\FinalSun\FinalSun.ini
/%localappdata%\FinalAlert 2\FinalAlert.ini
The client needs these change:
Make
FinalSunSettings.WriteFinalSunIni()
optional. The option should be enabled when modders distribute the legacy FinalSun/Final Alert 2. If they choose the new FinalSun/Final Alert 2 comes with Steam, or WorldAlteringEditor, this option should be disabled.Differ
WriteInstallPathToRegistry()
from game registry. TS/RA2 writes the game path to registry in WOW6432Node view, while the client writes the registry in normal view and it is not intended for registering the game. Since the new map editors from steam reads the game path (in WOW6432Node), the client should probably writes the game path in WOW6432View if a new option is enabled