Esempio n. 1
0
        static void SortTextureData(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder, Func <BuildReportTool.TextureData.Entry, int> func)
        {
            var textureEntries = textureData.GetTextureData();

            for (int n = 0; n < assetList.Length; ++n)
            {
                int intValue = 0;
                if (textureEntries.ContainsKey(assetList[n].Name))
                {
                    intValue = func(textureEntries[assetList[n].Name]);
                }

                assetList[n].SetIntAuxData(intValue);
            }

            SortByInt(assetList, sortOrder);
        }
Esempio n. 2
0
        static void SortTextureData(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder, Func <BuildReportTool.TextureData.Entry, string> func)
        {
            var textureEntries = textureData.GetTextureData();

            for (int n = 0; n < assetList.Length; ++n)
            {
                string textData = null;
                if (textureEntries.ContainsKey(assetList[n].Name))
                {
                    textData = func(textureEntries[assetList[n].Name]);
                }

                assetList[n].SetTextAuxData(textData);
            }

            SortByText(assetList, sortOrder);
        }
Esempio n. 3
0
        // NPotScale sort is special: we want the "None (Not Power of 2)" values to go at top, ignoring alphabetical order for that special value
        static void SortNPotScale(BuildReportTool.SizePart[] assetList, BuildReportTool.TextureData textureData, BuildReportTool.AssetList.SortOrder sortOrder)
        {
            var textureEntries = textureData.GetTextureData();

            for (int n = 0; n < assetList.Length; ++n)
            {
                string textData = null;
                if (textureEntries.ContainsKey(assetList[n].Name))
                {
                    textData = textureEntries[assetList[n].Name].NPotScale;
                }

                assetList[n].SetTextAuxData(textData);
            }

            if (sortOrder == BuildReportTool.AssetList.SortOrder.Descending)
            {
                Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
                {
                    string nPotScale1 = entry1.GetTextAuxData();
                    string nPotScale2 = entry2.GetTextAuxData();

                    // put non-power-of-2 at top
                    bool nPotScale1IsNoneNot = nPotScale1 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
                    bool nPotScale2IsNoneNot = nPotScale2 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
                    if (nPotScale1IsNoneNot && !nPotScale2IsNoneNot)
                    {
                        return(-1);
                    }
                    if (!nPotScale1IsNoneNot && nPotScale2IsNoneNot)
                    {
                        return(1);
                    }

                    // at this point, entry1 and entry 2 are not non-power-of-2 (or both of them are), so compare them as usual
                    int sortTextureTypeResult = string.Compare(nPotScale1, nPotScale2, StringComparison.OrdinalIgnoreCase);
                    if (sortTextureTypeResult != 0)
                    {
                        return(sortTextureTypeResult);
                    }

                    // same nPotScale type
                    // sort by asset size for assets with same nPotScale types
                    if (entry1.UsableSize > entry2.UsableSize)
                    {
                        return(-1);
                    }
                    if (entry1.UsableSize < entry2.UsableSize)
                    {
                        return(1);
                    }

                    // same size
                    // sort by asset name for assets with same sizes
                    return(SortByAssetNameDescending(entry1, entry2));
                });
            }
            else
            {
                Array.Sort(assetList, delegate(BuildReportTool.SizePart entry1, BuildReportTool.SizePart entry2)
                {
                    string nPotScale1 = entry1.GetTextAuxData();
                    string nPotScale2 = entry2.GetTextAuxData();

                    // put non-power-of-2 at bottom
                    bool nPotScale1IsNoneNot = nPotScale1 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
                    bool nPotScale2IsNoneNot = nPotScale2 == BuildReportTool.TextureData.NPOT_SCALE_NONE_NOT_POT;
                    if (nPotScale1IsNoneNot && !nPotScale2IsNoneNot)
                    {
                        return(1);
                    }
                    if (!nPotScale1IsNoneNot && nPotScale2IsNoneNot)
                    {
                        return(-1);
                    }

                    // at this point, entry1 and entry 2 are not non-power-of-2 (or both of them are), so compare them as usual
                    int sortTextureTypeResult = string.Compare(nPotScale2, nPotScale1, StringComparison.OrdinalIgnoreCase);
                    if (sortTextureTypeResult != 0)
                    {
                        return(sortTextureTypeResult);
                    }

                    // same nPotScale type
                    // sort by asset size for assets with same nPotScale types
                    if (entry1.UsableSize > entry2.UsableSize)
                    {
                        return(1);
                    }
                    if (entry1.UsableSize < entry2.UsableSize)
                    {
                        return(-1);
                    }

                    // same size
                    // sort by asset name for assets with same sizes
                    return(SortByAssetNameAscending(entry1, entry2));
                });
            }
        }