Ejemplo n.º 1
0
 protected override string GetResourceName(SimPe.Data.TypeAlias ta)
 {
     if (!this.Processed)
     {
         ProcessData(FileDescriptor, Package);
     }
     return(LotName);
 }
Ejemplo n.º 2
0
 protected override string GetResourceName(SimPe.Data.TypeAlias ta)
 {
     if (!this.Processed)
     {
         ProcessData(FileDescriptor, Package);
     }
     return(this.Folder + " / " + this.NodeText + " (" + this.ObjectType + ")");
 }
Ejemplo n.º 3
0
 public ResourceTreeTypeNodeExt(ResourceViewManager.ResourceNameList list, uint type)
     : base(type, list, "")
 {
     this.type               = type;
     this.ImageIndex         = ResourceViewManager.GetIndexForResourceType(type);
     this.SelectedImageIndex = this.ImageIndex;
     SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(type);
     this.Text = ta.Name + " (" + ta.shortname + ") (" + list.Count + ")";
 }
Ejemplo n.º 4
0
        protected override string GetResourceName(SimPe.Data.TypeAlias ta)
        {
            if (!this.Processed)
            {
                ProcessData(FileDescriptor, Package);
            }
            CpfItem item = this.GetItem("name");

            if (item == null)
            {
                return(base.GetResourceName(ta));
            }
            else
            {
                return(item.StringValue);
            }
        }
