Example #1
0
        public virtual void SetFromObjectCacheItem(SimPe.Cache.ObjectCacheItem oci)
        {
            if (oci == null)
            {
                objd = null;
                ClearScreen();
                return;
            }

            objd = null;
            if (oci.Tag != null)
            {
                if (oci.Tag is SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)
                {
                    objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                    objd.ProcessData((SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag);
                }
            }


            UpdateScreen();
            if (oci.Thumbnail == null)
            {
                pb.Image = defimg;
            }
            else
            {
                pb.Image = GenerateImage(pb.Size, oci.Thumbnail, true);
            }
            lbName.Text = oci.Name;
            lbVert.Text = "---";
        }
Example #2
0
        public virtual void SetFromObjectCacheItem(SimPe.Cache.ObjectCacheItem oci)
        {
            ClearScreen();
            if (oci == null)
            {
                objd = null;

                return;
            }

            objd = null;
            if (oci.Tag != null)
            {
                if (oci.Tag is SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)
                {
                    objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                    objd.ProcessData((SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)oci.Tag);
                }
            }


            UpdateScreen(null, false);
            if (oci.Thumbnail == null)
            {
                nfo.Image = null;
            }
            else
            {
                nfo.Image = oci.Thumbnail;
            }
            nfo.Name        = oci.Name;
            nfo.VertexCount = 0;
            nfo.FaceCount   = 0;
        }
Example #3
0
        protected void ScanFileTable(uint inst)
        {
            if (Helper.StartedGui == Executable.Classic)
            {
                return;
            }
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileDiscardingGroup(Data.MetaData.OBJD_FILE, inst);
            Wait.MaxProgress = items.Length;
            int ct   = 0;
            int step = Math.Max(2, Wait.MaxProgress / 100);

            foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
            {
                if (this.HaveToStop)
                {
                    break;
                }

                SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                objd.ProcessData(item);

                if (objd.Type == Data.ObjectTypes.Person || objd.Type == Data.ObjectTypes.Template)
                {
                    AddSim(objd, ref ct, step, true);
                }
            }
        }
Example #4
0
        protected Alias AddSim(SimPe.Interfaces.Files.IPackageFile fl, IPackedFileDescriptor objdpfd, ref int ct, int step)
        {
            SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
            objd.ProcessData(objdpfd, fl);

            return(AddSim(objd, ref ct, step, false));
        }
Example #5
0
        protected void GetObjd(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.OBJD_FILE);
            if (pfds.Length > 0)
            {
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.ExtObjd mobjd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                    mobjd.ProcessData(pfd, pkg);

                    nfo.AddGuid(mobjd.Guid);

                    if (objd == null)
                    {
                        objd = mobjd;
                    }
                    if (pfds.Length == 1)
                    {
                        break;
                    }
                    if (mobjd.Data.Length > 0xb)
                    {
                        if (mobjd.Data[0xb] == -1)
                        {
                            objd = mobjd;
                        }
                    }
                }
            }
        }
Example #6
0
        public virtual void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            ClearScreen();
            if (pkg == null)
            {
                objd = null;
                return;
            }

            GetObjd(pkg);
            UpdateScreen(pkg, false);
        }
Example #7
0
        /// <summary>
        /// Load a List of all available GUIDs in the package
        /// </summary>
        /// <returns>The list of GUIDs</returns>
        public ArrayList GetGuidList()
        {
            ArrayList list = new ArrayList();

            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                objd.ProcessData(pfd, package);
                list.Add(objd.Guid);
            }

            return(list);
        }
Example #8
0
        /// <summary>
        /// Returns the Primary Guid of the Object
        /// </summary>
        /// <returns>0 or the default guid</returns>
        public uint GetPrimaryGuid()
        {
            uint guid = 0;

            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFile(Data.MetaData.OBJD_FILE, 0, 0x41A7);
            if (pfds.Length == 0)
            {
                pfds = package.FindFiles(Data.MetaData.OBJD_FILE);
            }
            if (pfds.Length > 0)
            {
                SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                objd.ProcessData(pfds[0], package);
                guid = objd.Guid;
            }
            return(guid);
        }
