/// <summary> /// Write a SubKey /// </summary> /// <param name="sw"></param> /// <param name="key"></param> void WriteKey(System.IO.StreamWriter sw, XmlRegistryKey key) { if (key != root) { sw.WriteLine("<key name=\"" + key.Name + "\">"); } string[] keys = key.GetSubKeyNames(); foreach (string s in keys) { WriteKey(sw, key.OpenSubKey(s, false)); } string[] values = key.GetValueNames(); foreach (string s in values) { WriteValue(sw, s, key.GetValue(s)); } if (key != root) { sw.WriteLine("</key>"); } }
internal ExpansionItem(XmlRegistryKey key) { filtablefolders = new Ambertation.CaseInvariantArrayList(); preobjectfiltablefolders = new Ambertation.CaseInvariantArrayList(); shortname = "Unk."; shortername = "Unknown"; longname = "The Sims 2 - Unknown"; namelistnr = "0"; if (key != null) { name = key.Name; ; XmlRegistryKey lang = key.OpenSubKey(System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLower(), false); if (lang == null) { lang = key.OpenSubKey(System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName.ToLower(), false); } version = (int)key.GetValue("Version", 0); runtimeversion = (int)key.GetValue("PreferedRuntimeVersion", version); exp = (Expansions)(Math.Pow(2, version)); int isnum = -1; object o = key.GetValue("RegKey", null); if (o is string) { rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey((string)o, false); } else if (o is Ambertation.CaseInvariantArrayList) { foreach (string s in (Ambertation.CaseInvariantArrayList)o) { isnum++; rk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(s, false); if (rk != null) { break; } } } if (rk == null) { isnum = -1; } o = key.GetValue("InstallSuffix", null); if (o is string) { installsuffix = (string)o; } else if (o is Ambertation.CaseInvariantArrayList && isnum >= 0 && isnum < ((Ambertation.CaseInvariantArrayList)o).Count) { installsuffix = (string)((Ambertation.CaseInvariantArrayList)o)[isnum]; } exe = (string)key.GetValue("ExeName", "Sims2.exe"); flag = new Flags((int)key.GetValue("Flag", 0)); censor = (string)key.GetValue("Censor", ""); group = (int)key.GetValue("Group", 1); objfolder = (string)key.GetValue("ObjectsFolder", "TSData" + Helper.PATH_SEP + "Res" + Helper.PATH_SEP + "Objects"); simnamedeep = (Ambertation.CaseInvariantArrayList)key.GetValue("SimNameDeepSearch", new Ambertation.CaseInvariantArrayList()); savegames = (Ambertation.CaseInvariantArrayList)key.GetValue("SaveGameLocationsForGroup", new Ambertation.CaseInvariantArrayList()); if (savegames.Count == 0) { savegames.Add(PathProvider.SimSavegameFolder); } Ambertation.CaseInvariantArrayList ftf = (Ambertation.CaseInvariantArrayList)key.GetValue("FileTableFolders", new Ambertation.CaseInvariantArrayList()); if (ftf.Count == 0) { SetDefaultFileTableFolders(); } else { foreach (string folder in ftf) { AddFileTableFolder(folder); } } ftf = (Ambertation.CaseInvariantArrayList)key.GetValue("AdditionalFileTableFolders", new Ambertation.CaseInvariantArrayList()); foreach (string folder in ftf) { AddFileTableFolder(folder); } System.Diagnostics.Debug.WriteLine(this.ToString()); namelistnr = (string)key.GetValue("namelistnr", "0"); string dname = name; if (lang != null) { shortname = (string)lang.GetValue("short", name); shortername = (string)lang.GetValue("name", shortname); if (rk != null) { dname = (string)rk.GetValue("DisplayName", shortername); } longname = (string)lang.GetValue("long", dname); } else //1. check the resource files, then try default language, then set to defaults { if (lang == null) { lang = key.OpenSubKey("en", false); } shortname = SimPe.Localization.GetString("EP SNAME " + version); shortername = shortname; if (shortname == "EP SNAME " + version && lang != null) { shortname = (string)lang.GetValue("short", name); shortername = (string)lang.GetValue("name", shortname); } if (shortname == "EP SNAME " + version) { shortname = name; } if (rk != null) { dname = (string)rk.GetValue("DisplayName", shortername); } longname = SimPe.Localization.GetString("EP NAME " + version); if (longname == "EP NAME " + version && lang != null) { longname = (string)lang.GetValue("long", dname); } if (longname == "EP NAME " + version) { longname = dname; } } } else { name = "NULL"; flag = new Flags(0); censor = ""; exe = ""; exp = (Expansions)0; version = -1; runtimeversion = -1; simnamedeep = new Ambertation.CaseInvariantArrayList(); savegames = new Ambertation.CaseInvariantArrayList(); savegames.Add(PathProvider.SimSavegameFolder); SetDefaultFileTableFolders(); objfolder = "TSData" + Helper.PATH_SEP + "Res" + Helper.PATH_SEP + "Objects"; group = 0; } BuildGroupList(); sname = GetShortName(); }
void Load() { censorfiles.Add(System.IO.Path.Combine(SimSavegameFolder, @"Downloads\quaxi_nl_censor_v1.package")); censorfiles.Add(System.IO.Path.Combine(SimSavegameFolder, @"Downloads\quaxi_nl_censor.package")); string[] names = xrk.GetSubKeyNames(); int ver = -1; avlgrp = 0; System.Diagnostics.Debug.WriteLine("\r\n----\r\nExpansionItems"); foreach (string name in names) { ExpansionItem i = new ExpansionItem(xrk.OpenSubKey(name, false)); exps.Add(i); map[i.Expansion] = i; if (i.Flag.Class == ExpansionItem.Classes.Story) { continue; } if (i.CensorFile != "") { string fl = System.IO.Path.Combine(SimSavegameFolder, @"Downloads\" + i.CensorFileName); if (!censorfiles.Contains(fl)) { censorfiles.Add(fl); } fl = System.IO.Path.Combine(SimSavegameFolder, @"Config\" + i.CensorFileName); if (!censorfiles.Contains(fl)) { censorfiles.Add(fl); } } if (i.Version > ver) { ver = i.Version; lastknown = i.Expansion; } avlgrp = avlgrp | (uint)i.Group; } System.Diagnostics.Debug.WriteLine("----\r\n"); spver = GetMaxVersion(ExpansionItem.Classes.StuffPack); epver = GetMaxVersion(ExpansionItem.Classes.ExpansionPack); stver = GetMaxVersion(ExpansionItem.Classes.Story); latest = this.GetLatestExpansion(); exps.Sort(); CreateSaveGameMap(); paths = new List <string>(); foreach (ExpansionItem ei in exps) { if (ei.Exists) { if (System.IO.Directory.Exists(ei.InstallFolder)) { paths.Add(ei.InstallFolder); } } } }