Esempio n. 1
0
        public void PopulateRegistryWithInstances()
        {
            var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\CKAN");

            if (key == null)
            {
                Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\CKAN");
            }

            KSPPathConstants.SetRegistryValue(@"KSPAutoStartInstance", _AutoStartInstance ?? "");
            KSPPathConstants.SetRegistryValue(@"KSPInstanceCount", _Instances.Count);

            int i = 0;

            foreach (var instance in _Instances)
            {
                var name = instance.Key;
                var ksp  = instance.Value;

                KSPPathConstants.SetRegistryValue(@"KSPInstanceName_" + i, name);
                KSPPathConstants.SetRegistryValue(@"KSPInstancePath_" + i, ksp.GameDir());

                i++;
            }
        }
Esempio n. 2
0
        public void LoadInstancesFromRegistry()
        {
            log.Debug("Loading KSP instances from registry");

            _Instances.Clear();

            var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\CKAN");

            if (key == null)
            {
                Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\CKAN");
            }

            _AutoStartInstance = KSPPathConstants.GetRegistryValue(@"KSPAutoStartInstance", "");
            var instanceCount = KSPPathConstants.GetRegistryValue(@"KSPInstanceCount", 0);

            for (int i = 0; i < instanceCount; i++)
            {
                var name = KSPPathConstants.GetRegistryValue(@"KSPInstanceName_" + i, "");
                var path = KSPPathConstants.GetRegistryValue(@"KSPInstancePath_" + i, "");

                log.DebugFormat("Loading {0} from {1}", name, path);
                if (KSP.IsKspDir(path))
                {
                    _Instances.Add(name, new KSP(path, User));
                    log.DebugFormat("Added {0} at {1}", name, path);
                }
                else
                {
                    log.DebugFormat("{0} at {1} is not a vaild install", name, path);
                }
            }

            instances_loaded = true;
        }