Ejemplo n.º 5
0
        public AddExtTool()
        {
            //
            // Erforderlich für die Windows Form-Designerunterstützung
            //
            InitializeComponent();

            foreach (SimPe.Data.TypeAlias a in SimPe.Helper.TGILoader.FileTypes)
            {
                if (a.Id == 0xffffffff)
                {
                    SimPe.Data.TypeAlias an = new SimPe.Data.TypeAlias(false, "ALL", 0xffffffff, "---  All Types ---", true, true);
                    cbtypes.Items.Add(an);
                }
                else
                {
                    cbtypes.Items.Add(a);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds all Orphants to the Tree
        /// </summary>
        /// <param name="pkg"></param>
        public void FindUnused(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            int top  = 0;
            int left = 0;

            foreach (int t in coords.Keys)
            {
                if (t > top)
                {
                    top = t;
                }
            }

            top += 128;
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pkg.Index)
            {
                if ((pfd.Type == Data.MetaData.MMAT) || (Data.MetaData.RcolList.Contains(pfd.Type)))
                {
                    GraphItem gi = new GraphItem(new Ambertation.Collections.PropertyItems());
                    gi.Text = Hashes.StripHashFromName(pfd.Filename);

                    //gi.BeginUpdate();
                    gi.SetBounds(left, top, 200, 64);
                    //gi.Location = new Point(left, top);
                    gi.GotFocus += new EventHandler(gi_GotFocus);

                    gi.Tag  = Hashes.StripHashFromName(pfd.Filename);
                    gi.Fade = 0.7f;
                    //gi.LinkColor = Color.FromArgb(35, Color.Black);

                    //gi.SelectedLinkColor = Color.FromArgb(0xff, Color.DarkBlue);

                    SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(pfd.Type);
                    gi.Properties["Type"].Value      = ta.shortname;
                    gi.Properties["Available"].Value = "true (orphan)";
                    if (colors.ContainsKey(ta.shortname))
                    {
                        gi.PanelColor = (Color)colors[ta.shortname];
                    }

                    SimPe.Interfaces.Scenegraph.IScenegraphItem item = null;
                    if (Data.MetaData.RcolList.Contains(pfd.Type))
                    {
                        item = BuildRcol(pfd, pkg, gi);
                    }
                    else if (pfd.Type == Data.MetaData.MMAT)
                    {
                        item = BuildMmat(pfd, pkg, gi);
                    }
                    //gi.Parent = gc;
                    if (item != null)
                    {
                        string name = gi.Text.Trim().ToLower();
                        if (!names.ContainsKey(name))
                        {
                            //gc.Add(gi);
                            gi.Parent = gc;
                            left     += gi.Size.Width + 8;
                            //gi.EndUpdate();
                        }
                    }
                }
            }

            gc.Update();
        }
Ejemplo n.º 7
0
        void AddItem(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg, GraphItem parent, SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fileindex)
        {
            #region Default Setup
            int top  = -128;
            int left = 0;

            if (parent != null)
            {
                top = parent.Location.Y;
            }
            do
            {
                top += 128;
                if (coords.ContainsKey(top))
                {
                    left = (int)coords[top];
                }
                //if (parent!=null) if (left<parent.Location.X) left = parent.Location.X;
            } while (left > gc.Parent.Width && false);

            GraphItem gi = new GraphItem(new Ambertation.Collections.PropertyItems());
            gi.Text = Hashes.StripHashFromName(pfd.Filename);
            //gi.BeginUpdate();
            //gi.Location = new Point(left, top);
            gi.SetBounds(left, top, 200, 64);
            gi.GotFocus += new EventHandler(gi_GotFocus);
            gi.Tag       = Hashes.StripHashFromName(pfd.Filename);
            gi.Fade      = 0.7f;
            //gi.LinkColor = Color.FromArgb(35, Color.Black);
            //gi.SelectedLinkColor = Color.FromArgb(0xff, Color.DarkBlue);

            SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(pfd.Type);
            gi.Properties["Type"].Value      = ta.shortname;
            gi.Properties["Available"].Value = "false";
            //gi.Parent = gc;
            #endregion

            //check if we already have a reource of that kind
            string name = gi.Text.Trim().ToLower();
            if (names.ContainsKey(name))
            {
                //gi.EndUpdate();
                gi = (GraphItem)names[name];

                if (parent != null)
                {
                    parent.ChildItems.Add(gi);
                }
            }
            else
            {
                #region find File
                SimPe.Interfaces.Scenegraph.IScenegraphItem  item   = null;
                SimPe.Interfaces.Files.IPackedFileDescriptor pkgpfd = pkg.FindFile(pfd);

                //not found in the passed package, look for a global File with that Name
                if (pkgpfd == null)
                {
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem items = FileTable.FileIndex.FindFileByName(pfd.Filename, pfd.Type, pfd.Group, true);
                    if (items != null)
                    {
                        gi.Properties["Available"].Value = "extern";
                        gi.Properties["File"].Value      = items.Package.FileName;
                        gi.Size       = new Size(gi.Size.Width, 70);
                        gi.PanelColor = Color.Black;
                    }
                }
                #endregion

                //the file is available, so add it
                if (pkgpfd != null)
                {
                    gi.Properties["Available"].Value = "true";
                    if (colors.ContainsKey(ta.shortname))
                    {
                        gi.PanelColor = (Color)colors[ta.shortname];
                    }

                    if (Data.MetaData.RcolList.Contains(pfd.Type))
                    {
                        item = BuildRcol(pkgpfd, pkg, gi);
                    }
                    else if (pfd.Type == Data.MetaData.MMAT)
                    {
                        item = BuildMmat(pkgpfd, pkg, gi);
                    }

                    /*}
                     * else
                     * {
                     *      if (Data.MetaData.RcolList.Contains(pfd.Type)) item = BuildRcol(pkgpfd, altpkg, gi);
                     *      else if (pfd.Type==Data.MetaData.MMAT) item = BuildMmat(pkgpfd, altpkg, gi);
                     * }*/

                    //check again if we still don't have that file
                    name = gi.Text.Trim().ToLower();
                    if (names.ContainsKey(name))
                    {
                        //gi.EndUpdate();
                        gi = (GraphItem)names[name];
                    }
                    else
                    {
                        //now process the Reference Files
                        if (item != null)
                        {
                            Hashtable ht = item.ReferenceChains;
                            foreach (ArrayList list in ht.Values)
                            {
                                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor spfd in list)
                                {
                                    AddItem(spfd, pkg, gi, fileindex);
                                }
                            }
                        }
                    }
                }

                gi.Invalidate();

                if (!names.ContainsKey(name))
                {
                    names.Add(name, gi);
                    gi.Parent   = gc;
                    coords[top] = left + 8 + gi.Size.Width;

                    if (pkgpfd == null)
                    {
                        gi.PanelColor  = Color.DarkRed;
                        gi.ForeColor   = Color.White;
                        gi.BorderColor = gi.ForeColor;

                        if ((string)gi.Properties["Available"].Value == "extern")
                        {
                            gi.PanelColor = Color.Black;
                        }
                    }
                }


                if (parent != null)
                {
                    parent.ChildItems.Add(gi);
                }
            }

            //gi.EndUpdate();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds the given .package file to the cache
        /// </summary>
        /// <param name="flname">Complete name of the .package file</param>
        /// <returns>true, if the contents had to get updated</returns>
        public bool AddPackageFile(string flname)
        {
            if (!System.IO.File.Exists(flname))
            {
                return(false);
            }
            DateTime filemod = System.IO.File.GetLastWriteTime(flname);
            bool     mod     = false;

            SqlCommands.LoadFileRow lfr = new SimPe.Database.SqlCommands.LoadFileRow(sql);
            lfr.FileName = flname;

            SQLiteDataReader dr  = AddPackageWhenNew(ref filemod, ref mod, lfr);
            long             fid = UpdatePackageModDate(flname, ref filemod, ref mod, lfr, dr);

            if (mod)
            {
                SimPe.Packages.File      pkg = SimPe.Packages.File.LoadFromFile(flname);
                SqlCommands.AddResources ar  = new SimPe.Database.SqlCommands.AddResources(sql);
                ar.PrepareLoop(fid);
                Dictionary <uint, Performance> dict = new Dictionary <uint, Performance>();
                List <Performance>             list = new List <Performance>();

                foreach (SimPe.Packages.PackedFileDescriptor pfd in pkg.Index)
                {
                    Performance p, op;
                    if (!dict.ContainsKey(pfd.Type))
                    {
                        p = new Performance(pfd.Type);
                        list.Add(p);
                        dict[pfd.Type] = p;
                    }
                    else
                    {
                        p = dict[pfd.Type];
                    }

                    if (!odict.ContainsKey(pfd.Type))
                    {
                        op = new Performance(pfd.Type);
                        olist.Add(op);
                        odict[pfd.Type] = op;
                    }
                    else
                    {
                        op = odict[pfd.Type];
                    }
                    DateTime start = DateTime.Now;

                    SimPe.Data.TypeAlias ta = pfd.TypeName;
                    SimPe.Interfaces.Plugin.Internal.IPackedFileWrapper wrp;
                    if (ta.IgnoreDuringCacheBuild)
                    {
                        wrp = null;
                    }
                    else if (pfd.Type == Data.MetaData.LIFO || pfd.Type == Data.MetaData.GMDC)
                    {
                        wrp = new SimPe.Plugin.GenericRcol(null, true);
                    }
                    else
                    {
                        wrp = SimPe.FileTable.WrapperRegistry.FindHandler(pfd.Type);
                    }

                    if (wrp != null)
                    {
                        lock (wrp)
                        {
                            wrp.ProcessData(pfd, pkg, true);
                            ar.AddResourceLoop(fid, pfd, wrp);

                            wrp.Dispose();
                        }
                        wrp = null;
                    }
                    else
                    {
                        ar.AddResourceLoop(fid, pfd, null);
                    }

                    TimeSpan runtime = DateTime.Now - start;
                    p.Add(runtime);
                    op.Add(runtime);
                }
                ShowPerformance(list);
                list.Clear();
                list = null;

                dict.Clear();
                dict = null;

                ar.FinishLoop();
                pkg.Close();
            }

            lfr = null;
            return(mod);
        }
Ejemplo n.º 9
0
 public override string ToString()
 {
     SimPe.Data.TypeAlias ta = Data.MetaData.FindTypeAlias(t);
     return(ta.shortname + ": Calls= " + Count() + ", Overall= " + Total().ToString() + ", Avg= " + Avarage().ToString());
 }