コード例 #1
0
        //Write modificator methods below

        private static void ModificateCharacters(SpriteDescription spriteDescription)
        {
            if (spriteDescription.FileName.Contains("Characters/"))
            {
                spriteDescription.Pivot = new Vector2(.5f, 0);
            }
        }
コード例 #2
0
ファイル: Dissolve.cs プロジェクト: starrodkirby86/Midori
                /// <summary>
                /// Provides a 2D array of dissolve pixels that can be used as information to generate
                /// a set of OsbSprites used in a dissolve effect. Make sure to set the pixelSize value
                /// to a reasonable value, as the amount of sprites used is the image area divided by pixelSize.
                /// </summary>
                public static SpriteDescription[,] Dissolve(string baseImagePath, string spritePath, float baseImageScale, int pixelSize)
                {
                    var baseImage   = StoryboardObjectGenerator.Current.GetMapsetBitmap(baseImagePath);
                    var spriteScale = ImageHelper.GetScaleRatio(spritePath, pixelSize) * baseImageScale;
                    var xMax        = baseImage.Width / pixelSize;
                    var yMax        = baseImage.Height / pixelSize;

                    var dissolvePixels = new SpriteDescription[xMax, yMax];

                    for (int i = 0; i < xMax; i++)
                    {
                        for (int j = 0; j < yMax; j++)
                        {
                            var location = new Vector2(i * pixelSize * baseImageScale, j * pixelSize * baseImageScale) + new Vector2(-107, 0);
                            var color    = (Color4)baseImage.GetPixel(i * pixelSize, j * pixelSize);
                            dissolvePixels[i, j] = new SpriteDescription {
                                spritePath = spritePath,
                                location   = location,
                                scale      = spriteScale,
                                color      = color
                            };
                        }
                    }

                    return(dissolvePixels);
                }
コード例 #3
0
        private void DrawSpriteEditor(SpriteDescription spriteDescription, Folder folder, int index, int depth)
        {
            if (Searching && !spriteDescription.FileName.ToUpper().Contains(_actualSearchFilter))
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(depth * IndentWidth);
            GUILayout.Label(index == folder.SpriteDescriptions.Count - 1 ? LastItemPrefix : SimpleItemPrefix, GUILayout.Width(IndentWidth));
            if (!CheckForSelection(spriteDescription))
            {
                GUI.color = _defaultLabelColor;
            }
            if (GUILayout.Button(spriteDescription.FileName, GUI.skin.label))
            {
                if (_selectedSpriteDescription == spriteDescription)
                {
                    RaiseYes();
                }
                _selectedSpriteDescription = spriteDescription;
            }
            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();
        }
コード例 #4
0
 private void Select(SpriteDescription spriteDescription)
 {
     if (Sprite == spriteDescription.Sprite)
     {
         Sprite = null;
         return;
     }
     Sprite = spriteDescription.Sprite;
 }
コード例 #5
0
 private void SelectSprite(SpriteDescription spriteDescription)
 {
     if (_selectedSprites.Contains(spriteDescription))
     {
         _selectedSprites.Remove(spriteDescription);
         return;
     }
     _selectedSprites.Add(spriteDescription);
     _selectedFolder = null;
 }
コード例 #6
0
        private static SpriteDescription CreateSpriteDescription(Folder folder, Frame frame, TextureImporterWrapper textureImporterWrapper)
        {
            _outputlog.Append(' ', folder.Depth * 3);
            _outputlog.AppendLine(string.Format("- Sprite Description created: {0}", frame.filename));
            var spriteDesription = new SpriteDescription()
            {
                FileName = frame.filename, Pivot = new Vector2(frame.pivot.x, frame.pivot.y),
            };

            folder.SpriteDescriptions.Add(spriteDesription);
            return(spriteDesription);
        }
コード例 #7
0
ファイル: TestScene.cs プロジェクト: BlenderCN-Org/Skirmish
        private void InitializePan()
        {
            var desc = new SpriteDescription()
            {
                ContentPath = "Resources",
                Textures    = new[] { "pan.jpg" },
                Width       = 800,
                Height      = 650,
                FitScreen   = true,
            };

            textBackPanel = this.AddComponent <Sprite>(desc, SceneObjectUsages.UI, layerHUD).Instance;
        }
コード例 #8
0
ファイル: TestScene.cs プロジェクト: BlenderCN-Org/Skirmish
        private void InitializeSmiley()
        {
            var desc = new SpriteDescription()
            {
                ContentPath = "Resources",
                Textures    = new[] { "smiley.png" },
                Width       = 256,
                Height      = 256,
                FitScreen   = true,
            };
            var sprite = this.AddComponent <Sprite>(desc, SceneObjectUsages.None, 3);

            sprite.ScreenTransform.SetPosition(256, 0);

            this.spriteMov = sprite.Instance;
        }
