Ejemplo n.º 1
0
        public override void OnInitialization()
        {
            this.Bar = new VertexArray(VertexArrayType.Polygon)
            {
                Color = Color.White * 0.8
            };
            this.Bar.Add(0, new Vector(Width, 0), new Vector(Width, BarHeight), new Vector(0, BarHeight));
            this.Graphics.Add(this.Bar);

            this.Triangle = new VertexArray(VertexArrayType.LinesStrip)
            {
                Z = 1, Color = Color.Black
            };
            for (int i = 0; i <= 3; i++)
            {
                this.Triangle.Add(Vector.FromAngle(Meth.Tau / 4 + i / 3.0 * Meth.Tau) * 5);
            }
            this.Graphics.Add(this.Triangle);

            this.AddMouseArea(this.BarArea = new MouseArea(this.Bar)
            {
                OnClick = key => this.Opened = !this.Opened
            });

            this.Children.Add(this.ChildArea = new Entity());
            this.ChildArea.Children.Add(this.Contents);
        }
Ejemplo n.º 2
0
        public override void OnInitialization()
        {
            this.MouseArea          = new MouseArea(new Rectangle(0, new Vector(Size + this.Text.Width + 2, Size)));
            this.MouseArea.OnClick += key =>
            {
                if (this.Enabled)
                {
                    this.Checked     = !this.Checked;
                    this.JustClicked = true;

                    if (this.Checked && this.OnCheck != null)
                    {
                        this.OnCheck();
                    }
                    if (!this.Checked && this.OnUncheck != null)
                    {
                        this.OnUncheck();
                    }
                }
            };
            this.AddMouseArea(this.MouseArea);

            this.Graphics.Add(this.VertexArray);
            this.Graphics.Add(this.Text);

            this.Progress = this.Checked ? 1 : 0;
        }
Ejemplo n.º 3
0
 public override void OnInitialization()
 {
     this.AddMouseArea(this.MouseArea = new MouseArea(this.Background)
     {
         OnClick = key => this.OnClick()
     });
 }
Ejemplo n.º 4
0
 public override void OnInitialization()
 {
     this.Children.Add(this.Label);
     this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(-this.Cutoff, 0, this.Width + this.Cutoff * 2, this.Label.Height))
     {
         OnClick = key => ((TabList)this.Parents[0]).SelectTab(this)
     });
 }
Ejemplo n.º 5
0
 public override void OnInitialization()
 {
     this.Children.Add(this._Text);
     this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, 1))
     {
         OnClick = this.OnClick, ClickableBy = new Bunch <Key>(Key.MouseLeft, Key.MouseUp, Key.MouseDown)
     });
     this.UpdateMouseArea();
 }
Ejemplo n.º 6
0
 public override void OnInitialization()
 {
     this.StartPosition             = this.Position;
     this.AddMouseArea(this.BarArea = new MouseArea(new Rectangle(0, 1))
     {
         Draggable = true
     });
     this.MaxValue = 100;
 }
Ejemplo n.º 7
0
 public void AddMouseArea(MouseArea _mousearea)
 {
     if (!this.Interfacial)
     {
         throw new Exception("This entity was not declared interfacial.");
     }
     else
     {
         _mousearea.BindToEntity(this);
         this._MouseAreas.Add(_mousearea);
     }
 }
Ejemplo n.º 8
0
        public override void OnInitialization()
        {
            this.Children.Add(this.Labels = this.Items.Select(item => new Label(item)
            {
                Z = 1, Shader = Shader.TextOutline
            }));

            this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, 0, 100, 20))
            {
                ClickableBy = new Bunch <Key>(Key.MouseUp, Key.MouseDown), OnClick = Click
            });
            Parent.Clock.Add(2, () => this.LastHovered = true);
        }
Ejemplo n.º 9
0
            public override void OnInitialization()
            {
                this.Children.Add(this._InputControl);
                this.AddMouseArea(this.DragArea = new MouseArea(new Rectangle(new Vector(15, 0), this._InputControl.RectSize))
                {
                    OnClick = key => this.StartDrag(), OnRelease = key => this.StopDrag()
                });
                this.Graphics.Add(this.DragRectangle = new Rectangle(new Vector(15, 0), this._InputControl.RectSize));

                this.AddMouseArea(this.CrossArea = new MouseArea(new Rectangle(this.Cross.Position - 1, 13))
                {
                    OnClick = key => ((DragList <ArrayItem>) this.Parents[0]).RemoveItem(this)
                });
            }
