Example #1
0
        /*public IList<string> GetSaveGamePathForGroup()
         * {
         *  return GetSaveGamePathForGroup(AvailableGroups);
         * }*/

        public IList <string> GetSaveGamePathForGroup(long grp)
        {
            List <string> list = new List <string>();

            foreach (long g in savgamemap.Keys)
            {
                if ((g & grp) == 0)
                {
                    continue;
                }
                Ambertation.CaseInvariantArrayList ps = savgamemap[g];
                if (ps == null)
                {
                    continue;
                }
                foreach (string s in ps)
                {
                    if (!list.Contains(Helper.CompareableFileName(s)))
                    {
                        list.Add(Helper.CompareableFileName(s));
                    }
                }
            }

            return(list.AsReadOnly());
        }
Example #2
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);
        }
Example #3
0
 internal void AddSaveGamePaths(Ambertation.CaseInvariantArrayList realsavegames)
 {
     foreach (string s in savegames)
     {
         string pt = GetRealPath(s);
         if (System.IO.Directory.Exists(pt))
         {
             realsavegames.Add(pt);
         }
     }
 }
Example #4
0
        public long SaveGamePathProvidedByGroup(string path)
        {
            path = Helper.CompareableFileName(path);
            foreach (long grp in savgamemap.Keys)
            {
                Ambertation.CaseInvariantArrayList ps = savgamemap[grp];
                foreach (string s in ps)
                {
                    if (path.StartsWith(Helper.CompareableFileName(s)))
                    {
                        return(grp);
                    }
                }
            }

            return(0);
        }
Example #5
0
        private void CreateSaveGameMap()
        {
            foreach (ExpansionItem ei in exps)
            {
                foreach (long grp in ei.Groups)
                {
                    Ambertation.CaseInvariantArrayList list;
                    if (savgamemap.ContainsKey(grp))
                    {
                        list = savgamemap[grp];
                    }
                    else
                    {
                        list            = new Ambertation.CaseInvariantArrayList();
                        savgamemap[grp] = list;
                    }

                    ei.AddSaveGamePaths(list);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Adds a Folder to the list of FileTable Folders
        /// </summary>
        /// <param name="list">List to add to</param>
        /// <param name="fodler">The folder to add</param>
        /// <remarks>Use <code>&lt;</code> to insert a folder at the beginning of the specific list</remarks>
        /// <param name="folder"></param>
        void AddFileTableFolder(Ambertation.CaseInvariantArrayList list, string folder)
        {
            bool begin = false;

            if (folder.StartsWith("<"))
            {
                folder = folder.Substring(1);
                begin  = true;
            }

            if (!list.Contains(folder))
            {
                if (begin)
                {
                    list.Insert(0, folder);
                }
                else
                {
                    list.Add(folder);
                }
            }
        }
Example #7
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();
        }