示例#1
0
        /// <summary>
        /// Loads all package Files in the directory and scans them for Name Informations
        /// </summary>
        public void LoadOpcodes()
        {
            names = new ArrayList();
            if (BasePackage == null)
            {
                return;
            }

            //IPackedFileDescriptor pfd = BasePackage.FindFile(Data.MetaData.STRING_FILE, 0x00000000, 0x7FE59FD0, 0x0000008B);
            FileTable.FileIndex.Load();
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = SimPe.FileTable.FileIndex.FindFile(Data.MetaData.STRING_FILE, 0x7FE59FD0, 0x000000000000008B, null);
            SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();

            foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
            {
                str.ProcessData(item.FileDescriptor, BasePackage);

                for (ushort i = 0; i < str.Items.Length; i++)
                {
                    SimPe.PackedFiles.Wrapper.StrToken si = str.Items[i];

                    if (si.Language.Id == 1)
                    {
                        names.Add(si.Title);
                    }
                }                       //for
            }
        }
示例#2
0
        private static string LoadLabel(SimPe.Packages.File pk, out NeighborhoodType type)
        {
            string name = SimPe.Localization.GetString("Unknown");

            type = NeighborhoodType.Unknown;
            try
            {
                SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pk.FindFile(0x43545353, 0, 0xffffffff, 1);
                if (pfd != null)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(pfd, pk);
                    name = str.LanguageItems(new SimPe.PackedFiles.Wrapper.StrLanguage((byte)Data.MetaData.Languages.English))[0].Title;
                }

                pfd = pk.FindFile(0xAC8A7A2E, 0, 0xffffffff, 1);
                if (pfd != null)
                {
                    SimPe.Plugin.Idno idno = new Idno();
                    idno.ProcessData(pfd, pk);
                    type = idno.Type;
                }
                //pk.Reader.Close();
            }
            finally
            {
                //pk.Reader.Close();
            }
            return(name);
        }
示例#3
0
        protected ArrayList LoadStrLinked(SimPe.Interfaces.Files.IPackageFile pkg, CloneSettings.StrIntsanceAlias instance)
        {
            ArrayList list = new ArrayList();

            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.STRING_FILE, 0, instance.Instance);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, pkg);
                foreach (SimPe.PackedFiles.Wrapper.StrToken si in str.Items)
                {
                    string name = Hashes.StripHashFromName(si.Title).Trim();
                    if (name == "")
                    {
                        continue;
                    }

                    name += instance.Extension;
                    //Console.WriteLine("Str Linked: "+name);
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii = FileTable.FileIndex.FindFileByName(name, instance.Type, Hashes.GetHashGroupFromName(si.Title, Data.MetaData.GLOBAL_GROUP), true);
                    if (fii != null)
                    {
                        //Console.WriteLine("    --> found");
                        list.Add(fii);
                    }
                }
            }
            return(list);
        }
示例#4
0
        /// <summary>
        /// Use WantInformation::LoadWant() to create a new Instance
        /// </summary>
        /// <param name="guid">The guid of the Want</param>
        protected WantInformation(uint guid)
        {
            this.guid = guid;

            wnt      = WantLoader.GetWant(guid);
            str      = WantLoader.LoadText(wnt);
            primicon = WantLoader.LoadIcon(wnt);
        }
示例#5
0
        private void ScanSemiGlobals(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            lbfiles.Items.Clear();
            this.btimport.Enabled = false;

            if (cbsemi.SelectedIndex < 0)
            {
                return;
            }
            ArrayList loaded = new ArrayList();

            try
            {
                SimPe.Plugin.NamedGlob glob = (SimPe.Plugin.NamedGlob)cbsemi.Items[cbsemi.SelectedIndex];
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileByGroup(glob.SemiGlobalGroup);

                lbfiles.Sorted = false;
                foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    if (item.FileDescriptor.Type == Data.MetaData.BHAV_FILE)
                    {
                        SimPe.Plugin.Bhav bhav = new SimPe.Plugin.Bhav(null);
                        bhav.ProcessData(item);
                        item.FileDescriptor.Filename = item.FileDescriptor.TypeName.shortname + ": " + bhav.FileName + " (" + item.FileDescriptor.ToString() + ")";
                    }
                    else if (item.FileDescriptor.Type == Data.MetaData.STRING_FILE)
                    {
                        SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                        str.ProcessData(item);
                        item.FileDescriptor.Filename = item.FileDescriptor.TypeName.shortname + ": " + str.FileName + " (" + item.FileDescriptor.ToString() + ")";
                    }
                    else if (item.FileDescriptor.Type == 0x42434F4E)                      //BCON
                    {
                        SimPe.Plugin.Bcon bcon = new SimPe.Plugin.Bcon();
                        bcon.ProcessData(item);
                        item.FileDescriptor.Filename = item.FileDescriptor.TypeName.shortname + ": " + bcon.FileName + " (" + item.FileDescriptor.ToString() + ")";
                    }
                    else
                    {
                        item.FileDescriptor.Filename = item.FileDescriptor.ToString();
                    }

                    if (!loaded.Contains(item.FileDescriptor))
                    {
                        lbfiles.Items.Add(item, ((item.FileDescriptor.Type == Data.MetaData.BHAV_FILE) || (item.FileDescriptor.Type == 0x42434F4E)));
                        loaded.Add(item.FileDescriptor);
                    }
                }
                lbfiles.Sorted        = true;
                this.btimport.Enabled = (lbfiles.Items.Count > 0);
            }
            catch (Exception) {}

            this.Cursor = Cursors.Default;
        }
示例#6
0
 static void LoadModelName(ArrayList list, SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg)
 {
     SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
     str.ProcessData(pfd, pkg);
     SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1);
     for (int i = 1; i < items.Length; i++)
     {
         list.Add(items[i].Title);
     }
     str.Dispose();
 }
示例#7
0
        protected virtual SimPe.PackedFiles.Wrapper.StrItemList GetCtssItems(Interfaces.Files.IPackedFileDescriptor ctss, SimPe.Interfaces.Files.IPackageFile pkg)
        {
            if (ctss != null)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(ctss, pkg);

                return(str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode));
            }

            return(null);
        }
