Esempio n. 1
0
        public override void Update()
        {
            this._Sides[0].Y = -75 - ((this._Middle.Rotation / Meth.Tau * 10 * 30 + 5) % 30 - 5);
            this._Sides[1].Y = -75 + (this._Middle.Rotation / Meth.Tau * 10 * 30 + 25) % 30 - 25;

            if (this.Runtime == 330)
            {
                this._Done        = true;
                this._Middle.Done = true;
            }

            if (this._Done && this._DoneProgress0 < 100)
            {
                this._DoneProgress0++;

                this._Cutoffs[0].Position.Y += 1;
                this._Cutoffs[1].Position.Y -= 0.5;

                this.Position = this.Parent.Resolution / 2 - (Point)(new Vector(220, 70) * Meth.Smooth(this._DoneProgress0 / 100.0) * this.Scale);
            }

            if (this._Done && this._DoneProgress0 >= 50 && this._DoneProgress1 < 80)
            {
                this._DoneProgress1++;

                for (int i = 0; i < 6; i++)
                {
                    this._Letters[i].Color = Color.White * Meth.Limit(0, Meth.Smooth(this._DoneProgress1 / 80.0) * 6 - i, 1);
                }
            }

            this.Parent.Title = this.Parent.Fps.ToString();
        }
Esempio n. 2
0
        public override void Update()
        {
            double v = Meth.Limit(0, LocalMousePosition.X / Size.X * Sections, Sections);

            if (this.MouseArea.IsClicked)
            {
                this._Value = v;
            }

            this.Progress += ((this.MouseArea.IsHovered && !this.MouseArea.IsClicked ? 1 : 0) - this.Progress) * 0.3;

            this.Text.Color   ^= (byte)((255 - this.Progress * 255) * (this.MouseArea.IsClicked ? 1 : 0));
            this.Text.Origin   = new Vector(this.Value, 1);
            this.Text.Position = new Vector(this.Value * this.Size.X, this.Size.Y - this.Value * this.Size.Y - 6 + this.Value * 3);
            this.Text.Content  = this.ValueDisplay(this.Value);

            for (int i = 0; i < Sections; i++)
            {
                Progresses[i] += ((this._Value > i ? 1 : 0) - Progresses[i]) * 0.4;
            }

            this.VertexArray.Vertices.Clear();
            this.VertexArray.Add(0);
            this.VertexArray.Add(new Vector(Size.X, 0));
            for (int i = 0; i < Sections; i++)
            {
                double d = Meth.Abs((v - i) / Sections * Size.X);
                double f = (d <= Size.X / 4) ? 1 - Meth.RSmooth(d / (Size.X / 4)) * 0.2 * this.Progress : 1;

                VertexArray.Add(new Vector((i + 0.5) / (double)Sections * Size.X, -1));
                VertexArray.Add(new Vector((i + 0.5) / (double)Sections * Size.X, (Progresses[i] + (i > this._Value ? 1 - f : 0)) * i / Sections * -(Size.Y - 2) * f - 3));
            }
        }
Esempio n. 3
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;
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public void UpdateZoom(int _offset)
        {
            this.Zoom = Meth.Limit(1, this.Zoom + _offset, 4);

            this.Tileset.Scale    = this.Zoom;
            this.ColPreview.Scale = (this.Parent.TileSize / this.Parent.TileCollisionResolution) * this.Zoom;

            this.UpdateMouseArea();
        }
Esempio n. 6
0
        public void Click(Key _key)
        {
            this.TargetIndex    = (int)Meth.Limit(0, (this.TargetIndex + ((_key == Key.MouseDown) ? 1 : -1)), this.Items.LastIndex);
            this.TargetQuadRot += (_key == Key.MouseDown) ? 1 : -1;

            if (!this.Scrolling)
            {
                this.Scrolling   = true;
                this.ScrollStart = this.LocalMousePosition;
            }
        }
Esempio n. 7
0
        public int GetCharPosition(Vector _pos)
        {
            string c = this.Content;

            int y = (int)Meth.Limit(0, Meth.Down((_pos.Y - this.Edge.Y) / this.Font.CharSize), this.Lines.Length - 1);

            string[] lines = c.Split('\n');
            string   line  = lines[y];

            int  pos = 0;
            bool b   = false;

            for (int i = 0; i < line.Length; i++)
            {
                this._Text._Text.Content = line.Substring(0, i);
                double first = this._Text.Width;
                this._Text._Text.Content = line.Substring(0, i + 1);
                double second = this._Text.Width;

                if (_pos.X - this.Edge.X < first + (second - first) / 2 - 3)
                {
                    pos = i;
                    b   = true;
                    break;
                }
            }

            if (!b)
            {
                pos = line.Length;
            }

            int p = 0;

            for (int i = 0; i < y; i++)
            {
                p += lines[i].Length + 1;
            }
            p += pos;
            this._Text._Text.Content = c;
            return(p);
        }