Example #9
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();
            }
        }
Example #10
0
        public void DoSearchPackage(SimPe.Interfaces.Files.IPackageFile pkg, SimPe.Interfaces.Files.IPackedFileDescriptor pfd)
        {
            SimPe.PackedFiles.Wrapper.ExtObjd obj = new SimPe.PackedFiles.Wrapper.ExtObjd();
            obj.ProcessData(pfd, pkg);

            bool found = false;

            if (name != "")
            {
                string n = obj.FileName.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);
                }
            }

            if (guid > 0 && (found || name == ""))
            {
                found = obj.Guid == guid;
            }

            //we have a match, so add the result item
            if (found)
            {
                ResultGui.AddResult(pkg, pfd);
            }
        }
Example #11
0
        /// <summary>
        /// Make sure the fixes for OBJd Resources are considered
        /// </summary>
        /// <remarks>
        /// Currently this implements the Fixes needed for Rugs
        /// </remarks>
        void FixOBJd()
        {
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Updating Object Descriuptions");
            }
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(Data.MetaData.OBJD_FILE);                 //OBJd

            bool updaterugs = false;

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                objd.ProcessData(pfd, package);

                //is one of the objd's a rug?
                if (objd.FunctionSubSort == SimPe.Data.ObjFunctionSubSort.Decorative_Rugs)
                {
                    updaterugs = true;
                    break;
                }
            }

            //found at least one OBJd describing a Rug
            if (updaterugs)
            {
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                    objd.ProcessData(pfd, package);

                    //make sure the Type of a Rug is not a Tile, but Normal
                    if (objd.Type == SimPe.Data.ObjectTypes.Tiles)
                    {
                        objd.Type = SimPe.Data.ObjectTypes.Normal;
                        objd.SynchronizeUserData(true, true);
                    }
                }
            }
        }
Example #12
0
        public virtual void SetFromPackage(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            if (pkg == null)
            {
                objd = null;
                ClearScreen();
                return;
            }

            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(Data.MetaData.OBJD_FILE, 0, 0x41A7);
            if (pfds.Length > 0)
            {
                objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                objd.ProcessData(pfds[0], pkg);
            }
            int fct = 0; int vct = 0;

            pfds = pkg.FindFiles(Data.MetaData.GMDC);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol();
                rcol.ProcessData(pfd, pkg, true);

                SimPe.Plugin.GeometryDataContainer gmdc = rcol.Blocks[0] as SimPe.Plugin.GeometryDataContainer;
                foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups)
                {
                    fct += g.FaceCount;
                    vct += g.UsedVertexCount;
                }

                rcol.Dispose();
            }
            lbVert.Text = vct.ToString() + " (" + fct.ToString() + " Faces)";


            UpdateScreen();
        }
Example #13
0
        public void ReloadCache(SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fileindex, bool save)
        {
            Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = fileindex.FindFile(Data.MetaData.OBJD_FILE, true);

            bool added = false;

            Wait.MaxProgress = items.Length;
            Wait.Message     = "Updating Cache";
            int ct = 0;

            foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
            {
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] citems = this.FileIndex.FindFile(item.GetLocalFileDescriptor(), null);
                if (citems.Length == 0)
                {
                    SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                    objd.ProcessData(item);

                    this.AddItem(objd);
                    added = true;
                }
                Wait.Progress = ct++;
            }

            if (added)
            {
                this.map     = null;
                Wait.Message = "Saving Chache";
                if (save)
                {
                    this.Save(this.FileName);
                }
                this.LoadMemTable();
                this.LoadMemList();
            }
        }
Example #14
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);
        }
Example #15
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();
        }
Example #16
0
 public virtual void Dispose()
 {
     nfo    = null;
     flname = null;
     objd   = null;
 }
Example #17
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;
        }
