Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        protected string[] GetModelnames()
        {
            if (objd == null)
            {
                return(new string[0]);
            }
            if (objd.Package == null)
            {
                return(new string[0]);
            }

            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = objd.Package.FindFile(Data.MetaData.STRING_FILE, 0, objd.FileDescriptor.Group, 0x85);
            ArrayList list = new ArrayList();

            if (pfd != null)
            {
                SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str();
                str.ProcessData(pfd, objd.Package);
                SimPe.PackedFiles.Wrapper.StrItemList items = str.LanguageItems(1);
                for (int i = 1; i < items.Length; i++)
                {
                    list.Add(items[i].Title);
                }
            }
            string[] refname = new string[list.Count];
            list.CopyTo(refname);

            return(refname);
        }
Ejemplo n.º 3
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();
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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");
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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;
        }