示例#8
0
        /// <summary>
        /// Return all Modelnames that can be found in this package
        /// </summary>
        /// <param name="pkg">The Package you want to scan</param>
        /// <returns>a list of Modelnames</returns>
        public static string[] FindModelNames(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            ArrayList names = new ArrayList();

            Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.STRING_FILE, 0, 0x85);
            if (pfds.Length > 0)
            {
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(pfd, pkg);

                    foreach (SimPe.PackedFiles.Wrapper.StrToken item in str.Items)
                    {
                        string mname = Hashes.StripHashFromName(item.Title.Trim().ToLower());
                        if (!mname.EndsWith("_cres"))
                        {
                            mname += "_cres";
                        }
                        if ((mname != "") && (!names.Contains(mname)))
                        {
                            names.Add(mname);
                        }
                    }
                }
            }

            pfds = pkg.FindFiles(Data.MetaData.MMAT);
            if (pfds.Length > 0)
            {
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                    cpf.ProcessData(pfd, pkg);

                    string mname = Hashes.StripHashFromName(cpf.GetSaveItem("modelName").StringValue.Trim().ToLower());
                    if (!mname.EndsWith("_cres"))
                    {
                        mname += "_cres";
                    }
                    if ((mname != "") && (!names.Contains(mname)))
                    {
                        names.Add(mname);
                    }
                }
            }

            string[] ret = new string[names.Count];
            names.CopyTo(ret);

            return(ret);
        }
示例#9
0
        protected static void UpdateDescription(OWCloneSettings cs, SimPe.PackedFiles.Wrapper.Str str)
        {
            str.ClearNonDefault();
            while (str.Items.Length < 2)
            {
                str.Add(new SimPe.PackedFiles.Wrapper.StrToken(str.Items.Length, 1, "", ""));
            }

            str.Items[0].Title = cs.Title;
            str.Items[1].Title = cs.Description;

            str.SynchronizeUserData();
        }
示例#10
0
        protected SimPe.PackedFiles.Wrapper.StrItemList GetCtssItems()
        {
            //Get the Name of the Object
            Interfaces.Files.IPackedFileDescriptor ctss = CatalogDescription;
            if (ctss != null)
            {
                ctss.ChangedData += new SimPe.Events.PackedFileChanged(ctss_ChangedUserData);
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(ctss, pkg);

                return(str.LanguageItems(Helper.WindowsRegistry.LanguageCode));
            }
            return(null);
        }
示例#11
0
        public override void SearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd)
        {
            if (pfd.Type != Data.MetaData.STRING_FILE && pfd.Type != Data.MetaData.CTSS_FILE)
            {
                return;
            }

            SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
            str.ProcessData(pfd, pkg);

            SimPe.PackedFiles.Wrapper.StrItemList sitems = str.Items;
            //check all stored nMap entries for a match
            foreach (SimPe.PackedFiles.Wrapper.StrToken item in sitems)
            {
                bool   found = false;
                string n     = item.Title.Trim().ToLower();
                if (compareType == CompareType.Equal)
                {
                    found = n == name;
                }
                else if (compareType == CompareType.Start)
                {
                    found = n.StartsWith(name);
                }
                else if (compareType == CompareType.End)
                {
                    found = n.EndsWith(name);
                }
                else if (compareType == CompareType.Contain)
                {
                    found = n.IndexOf(name) > -1;
                }
                else if (compareType == CompareType.RegExp && reg != null)
                {
                    found = reg.IsMatch(n);
                }

                //we have a match, so add the result item
                if (found)
                {
                    ResultGui.AddResult(pkg, pfd);
                    break;
                }
            }
        }
示例#12
0
        /// <summary>
        /// Loads String Resource from the Package
        /// </summary>
        /// <param name="list">The List where you want to store the Resource</param>
        /// <param name="instance">The Instance of the TextFile</param>
        /// <param name="lang">The Language Number</param>
        public void LoadData(ref ArrayList list, ushort instance, ushort lang)
        {
            list = new ArrayList();
            if (BasePackage == null)
            {
                return;
            }

            IPackedFileDescriptor pfd = BasePackage.FindFile(Data.MetaData.STRING_FILE, 0x00000000, 0x7FE59FD0, instance);

            SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
            str.ProcessData(pfd, BasePackage);
            SimPe.PackedFiles.Wrapper.StrItemList sis = str.FallbackedLanguageItems((SimPe.Data.MetaData.Languages)lang);
            for (ushort i = 0; i < sis.Length; i++)
            {
                list.Add(sis[i].Title);
            }                   //for
        }
示例#13
0
        /// <summary>
        /// Create a new Instance and load the main Template Files
        /// </summary>
        /// <param name="package"></param>
        public PhotoStudioTemplate(Interfaces.Files.IPackageFile package)
        {
            this.package = package;

            Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile(0xEBCF3E27, 0xffffffff, 0xffffffff, 0xffffffff);
            pset = new SimPe.PackedFiles.Wrapper.Cpf();
            ctss = null;
            if (pfd != null)
            {
                pset.ProcessData(pfd, package);

                pfd = package.FindFile(Data.MetaData.CTSS_FILE, 0xffffffff, 0xffffffff, pset.GetSaveItem("description").UIntegerValue);
                if (pfd != null)
                {
                    ctss = new SimPe.PackedFiles.Wrapper.Str();
                    ctss.ProcessData(pfd, package);
                }
            }
        }
示例#14
0
        protected static void UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package)
        {
            //change the price in the OBJd
            SimPe.PackedFiles.Wrapper.ExtObjd obj = new SimPe.PackedFiles.Wrapper.ExtObjd();
            SimPe.PackedFiles.Wrapper.Str     str = new SimPe.PackedFiles.Wrapper.Str();
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                obj.ProcessData(pfd, package);

                SimPe.Interfaces.Files.IPackedFileDescriptor spfd = UpdateDescription(cs, package, obj);

                if (spfd != null)
                {
                    str.ProcessData(spfd, package);
                    UpdateDescription(cs, str);
                }
            }

            //change Price, Title, Desc in the XObj Files
            uint[] types = new uint[] { Data.MetaData.XFNC, Data.MetaData.XROF, Data.MetaData.XFLR, Data.MetaData.XOBJ };
            SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
            foreach (uint t in types)
            {
                pfds = package.FindFiles(t);
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    cpf.ProcessData(pfd, package);
                    SimPe.Interfaces.Files.IPackedFileDescriptor spfd = UpdateDescription(cs, package, cpf);

                    if (spfd != null)
                    {
                        str.ProcessData(spfd, package);
                        UpdateDescription(cs, str);
                    }
                }
            }

            if (package.FileName != null)
            {
                package.Save();
            }
        }