コード例 #9
0
ファイル: Strip.cs プロジェクト: starrodkirby86/Midori
                /// <summary>
                /// Provides a 2D array of strips that can be used as information to generate
                /// a set of OsbSprites in a wipe transition. The image is split into strips based on
                /// a given size, with the strips being generated if the files don't exist yet.
                /// By default, regeneration of bitmaps is turned off for efficiency, but they can be forcefully
                /// turned on given the forceGeneration param set to true.
                /// </summary>
                public static SpriteDescription[,] Strip(string baseImagePath, string spriteDirectory, Vector2 stripSize, float baseImageScale, bool forceGeneration = false)
                {
                    var baseImage = StoryboardObjectGenerator.Current.GetMapsetBitmap(baseImagePath);

                    if (forceGeneration)
                    {
                        FileHelper.CleanDirectory(spriteDirectory);
                    }
                    else
                    {
                        FileHelper.CreateDirectory(spriteDirectory);
                    }

                    var xMax = baseImage.Width / (int)stripSize.X;
                    var yMax = baseImage.Height / (int)stripSize.Y;

                    var strips = new SpriteDescription[xMax, yMax];

                    for (int i = 0; i < xMax; i++)
                    {
                        for (int j = 0; j < yMax; j++)
                        {
                            var location = new Vector2(i * (int)stripSize.X, j * (int)stripSize.Y);
                            var sizeX    = (int)((stripSize.X + location.X) > baseImage.Width ? baseImage.Width - location.X : stripSize.X);
                            var sizeY    = (int)((stripSize.Y + location.Y) > baseImage.Height ? baseImage.Height - location.Y : stripSize.Y);

                            var stripPath = Path.Combine(spriteDirectory, $"{i:X4}{j:X4}.png");

                            if (!FileHelper.FileExists(stripPath) || forceGeneration)
                            {
                                var rect  = new Rectangle((int)location.X, (int)location.Y, sizeX, sizeY);
                                var strip = baseImage.Clone(rect, baseImage.PixelFormat);
                                FileHelper.SaveBitmap(strip, stripPath);
                                strip.Dispose();
                            }

                            strips[i, j] = new SpriteDescription
                            {
                                spritePath = stripPath,
                                location   = location * baseImageScale + new Vector2(-107, 0),
                                scale      = baseImageScale,
                            };
                        }
                    }

                    return(strips);
                }
コード例 #10
0
        /// <summary>
        /// The Sprite costructor
        /// </summary>
        /// <param name="spriteDescription"></param>
        /// <param name="sheet">The image in which the Sprite is contained</param>
        public Sprite(
            SpriteDescription spriteDescription,
            Texture2D sheet)
        {
            Sheet = sheet ?? throw new ArgumentNullException(nameof(sheet));

            SourceRectangle = new Rectangle(
                spriteDescription.X, spriteDescription.Y,
                spriteDescription.Width, spriteDescription.Height);

            Width  = spriteDescription.Width;
            Height = spriteDescription.Height;

            SpriteCenter = new Vector2(
                SourceRectangle.Width / 2,
                SourceRectangle.Height / 2);
        }
コード例 #11
0
ファイル: Sprite.cs プロジェクト: Samaed/ChickenDodge
 void UpdateComponents(SpriteDescription descr)
 {
     mVertex = new [] {
         new Vertex {
             position = descr.mPixelOffset,
             uv       = new Vector2(descr.mUV.xMin, descr.mUV.yMin)
         },
         new Vertex {
             position = descr.mPixelOffset + descr.mPixelSize.x * Vector2.right,
             uv       = new Vector2(descr.mUV.xMax, descr.mUV.yMin)
         },
         new Vertex {
             position = descr.mPixelOffset + descr.mPixelSize,
             uv       = new Vector2(descr.mUV.xMax, descr.mUV.yMax)
         },
         new Vertex {
             position = descr.mPixelOffset + descr.mPixelSize.y * Vector2.up,
             uv       = new Vector2(descr.mUV.xMin, descr.mUV.yMax)
         },
     };
     mIndices = new[] { 2, 1, 0, 3, 2, 0 };
 }