Esempio n. 8
0
 public static double Smooth(double _percent)
 {
     return((Meth.Cos(Meth.Limit(0, _percent, 1) * Meth.Tau / 2) * -1 + 1) / 2);
 }
Esempio n. 9
0
 private void _ChangeValue(int _offset)
 {
     this._Value           = (int)Meth.Limit(this.MinValue, this._Value + _offset, this.MaxValue);
     this._TextBox.Content = this._Value.ToString("D" + this.Digits.ToString());
 }
Esempio n. 10
0
        public override void Update()
        {
            base.Update();

            this._Sides[0].Y = -75 - Meth.Up((this._Middle.Rotation / Meth.Tau * 10 * 30 + 5) % 30 - 5);
            this._Sides[1].Y = -75 + Meth.Up((this._Middle.Rotation / Meth.Tau * 10 * 30 + 25) % 30 - 25);

            DateTime start = DateTime.Now;

            while ((DateTime.Now - start).TotalMilliseconds < 3 && this._Loadables.Count > 0)
            {
                if (this._Loadables[0].FinishedLoading)
                {
                    this._Loadables.RemoveAt(0);
                    if (this._Loadables.Count == 0)
                    {
                        this._DoneLoading = true;
                        this.Skippable    = true;
                    }
                }
                else
                {
                    this._Loadables[0].LoadStep();
                }
            }

            if (this.Runtime % 110 == 0 && this._DoneLoading)
            {
                this._Done        = true;
                this._Middle.Done = true;
                this.Skippable    = true;
            }

            if (this._Done && this._DoneProgress0 < 100)
            {
                this._DoneProgress0++;

                this._Cutoffs[0].Position.Y += 1;
                this._Cutoffs[1].Position.Y -= 0.5;

                this.Position = this.Parent.Resolution / 2 - (Point)(new Vector(220, 70) * Meth.Smooth(this._DoneProgress0 / 100.0) * this.Scale);
            }

            if (this._Done && this._DoneProgress0 >= 50 && this._DoneProgress1 < 80)
            {
                this._DoneProgress1++;

                for (int i = 0; i < 6; i++)
                {
                    this._Letters[i].TextColor = Color.White * Meth.Limit(0, Meth.Smooth(this._DoneProgress1 / 80.0) * 6 - i, 1);
                }
            }

            if (this._DoneProgress1 >= 80 && this._DoneProgress1 < 120)
            {
                this._DoneProgress1++;
            }

            if (this._DoneProgress1 == 120)
            {
                this._DoneProgress2++;
                this.Color = Color.White * Meth.Smooth(1 - this._DoneProgress2 * 3 / 255.0);
                if (this._DoneProgress2 == 85)
                {
                    this.Kill();
                }
            }
        }
Esempio n. 11
0
        public override void Update()
        {
            if (this.Scrolling && (this.LocalMousePosition - this.ScrollStart).Length >= 2)
            {
                this.Scrolling = false;
            }
            //if (this.Scrolling)
            //	Parent.CursorVisible = false;

            this.Index     += (this.TargetIndex - this.Index) / 5;
            this.Expansion += ((this.MouseArea.IsHovered ? 1 : 0) - this.Expansion) / 5;

            this.Quad.Rotation += ((this.TargetQuadRot * Meth.Tau / -4) - this.Quad.Rotation) / 5;
            if (Meth.Abs(this.Quad.Rotation - this.TargetQuadRot * Meth.Tau / -4) < 0.1)
            {
                this.Quad.Rotation = this.TargetQuadRot * Meth.Tau / -4;
            }

            this.Quad.Scale = new Vector(1, 2 / 3.0 + this.Expansion / 3.0);
            if (Meth.Abs(this.TargetQuadRot % 2) == 1)
            {
                this.Quad.Scale.Angle += Meth.Tau / 4;
            }

            if (this.LastHovered != this.MouseArea.IsHovered)
            {
                this.LastHovered = this.MouseArea.IsHovered;

                if (!this.MouseArea.IsHovered)
                {
                    this.MouseArea.Shape = new Rectangle(this.Labels[this.TargetIndex].Position, this.Labels[this.TargetIndex].Size);
                }
            }

            if (Meth.Abs(this.TargetIndex - this.Index) < 0.05)
            {
                this.Index = this.TargetIndex;
            }

            for (int i = 0; i < this.Labels.Count; i++)
            {
                byte a = (byte)(Meth.Pow(Meth.Limit(0, 3 - Meth.Abs(i - this.Index), 3) / 3.0 * ((i == this.TargetIndex) ? 1 : this.Expansion), 0.4) * 255);

                //if (a != 0 && !this.Labels[i].Visible)
                //{
                //	this.Labels[i].Visible = true;
                //	//this.Labels[i].Shader = Shader.TextOutline;
                //	//this.Labels[i].Shader["Color"] = Color.Red;

                //	//this.Labels[i].RenderIntermediately = true;
                //	//this.Labels[i].RenderGraphicsIntermediately = true;
                //	//this.Labels[i].IntermediateSize = this.Labels[i].Size;
                //	//this.Labels[i].IntermediateShader = Shader.TextOutline;
                //}

                //if (this.Labels[i].Visible)
                //{
                double dis = Meth.Limit(0, Meth.Abs(i - this.Index) - 2, 1);

                this.Labels[i].Color ^= (byte)(((i == this.TargetIndex) ? 255 : this.Expansion * 255) * (1 - dis));
                //this.Labels[i].Shader["Alpha"] = (a / 255.0);

                this.Labels[i].Z = a / 255.0 * this.Expansion;

                Vector p = this.GetPosition(i - this.Index);
                double r = p.Angle.ToHalfTau() / 4;
                this.Labels[i].Rotation = r;
                this.Labels[i].Position = p;
                //}
            }
        }
