예제 #1
0
        public override void Update()
        {
            Vector size  = this.Editor.TileEditor.Size * this.Parent.TileSize * this.Editor.TileEditor.Scale;
            Vector esize = this.Editor.EditorSize;

            if (this.MouseArea.IsClicked)
            {
                this.Editor.TileEditor.Position = -(this.LocalMousePosition - this.FitPosition) / this.FitRect.Size * size + this.Editor.EditorSize / 2 + new Vector(this.Editor.TabListLeft.TotalSize.X, 20);
            }

            this.Editor.TileEditor.X = Meth.Limit(this.Editor.TabListLeft.TotalSize.X - size.X + this.Editor.EditorSize.X, this.Editor.TileEditor.X, this.Editor.TabListLeft.TotalSize.X);
            this.Editor.TileEditor.Y = Meth.Limit(-size.Y + this.Editor.EditorSize.Y + 20, this.Editor.TileEditor.Y, 20);

            if (size.X < esize.X)
            {
                this.Editor.TileEditor.X = this.Editor.TabListLeft.TotalSize.X + (esize.X - size.X) / 2;
            }
            if (size.Y < esize.Y)
            {
                this.Editor.TileEditor.Y = (esize.Y - size.Y) / 2 + 20;
            }

            if (this.NeedsUpdate && this.UpdateTimer < 10)
            {
                this.NeedsUpdate = false;
                this.UpdateTimer = 10;
            }

            if (this.UpdateTimer > 0)
            {
                this.UpdateTimer--;
                if (this.UpdateTimer == 0)
                {
                    this.UpdatePreview();
                }
            }

            if (this.Updated)
            {
                this.Updated = false;

                this.Graphics.Remove(this.Image);
                this.Image = this.UpdatedImage;
                this.Graphics.Add(this.Image);

                this.Frame.Vertices.Clear();
                this.Frame.Add(this.FitPosition, this.FitPosition + this.FitRect.Size.OnlyX, this.FitPosition + this.FitRect.Size, this.FitPosition + this.FitRect.Size.OnlyY, this.FitPosition);
            }

            Vector topleft  = this.FitRect.Size * ((this.Editor.TileEditor.Position - new Vector(this.Editor.TabListLeft.TotalSize.X, 20)) / this.Editor.TileEditor.Scale / this.Parent.TileSize / -this.Editor.TileEditor.Size);
            Vector botright = topleft + this.FitRect.Size * this.Editor.EditorSize / this.Editor.TileEditor.Scale / this.Parent.TileSize / this.Editor.TileEditor.Size;

            topleft.X  = Meth.Max(topleft.X, 0);
            topleft.Y  = Meth.Max(topleft.Y, 0);
            botright.X = Meth.Min(botright.X, FitRect.Width);
            botright.Y = Meth.Min(botright.Y, FitRect.Height);

            this.Viewpoint.Position = FitPosition + topleft;
            this.Viewpoint.Scale    = botright - topleft;
        }
예제 #2
0
        public void SetZoom(int _zoom)
        {
            this.Zoom = Meth.Limit(1, _zoom, 8);

            this.Spritesheet.Scale  = this.Zoom;
            this.Animation.Scale    = this.Zoom;
            this.Animation.Position = new Vector(this.Bottom.RectSize.X, this.Spritesheet.Height * this.Spritesheet.Scale.Y);
            this.Bottom.Y           = Meth.Max(this.Zooms.RectSize.Y, this.Spritesheet.Height * this.Zoom);
        }
예제 #3
0
 internal void _Update()
 {
     foreach (ControlButton button in _Buttons.Select(item => item.Value))
     {
         button._GotPressed         = false;
         button._GotDoubleTapped    = false;
         button._GotReleased        = false;
         button._DoubleTapCountdown = Meth.Max(0, button._DoubleTapCountdown - 1);
         button._NumberOfPresses    = 0;
     }
 }
예제 #4
0
            public override Tuple <int, int> GetRange(string _content, int _pos)
            {
                Tuple <int, int> @out = new Tuple <int, int>(_pos, 0);

                for (int i = _pos; i >= Meth.Max(0, _pos - this.Words.Max(item => item.Length)); i--)
                {
                    foreach (string word in this.Words)
                    {
                        if (i + word.Length > _pos && _content.Length - i >= word.Length && _content.Substring(i, word.Length) == word && word.Length > @out.Item2)
                        {
                            @out = new Tuple <int, int>(i, word.Length);
                        }
                    }
                }

                return(@out);
            }
예제 #5
0
 internal override double _GetRectHeight() => Meth.Max(this.Bottom.Y + this.Bottom.RectSize.Y, this.Spritesheet.Height * this.Spritesheet.Scale.Y * 2);
예제 #6
0
 internal override double _GetRectWidth() => Meth.Max(this.Bottom.RectSize.X + this.Spritesheet.Width / this.AnimSprites * this.Spritesheet.Scale.X, this.Spritesheet.Width * this.Spritesheet.Scale.X);
예제 #7
0
 internal override double _GetRectHeight() => this.Vertical ? this._Items.Sum(item => item._GetRectHeight()) + this.Spacing * Meth.Max(0, this._Items.Count - 1) : this._Items.Max(item => item._GetRectHeight());
예제 #8
0
 public static int Limit(int _min, int _num, int _max)
 {
     return(Meth.Min(Meth.Max(_num, _min), _max));
 }
예제 #9
0
 public static double Limit(double _min, double _num, double _max)
 {
     return(Meth.Min(Meth.Max(_num, _min), _max));
 }
예제 #10
0
 internal override double _GetRectHeight() => Meth.Max(this.AlignmentZoom.RectSize.Y, this.Tileset.Height * this.Zoom) + this.AlignmentButtons.RectSize.Y;
예제 #11
0
 internal override double _GetRectWidth() => Meth.Max(this.AlignmentZoom.RectSize.X + this.Tileset.Width * this.Zoom, this.AlignmentButtons.RectSize.X);
예제 #12
0
 public void UpdateMouseArea()
 {
     this.MouseArea.Shape           = new Rectangle(new Vector(this.AlignmentZoom.RectSize.X, 0), this.TilesetSource.Size * this.Zoom);
     this.AlignmentButtons.Position = new Vector(0, Meth.Max(this.AlignmentZoom.RectSize.Y, this.TilesetSource.Height * this.Zoom));
 }
예제 #13
0
 internal override double _GetRectHeight() => Meth.Max((this.FixedSize != 0) ? this.FixedSize.Y : this._Text.Height + this.Edge.Y * 2, this.MinSize.Y);
예제 #14
0
 internal override double _GetRectWidth() => Meth.Max((this.FixedSize != 0) ? this.FixedSize.X : this._Text.Width + this.Edge.X * 2, this.MinSize.X);
예제 #15
0
 public int GetRight()
 {
     return(Meth.Max(this.CursorPosition, this.CursorPosition + this.SelectionLength));
 }