示例#15
0
        private void addStr(SimPe.PackedFiles.Wrapper.Cpf srcCpf, SimPe.Plugin.RefFile src3idr)
        {
            SimPe.PackedFiles.Wrapper.CpfItem cpfItem = srcCpf.GetItem("stringsetidx");
            if (cpfItem == null || cpfItem.Datatype != SimPe.Data.MetaData.DataTypes.dtUInteger)
            {
                return;
            }

            IPackedFileDescriptor ps = srcCpf.Package.FindFile(src3idr.Items[cpfItem.UIntegerValue]);

            if (ps == null)
            {
                return;
            }

            SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
            str.ProcessData(ps, srcCpf.Package);

            addFile(str);
        }
示例#16
0
        /// <summary>
        /// Updates the S2CP ID File with the cuurrent settings
        /// </summary>
        /// <param name="p">The Package to change/read from</param>
        /// <param name="guid">The packages GUID</param>
        /// <param name="name">The Name for the Package (used if the File is created)</param>
        /// <param name="author">Author of this package</param>
        /// <param name="contact">How to contact the Author</param>
        /// <param name="gameguid">The List of original Game Guids</param>
        /// <returns>the stored or the new GlobalGUID</returns>
        public static void UpdateGlobalGuid(File p, string guid, string name, string author, string contact, string gameguid)
        {
            Interfaces.Files.IPackedFileDescriptor pfd = p.FindFile(Data.MetaData.STRING_FILE, 0xffffffff, 0x00000000, 0xffffffff);
            SimPe.PackedFiles.Wrapper.Str          str = null;
            if (pfd == null)
            {
                str = new SimPe.PackedFiles.Wrapper.Str();

                str.FileDescriptor          = new SimPe.Packages.PackedFileDescriptor();
                str.FileDescriptor.Type     = Data.MetaData.STRING_FILE;
                str.FileDescriptor.Group    = 0;
                str.FileDescriptor.SubType  = 0xffffffff;
                str.FileDescriptor.Instance = 0xffffffff;
                str.SynchronizeUserData();
                str.Package = p;

                p.Add(str.FileDescriptor);
            }
            else
            {
                str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, p);
            }

            SimPe.PackedFiles.Wrapper.StrLanguageList lng = new SimPe.PackedFiles.Wrapper.StrLanguageList();
            lng.Add(new SimPe.PackedFiles.Wrapper.StrLanguage(1));
            str.Languages = lng;

            if (guid == null)
            {
                guid = System.Guid.NewGuid().ToString();
            }
            str.Items = new SimPe.PackedFiles.Wrapper.StrItemList();
            str.Items.Add(new SimPe.PackedFiles.Wrapper.StrToken(0, lng[0], guid, gameguid));
            str.Items.Add(new SimPe.PackedFiles.Wrapper.StrToken(1, lng[0], author, contact));
            str.Items.Add(new SimPe.PackedFiles.Wrapper.StrToken(2, lng[0], name, ""));

            str.SynchronizeUserData();
        }
示例#17
0
        /// <summary>
        /// Returns the String File describing that want
        /// </summary>
        /// <param name="wnt">The Want File</param>
        /// <returns>The Str File or null if none was found</returns>
        public static SimPe.PackedFiles.Wrapper.Str LoadText(XWant wnt)
        {
            if (wnt == null)
            {
                return(null);
            }
            if (txtpkg == null)
            {
                LoadTextPackage();
            }

            Interfaces.Files.IPackedFileDescriptor[] pfds = txtpkg.FindFile(Data.MetaData.STRING_FILE, 0, wnt.StringInstance);
            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                pfds[0].UserData = txtpkg.Read(pfds[0]).UncompressedData;
                str.ProcessData(pfds[0], txtpkg);

                return(str);
            }

            return(null);
        }
示例#18
0
        /// <summary>
        /// Find the Modelname of the Original Object
        /// </summary>
        /// <param name="package">The Package containing the Data</param>
        /// <returns>The Modelname</returns>
        public static string FindMainOldName(SimPe.Interfaces.Files.IPackageFile package)
        {
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.STRING_FILE);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                if (pfd.Instance == 0x85)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(pfd, package);

                    SimPe.PackedFiles.Wrapper.StrItemList sil = str.LanguageItems(1);
                    if (sil.Length > 1)
                    {
                        return(sil[1].Title);
                    }
                    else if (str.Items.Length > 1)
                    {
                        return(str.Items[1].Title);
                    }
                }
            }

            pfds = package.FindFiles(0x4C697E5A);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
                cpf.ProcessData(pfd, package);

                if (cpf.GetSaveItem("modelName").StringValue.Trim() != "")
                {
                    return(cpf.GetSaveItem("modelName").StringValue.Trim());
                }
            }

            return("SimPE");
        }
示例#19
0
        protected override void StartThread()
        {
            lotfi.Load();
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = lotfi.FindFile(0x856DDBAC, Data.MetaData.LOCAL_GROUP, 0x35CA0002, null);
            bool run = Wait.Running;

            if (!run)
            {
                Wait.Start();
            }
            Wait.SubStart(items.Length);
            try
            {
                int ct   = 0;
                int step = Math.Max(2, Wait.MaxProgress / 100);
                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    if (this.HaveToStop)
                    {
                        break;
                    }


                    SimPe.Interfaces.Files.IPackageFile pkg = item.Package;

                    SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pkg.FindFile(Data.MetaData.STRING_FILE, 0, Data.MetaData.LOCAL_GROUP, 0x00000A46);
                    string name = SimPe.Localization.GetString("Unknown");
                    if (pfd != null)
                    {
                        SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                        str.ProcessData(pfd, pkg);

                        SimPe.PackedFiles.Wrapper.StrItemList list = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode);
                        if (list.Count > 0)
                        {
                            name = list[0].Title;
                        }
                    }

                    SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
                    pic.ProcessData(item);

                    uint inst = GetInstanceFromFilename(pkg.SaveFileName);

                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] ltxtitems = ngbhfi.FindFile(0x0BF999E7, Data.MetaData.LOCAL_GROUP, inst, null);
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem   ltxt      = null;
                    if (ltxtitems.Length > 0)
                    {
                        ltxt = ltxtitems[0];
                    }

                    LotItem li = new LotItem(inst, name, pic.Image, ltxt);
                    if (LoadingLot != null)
                    {
                        LoadingLot(this, li);
                    }
                    content[li.Instance] = li;
                    ct++;
                    if (ct % step == 0)
                    {
                        Wait.Message  = name;
                        Wait.Progress = ct;
                    }
                }                //foreach
            }