Example #18
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);
        }
Example #19
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)
 {
 }
Example #20
0
        public void ExecuteEventHandler(object sender, SimPe.Events.ResourceEventArgs e)
        {
            if (!ChangeEnabledStateEventHandler(null, e))
            {
                return;
            }

            SimPe.FileTable.FileIndex.Load();

            System.IO.StreamWriter sw = new System.IO.StreamWriter(new System.IO.MemoryStream());
            try
            {
                System.Collections.ArrayList guids = new System.Collections.ArrayList();
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = SimPe.FileTable.FileIndex.FindFile(Data.MetaData.OBJD_FILE, true);
                sw.WriteLine("<?");
                sw.WriteLine("$guids = array(");
                sw.Write("    ");
                Wait.SubStart(items.Length);
                int ct = 0;
                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    SimPe.PackedFiles.Wrapper.ExtObjd objd = new SimPe.PackedFiles.Wrapper.ExtObjd();
                    objd.ProcessData(item);

                    if (guids.Contains(objd.Guid))
                    {
                        continue;
                    }
                    if (objd.Type == SimPe.Data.ObjectTypes.Memory)
                    {
                        continue;
                    }
                    if (objd.Type == SimPe.Data.ObjectTypes.Person)
                    {
                        continue;
                    }

                    if (ct > 0)
                    {
                        sw.Write(",");
                    }
                    ct++;
                    Wait.Progress = ct;
                    sw.Write("array(");
                    sw.Write("0x" + Helper.HexString(objd.Guid));
                    guids.Add(objd.Guid);
                    sw.Write(", '");
                    sw.Write("Maxis: " + objd.FileName.Replace("'", "").Replace("\\", "").Replace("\"", ""));

                    /*SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] list = SimPe.FileTable.FileIndex.FindFile(Data.MetaData.CTSS_FILE, objd.FileDescriptor.Group, objd.CTSSInstance, null);
                     * if (list.Length==0) sw.Write(objd.FileName.Replace("'", "").Replace("\\", "").Replace("\"", ""));
                     * else
                     * {
                     *      SimPe.PackedFiles.Wrapper.Str str = new SimPe.PackedFiles.Wrapper.Str(1);
                     *      str.ProcessData(list[0]);
                     *      SimPe.PackedFiles.Wrapper.StrItemList strs = str.LanguageItems(SimPe.Data.MetaData.Languages.English);
                     *      if (strs.Count==0) sw.Write(objd.FileName.Replace("'", "").Replace("\\", "").Replace("\"", ""));
                     *      else sw.Write(strs[0].Title.Replace("'", "").Replace("\\", "").Replace("\"", ""));
                     * }*/
                    sw.WriteLine("')");
                }
                Wait.SubStop();
                sw.WriteLine(");");
                sw.WriteLine("?>");

                Report f = new Report();
                f.Execute(sw);
            }
            finally
            {
                sw.Close();
            }
        }
Example #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="cpf"></param>
        /// <returns>ResourceDescriptor for the references String</returns>
        protected static SimPe.Interfaces.Files.IPackedFileDescriptor UpdateDescription(OWCloneSettings cs, SimPe.Packages.GeneratableFile package, SimPe.PackedFiles.Wrapper.ExtObjd obj)
        {
            obj.Price      = cs.Price;
            obj.Data[0x22] = (short)Math.Floor(cs.Price * 0.035); // sale price
            obj.Data[0x23] = (short)Math.Floor(cs.Price * 0.15);  // initial depreciation
            obj.Data[0x24] = (short)Math.Floor(cs.Price * 0.10);  // daily depreciation
            obj.Data[0x25] = 0;                                   // self depreciation
            obj.Data[0x26] = (short)Math.Floor(cs.Price * 0.40);  // depreciation limit
            obj.SynchronizeUserData();
            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile(Data.MetaData.CTSS_FILE, 0, obj.FileDescriptor.Group, obj.CTSSInstance);

            return(pfd);
        }
Example #22
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);
        }