Esempio n. 1
0
        public void ResizeFootStepSounds(int width, int height)
        {
            int requiredTextureSoundWidth  = Math.Max(FootStepSoundWidth, width);
            int requiredTextureSoundHeight = Math.Max(FootStepSoundHeight, height);

            if (FootStepSoundWidth < requiredTextureSoundWidth ||
                FootStepSoundHeight < requiredTextureSoundHeight)
            {
                var newTextureSounds = new TextureFootStepSound[requiredTextureSoundWidth, requiredTextureSoundHeight];
                for (int y = 0; y < requiredTextureSoundHeight; ++y)
                {
                    for (int x = 0; x < requiredTextureSoundWidth; ++x)
                    {
                        newTextureSounds[x, y] = TextureFootStepSound.Stone;
                    }
                }
                for (int y = 0; y < FootStepSoundHeight; ++y)
                {
                    for (int x = 0; x < FootStepSoundWidth; ++x)
                    {
                        newTextureSounds[x, y] = _footStepSounds[x, y];
                    }
                }
                _footStepSounds = newTextureSounds;
            }
        }
Esempio n. 2
0
 public void SetFootStepSound(int x, int y, TextureFootStepSound value)
 {
     _footStepSounds[x, y] = value;
 }
Esempio n. 3
0
            protected override void OnPaintSelection(PaintEventArgs e)
            {
                var texture = VisibleTexture;

                // Determine relevant area
                Vector2 start = FromVisualCoord(new PointF());
                Vector2 end   = FromVisualCoord(new PointF() + ClientSize);

                start = Vector2.Min(texture.Image.Size, Vector2.Max(new Vector2(0), start));
                end   = Vector2.Min(texture.Image.Size, Vector2.Max(new Vector2(0), end));
                int soundTileStartX = (int)Math.Floor(start.X / LevelTexture.FootStepSoundGranularity);
                int soundTileStartY = (int)Math.Floor(start.Y / LevelTexture.FootStepSoundGranularity);
                int soundTileEndX   = (int)Math.Ceiling(end.X / LevelTexture.FootStepSoundGranularity);
                int soundTileEndY   = (int)Math.Ceiling(end.Y / LevelTexture.FootStepSoundGranularity);

                // Draw texture sounds
                using (Font textureSoundFont = new Font(Font.FontFamily, _textureSoundStringSize * _textureSoundProportion * LevelTexture.FootStepSoundGranularity * Math.Min(100, ViewScale)))
                    for (int y = soundTileStartY; y <= soundTileEndY; ++y)
                    {
                        for (int x = soundTileStartX; x <= soundTileEndX; ++x)
                        {
                            if (x < 0 || x >= texture.FootStepSoundWidth || y < 0 || y >= texture.FootStepSoundHeight)
                            {
                                continue;
                            }

                            TextureFootStepSound sound = texture.GetFootStepSound(x, y);
                            Brush soundBrush           = _textureSoundBrushes[(int)sound];

                            Vector2 tileStartTexCoord = new Vector2(x, y) * LevelTexture.FootStepSoundGranularity;
                            PointF  tileStart         = ToVisualCoord(tileStartTexCoord);
                            PointF  tileEnd           = ToVisualCoord(tileStartTexCoord + new Vector2(LevelTexture.FootStepSoundGranularity));
                            PointF  descStart         = new PointF(tileStart.X, tileStart.Y * _textureSoundProportion + tileEnd.Y * (1 - _textureSoundProportion));

                            RectangleF descArea = RectangleF.FromLTRB(descStart.X, descStart.Y, tileEnd.X, tileEnd.Y);
                            e.Graphics.FillRectangle(soundBrush, descArea);
                            if (ViewScale > 6)
                            {
                                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                            }
                            e.Graphics.DrawString(sound.ToString(), textureSoundFont, Brushes.Black, descArea, _textureSoundStringFormat);

                            RectangleF tileArea = RectangleF.FromLTRB(tileStart.X, tileStart.Y, tileEnd.X, tileEnd.Y);
                            e.Graphics.DrawRectangle(Pens.White, tileArea);
                        }
                    }

                // Fill covered tiles
                Vector2 p0 = SelectedTexture.TexCoord0 / LevelTexture.FootStepSoundGranularity;
                Vector2 p1 = SelectedTexture.TexCoord1 / LevelTexture.FootStepSoundGranularity;
                Vector2 p2 = SelectedTexture.TexCoord2 / LevelTexture.FootStepSoundGranularity;
                Vector2 p3 = SelectedTexture.TexCoord3 / LevelTexture.FootStepSoundGranularity;

                int xMin = (int)Math.Min(Math.Min(Math.Min(p0.X, p1.X), p2.X), p3.X);
                int xMax = (int)Math.Max(Math.Max(Math.Max(p0.X, p1.X), p2.X), p3.X);
                int yMin = (int)Math.Min(Math.Min(Math.Min(p0.Y, p1.Y), p2.Y), p3.Y);
                int yMax = (int)Math.Max(Math.Max(Math.Max(p0.Y, p1.Y), p2.Y), p3.Y);

                PointF     selStart = ToVisualCoord(new Vector2(xMin, yMin) * LevelTexture.FootStepSoundGranularity);
                PointF     selEnd   = ToVisualCoord(new Vector2(xMax, yMax) * LevelTexture.FootStepSoundGranularity);
                RectangleF selArea  = RectangleF.FromLTRB(selStart.X, selStart.Y, selEnd.X, selEnd.Y);

                e.Graphics.FillRectangle(_coverBrush, selArea);

                // TODO: disabled for now

                /*ConservativeRasterizer.RasterizeQuadUniquely(
                 *  SelectedTexture.TexCoord0 / LevelTexture.FootStepSoundGranularity,
                 *  SelectedTexture.TexCoord1 / LevelTexture.FootStepSoundGranularity,
                 *  SelectedTexture.TexCoord2 / LevelTexture.FootStepSoundGranularity,
                 *  SelectedTexture.TexCoord3 / LevelTexture.FootStepSoundGranularity,
                 *  (startX, startY, endX, endY) =>
                 *  {
                 *      PointF tileStart = ToVisualCoord(new Vector2(startX, startY) * LevelTexture.FootStepSoundGranularity);
                 *      PointF tileEnd = ToVisualCoord(new Vector2(endX, endY) * LevelTexture.FootStepSoundGranularity);
                 *      RectangleF tileArea = RectangleF.FromLTRB(tileStart.X, tileStart.Y, tileEnd.X, tileEnd.Y);
                 *      e.Graphics.FillRectangle(_coverBrush, tileArea);
                 *  });*/

                base.OnPaintSelection(e);
            }