Esempio n. 12
0
        public override void Update()
        {
            double         y        = this.Spacing;
            Bunch <double> pos      = new Bunch <double>();
            Bunch <double> threshes = new Bunch <double>();
            Bunch <double> middles  = new Bunch <double>();

            foreach (T item in this.Items)
            {
                pos.Add(y);
                threshes.Add(y + item.GetHeight() + this.Spacing / 2);
                middles.Add(y + item.GetHeight() / 2);
                y += item.GetHeight() + this.Spacing;
            }

            double lheight = 0;

            if (this.Items.Count > 0)
            {
                middles.Add(y + this.Items.Last.GetHeight() / 2);

                T d = this.Items.First(item => item._BeingDragged);
                if (d != null)
                {
                    int    index = d._ListIndex;
                    double p     = d.Y + d.GetHeight() / 2;

                    if (p < threshes[0])
                    {
                        index = 0;
                    }
                    else if (p > threshes.Last)
                    {
                        index = threshes.Count - 1;
                    }
                    else
                    {
                        for (int i = 0; i < threshes.Count; i++)
                        {
                            if (p < threshes[i])
                            {
                                index = i;
                                break;
                            }
                        }
                    }

                    T[] items = this.Items.ToArray();

                    int dif = index - d._ListIndex;
                    if (dif > 0)
                    {
                        for (int i = d._ListIndex + 1; i <= index; i++)
                        {
                            items[i]._ListIndex--;
                        }
                    }
                    else if (dif < 0)
                    {
                        for (int i = index; i < d._ListIndex; i++)
                        {
                            items[i]._ListIndex++;
                        }
                    }

                    d._ListIndex = index;

                    if (dif != 0)
                    {
                        this.OnOrderChange();
                    }
                }

                foreach (T item in this.Items)
                {
                    if (!item._BeingDragged)
                    {
                        item.Y += (pos[item._ListIndex] - item.Y) / 2;
                        if (Meth.Abs(item.Y - pos[item._ListIndex]) < 1)
                        {
                            item.Y            = pos[item._ListIndex];
                            item._NeedsUpdate = false;
                        }
                    }
                    else
                    {
                        item.Y += item.LocalMousePosition.Y - item._DragStart.Y;
                    }

                    item.Y = Meth.Limit(0, item.Y, this.Height - item.GetHeight());
                    item.Z = item._BeingDragged ? 1 : 0;
                }

                lheight = this.Items.Last.GetHeight();
            }
            else
            {
                pos.Add(0);
                middles.Add(double.MaxValue);
            }

            if (this.LocalMousePosition.X >= 0 && this.LocalMousePosition.X < this.Width && this.LocalMousePosition.Y >= 0 && this.LocalMousePosition.Y < pos.Last + lheight + this.Spacing && !this.Items.Any(item => item._BeingDragged))
            {
                this._MousePos = threshes.IndexOf((this.Spacing / 2 + threshes).Last(t => t < middles.First(m => m > this.LocalMousePosition.Y))) + 1;
                Vector v = new Vector(this.Width / 2, (this.Spacing / 2 + threshes)[this._MousePos]);
                if (this.Plus.Position != v)
                {
                    this.Plus.Position  = v;
                    this.PlusArea.Shape = new Rectangle(this.Plus.Position - this.Spacing / 2, this.Spacing);
                }
                this.Plus.Visible = true;
            }
            else
            {
                this.Plus.Visible = false;
            }

            this.Plus.Color = this.PlusArea.IsHovered ? Color.White * 0.5 : Color.Black;
        }
Esempio n. 13
0
 public override void OnDrag(Vector _position)
 {
     this.Value = Meth.Limit(0, ((this.Vertical ? _position.Y : _position.X) - this.Pos) / this.Height * this.MaxValue, this.MaxValue - this.ValueRange);
     this.SetPos(this.Pos + this.Value / this.MaxValue * this.Height);
 }