Ejemplo n.º 10
0
 public override void OnInitialization()
 {
     this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, 1))
     {
         ClickableBy = new Bunch <Key>(Key.MouseDown, Key.MouseUp, Key.MouseLeft), OnClick = key =>
         {
             if (key == Key.MouseLeft)
             {
                 this.Editor.EntityEditor.Select(null);
             }
             else
             {
                 this.Preview.Zoom((key == Key.MouseDown) ? 0.5 : 2, 0);
             }
         }
     });
 }
Ejemplo n.º 11
0
            public override void OnInitialization()
            {
                FileMenu m = (FileMenu)this.Parents[0];

                this.Children.Add(this.Label = new Label(this.Selectable.Name)
                {
                    Position = new Vector(0.5, 0.5), TextColor = m.TextColor
                });

                //VertexArray v = new VertexArray(VertexArrayType.LinesStrip) { Color = this.Color };
                Bunch <Vector> vs = new Bunch <Vector>();

                vs.Add(new Vector(0, 0));
                vs.Add(new Vector(0, this.Label.Height / 4 * 3));
                vs.Add(new Vector(this.Label.Height / 4, this.Label.Height));
                vs.Add(new Vector(this.Label.Width - this.Label.Height / 4, this.Label.Height));
                vs.Add(new Vector(this.Label.Width, this.Label.Height / 4 * 3));
                vs.Add(new Vector(this.Label.Width, 0));

                VertexArray v;

                this.Graphics.Add(v = new VertexArray(VertexArrayType.Polygon)
                {
                    Vertices = vs.Select(item => (Vertex)item), Color = m.BackgroundColor
                });
                this.Graphics.Add(new VertexArray(VertexArrayType.LinesStrip)
                {
                    Vertices = vs.Select(item => (Vertex)item), Color = m.EdgeColor
                });

                this.AddMouseArea(this.MouseArea = new MouseArea(v)
                {
                    OnClick = key =>
                    {
                        if (this.Selectable.IsEnabled())
                        {
                            this.Parent.ReleaseKey(key);
                            this.Selectable.Action();
                        }
                    }
                });

                this.Progress = this.Selectable.IsEnabled() ? 0 : -1;
            }
Ejemplo n.º 12
0
        public override void OnInitialization()
        {
            this.Plus.Add(new Vector(this.Spacing / -3, 0));
            this.Plus.Add(new Vector(this.Spacing / 3, 0));
            this.Plus.Add(new Vector(0, this.Spacing / -3));
            this.Plus.Add(new Vector(0, this.Spacing / 3));
            this.Graphics.Add(this.Plus);

            this.AddMouseArea(this.PlusArea = new MouseArea(new Rectangle(0, 1))
            {
                OnClick = key =>
                {
                    T[] items = this.Items.ToArray();
                    for (int i = this._MousePos; i < items.Length; i++)
                    {
                        items[i]._ListIndex++;
                    }

                    T item = this.OnItemAdd(this._MousePos);

                    this.Children.Add(item);

                    item._ListIndex = this._MousePos;
                    if (items.Length == 0)
                    {
                        item.Y = 0;
                    }
                    else
                    {
                        if (this._MousePos < items.Length)
                        {
                            item.Y = items[this._MousePos].Y - this.Spacing / 2 - item.GetHeight() / 2;
                        }
                        else
                        {
                            item.Y = items[this._MousePos - 1].Y + items[this._MousePos - 1].GetHeight() + this.Spacing / 2 - item.GetHeight() / 2;
                        }
                    }

                    this.OnOrderChange();
                }
            });
        }
Ejemplo n.º 13
0
        public override void OnInitialization()
        {
            this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, 1))
            {
                ClickableBy = new Bunch <Key>(Key.MouseLeft, Key.MouseRight), OnClick = key =>
                {
                    this.LastPosition = (this.LocalMousePosition - new Vector(this.AlignmentZoom.RectSize.X, 0)) / (this.Parent.TileSize / this.Parent.TileCollisionResolution) / this.Zoom;
                }
            });

            this.Children.Add(this.AlignmentZoom = new Alignment(new Button("+", () => this.UpdateZoom(1)), new Button("-", () => this.UpdateZoom(-1)))
            {
                Vertical = true
            });
            this.Children.Add(this.AlignmentButtons = new Alignment(new Button("Add", () => { }), new Button("Export", this.Save), new Button("Cancel", () => ((AreasetEditor)this.Parents[0]).EditorShown = false))
            {
                Spacing = 3
            });
        }
