示例#1
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);
        }
示例#2
0
        public void UpdateScreen()
        {
            ClearScreen();
            if (objd == null)
            {
                return;
            }


            this.lbExpansion.Text = SimPe.Localization.GetString(FileFrom(objd.FileDescriptor).ToString());

            string[] mn = GetModelnames();
            if (mn.Length > 0)
            {
                uint grp = objd.FileDescriptor.Group;

                /*if (grp==0xffffffff && objd.Package!=null && loadimg)
                 *      if (objd.Package.FileName!=null)
                 *      {
                 *              FileTable.FileIndex.Load();
                 *              SimPe.Interfaces.Wrapper.IGroupCacheItem gci = FileTable.GroupCache.GetItem(objd.Package.FileName);
                 *              if (gci!=null) grp = gci.LocalGroup;
                 *      }*/
                pb.Image = GenerateImage(pb.Size, GetThumbnail(objd.FileDescriptor.Group, mn[0]), true);
            }
            else
            {
                pb.Image = null;
            }

            SetupCategories(SimPe.Cache.ObjectCacheItem.GetCategory(SimPe.Cache.ObjectCacheItemVersions.DockableOW, objd.FunctionSubSort, objd.Type, SimPe.Cache.ObjectClass.Object));

            SimPe.PackedFiles.Wrapper.StrItemList strs = GetCtssItems();
            if (strs != null)
            {
                if (strs.Count > 0)
                {
                    this.lbName.Text = strs[0].Title;
                }
                if (strs.Count > 1)
                {
                    this.lbAbout.Text = strs[1].Title;
                }
            }
            else
            {
                this.lbName.Text = objd.FileName;
            }

            this.lbPrice.Text = objd.Price.ToString() + " $";

            if (pb.Image == null)
            {
                pb.Image = defimg;
            }
        }
示例#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();
 }
示例#4
0
        public void UpdateScreen(SimPe.Interfaces.Files.IPackageFile pkg, bool clear)
        {
            if (clear)
            {
                ClearScreen();
            }
            if (objd == null)
            {
                return;
            }


            nfo.FirstExpansion = PackageInfo.FileFrom(objd.FileDescriptor);

            string[] mn = GetModelnames();
            if (mn.Length > 0)
            {
                uint grp = objd.FileDescriptor.Group;
                nfo.Image = GetThumbnail(objd.FileDescriptor.Group, mn[0]);
            }
            else
            {
                nfo.Image = null;
            }

            if (pkg != null)
            {
                RenderGmdcPreview(pkg);
            }

            SetupCategories(SimPe.Cache.ObjectCacheItem.GetCategory(SimPe.Cache.ObjectCacheItemVersions.DockableOW, objd.FunctionSubSort, objd.Type, SimPe.Cache.ObjectClass.Object));

            SimPe.PackedFiles.Wrapper.StrItemList strs = GetCtssItems();
            if (strs != null)
            {
                if (strs.Count > 0)
                {
                    nfo.Name = strs[0].Title;
                }
                if (strs.Count > 1)
                {
                    nfo.Description = strs[1].Title;
                }
            }
            else
            {
                nfo.Name = objd.FileName;
            }

            nfo.Price = objd.Price;
            UpdateScreen();
        }
示例#5
0
        protected void SetName(uint type, SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(type);

            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.StrItemList items = Downloads.DefaultTypeHandler.GetCtssItems(pfds[0], pkg);
                if (items.Length > 0)
                {
                    nfo.Name = items[0].Title;
                }
            }
        }
示例#6
0
        protected override void SetName(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.CTSS_FILE);

            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.StrItemList items = Downloads.DefaultTypeHandler.GetCtssItems(pfds[0], pkg);
                if (items.Length > 0)
                {
                    nfo.Name = items[0].Title;
                }
                if (items.Length > 1)
                {
                    nfo.Description = items[1].Title;
                }
            }
        }
示例#7
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;
                }
            }
        }
示例#8
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
        }
示例#9
0
        protected void UpdateXObjScreen(SimPe.Interfaces.Files.IPackageFile pkg, bool clear)
        {
            if (clear)
            {
                ClearScreen();
            }
            if (cpf == null)
            {
                return;
            }

            nfo.FirstExpansion = PackageInfo.FileFrom(cpf.FileDescriptor);
            SetupCategories(SimPe.Cache.ObjectCacheItem.GetCategory(SimPe.Cache.ObjectCacheItemVersions.DockableOW, (SimPe.Data.ObjFunctionSubSort)GetFunctionSort(cpf), Data.ObjectTypes.Normal, SimPe.Cache.ObjectClass.XObject));

            nfo.Image = GetXThumbnail(cpf);
            if (pkg != null)
            {
                RenderGmdcPreview(pkg);
            }

            SimPe.PackedFiles.Wrapper.StrItemList strs = GetCtssItems();
            if (strs != null)
            {
                if (strs.Count > 0)
                {
                    nfo.Name = strs[0].Title;
                }
                if (strs.Count > 1)
                {
                    nfo.Description = strs[1].Title;
                }
            }
            else
            {
                nfo.Name        = cpf.GetSaveItem("name").StringValue;
                nfo.Description = cpf.GetSaveItem("description").StringValue;
            }


            nfo.Price = (int)cpf.GetSaveItem("cost").UIntegerValue;
            UpdateScreen();
        }
