Пример #1
0
        /// <summary>
        /// Refreshes atlas details if necessary.
        /// </summary>
        /// <remarks>
        /// <para>These details are shown on the user interface to provide the user with an
        /// indication of atlas usage.</para>
        /// </remarks>
        private void RefreshAtlasDetails()
        {
            if (!this.invalidateAtlasDetails)
            {
                return;
            }

            this.invalidateAtlasDetails = false;

            // No details to show when no autotile artwork is specified
            if (this.inputNewAutotileArtwork /*Uncompressed*/ == null)
            {
                this.atlasDetails = null;
                return;
            }

            var autotileExpanderUtility = new AutotileExpanderUtility(
                layout: this.autotileTileset.AutotileLayout,
                autotileArtwork: this.inputNewAutotileArtworkUncompressed,
                tileWidth: this.inputTileWidth,
                tileHeight: this.inputTileHeight,
                innerJoins: this.autotileTileset.HasInnerJoins,
                border: this.inputBorderSize,
                clampEdges: false
                );

            int atlasWidth;
            int atlasHeight;
            int atlasUnused;

            autotileExpanderUtility.CalculateMetrics(out atlasWidth, out atlasHeight, out atlasUnused);

            int atlasUnusedPercentage = 100 * atlasUnused / (atlasWidth * atlasHeight);

            this.atlasDetails = string.Format(

                /* 0: width of atlas texture in pixels
                 * 1: height of atlas texture in pixels
                 * 2: percentage of unused area of atlas texture */
                TileLang.Text("Output Atlas: {0}x{1}   Unused: {2}%"),
                atlasWidth, atlasHeight, atlasUnusedPercentage
                );
        }
Пример #2
0
        private void RecalculateMetrics()
        {
            if (this.autotileTextureUncompressed != null)
            {
                var autotileExpanderUtility = new AutotileExpanderUtility(s_SelectedAutotileLayout, this.autotileTextureUncompressed, this.tileWidth, this.tileHeight, s_InnerJoins, s_BorderSize, false);
                autotileExpanderUtility.CalculateMetrics(out this.metricAtlasWidth, out this.metricAtlasHeight, out this.metricAtlasUnused);

                this.metricAtlasUnusedPercentage = 100 * this.metricAtlasUnused / (this.metricAtlasWidth * this.metricAtlasHeight);

                this.metricSummary.text = string.Format(

                    /* 0: width of atlas texture in pixels
                     * 1: height of atlas texture in pixels
                     * 2: percentage of unused area of atlas texture */
                    TileLang.Text("Output Atlas: {0}x{1}   Unused: {2}%"),
                    this.metricAtlasWidth, this.metricAtlasHeight, this.metricAtlasUnusedPercentage
                    );
            }
            else
            {
                this.metricAtlasUnusedPercentage = this.metricAtlasUnused = this.metricAtlasHeight = this.metricAtlasWidth = 0;
                this.metricSummary.text          = string.Empty;
            }
        }