Ejemplo n.º 14
0
        public override void OnInitialization()
        {
            this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, this.Size))
            {
                ClickableBy = new Bunch <Key>(Key.MouseLeft, Key.MouseDown, Key.MouseUp),
                OnClick     = key =>
                {
                    if (key == Key.MouseDown)
                    {
                        this.Zoom(0.5, this.LocalMousePosition / this.Size * this.Editor.TileEditor.Size * this.Parent.TileSize);
                    }
                    if (key == Key.MouseUp)
                    {
                        this.Zoom(2, this.LocalMousePosition / this.Size * this.Editor.TileEditor.Size * this.Parent.TileSize);
                    }
                }
            });

            this.UpdatePreview();
        }
Ejemplo n.º 15
0
        public override void OnInitialization()
        {
            this.CollapseProgress = this.Collapsed ? 0 : 1;

            double d = Border / 2;
            double x = d;

            for (int i = 0; i < this.TabInfos.Count; i++)
            {
                Tab t = new Tab(this.TabInfos[i].Name)
                {
                    Position = new Vector(x, 0.5)
                };
                this.Children.Add(t);
                x += t.Width;
            }

            if (this.AlignRight)
            {
                foreach (Entity c in this.Children)
                {
                    c.X += (this.OuterSize.X - x - d);
                }
            }

            this.CollapseArrow.Add(new Vector(0, -1), new Vector(-1, 0), new Vector(-1, 0), new Vector(0, 1), new Vector(0, 0.5), new Vector(1, 0.5), new Vector(1, -0.5), new Vector(0, -0.5));
            this.CollapseArrow.Scale    = this.TabOffset / 2 * 0.8;
            this.CollapseArrow.Position = new Vector(this.AlignRight ? this.TabOffset / 2 : (this.OuterSize.X - this.TabOffset / 2), this.TabOffset / 2);
            this.CollapseArrow.Rotation = this.AlignRight ? Meth.Tau / 2 : 0;
            this.Graphics.Add(this.CollapseArrow);

            this.AddMouseArea(this.CollapseArea = new MouseArea(this.CollapseArrow)
            {
                OnClick = key => this.Collapsed = !this.Collapsed
            });

            this._UpdateGraphics();

            this.Children.Add(this.Group = this.TabInfos[0].Entity);
            this.SelectTab(this.Children.GetTypes <Tab>()[0]);
        }
Ejemplo n.º 16
0
        public override void OnInitialization()
        {
            this.Sections = (int)this.Size.X / 4;
            if (!this._SetValue)
            {
                this.Value = 1;
            }
            else
            {
                this.Value = this._Value;
            }
            this.Progresses = new double[Sections];

            this.VertexArray.Position = new Vector(0, Size.Y);
            this.Graphics.Add(this.VertexArray);

            this.MouseArea = new MouseArea(new Rectangle(0, this.Size));
            this.AddMouseArea(this.MouseArea);

            this.Graphics.Add(this.Text);
        }
Ejemplo n.º 17
0
        public override void OnInitialization()
        {
            this.Size = this.Editor.LevelSize;

            this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, this.Size * this.Parent.TileSize))
            {
                ClickableBy = new Bunch <Key>(Key.MouseLeft, Key.MouseRight, Key.MouseMiddle, Key.MouseDown, Key.MouseUp),
                Draggable   = true,
                DragKey     = Key.MouseMiddle,
                OnClick     = key =>
                {
                    if (Editor.TabListRight.CurName == "Tiles")
                    {
                        if (key == Key.MouseLeft || key == Key.MouseRight)
                        {
                            if (this.Enabled)
                            {
                                DrawStart = this.LocalMousePosition / this.Parent.TileSize;
                            }
                        }
                    }
                    else if (key == Key.MouseLeft)
                    {
                        Editor.EntityEditor.Select(null);
                    }

                    if (key == Key.MouseDown || key == Key.MouseUp)
                    {
                        this.Editor.LevelPreview.Zoom((key == Key.MouseDown) ? 0.5 : 2, this.LocalMousePosition);
                    }
                }
            });

            this.Scale = 2;
            this.Z     = -4;
        }
