HaloMap.Meta.Meta.SortItemsByOffset C# (CSharp) Method

SortItemsByOffset() public method

The sort items by offset.
public SortItemsByOffset ( ) : void
return void
        public void SortItemsByOffset()
        {
            Comparison<Item> compareBySalary;
            compareBySalary = new Comparison<Item>(new ItemSorter().Compare);

            this.items.Sort(compareBySalary);
        }

Usage Example

Example #1
0
        /// <summary>
        /// The save recursive function.
        /// </summary>
        /// <param name="meta">The meta.</param>
        /// <param name="metas">The metas.</param>
        /// <param name="parsed">The parsed.</param>
        /// <param name="pb">The pb.</param>
        /// <param name="percent">The percent.</param>
        /// <param name="percentsize">The percentsize.</param>
        /// <remarks></remarks>
        private void SaveRecursiveFunction(
            Meta meta, 
            ref ArrayList metas, 
            bool parsed, 
            ToolStripProgressBar pb, 
            float percent, 
            float percentsize)
        {
            int wtf = metas.Count;
            if (meta.items.Count == 0)
            {
                return;
            }

            float test = meta.items.Count;

            float currentpercentsize = percentsize / test;

            Item i = null;

            try
            {
                for (int x = 0; x < meta.items.Count; x++)
                {
                    i = meta.items[x];
                    if (i.type != ItemType.Ident)
                    {
                        continue;
                    }

                    float currentpercentage = percent + (currentpercentsize * x);
                    pb.Value = (int)currentpercentage;
                    Application.DoEvents();

                    Ident id = (Ident)i;

                    if (id.ident == -1)
                    {
                        continue;
                    }

                    if (id.ident == 0)
                    {
                        int tagIndex = Map.Functions.ForMeta.FindByNameAndTagType("sbsp", i.intagname);
                        id.ident = Map.MetaInfo.Ident[tagIndex];
                    }

                    bool exists = false;

                    for (int e = 0; e < metas.Count; e++)
                    {
                        Meta tempmeta = (Meta)metas[e];

                        // if (id.pointstotagtype  ==tempmeta.type&&id.pointstotagname ==tempmeta.name )
                        if (id.ident == tempmeta.ident)
                        {
                            exists = true;
                            break;
                        }
                    }

                    if (exists)
                    {
                        continue;
                    }

                    // Drag & drop w/ recursive locks up. num == -1
                    int num = Map.Functions.ForMeta.FindMetaByID(id.ident);
                    if (num < 0)
                    {
                        MessageBox.Show("ERROR! Not Found!");
                    }

                    Meta m = new Meta(Map);
                    if (parsed)
                    {
                        m.parsed = true;
                    }

                    m.ReadMetaFromMap(num, false);
                    if (m.type == "ltmp" | m.type == "matg")
                    {
                        continue;
                    }

                    if (m.type == "phmo" | m.type == "coll" | m.type == "jmad")
                    {
                        m.parsed = false;
                    }

                    if (m.type != "jmad")
                    {
                        IFPIO ifp = IFPHashMap.GetIfp(m.type, Map.HaloVersion);
                        m.headersize = ifp.headerSize;

                        m.scanner.ScanWithIFP(ref ifp);
                    }
                    else
                    {
                        m.scanner.ScanManually();
                    }

                    m.SortItemsByOffset();

                    metas.Add(m);

                    Application.DoEvents();
                    SaveRecursiveFunction(m, ref metas, parsed, pb, currentpercentage, currentpercentsize);
                }
            }
            catch (Exception e)
            {
                string addOn = "\nin [" + meta.type + "] " + meta.name;
                if (i.type == ItemType.Ident)
                    addOn = "\n" + i.description + ", Ident: " + ((Ident)i).ident + addOn;
                throw new Exception(e.Message + addOn, e.InnerException);
            }
        }
All Usage Examples Of HaloMap.Meta.Meta::SortItemsByOffset