示例#10
0
        protected void UpdateXObjScreen()
        {
            ClearScreen();
            if (cpf == null)
            {
                return;
            }
            this.lbEPs.Visible = this.lbEPList.Visible = false;

            SetupCategories(SimPe.Cache.ObjectCacheItem.GetCategory(SimPe.Cache.ObjectCacheItemVersions.DockableOW, (SimPe.Data.ObjFunctionSubSort)GetFunctionSort(cpf), Data.ObjectTypes.Normal, SimPe.Cache.ObjectClass.XObject));

            pb.Image = null;
            pb.Image = GenerateImage(pb.Size, GetXThumbnail(cpf), true);

            SimPe.PackedFiles.Wrapper.StrItemList strs = GetCtssItems();
            if (strs != null)
            {
                if (strs.Count > 0)
                {
                    this.lbName.Text = strs[0].Title;
                }
                if (strs.Count > 1)
                {
                    this.lbAbout.Text = strs[1].Title;
                }
            }
            else
            {
                this.lbName.Text  = cpf.GetSaveItem("name").StringValue;
                this.lbAbout.Text = cpf.GetSaveItem("description").StringValue;
            }


            this.lbPrice.Text = cpf.GetSaveItem("cost").UIntegerValue.ToString() + " $";

            if (pb.Image == null)
            {
                pb.Image = defimg;
            }
        }
示例#11
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");
        }
示例#12
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);
        }
示例#13
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();
        }
示例#14
0
        public void UpdateScreen()
        {
            ClearScreen();
            if (objd == null)
            {
                return;
            }

            string[] mn = GetModelnames();
            if (mn.Length > 0)
            {
                uint grp = objd.FileDescriptor.Group;
                pb.Image = GenerateImage(pb.Size, GetThumbnail(objd.FileDescriptor.Group, mn[0]), true);
            }
            else
            {
                pb.Image = null;
            }

            if (pb.Image == null)
            {
                pb.Image = defimg;
            }

            SetupCategories(SimPe.Cache.ObjectCacheItem.GetCategory(SimPe.Cache.ObjectCacheItemVersions.DockableOW, objd.FunctionSubSort, objd.Type, SimPe.Cache.ObjectClass.Object));

            SimPe.PackedFiles.Wrapper.StrItemList strs = GetCtssItems();
            if (strs != null)
            {
                if (strs.Count > 0)
                {
                    this.lbName.Text = strs[0].Title;
                }
                if (strs.Count > 1)
                {
                    this.lbAbout.Text = strs[1].Title;
                }
            }
            else
            {
                this.lbName.Text = objd.FileName;
            }

            this.lbPrice.Text = objd.Price.ToString() + " $";

            Boolset       bs      = (ushort)objd.Data[0x40]; // EPFlags1
            List <string> epNames = pjse.BhavWiz.readStr(pjse.GS.BhavStr.GameEditionFlags);

            this.lbEPList.Text = "";
            for (int i = 0; i < bs.Length; i++)
            {
                if (bs[i])
                {
                    this.lbEPList.Text += (this.lbEPList.Text.Length == 0 ? "" : "; ") + epNames[i];
                }
            }

            bs      = (ushort)objd.Data[0x41]; // EPFlags2
            epNames = pjse.BhavWiz.readStr(pjse.GS.BhavStr.UnknownFlags);
            for (int i = 0; i < bs.Length; i++)
            {
                if (bs[i])
                {
                    this.lbEPList.Text += (this.lbEPList.Text.Length == 0 ? "" : "; ") + epNames[i];
                }
            }
        }
示例#15
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;
        }
示例#16
0
        public void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            loaded = false;
            ClearScreen();
            this.pkg = pkg;
            if (pkg == null)
            {
                return;
            }
            if (!Helper.IsNeighborhoodFile(pkg.FileName))
            {
                return;
            }
            loaded = true;



            try
            {
                SimPe.PackedFiles.Wrapper.StrItemList strs = GetCtssItems();
                if (strs != null)
                {
                    this.llEdit.Enabled = true;
                    if (strs.Count > 0)
                    {
                        this.lbName.Text = strs[0].Title;
                    }
                    if (strs.Count > 1)
                    {
                        this.lbAbout.Text = strs[1].Title;
                    }
                }


                string tname = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(pkg.FileName), System.IO.Path.GetFileNameWithoutExtension(pkg.FileName) + ".png");
                pb.Image = null;
                if (System.IO.File.Exists(tname))
                {
                    try
                    {
                        pb.Image = ObjectPreview.GenerateImage(pb.Size, Image.FromFile(tname), false);
                    }
                    catch {}
                }

                if (pb.Image == null)
                {
                    pb.Image = defimg;
                }
                lbPop.Text = pkg.FindFiles(Data.MetaData.SIM_DESCRIPTION_FILE).Length.ToString();
                if (pkg.FileName != null)
                {
                    lbUni.Text = System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(pkg.FileName), "N*_University*.package").Length.ToString();
                }
                else
                {
                    lbUni.Text = "0";
                }

                ShowVersion();
            }
            catch (Exception ex)
            {
                this.lbAbout.Text = ex.Message;
            }
        }
示例#17
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();
        }
示例#18
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);
        }
示例#19
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;
        }
示例#20
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);
        }
示例#21
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);
        }