Exemple #1
0
        protected static void Load()
        {
            ArrayList list = new ArrayList();

            XmlRegistryKey rk = Helper.WindowsRegistry.RegistryKey.CreateSubKey("ExtTools");

            string[] names = rk.GetSubKeyNames();

            foreach (string name in names)
            {
                string         rname = ToolLoaderItemExt.SplitName(name);
                XmlRegistryKey srk   = rk.CreateSubKey(name);

                ToolLoaderItemExt tli = new ToolLoaderItemExt(rname);
                tli.Type = Convert.ToUInt32(srk.GetValue("type"));
                //tli.Name = Convert.ToString(srk.GetValue("name"));
                tli.FileName   = Convert.ToString(srk.GetValue("filename"));
                tli.Attributes = Convert.ToString(srk.GetValue("attributes"));

                list.Add(tli);
            }

            items = new ToolLoaderItemExt[list.Count];
            list.CopyTo(items);
        }
Exemple #2
0
        /// <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>");
            }
        }
Exemple #3
0
        /// <summary>
        /// Parse a certain SubNode Level of the XML File
        /// </summary>
        /// <param name="node">The current Node</param>
        /// <param name="key">The current SubTree</param>
        /// <param name="caseinvariant">true if you want a case Invariant List</param>
        void ParseListNode(XmlNode node, XmlRegistryKey key, bool caseinvariant)
        {
            XmlRegistryKey subkey = new XmlRegistryKey();
            ArrayList      names  = new ArrayList();

            foreach (XmlNode subnode in node)
            {
                if (subnode.Attributes == null)
                {
                    continue;
                }
                names.Add(subnode.Attributes["name"].Value);
                ParseValues(subnode, subkey);
            }

            ArrayList list = null;

            if (!caseinvariant)
            {
                list = new ArrayList();
            }
            else
            {
                list = new Ambertation.CaseInvariantArrayList();
            }

            foreach (string s in names)
            {
                list.Add(subkey.GetValue(s));
            }

            key.SetValue(node.Attributes["name"].Value, list);
        }
Exemple #4
0
        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();
        }