#if !DEBUG
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }
#endif
            finally
            {
                Wait.SubStop();
                if (!run)
                {
                    Wait.Stop();
                }
            }

            ended.Set();
        }
示例#20
0
        /// <summary>
        /// Add a MaterialOverride to the Cache
        /// </summary>
        /// <param name="objd">The Object Data File</param>
        public MemoryCacheItem AddItem(SimPe.PackedFiles.Wrapper.ExtObjd objd)
        {
            CacheContainer mycc = this.UseConatiner(ContainerType.Memory, objd.Package.FileName);

            MemoryCacheItem mci = new MemoryCacheItem();

            mci.FileDescriptor       = objd.FileDescriptor;
            mci.Guid                 = objd.Guid;
            mci.ObjectType           = objd.Type;
            mci.ObjdName             = objd.FileName;
            mci.ParentCacheContainer = mycc;

            try
            {
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, objd.FileDescriptor.Group, objd.CTSSInstance, null);
                if (sitems.Length > 0)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(sitems[0]);
                    SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Helper.WindowsRegistry.LanguageCode);
                    if (strs.Length > 0)
                    {
                        mci.Name = strs[0].Title;
                    }

                    //not found?
                    if (mci.Name == "")
                    {
                        strs = str.LanguageItems(1);
                        if (strs.Length > 0)
                        {
                            mci.Name = strs[0].Title;
                        }
                    }
                }
            }
            catch (Exception) {}

            try
            {
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.STRING_FILE, objd.FileDescriptor.Group, 0x100, null);
                if (sitems.Length > 0)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(sitems[0]);
                    SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Data.MetaData.Languages.English);
                    string[] res = new string[strs.Count];
                    for (int i = 0; i < res.Length; i++)
                    {
                        res[i] = strs[i].Title;
                    }
                    mci.ValueNames = res;
                }
            }
            catch (Exception) {}

            //still no name?
            if (mci.Name == "")
            {
                mci.Name = objd.FileName;
            }

            //having an icon?
            SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
            Interfaces.Scenegraph.IScenegraphFileIndexItem[] iitems = FileTable.FileIndex.FindFile(Data.MetaData.SIM_IMAGE_FILE, objd.FileDescriptor.Group, 1, null);
            if (iitems.Length > 0)
            {
                pic.ProcessData(iitems[0]);
                mci.Icon   = pic.Image;
                Wait.Image = mci.Icon;
            }

            Wait.Message = mci.Name;
            //mci.ParentCacheContainer = mycc; //why was this disbaled?
            mycc.Items.Add(mci);

            return(mci);
        }
示例#21
0
        /// <summary>
        /// Loads Memory Files form the Object Package
        /// </summary>
        public void LoadMemories()
        {
            memories = new Hashtable();
            //if (BasePackage==null) return;

            Registry  reg  = Helper.WindowsRegistry;
            ArrayList list = new ArrayList();

            Interfaces.Files.IPackedFileDescriptor pfd;

            SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
            SimPe.PackedFiles.Wrapper.Str     str  = new SimPe.PackedFiles.Wrapper.Str();

            FileTable.FileIndex.Load();
            Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileDiscardingGroup(Data.MetaData.OBJD_FILE, 0x00000000000041A7);

            string max = " / " + items.Length.ToString();
            int    ct  = 0;

            if (items.Length != 0)           //found anything?
            {
                bool wasrunning = WaitingScreen.Running;
                WaitingScreen.Wait();
                try
                {
                    foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                    {
                        ct++;
                        if (ct % 137 == 1)
                        {
                            WaitingScreen.UpdateMessage(ct.ToString() + max);
                        }
                        pfd = item.FileDescriptor;

                        string name = "";
                        objd.ProcessData(item);

                        if (memories.Contains(objd.Guid))
                        {
                            continue;
                        }
                        try
                        {
                            Interfaces.Scenegraph.IScenegraphFileIndexItem[] sitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, pfd.Group, objd.CTSSInstance, null);
                            if (sitems.Length > 0)
                            {
                                str.ProcessData(sitems[0]);
                                SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(Helper.WindowsRegistry.LanguageCode);
                                if (strs.Length > 0)
                                {
                                    name = strs[0].Title;
                                }


                                //not found?
                                if (name == "")
                                {
                                    strs = str.LanguageItems(1);
                                    if (strs.Length > 0)
                                    {
                                        name = strs[0].Title;
                                    }
                                }
                            }
                        }
                        catch (Exception) { }
                        //still no name?
                        if (name == "")
                        {
                            name = objd.FileName;
                        }

#if DEBUG
                        IAlias a = new Alias(objd.Guid, name, "{1}: {name} (0x{id})");
#else
                        IAlias a = new Alias(objd.Guid, name, "{1}: {name}");
#endif

                        object[] o = new object[3];

                        o[0] = pfd;
                        o[1] = (Data.ObjectTypes)objd.Type;
                        o[2] = null;
                        SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
                        Interfaces.Scenegraph.IScenegraphFileIndexItem[] iitems = FileTable.FileIndex.FindFile(Data.MetaData.SIM_IMAGE_FILE, pfd.Group, 1, null);
                        if (iitems.Length > 0)
                        {
                            pic.ProcessData(iitems[0]);
                            System.Drawing.Image img = pic.Image;
                            o[2] = img;

                            WaitingScreen.Update(img, ct.ToString() + max);
                        }
                        a.Tag = o;
                        if (!memories.Contains(objd.Guid))
                        {
                            memories.Add(objd.Guid, a);
                        }
                    } //foreach item
                }
                finally { if (!wasrunning)
                          {
                              WaitingScreen.Stop();
                          }
                }
            }             // if items>0
                          //System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Normal;
        }
