/// <summary>
        /// Checks which existing texture file closest resembles the specified <paramref name="matchTextureName"/>.
        /// </summary>
        /// <param name="matchTextureName">Name of the texture to to find the best match for.</param>
        /// <returns>
        /// Name of the texture file that best matches the specified <paramref name="matchTextureName"/>, or
        /// null if no decent matches were found.
        /// </returns>
        public string FindBestMatchTexture(string matchTextureName)
        {
            // Check that we even have this texture
            if (!Contains(matchTextureName))
            {
                return(null);
            }

            // Get the info for the texture to match against
            var target = this[matchTextureName];

            // Loop through every existing hash until we find one with the same size and hash, but the file exists
            foreach (var kvp in _textureHash)
            {
                var hashInfo = kvp.Value;
                if (hashInfo == target || hashInfo.FileSize != target.FileSize || hashInfo.Hash != target.Hash)
                {
                    continue;
                }

                var textureName = kvp.Key;
                var assetName   = new ContentAssetName(textureName);
                if (assetName.ContentExists())
                {
                    return(textureName);
                }
            }

            return(null);
        }
예제 #2
0
        void NewTxt_TextChanged(object sender, EventArgs e)
        {
            var textureName = NewTxt.Text;

            var assetName = new ContentAssetName(NewTxt.Text);

            if (!string.IsNullOrEmpty(textureName) && assetName.ContentExists())
            {
                NewTxt.BackColor = EditorColors.Normal;

                var texture = _cm.LoadImage(assetName, ContentLevel.Temporary);
                var w       = (int)texture.Width;
                var h       = (int)texture.Height;

                Image previewImage = texture.ToBitmap(new Rectangle(0, 0, w, h), PreviewPic.Width, PreviewPic.Height);
                PreviewPic.Image = previewImage;
            }
            else
            {
                PreviewPic.Image = null;
                NewTxt.BackColor = EditorColors.Error;
            }
        }
예제 #3
0
        void NewTxt_TextChanged(object sender, EventArgs e)
        {
            var textureName = NewTxt.Text;

            var assetName = new ContentAssetName(NewTxt.Text);
            if (!string.IsNullOrEmpty(textureName) && assetName.ContentExists())
            {
                NewTxt.BackColor = EditorColors.Normal;

                var texture = _cm.LoadImage(assetName, ContentLevel.Temporary);
                var w = (int)texture.Width;
                var h = (int)texture.Height;

                Image previewImage = texture.ToBitmap(new Rectangle(0, 0, w, h), PreviewPic.Width, PreviewPic.Height);
                PreviewPic.Image = previewImage;
            }
            else
            {
                PreviewPic.Image = null;
                NewTxt.BackColor = EditorColors.Error;
            }
        }
예제 #4
0
        /// <summary>
        /// Checks which existing texture file closest resembles the specified <paramref name="matchTextureName"/>.
        /// </summary>
        /// <param name="matchTextureName">Name of the texture to to find the best match for.</param>
        /// <returns>
        /// Name of the texture file that best matches the specified <paramref name="matchTextureName"/>, or
        /// null if no decent matches were found.
        /// </returns>
        public string FindBestMatchTexture(string matchTextureName)
        {
            // Check that we even have this texture
            if (!Contains(matchTextureName))
                return null;

            // Get the info for the texture to match against
            var target = this[matchTextureName];

            // Loop through every existing hash until we find one with the same size and hash, but the file exists
            foreach (var kvp in _textureHash)
            {
                var hashInfo = kvp.Value;
                if (hashInfo == target || hashInfo.FileSize != target.FileSize || hashInfo.Hash != target.Hash)
                    continue;

                var textureName = kvp.Key;
                var assetName = new ContentAssetName(textureName);
                if (assetName.ContentExists())
                    return textureName;
            }

            return null;
        }