コード例 #1
0
        public bool Initialize()
        {
            if (((currentMode == Mode.Asset && assetType == AssetType.EMO) || currentMode == Mode.Global) && !SettingsManager.Instance.LoadTextures)
            {
                MessageBox.Show("This option is not available while textures are turned off. Enable Load Textures in the settings to use this option.", "Not Available", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }

            List <RgbColor> colors = null;

            if (currentMode == Mode.Asset)
            {
                colors = asset.GetUsedColors();
            }
            else if (currentMode == Mode.Material)
            {
                colors = material.GetUsedColors();
            }
            else if (currentMode == Mode.Global)
            {
                colors = GetUsedColorsByEverything();
            }
            else if (currentMode == Mode.ParticleEffect)
            {
                colors = particleEffect.GetUsedColors();
            }


            if (colors.Count == 0)
            {
                MessageBox.Show("No color information was found on this asset so it cannot be hue shifted.\n\nThe most likely cause of this is that all color sources for this asset were either all white (1,1,1) or all black (0,0,0).", "No color information", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }

            rgbColor = ColorEx.GetAverageColor(colors);
            hslColor = rgbColor.ToHsl();

            //hslColor.Lightness = 0.5f; //Gives a "pure" color. Not light or dark. Good for previewing.
            //hslColor.Saturation = 1f; //Completely saturated. Good for previewing.
            initialHue        = hslColor.Hue;
            initialSaturation = hslColor.Saturation;
            initialLightness  = hslColor.Lightness;

            ValueChanged();

            return(true);
        }
コード例 #2
0
        private void SetInitialColor()
        {
            List <RgbColor> colors = null;

            if (currentMode == Mode.Asset)
            {
                colors = asset.GetUsedColors();
            }
            else if (currentMode == Mode.Material)
            {
                colors = material.GetUsedColors();
            }
            else if (currentMode == Mode.Global)
            {
                colors = GetUsedColorsByEverything();
            }
            else if (currentMode == Mode.ParticleEffect)
            {
                colors = particleEffect.GetUsedColors();
            }


            if (colors.Count == 0)
            {
                Close();
                MessageBox.Show("No color information was found on this asset so it cannot be hue shifted.\n\nThe most likely cause of this is that all color sources for this asset were either all white (1,1,1) or all black (0,0,0).", "No color information", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            rgbColor = ColorEx.GetAverageColor(colors);
            hslColor = rgbColor.ToHsl();

            //hslColor.Lightness = 0.5f; //Gives a "pure" color. Not light or dark. Good for previewing.
            //hslColor.Saturation = 1f; //Completely saturated. Good for previewing.
            initialHue        = hslColor.Hue;
            initialSaturation = hslColor.Saturation;
            initialLightness  = hslColor.Lightness;

            ValueChanged();
        }