示例#22
0
 /// <summary>
 /// Creates an Alias out of a Memory File
 /// </summary>
 /// <returns>the IAlias Object</returns>
 protected static void ProcessMemoryFile(Interfaces.Files.IPackedFileDescriptor pfd, SimPe.PackedFiles.Wrapper.ExtObjd objd, SimPe.PackedFiles.Wrapper.ExtObjd objd_pr, SimPe.PackedFiles.Wrapper.Str str, ArrayList list, ref Hashtable memories, SimPe.Interfaces.Files.IPackageFile BasePackage)
 {
 }
示例#23
0
        /// <summary>
        /// Updates the S2CP ID File with the cuurrent settings
        /// </summary>
        /// <param name="p">The Package to change/read from</param>
        /// <param name="title">Title of this Object</param>
        /// <param name="description">Description of this Package</param>
        /// <returns>the stored or the new GlobalGUID</returns>
        public static void UpdateGlobalGuid(File p, string title, string description)
        {
            Interfaces.Files.IPackedFileDescriptor pfd = null;
            SimPe.PackedFiles.Wrapper.Str          str = null;

            SimPe.PackedFiles.Wrapper.StrLanguage[] lng = new SimPe.PackedFiles.Wrapper.StrLanguage[1];
            lng[0] = new SimPe.PackedFiles.Wrapper.StrLanguage(1);

            //Title and Description is stored in the CatalogString
            Interfaces.Files.IPackedFileDescriptor[] pfds = p.FindFiles(Data.MetaData.OBJD_FILE);
            uint ctssid = 1;
            uint group  = 0xffffffff;

            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.Objd objd = new SimPe.PackedFiles.Wrapper.Objd(null);
                objd.ProcessData(pfds[0], p);
                ctssid = objd.CTSSId;
                group  = objd.FileDescriptor.Group;
            }

            pfd = p.FindFile(Data.MetaData.CTSS_FILE, 0, group, ctssid);
            if (pfd == null)
            {
                str = new SimPe.PackedFiles.Wrapper.Str();

                str.FileDescriptor          = new SimPe.Packages.PackedFileDescriptor();
                str.FileDescriptor.Type     = Data.MetaData.CTSS_FILE;
                str.FileDescriptor.Group    = 0xffffffff;
                str.FileDescriptor.SubType  = 0x00000000;
                str.FileDescriptor.Instance = 0x1;

                str.Languages.Add(lng[0]);

                p.Add(str.FileDescriptor);
            }
            else
            {
                str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, p);
            }

            SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1);
            if (str.Items.Length > 0)
            {
                str.Items[0].Title = title;
            }
            else
            {
                str.Add(new SimPe.PackedFiles.Wrapper.StrToken(0, lng[0], title, ""));
            }

            if (str.Items.Length > 1)
            {
                str.Items[1].Title = description;
            }
            else
            {
                str.Add(new SimPe.PackedFiles.Wrapper.StrToken(1, lng[0], description, ""));
            }

            str.SynchronizeUserData();
        }
