Exemplo n.º 1
0
 private void ver1_LoadedItem(SimPe.Cache.ObjectCacheItem oci, SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii, SimPe.Data.Alias a)
 {
     if (LoadedItem != null)
     {
         LoadedItem(oci, fii, a);
     }
 }
Exemplo n.º 2
0
        public static void Execute(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem animitem)
        {
            SimPe.Plugin.GenericRcol rcol = new GenericRcol();
            rcol.ProcessData(animitem);

            Execute(rcol);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Call this if you want to unload a Wrapper
        /// </summary>
        /// <param name="doc">The document presenting the Wrapper</param>
        /// <returns>true, if the Wrapper was unloaded completley (false if User decided to answer with Cancel)</returns>
        bool UnloadWrapper(TD.SandDock.DockControl doc)
        {
            SimPe.Interfaces.Plugin.IFileWrapper wrapper = (SimPe.Interfaces.Plugin.IFileWrapper)doc.Tag;
            bool multi = wrapper.AllowMultipleInstances;
            bool res   = UnloadWrapper(wrapper);

            if (res)
            {
                //doc.Controls.Clear();
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii = this.GetResourceFromDocument(doc);
                RemoveResource(fii, wrapper);

                if (multi)
                {
                    DisposeSubControls(doc.Controls);
                    ClearControls(doc);
                }
                else
                {
                    doc.Controls.Clear();
                }

                this.UnlinkWrapper(wrapper);
            }


            return(res);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Closes the passed Document (which represents the passed Resource)
        /// </summary>
        /// <param name="fii">the Reource represented by the Document</param>
        /// <returns>true, if the Document was closed</returns>
        bool CloseDocument(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            bool remain = false;

            TD.SandDock.DockControl doc = (TD.SandDock.DockControl)loaded[fii];
            if (doc != null)
            {
                doc.Close();
            }
            else
            {
                RemoveResource(fii, null);
            }

            if (doc != null)
            {
                if (doc.IsOpen)
                {
                    remain = true;
                }
                else
                {
                    RemoveResource(fii, null);
                }
            }

            return(!remain);
        }
Exemplo n.º 5
0
        public GenericRcol FindUsedGMDC(GenericRcol cres)
        {
            if (cres == null)
            {
                return(null);
            }

            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = cres.FindReferencedType(Data.MetaData.SHPE);
            if (item != null)
            {
                GenericRcol rcol = new GenericRcol();
                rcol.ProcessData(item);

                item = rcol.FindReferencedType(Data.MetaData.GMND);
                if (item != null)
                {
                    rcol.ProcessData(item);
                    item = rcol.FindReferencedType(Data.MetaData.GMDC);
                    if (item != null)
                    {
                        rcol.ProcessData(item);
                        return(rcol);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Selects the Document that shows the selected Resource
        /// </summary>
        /// <param name="fii">The Resource you want to select</param>
        /// <returns>true, if that resource was found</returns>
        public bool SelectResource(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            if (fii == null)
            {
                return(false);
            }

            if (loaded.ContainsKey(fii))
            {
                TD.SandDock.DockControl doc = (TD.SandDock.DockControl)loaded[fii];

                if (doc.Parent == null)
                {
                    return(true);
                }
                if (doc.Parent is TD.SandDock.TabControl)
                {
                    ((TD.SandDock.TabControl)doc.Parent).SelectedPage = (TD.SandDock.TabPage)doc;
                }
                else
                {
                    doc.LayoutSystem.SelectedControl = doc;
                }


                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// If the Resource was already Loaded, this Method Wil Focus it and optional Reload the Content
        /// </summary>
        /// <param name="fii"></param>
        /// <param name="reload"></param>
        /// <returns>true, if a Document was highlighted</returns>
        bool FocusResource(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii, bool reload)
        {
            //already in List
            if (SelectResource(fii))
            {
                if (reload)
                {
                    TD.SandDock.DockControl doc = this.GetDocument(fii);
                    if (doc == null)
                    {
                        return(false);
                    }

                    SimPe.Interfaces.Plugin.IFileWrapper wrp = (SimPe.Interfaces.Plugin.IFileWrapper)doc.Tag;
                    if (UnloadWrapper(wrp))
                    {
                        wrp.ProcessData(fii);
                        wrp.RefreshUI();
                    }
                }
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        public ScenegraphResultItem(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
            : base(SimPe.Localization.GetString("Unknown"))
        {
            this.fii = fii;
            SimPe.Interfaces.Plugin.Internal.IPackedFileWrapper wrp = FileTable.WrapperRegistry.FindHandler(fii.FileDescriptor.Type);
            if (wrp != null)
            {
                ((SimPe.Interfaces.Plugin.AbstractWrapper)wrp).Package        = fii.Package;
                ((SimPe.Interfaces.Plugin.AbstractWrapper)wrp).FileDescriptor = fii.FileDescriptor;
                this.Text = wrp.ResourceName;
            }
            else
            {
                this.Text = fii.FileDescriptor.ToString();
            }

            this.SubItems.Add("0x" + Helper.HexString(fii.FileDescriptor.Type));
            this.SubItems.Add("0x" + Helper.HexString(fii.FileDescriptor.Group));
            this.SubItems.Add("0x" + Helper.HexString(fii.FileDescriptor.LongInstance));
            this.SubItems.Add("0x" + Helper.HexString(fii.FileDescriptor.Offset));
            this.SubItems.Add("0x" + Helper.HexString(fii.FileDescriptor.Size));
            this.SubItems.Add(fii.Package.SaveFileName);

            /*this.SubItems.Add("    Type: 0x"+Helper.HexString(fii.FileDescriptor.Type));
             * this.SubItems.Add("    Group: 0x"+Helper.HexString(fii.FileDescriptor.Group));
             * this.SubItems.Add("    Instance: 0x"+Helper.HexString(fii.FileDescriptor.LongInstance));
             * this.SubItems.Add("    Offset: 0x"+Helper.HexString(fii.FileDescriptor.Offset));
             * this.SubItems.Add("    Size: 0x"+Helper.HexString(fii.FileDescriptor.Size));
             * this.SubItems.Add("    "+fii.Package.SaveFileName);*/
        }
Exemplo n.º 9
0
 public CorruptedFileException(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item, Exception inner)
     : base(
         "A corrupted PackedFile was found.",
         new Exception("The File '" + GetFileName(item) + "' contains a Corrupted File (" + item.FileDescriptor.ToString() + ").\n\n SimPE will Ignore this File, but the resulting Package might be broken!", inner)
         )
 {
     FileTable.FileIndex.RemoveItem(item);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Returns the Document that contains a given Resource
 /// </summary>
 /// <param name="fii">The Resource you want to select</param>
 /// <returns>the Document that contains the PluginView for the passed Resource (null if none)</returns>
 public TD.SandDock.DockControl GetDocument(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
 {
     if (loaded.ContainsKey(fii))
     {
         return((TD.SandDock.DockControl)loaded[fii]);
     }
     return(null);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Load the assigned Wrapper, and initiate the Resource
 /// </summary>
 /// <param name="fii"></param>
 /// <returns></returns>
 public void LoadWrapper(ref SimPe.Interfaces.Plugin.IFileWrapper wrapper, SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
 {
     if (wrapper != null)
     {
         wrapper = wrapper.Activate();
         wrapper.ProcessData(fii.Package.FindExactFile(fii.FileDescriptor), fii.Package);
     }
 }
Exemplo n.º 12
0
 internal LotItem(uint inst, string name, System.Drawing.Image img, SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
 {
     this.name = name;
     this.img  = img;
     this.inst = inst;
     owner     = 0;
     tags      = new ArrayList();
     this.fii  = fii;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Removes the Resource from the internal storage
 /// </summary>
 /// <param name="fii"></param>
 /// <param name="wrapper"></param>
 public void RemoveResource(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii, SimPe.Interfaces.Plugin.IFileWrapper wrapper)
 {
     if (fii != null)
     {
         loaded.Remove(fii);
         if (wrapper != null)
         {
             single.Remove(wrapper.GetType().ToString());
         }
     }
 }
Exemplo n.º 14
0
 public void Dispose()
 {
     img  = null;
     name = null;
     if (tags != null)
     {
         tags.Clear();
     }
     tags = null;
     fii  = null;
 }
Exemplo n.º 15
0
            public Entry(IPackageFile package, IPackedFileDescriptor pfd, bool isMaxis, bool isFixed)
            {
                this.package = package;
                this.pfd     = pfd;
                this.isMaxis = isMaxis;
                this.isFixed = isFixed;

                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] fiis = SimPe.FileTable.FileIndex.FindFile(pfd, package);
                this.fii = (fiis.Length == 1) ? fiis[0] : null;

                this.pfd.ChangedData += new SimPe.Events.PackedFileChanged(pfd_ChangedData);
            }
Exemplo n.º 16
0
 /// <summary>
 /// Close the given Document
 /// </summary>
 /// <param name="doc"></param>
 /// <returns>true, if the Document was closed</returns>
 public bool CloseDocument(TD.SandDock.DockControl doc)
 {
     SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii = GetResourceFromDocument(doc);
     if (fii != null)
     {
         return(CloseDocument(fii));
     }
     else
     {
         doc.Close();
         return(!doc.IsOpen);
     }
 }
Exemplo n.º 17
0
 public static void Refresh(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
 {
     if (srl != null)
     {
         foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem loaded in srl.loaded.Keys)
         {
             if (loaded.Package == fii.Package && loaded.FileDescriptor.Equals(fii.FileDescriptor))
             {
                 srl.RefreshUI(loaded);
             }
         }
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// Starts the external Plugin
        /// </summary>
        /// <param name="pfd">File Descriptor of the Selected File</param>
        /// <param name="package">The package the File is stored in</param>
        public void Execute(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item)
        {
            if (item == null)
            {
                return;
            }
            if (item.FileDescriptor == null)
            {
                return;
            }
            if (item.Package == null)
            {
                return;
            }

            string extfile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "simpe");
            uint   ct      = 0;

            while (System.IO.File.Exists(extfile + Helper.HexString(ct) + ".tmp"))
            {
                ct++;
            }
            extfile = extfile + Helper.HexString(ct) + ".tmp";

            try
            {
                SavePackedFile(extfile, false, (SimPe.Packages.PackedFileDescriptor)item.FileDescriptor, (SimPe.Packages.GeneratableFile)item.Package);

                Process p = new Process();
                p.StartInfo.FileName  = RealFileName;
                p.StartInfo.Arguments = Attributes.Replace("{tempname}", "\"" + extfile + "\"").Replace("{tempfile}", "\"" + extfile + "\"");

                p.Start();

                p.WaitForExit();
                p.Close();

                SimPe.Packages.PackedFileDescriptor pfd = (SimPe.Packages.PackedFileDescriptor)item.FileDescriptor;
                OpenPackedFile(extfile, ref pfd);
                pfd.Filename = null;
                pfd.Path     = null;
            }
            finally
            {
                try
                {
                    System.IO.File.Delete(extfile);
                }
                catch (Exception) {}
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Returns the resource stored in a Document
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem GetResourceFromDocument(TD.SandDock.DockControl doc)
        {
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii = null;
            foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem localfii in loaded.Keys)
            {
                if (loaded[localfii] == doc)
                {
                    fii = localfii;
                    break;
                }
            }

            return(fii);
        }
Exemplo n.º 20
0
        public void RefreshUI(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            TD.SandDock.DockControl doc = this.GetDocument(fii);
            if (doc == null)
            {
                return;
            }

            SimPe.Interfaces.Plugin.IFileWrapper wrp = (SimPe.Interfaces.Plugin.IFileWrapper)doc.Tag;
            if (UnloadWrapper(wrp))
            {
                wrp.ProcessData(fii);
                wrp.RefreshUI();
            }
        }
Exemplo n.º 21
0
        public bool SelectResource(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem resource)
        {
            bool res = false;

            if (lv != null)
            {
                res = lv.SelectResource(resource);
            }
            if (!res && tv != null && lv != null)
            {
                tv.SelectAll();
                res = lv.SelectResource(resource);
            }
            return(res);
        }
Exemplo n.º 22
0
        static string GetFileName(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item)
        {
            if (item == null)
            {
                return("");
            }
            if (item.Package == null)
            {
                return("");
            }
            if (item.Package.FileName == null)
            {
                return("");
            }

            return(item.Package.FileName);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Open a Package in the main SimPE Gui
        /// </summary>
        /// <param name="pfd">The FileDescriptor</param>
        /// <returns>true, if the package was opened</returns>
        public static bool OpenPackedFile(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            if (opf == null)
            {
                return(false);
            }

            try
            {
                return(opf(fii));
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage("Unable to open a resource in the SimPE GUI. (" + fii.ToString() + ")", ex);
            }
            return(false);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Returns a XWAnt File for this Item or null
        /// </summary>
        /// <param name="guid">The GUID of the Want</param>
        /// <returns>The Xant Object representing That want (or null if not found)</returns>
        public static XWant GetWant(uint guid)
        {
            if (wants == null)
            {
                LoadWants();
            }

            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem wts = (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem)wants[guid];
            if (wts != null)
            {
                XWant xwnt = new XWant();
                wts.FileDescriptor.UserData = wts.Package.Read(wts.FileDescriptor).UncompressedData;
                xwnt.ProcessData(wts);

                return(xwnt);
            }

            return(null);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Load the assigned Wrapper, and initiate the Resource
        /// </summary>
        /// <param name="fii"></param>
        /// <returns></returns>
        public SimPe.Interfaces.Plugin.IFileWrapper GetWrapper(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            if (fii == null)
            {
                return(null);
            }

            //try by Type
            SimPe.Interfaces.Plugin.IFileWrapper wrapper =
                (SimPe.Interfaces.Plugin.IFileWrapper)FileTable.WrapperRegistry.FindHandler(fii.FileDescriptor.Type);

            //try by Signature
            if (wrapper == null)
            {
                SimPe.Interfaces.Files.IPackedFile pf = pkg.Package.Read(fii.FileDescriptor);
                wrapper = FileTable.WrapperRegistry.FindHandler(pf.GetUncompressedData(0x40));
            }

            return(wrapper);
        }
Exemplo n.º 26
0
        /// <summary>
        /// The resource that should be added to the Container
        /// </summary>
        /// <param name="fii"></param>
        /// <param name="reload">
        /// when the Resource is already visible, and this Argument is true, the Gui
        /// will be reloaded. This means, that all unsaved changes will get lost!
        /// </param>
        /// <param name="overload">Replace the currently active Document Tab with the new one</param>
        /// <returns>true, if the Plugin was loaded</returns>
        public bool AddResource(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii, bool reload, bool overload)
        {
            if (!pkg.Loaded)
            {
                return(false);
            }

            //already Loaded?
            if (FocusResource(fii, reload))
            {
                return(true);
            }

            //only one File at a Time?
            if (!Helper.WindowsRegistry.MultipleFiles)
            {
                this.Clear();
            }

            //get the Wrapper
            SimPe.Interfaces.Plugin.IFileWrapper wrapper = GetWrapper(fii);

            //unload if only one instance can be loaded
            if (!UnloadSingleInstanceWrappers(wrapper, ref overload))
            {
                return(false);
            }

            try
            {
                //load the new Data into the Wrapper
                LoadWrapper(ref wrapper, fii);

                //Present the passed Wrapper
                return(Present(fii, wrapper, overload));
            }
#if !DEBUG
            catch (Exception ex) { Helper.ExceptionMessage(ex); return(false); }
#endif
            finally { }
        }
Exemplo n.º 27
0
        string FindTxtrName(string name)
        {
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(name, Data.MetaData.TXTR, 0xffffffff, true);
            if (item != null)
            {
                Rcol txtr = new GenericRcol(null, false);
                txtr.ProcessData(item);
                name = txtr.FileName.Trim();
                if (name.ToLower().EndsWith("_txtr"))
                {
                    name = name.Substring(0, name.Length - 5);
                }
                if (name.StartsWith("#"))
                {
                    name = "_" + name;
                }
            }
            name = name.Replace("-", "_");

            return(name);
        }
Exemplo n.º 28
0
 public bool SelectResource(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem resource)
 {
     lock (names)
     {
         int ct = 0;
         foreach (NamedPackedFileDescriptor pfd in names)
         {
             if (pfd.Resource.FileDescriptor.Equals(resource.FileDescriptor))
             {
                 BeginUpdate();
                 lv.SelectedIndices.Clear();
                 lv.SelectedIndices.Add(ct);
                 lv.EnsureVisible(ct);
                 EndUpdate();
                 return(true);
             }
             ct++;
         }
     }
     return(false);
 }
Exemplo n.º 29
0
        public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.MMAT);
            //ArrayList list = new ArrayList();

            ps.State = TriState.True;
            //FileTable.FileIndex.StoreCurrentState();
            if (!FileTable.FileIndex.ContainsPath(System.IO.Path.GetDirectoryName(si.FileName)))
            {
                FileIndex.AddIndexFromFolder(System.IO.Path.GetDirectoryName(si.FileName));
            }

            FileIndex.AddIndexFromPackage(si.Package);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.MmatWrapper mmat = new MmatWrapper();
                mmat.ProcessData(pfd, si.Package, false);

                string m = mmat.ModelName.Trim().ToLower();
                if (!m.EndsWith("_cres"))
                {
                    m += "_cres";
                }

                //Add the current package
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(m, Data.MetaData.CRES, Data.MetaData.LOCAL_GROUP, true);

                if (item == null)
                {
                    ps.State = TriState.False;
                }

                item = null;
                mmat.Dispose();
                m = null;
            }
            //FileTable.FileIndex.RestoreLastState();

            UpdateState(si, ps, lvi);
        }
Exemplo n.º 30
0
        public bool OpenPackedFile(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem fii)
        {
            if (fii == null)
            {
                return(false);
            }

            try
            {
                if (fii.Package != null)
                {
                    if (!fii.Package.Equals(lp.Package))
                    {
                        int bprc = Helper.WindowsRegistry.BigPackageResourceCount;
                        Helper.WindowsRegistry.BigPackageResourceCount = int.MaxValue;

                        if (!lp.LoadFromPackage((SimPe.Packages.GeneratableFile)fii.Package))
                        {
                            Helper.WindowsRegistry.BigPackageResourceCount = bprc;
                            return(false);
                        }
                        Helper.WindowsRegistry.BigPackageResourceCount = bprc;
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage(ex);
                return(false);
            }

            bool res = rl.AddResource(fii, false);

            if (res && LoadedResource != null)
            {
                FireLoadEvent(fii);
            }

            return(res);
        }