コード例 #12
0
        private void InitializeTexts()
        {
            this.text = this.AddComponent <TextDrawer>(new TextDrawerDescription()
            {
                Font = "Arial", FontSize = 20, TextColor = Color.Yellow, ShadowColor = Color.OrangeRed
            }, SceneObjectUsages.UI, layerHUD);
            this.statistics = this.AddComponent <TextDrawer>(new TextDrawerDescription()
            {
                Font = "Arial", FontSize = 10, TextColor = Color.LightBlue, ShadowColor = Color.DarkBlue
            }, SceneObjectUsages.UI, layerHUD);
            this.text1 = this.AddComponent <TextDrawer>(new TextDrawerDescription()
            {
                Font = "Arial", FontSize = 10, TextColor = Color.LightBlue, ShadowColor = Color.DarkBlue
            }, SceneObjectUsages.UI, layerHUD);
            this.text2 = this.AddComponent <TextDrawer>(new TextDrawerDescription()
            {
                Font = "Arial", FontSize = 10, TextColor = Color.LightBlue, ShadowColor = Color.DarkBlue
            }, SceneObjectUsages.UI, layerHUD);

            this.text.Instance.Position       = Vector2.One;
            this.statistics.Instance.Position = Vector2.One;
            this.text1.Instance.Position      = Vector2.One;
            this.text2.Instance.Position      = Vector2.One;

            this.statistics.Instance.Top = this.text.Instance.Top + this.text.Instance.Height + 5;
            this.text1.Instance.Top      = this.statistics.Instance.Top + this.statistics.Instance.Height + 5;
            this.text2.Instance.Top      = this.text1.Instance.Top + this.text1.Instance.Height + 5;

            var spDesc = new SpriteDescription()
            {
                AlphaEnabled = true,
                Width        = this.Game.Form.RenderWidth,
                Height       = this.text2.Instance.Top + this.text2.Instance.Height + 3,
                Color        = new Color4(0, 0, 0, 0.75f),
            };

            this.AddComponent <Sprite>(spDesc, SceneObjectUsages.UI, layerHUD - 1);
        }
コード例 #13
0
        private void DrawSpriteEditor(SpriteDescription spriteDescription, Folder folder, int index, int depth)
        {
            if (Searching && !spriteDescription.FileName.ToUpper().Contains(_actualSearchFilter))
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(depth * IndentWidth);
            GUILayout.Label(index == folder.SpriteDescriptions.Count - 1 ? LastItemPrefix : SimpleItemPrefix, GUILayout.Width(IndentWidth));
            if (!CheckForSelection(spriteDescription))
            {
                GUI.color = _defaultLabelColor;
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(spriteDescription.FileName, GUI.skin.label, GUILayout.MinWidth(50)))
            {
                if (_ctrlPressed)
                {
                    SelectSprite(spriteDescription);
                }
                else
                {
                    SelectSpriteOnly(spriteDescription);
                }
            }
            GUI.color = Color.white;
            GUILayout.FlexibleSpace();
            //if (GUILayout.Button("Set sprite", EditorStyles.miniButton, GUILayout.Width(70))) SetSprite(spriteDescription.Sprite);
            if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.Width(50)))
            {
                Dialog.ShowDialog <YesNoDialogWindow>("Delete item", DialogType.YesNo).Yes += (sender) =>
                                                                                              folder.SpriteDescriptions.RemoveAt(index);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();
        }
コード例 #14
0
 private bool CheckForSelection(SpriteDescription spriteDescription)
 {
     return(_selectedSprites.Contains(spriteDescription));
 }
コード例 #15
0
 private void SelectSpriteOnly(SpriteDescription spriteDescription)
 {
     _selectedSprites.Clear();
     _selectedSprites.Add(spriteDescription);
     _selectedFolder = null;
 }
コード例 #16
0
 public static void Modificate(SpriteDescription spriteDescription)
 {
     Modificators.ForEach(x => x(spriteDescription));
 }
コード例 #17
0
 private bool CheckForSelection(SpriteDescription spriteDescription)
 {
     return(spriteDescription == _selectedSpriteDescription);
 }
コード例 #18
0
        private static void CreateSpriteMetaData(Frame frame, TextureImporterWrapper textureImporterWrapper, SpriteDescription spriteDescription)
        {
            var rect = new Rect(frame.frame.x, _textureDescription.Texture.height - frame.frame.y - frame.frame.h, frame.frame.w, frame.frame.h);

            textureImporterWrapper.AddSpriteMetaData(frame.filename, rect, spriteDescription.Pivot, spriteDescription.Borders);
        }
コード例 #19
0
 private bool CheckForSelection(SpriteDescription spriteDescription)
 {
     return(Sprite == spriteDescription.Sprite);
 }
コード例 #20
0
ファイル: Sprite.cs プロジェクト: Samaed/ChickenDodge
 void UpdateComponents( SpriteDescription descr )
 {
     mVertex = new [] {
         new Vertex {
             position = descr.mPixelOffset,
             uv = new Vector2( descr.mUV.xMin, descr.mUV.yMin )
         },
         new Vertex {
             position = descr.mPixelOffset + descr.mPixelSize.x * Vector2.right,
             uv = new Vector2( descr.mUV.xMax, descr.mUV.yMin )
         },
         new Vertex {
             position = descr.mPixelOffset + descr.mPixelSize,
             uv = new Vector2( descr.mUV.xMax, descr.mUV.yMax )
         },
         new Vertex {
             position = descr.mPixelOffset + descr.mPixelSize.y * Vector2.up,
             uv = new Vector2( descr.mUV.xMin, descr.mUV.yMax )
         },
     };
     mIndices = new[]{ 2, 1, 0, 3, 2, 0 };
 }