示例#24
0
        /// <summary>
        /// Runs the Fix Operation
        /// </summary>
        /// <param name="map">the map we have to use for name Replacements</param>
        /// <param name="uniquefamily">change the family values in the MMAT Files</param>
        public void Fix(Hashtable map, bool uniquefamily)
        {
            string grouphash = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!";        //"#0x"+Helper.HexString(package.FileGroupHash)+"!";


            Hashtable refmap         = new Hashtable();
            Hashtable completerefmap = new Hashtable();

            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Fixing Names");
            }
            FixNames(map);

            foreach (uint type in Data.MetaData.RcolList)
            {
                Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(type);

                //build a List of RefItems
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                    rcol.ProcessData(pfd, package);

                    //rcol.FileName = Hashes.StripHashFromName(rcol.);

                    /*if (types.Contains(pfd.Type)) rcol. = Hashes.StripHashFromName(rcol.);
                     * else rcol.FileName = grouphash + Hashes.StripHashFromName(rcol.FileName);*/

                    foreach (Interfaces.Files.IPackedFileDescriptor rpfd in rcol.ReferencedFiles)
                    {
                        string refstr = BuildRefString(rpfd);
                        if (!refmap.Contains(refstr))
                        {
                            refmap.Add(refstr, null);
                        }
                    }
                    //rcol.SynchronizeUserData();
                }
            }

            //Updated TGI Values and update the refmap
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Updating TGI Values");
            }
            foreach (uint type in Data.MetaData.RcolList)
            {
                Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(type);

                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    string            refstr = BuildRefString(pfd);
                    SimPe.Plugin.Rcol rcol   = new GenericRcol(null, false);
                    rcol.ProcessData(pfd, package);

                    //rcol.FileName = grouphash + Hashes.StripHashFromName(rcol.);
                    rcol.FileDescriptor.Instance = Hashes.InstanceHash(Hashes.StripHashFromName(rcol.FileName));
                    rcol.FileDescriptor.SubType  = Hashes.SubTypeHash(Hashes.StripHashFromName(rcol.FileName));

                    if (refmap.Contains(refstr))
                    {
                        refmap[refstr] = rcol.FileDescriptor;
                    }
                    completerefmap[refstr] = rcol.FileDescriptor;
                }
            }

            //Update the References
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Updating TGI References");
            }
            foreach (uint type in Data.MetaData.RcolList)
            {
                Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(type);

                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                    rcol.ProcessData(pfd, package);

                    foreach (Interfaces.Files.IPackedFileDescriptor rpfd in rcol.ReferencedFiles)
                    {
                        string refstr = Helper.HexString(rpfd.Group) + Helper.HexString(rpfd.Type) + Helper.HexString(rpfd.Instance) + Helper.HexString(rpfd.SubType);

                        if (ver == FixVersion.UniversityReady2)
                        {
                            if (types.Contains(rpfd.Type))
                            {
                                rpfd.Group = Data.MetaData.CUSTOM_GROUP;
                            }
                            else
                            {
                                rpfd.Group = Data.MetaData.LOCAL_GROUP;
                            }
                        }
                        else
                        {
                            if (rpfd.Type != Data.MetaData.ANIM)
                            {
                                rpfd.Group = Data.MetaData.CUSTOM_GROUP;
                            }
                            else
                            {
                                rpfd.Group = Data.MetaData.GLOBAL_GROUP;
                            }
                        }

                        if (refmap.Contains(refstr))
                        {
                            Interfaces.Files.IPackedFileDescriptor npfd = (Interfaces.Files.IPackedFileDescriptor)refmap[refstr];
                            if (npfd != null)
                            {
                                rpfd.Instance = npfd.Instance;
                                rpfd.SubType  = npfd.SubType;
                            }
                        }
                    }                     //foreach

                    rcol.SynchronizeUserData();
                }
            }

            //Make sure XObjects and Skins get Fixed Too
            FixXObject(map, completerefmap, grouphash);
            FixSkin(map, completerefmap, grouphash);

            //Make sure MMATs get fixed
            FixMMAT(map, uniquefamily, grouphash);

            //Make sure OBJd's get fixed too
            FixOBJd();

            //And finally the Root String
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Updating Root");
            }
            SimPe.Interfaces.Files.IPackedFileDescriptor[] mpfds = package.FindFiles(Data.MetaData.STRING_FILE);
            string modelname = null;

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in mpfds)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, package);

                foreach (SimPe.PackedFiles.Wrapper.StrToken i in str.Items)
                {
                    string name = Hashes.StripHashFromName(i.Title.Trim().ToLower());

                    if (name == "")
                    {
                        continue;
                    }
                    if (pfd.Instance == 0x88)
                    {
                        if (!name.EndsWith("_txmt"))
                        {
                            name += "_txmt";
                        }
                    }
                    else if (pfd.Instance == 0x85)
                    {
                        if (!name.EndsWith("_cres"))
                        {
                            name += "_cres";
                        }
                    }
                    else if ((pfd.Instance == 0x81) || (pfd.Instance == 0x82) || (pfd.Instance == 0x86) || (pfd.Instance == 0x192))
                    {
                        if (!name.EndsWith("_anim"))
                        {
                            name += "_anim";
                        }
                    }
                    else
                    {
                        continue;
                    }


                    string newref = (string)map[name];
                    if (newref != null)
                    {
                        i.Title = Hashes.StripHashFromName(newref.Substring(0, newref.Length - 5));
                    }
                    else
                    {
                        i.Title = Hashes.StripHashFromName(i.Title);
                    }

                    if (((ver == FixVersion.UniversityReady) || (pfd.Instance == 0x88)) && (newref != null))
                    {
                        i.Title = Hashes.StripHashFromName(i.Title);

                        if (!((pfd.Instance == 0x81) || (pfd.Instance == 0x82) || (pfd.Instance == 0x86) || (pfd.Instance == 0x192)))
                        {
                            i.Title = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + i.Title;
                        }
                    }
                    else
                    {
                        uint tp = Data.MetaData.ANIM;
                        if (pfd.Instance == 0x88)
                        {
                            tp = Data.MetaData.TXMT;
                        }
                        else if (pfd.Instance == 0x85)
                        {
                            tp = Data.MetaData.CRES;
                        }

                        SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii = FileTable.FileIndex.FindFileByName(i.Title, tp, Data.MetaData.LOCAL_GROUP, true);
                        if (fii != null)
                        {
                            if (fii.FileDescriptor.Group == Data.MetaData.CUSTOM_GROUP)
                            {
                                i.Title = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + Hashes.StripHashFromName(i.Title);
                            }
                        }
                    }

                    if ((modelname == null) && (i.Language.Id == 1) && (pfd.Instance == 0x85))
                    {
                        modelname = name.ToUpper().Replace("-", "_");
                    }
                }

                if (RemoveNonDefaultTextReferences)
                {
                    if (pfd.Instance == 0x88 || pfd.Instance == 0x85 || (pfd.Instance == 0x81) || (pfd.Instance == 0x82) || (pfd.Instance == 0x86) || (pfd.Instance == 0x192))
                    {
                        str.ClearNonDefault();
                    }
                }


                str.SynchronizeUserData();
            }

            //Now change the NREF

            if (modelname != null)
            {
                mpfds = package.FindFiles(0x4E524546);
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in mpfds)
                {
                    SimPe.PackedFiles.Wrapper.Nref nref = new SimPe.PackedFiles.Wrapper.Nref();
                    nref.ProcessData(pfd, package);
                    if (ver == FixVersion.UniversityReady)
                    {
                        nref.FileName = "SIMPE_" + modelname;
                    }
                    else
                    {
                        nref.FileName = "SIMPE_v2_" + modelname;
                    }

                    nref.SynchronizeUserData();
                }
            }
        }
示例#25
0
        /// <summary>
        /// Reads the Guid from the Package
        /// </summary>
        /// <param name="p">The Package to load the Guid From</param>
        /// <param name="name">Returns the name stored in te package</param>
        /// <param name="title">The Title of this package</param>
        /// <param name="author">Author of this package</param>
        /// <param name="contact">How to contact the Author</param>
        /// <param name="description">Description of this Package</param>
        /// <param name="gameguid">The List of original Game Guids</param>
        /// <returns>null if no GUID Data was found, otherwise null</returns>
        public static string GetGlobalGuid(File p, ref string name, ref string title, ref string author, ref string contact, ref string description, ref string gameguid)
        {
            string guid = null;

            Interfaces.Files.IPackedFileDescriptor pfd = p.FindFile(Data.MetaData.STRING_FILE, 0xffffffff, 0x00000000, 0xffffffff);
            if (pfd != null)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, p);
                SimPe.PackedFiles.Wrapper.StrItemList sitems = str.LanguageItems(1);

                if (sitems.Length > 0)
                {
                    guid     = sitems[0].Title;
                    gameguid = sitems[0].Description;
                }
                else
                {
                    guid = System.Guid.NewGuid().ToString();
                }

                if (sitems.Length > 1)
                {
                    author  = sitems[1].Title;
                    contact = sitems[1].Description;
                }

                if (sitems.Length > 2)
                {
                    name = sitems[1].Title;
                }
            }



            //Title and Description is stored in the CatalogString
            Interfaces.Files.IPackedFileDescriptor[] pfds = p.FindFiles(Data.MetaData.OBJD_FILE);

            uint ctssid = 1;
            uint group  = 0xffffffff;

            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.Objd objd = new SimPe.PackedFiles.Wrapper.Objd(null);
                objd.ProcessData(pfds[0], p);
                ctssid = objd.CTSSId;
                group  = objd.FileDescriptor.Group;
            }


            pfd = p.FindFile(Data.MetaData.CTSS_FILE, 0, group, ctssid);
            if (pfd != null)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, p);
                SimPe.PackedFiles.Wrapper.StrItemList sitems = str.LanguageItems(1);

                if (sitems.Length > 0)
                {
                    title = sitems[0].Title;
                }

                if (sitems.Length > 1)
                {
                    description = sitems[1].Title;
                }
            }
            return(guid);
        }