Ejemplo n.º 18
0
        public override void OnInitialization()
        {
            this.AddMouseArea(this.MouseArea = new MouseArea(new Rectangle(0, new Vector(this.Editor.Editor.TabListRight.InnerSize.X, 100)))
            {
                OnClick = key =>
                {
                    this.StartDrag();
                    int index = this.Editor.Layers.IndexOf(this.Layer);
                    if (this.Editor.CurLayer != index)
                    {
                        this.Editor.SwitchToLayer(index);
                        this.Editor.Editor.EntityEditor.NeedsToDeselect = true;
                    }
                }, OnRelease = key =>
                {
                    this.StopDrag();
                    if (((LayerList)this.Parents[0]).Changed)
                    {
                        ((LayerList)this.Parents[0]).Changed = false;
                        this.Editor.Editor.LevelPreview.UpdatePreview();
                    }
                }
            });

            this.Children.Add(this.Delete = new Checkbox(true)
            {
                Z         = 1,
                Position  = new Vector(this.Size.X + this.Side / 2 - Checkbox.Size / 2, this.Size.Y / 4 - Checkbox.Size / 2),
                OnUncheck = () =>
                {
                    if (this.Layer == this.Editor.Layer)
                    {
                        if (((LayerList)this.Parents[0]).Items.Count <= this._ListIndex + 1)
                        {
                            this.Editor.SwitchToLayer(this._ListIndex - 1);
                        }
                        else
                        {
                            this.Editor.SwitchToLayer(this._ListIndex + 1);
                        }
                    }
                    ((LayerList)this.Parents[0]).RemoveItem(this);
                    this.Editor.Editor.EntityEditor.NeedsToDeselect = true;
                }
            });
            this.Children.Add(this.Main = new Checkbox(this.Editor.MainLayer == this.Layer)
            {
                Z        = 1,
                Position = new Vector(this.Size.X + this.Side / 2 - Checkbox.Size / 2, this.Size.Y / 4 * 3 - Checkbox.Size / 2),
                OnCheck  = () =>
                {
                    foreach (LayerItem item in ((LayerList)this.Parents[0]).Items)
                    {
                        item.Main.Checked = false;
                    }

                    this.Editor.MainLayer = this.Layer;
                    this.Main.Checked     = true;
                }
            });

            Label l = new Label("Main:");

            l.Position = new Vector(this.Size.X + this.Side / 2 - l.Width / 2 + 2, this.Size.Y * 0.55 - l.Height / 2);
            this.Children.Add(l);
        }
Ejemplo n.º 19
0
        public override void OnInitialization()
        {
            if (this.LoadInfo == null)
            {
                this.EntityZ = (this.Type.Name == "Decoration") ? -1 : 0;

                if (this.Type.Name != "Decoration")
                {
                    this.Properties.First(item => item.Name == "Identifier").Value = this.Type.Name + this.Parents[0].Children.GetTypes <EntityIcon>().Count(item => item.Type.Name == this.Type.Name).ToString();
                }
            }
            else
            {
                this.LoadFromItem(this.LoadInfo);
            }

            ImageSource src = this.Type.Name == "Decoration" ? this.Parent.Areasets.First(item => item.Value.Name == this.Properties.First(prop => prop.Name == "Areaset").Value).Value.Decorations[this.Properties.First(item => item.Name == "Name").Value] : this.Type.Icon;

            Image img0 = (new Image(src)
            {
                Origin = this.Type.Origin
            }).Extend();

            img0.Shader = Shader.Outline;
            this.Graphics.Add(this.Icon = img0);

            Image img1 = (new Image(src)
            {
                Origin = this.Type.Origin
            }).Extend();

            img1.Shader = Shader.Outline;
            img1.Z      = 8;
            this.Graphics.Add(this.IconOverlay = img1);

            if (this.Type.Entrance)
            {
                VertexArray v = new VertexArray(VertexArrayType.Triangles);
                v.Add(new Vector(0, -8), new Vector(6, -4), new Vector(0, 0));
                v.Position = new Vector(this.Icon.Scale.X * this.Icon.Width * this.Icon.Origin.X * -1, this.Icon.Scale.Y * this.Icon.Height * (1 - this.Icon.Origin.Y)) + new Vector(1, -1);
                v.Z        = 8;

                this.Graphics.Add(this.TestButton = v);
                this.AddMouseArea(this.TestArea   = new MouseArea(v)
                {
                    Z = 8, OnClick = key => { this.LevelEditor.Test(this.Properties.First(item => item.Name == "Identifier").Value); this.TestArea._ClickedKey = null; }
                });
            }



            this.AddMouseArea(this.Area = new MouseArea(this.Icon)
            {
                _IsDragged = this.Dragged, Draggable = true, ClickableBy = new Bunch <Key>(Key.MouseLeft, Key.MouseDown, Key.MouseUp), OnClick = key =>
                {
                    if (key == Key.MouseLeft)
                    {
                        this.LevelEditor.EntityEditor.Select(this);
                    }
                    else
                    {
                        this.LevelEditor.LevelPreview.Zoom((key == Key.MouseDown) ? 0.5 : 2, this.TileEditor.LocalMousePosition);
                    }
                }
            });

            this._IsDragged = this.Dragged;
        }