示例#26
0
        /// <summary>
        /// Adds a Sim to the List
        /// </summary>
        /// <param name="objd"></param>
        /// <param name="ct"></param>
        /// <param name="step"></param>
        /// <returns>The Alias for that Sim</returns>
        /// <remarks>
        /// Alias.Tag has the following Structure:
        /// [0] : FileName of Character File (if NPC, this will be null)
        /// [1] : Thumbnail
        /// [2] : FamilyName
        /// [3] : Contains Age Data
        /// [4] : When NPC, this will get the Filename
        /// </remarks>
        protected Alias AddSim(SimPe.PackedFiles.Wrapper.ExtObjd objd, ref int ct, int step, bool npc)
        {
            //if (objd.Type!=Data.ObjectTypes.Person) return null;

            SimPe.Interfaces.Files.IPackageFile fl = objd.Package;
            //BinaryReader br = new BinaryReader(File.OpenRead(file));//new StreamReader(file)
            bool hasagedata = fl.FindFiles(0xAC598EAC).Length > 0;           //has Age Data

            object[] tags = new object[5];
            tags[0] = fl.FileName;
            tags[1] = null;
            tags[2] = Localization.Manager.GetString("Unknown");
            tags[3] = hasagedata;
            tags[4] = null;

            /*if (Helper.WindowsRegistry.HiddenMode)
             *      tags[5] = (!hasagedata) && (fl.FindFiles(0xAC506764).Length>0); //if this is true, the Sim has a Problem, and the package was probably split
             * else
             *      tags[5] = false;*/

            //set stuff for NPCs
            if (npc)
            {
                tags[4]  = tags[0];
                tags[0]  = "";
                tags[2] += " (NPC)";
            }

            Alias a = null;



            Interfaces.Files.IPackedFileDescriptor str_pfd = fl.FindFile(Data.MetaData.CTSS_FILE, 0, objd.FileDescriptor.Group, objd.CTSSInstance);

            if (str_pfd != null)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(str_pfd, fl);
                SimPe.PackedFiles.Wrapper.StrItemList its = str.FallbackedLanguageItems(Helper.WindowsRegistry.LanguageCode);
                if (its.Length > 0)
                {
#if DEBUG
                    a = new Alias(objd.Guid, its[0].Title, "{name} {2} (0x{id})");
#else
                    a = new Alias(objd.Guid, its[0].Title, "{name} {2} (0x{id})");
#endif
                    if (its.Length > 2)
                    {
                        tags[2] = its[2].Title;
                    }
                }
            }


            if (a != null)
            {
                IPackedFileDescriptor[] piclist = fl.FindFiles(Data.MetaData.SIM_IMAGE_FILE);
                foreach (IPackedFileDescriptor pfd in piclist)
                {
                    if (pfd.Group != objd.FileDescriptor.Group)
                    {
                        continue;
                    }
                    if (pfd.Instance < 0x200)
                    {
                        SimPe.PackedFiles.Wrapper.Picture pic = new SimPe.PackedFiles.Wrapper.Picture();
                        pic.ProcessData(pfd, fl);

                        /*if (Helper.StartedGui==Executable.Classic)
                         *      WaitingScreen.UpdateImage(pic.Image);
                         * else
                         *      Wait.Image = pic.Image;								*/

                        tags[1] = pic.Image;
                        break;
                    }
                }

                a.Tag = tags;
                //if (Helper.StartedGui!=Executable.Classic)
                {
                    ct++;
                    if (ct % step == 1)
                    {
                        Wait.Message  = a.ToString();
                        Wait.Progress = ct;
                    }
                }

                //set stuff for NPCs
                if (npc)
                {
                    a.Tag[2] = a.Tag[2].ToString() + " (NPC)";
                }

                if (names == null)
                {
                    return(null);
                }
                if (!names.Contains(objd.Guid))
                {
                    names.Add(objd.Guid, a);
                }
            }

            return(a);
        }
示例#27
0
        protected override void StartThread()
        {
            string[] files = Directory.GetFiles(dir, "*.package");
            if (Helper.StartedGui == Executable.Classic)
            {
                WaitingScreen.Wait();
            }
            else
            {
                Wait.SubStart(files.Length);
            }
            try
            {
                bool breaked = false;
                SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                SimPe.PackedFiles.Wrapper.Str     str  = new SimPe.PackedFiles.Wrapper.Str();
                //ArrayList al = new ArrayList();
                int ct   = 0;
                int step = Math.Max(2, Wait.MaxProgress / 100);
                foreach (string file in files)
                {
                    if (this.HaveToStop)
                    {
                        breaked = true;
                        break;
                    }

                    SimPe.Packages.File fl = null;
                    try
                    {
                        fl = SimPe.Packages.File.LoadFromFile(file);
                    }
                    catch { break; }

                    IPackedFileDescriptor[] list = fl.FindFiles(Data.MetaData.OBJD_FILE);
                    if (list.Length > 0)
                    {
                        AddSim(fl, list[0], ref ct, step);
                    }
                    //fl.Reader.Close();
                }                //foreach

                if (!breaked)
                {
                    ScanFileTable();
                }
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
            }
            finally
            {
                if (Helper.StartedGui == Executable.Classic)
                {
                    WaitingScreen.Stop();
                }
                else
                {
                    Wait.SubStop();
                }
            }

            ended.Set();
        }
示例#28
0
        static void ConsumeFromXobj(SimPe.Cache.ObjectCacheItem oci, Interfaces.Scenegraph.IScenegraphFileIndexItem nrefitem, SimPe.Data.MetaData.Languages deflang)
        {
            SimPe.PackedFiles.Wrapper.Cpf cpf = new SimPe.PackedFiles.Wrapper.Cpf();
            nrefitem.FileDescriptor.UserData = nrefitem.Package.Read(nrefitem.FileDescriptor).UncompressedData;
            cpf.ProcessData(nrefitem);

            oci.FileDescriptor = nrefitem.FileDescriptor;
            oci.LocalGroup     = nrefitem.LocalGroup;
            oci.ObjectType     = SimPe.Data.ObjectTypes.Normal;

            SetFunctionSortForXObj(cpf, oci);

            oci.ObjectFileName = cpf.GetSaveItem("filename").StringValue;
            if (oci.ObjectFileName == "")
            {
                oci.ObjectFileName = cpf.GetSaveItem("name").StringValue;
            }

            oci.Useable = true;
            oci.Class   = SimPe.Cache.ObjectClass.XObject;



            Interfaces.Scenegraph.IScenegraphFileIndexItem[] ctssitems = FileTable.FileIndex.FindFile(cpf.GetSaveItem("stringsetrestypeid").UIntegerValue, cpf.GetSaveItem("stringsetgroupid").UIntegerValue, cpf.GetSaveItem("stringsetid").UIntegerValue, null);             //Data.MetaData.STRING_FILE
            if (ctssitems.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(ctssitems[0]);
                SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(deflang);
                if (items.Length > 0)
                {
                    oci.Name = items[0].Title;
                }
                else
                {
                    items = str.LanguageItems(1);
                    if (items.Length > 0)
                    {
                        oci.Name = items[0].Title;
                    }
                    else
                    {
                        oci.Name = "";
                    }
                }
            }
            else
            {
                oci.Name = "";
            }

            if (oci.Name == "")
            {
                oci.Name = oci.ObjectFileName;
            }

            //now the ModeName File
            if (cpf.GetItem("texturetname") != null)
            {
                oci.ModelName = cpf.GetItem("texturetname").StringValue;
            }
            else if (cpf.GetItem("filename") != null)
            {
                oci.ModelName = cpf.GetItem("filename").StringValue;
            }
            else
            {
                oci.ModelName = cpf.GetSaveItem("material").StringValue;
            }

            //oci.Name = cpf.GetSaveItem("type").StringValue + " - "+ cpf.GetSaveItem("subsort").StringValue;


            if (oci.Thumbnail == null)
            {
                oci.Thumbnail = ObjectPreview.GetXThumbnail(cpf);
            }
            ObjectReader.changedcache = true;
        }
示例#29
0
        internal static bool DoConsume(Object o, ObjectLoader.LoadItemHandler LoadedItem, SimPe.Data.MetaData.Languages deflang)
        {
            SimPe.Cache.ObjectCacheItem oci = (SimPe.Cache.ObjectCacheItem)o;
            Interfaces.Scenegraph.IScenegraphFileIndexItem nrefitem = (Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag;


            //this item is new to the cache, so load the Data
            if ((!oci.Useable || oci.ObjectVersion != SimPe.Cache.ObjectCacheItemVersions.DockableOW) && nrefitem.FileDescriptor.Type == Data.MetaData.OBJD_FILE)
            {
                SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                nrefitem.FileDescriptor.UserData = nrefitem.Package.Read(nrefitem.FileDescriptor).UncompressedData;
                objd.ProcessData(nrefitem);

                oci.FileDescriptor     = nrefitem.FileDescriptor;
                oci.LocalGroup         = nrefitem.LocalGroup;
                oci.ObjectType         = objd.Type;
                oci.ObjectFunctionSort = (uint)objd.FunctionSubSort;
                oci.ObjectFileName     = objd.FileName;
                oci.Useable            = true;
                oci.Class = SimPe.Cache.ObjectClass.Object;

                //this is needed, so that objects get sorted into the right categories

                /*if (objd.Type == Data.ObjectTypes.Normal && objd.CTSSInstance==0)
                 * {
                 *      oci.Useable = false;
                 *      return true;
                 * }*/

                //Get the Name of the Object
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] ctssitems = FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, nrefitem.LocalGroup);
                if (ctssitems.Length > 0)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                    str.ProcessData(ctssitems[0]);
                    SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(deflang);
                    if (items.Length > 0)
                    {
                        oci.Name = items[0].Title;
                    }
                    else
                    {
                        items = str.LanguageItems(1);
                        if (items.Length > 0)
                        {
                            oci.Name = items[0].Title;
                        }
                        else
                        {
                            oci.Name = "";
                        }
                    }
                }
                else
                {
                    oci.Name = "";
                }

                if (oci.Name == "")
                {
                    oci.Name = objd.FileName;
                }

                //now the ModeName File
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] txtitems = FileTable.FileIndex.FindFile(Data.MetaData.STRING_FILE, nrefitem.LocalGroup, 0x85, null);
                if (txtitems.Length > 0)
                {
                    SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(2);
                    str.ProcessData(txtitems[0]);
                    SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1);
                    if (items.Length > 1)
                    {
                        oci.ModelName = items[1].Title;
                    }
                }

                ObjectReader.changedcache = true;
            }             //if not loaded from objd

            if ((!oci.Useable || oci.ObjectVersion != SimPe.Cache.ObjectCacheItemVersions.DockableOW) && nrefitem.FileDescriptor.Type != Data.MetaData.OBJD_FILE)
            {
                ConsumeFromXobj(oci, nrefitem, deflang);
            }

            if (oci.Thumbnail == null)
            {
                oci.Thumbnail = ObjectPreview.GetThumbnail(nrefitem.FileDescriptor.Group, oci.ModelName);

                if (oci.Thumbnail != null)
                {
                    Wait.Image = oci.Thumbnail;
                    ObjectReader.changedcache = true;
                }
            }

#if DEBUG
            Data.Alias a = new Data.Alias(oci.FileDescriptor.Group, "---");            //, "{name} ({id}: {1}, {2}) ");
#else
            Data.Alias a = new Data.Alias(oci.FileDescriptor.Group, "---");            //, "{name} ({id}: {1}) ");
#endif
            object[] os = new object[4];
            os[0] = nrefitem.FileDescriptor;
            os[1] = nrefitem.LocalGroup;
            os[2] = oci.ModelName;
            os[3] = oci;

            a.Tag = os;

            if (Helper.WindowsRegistry.ShowObjdNames)
            {
                a.Name = oci.ObjectFileName;
            }
            else
            {
                a.Name = oci.Name;
            }
            a.Name += " (cached)";
            Image img = oci.Thumbnail;

            if (LoadedItem != null)
            {
                LoadedItem(oci, nrefitem, a);
            }

            return(true);
        }