예제 #1
0
        public void AddNode(string name)
        {
            var lbl = new LabelElement2D(Manager, fnt)
            {
                Text = name
            };
            var chk  = new CheckBoxElement2D(Manager);
            var more = new MoreCell(Manager);

            chk.Clicked += () =>
            {
                if (SetActive != null)
                {
                    SetActive(name, chk.Checked);
                }
            };
            more.Clicked += () =>
            {
                if (OpenMenu != null)
                {
                    OpenMenu(name);
                }
            };
            items.Add(new ListItem()
            {
                Active = chk, Name = lbl, More = more
            });
        }
예제 #2
0
        void NodeOptions(string name)
        {
            //Dialog
            var dlg = new List <UIElement>();

            dlg.Add(new PanelElement2D(manager)
            {
                FillColor = new Color4(0, 0, 0, 0.4f), Fullscreen = true
            });
            var bkg = new PanelElement2D(manager)
            {
                FillColor = Color4.White, Width = 300, Height = 200
            };

            bkg.CalculatePosition += () =>
            {
                bkg.Position2D = new Vector2(Game.Width / 2 - 150, Game.Height / 2 - 100);
            };
            dlg.Add(bkg);
            //Node info
            var node = fx.Nodes.Find((n) => n.NodeName == name);
            var lbl = new LabelElement2D(manager, uiFont);
            int a, b = 0;

            lbl.Text       = string.Join("\n", Infocards.InfocardDisplay.WrapText(Game.Renderer2D, uiFont, 10, string.Format("{0}: {1}", name, node.GetType().Name), 280, 0, out a, ref b));
            lbl.Position2D = new Vector2(10, 10);
            bkg.Children.Add(lbl);
            //Node options
            if (node is Fx.FxAppearance)
            {
                var fxapp      = (Fx.FxAppearance)node;
                var chkNormals = new CheckBoxElement2D(manager)
                {
                    Position2D = new Vector2(10, 40), Checked = fxapp.DrawNormals
                };
                chkNormals.Clicked += () => fxapp.DrawNormals = chkNormals.Checked;
                bkg.Children.Add(chkNormals);
                bkg.Children.Add(new LabelElement2D(manager, uiFont)
                {
                    Text = "Draw Normals", Position2D = new Vector2(30, 45)
                });
            }
            //Ok button
            var btnOk = new ButtonElement2D(manager, uiFont)
            {
                Label = "OK"
            };

            btnOk.AutoSize(Game.Renderer2D);
            btnOk.CalculatePosition += () =>
            {
                btnOk.Position2D = new Vector2(Game.Width / 2 - (btnOk.Width / 2), Game.Height / 2 + 50);
            };
            btnOk.Clicked += () => manager.Dialog = null;
            dlg.Add(btnOk);
            manager.Dialog = dlg;
        }
예제 #3
0
        void MessageDialog(string text, Action yes = null)
        {
            var dlg = new List <UIElement>();

            dlg.Add(new PanelElement2D(manager)
            {
                FillColor = new Color4(0, 0, 0, 0.4f), Fullscreen = true
            });
            var bkg = new PanelElement2D(manager)
            {
                FillColor = Color4.White, Width = 300, Height = 200
            };

            bkg.CalculatePosition += () =>
            {
                bkg.Position2D = new Vector2(Game.Width / 2 - 150, Game.Height / 2 - 100);
            };
            dlg.Add(bkg);
            var lbl = new LabelElement2D(manager, uiFont);
            int a, b = 0;

            lbl.Text       = string.Join("\n", Infocards.InfocardDisplay.WrapText(Game.Renderer2D, uiFont, 10, text, 280, 0, out a, ref b));
            lbl.Position2D = new Vector2(10, 10);
            bkg.Children.Add(lbl);

            if (yes == null)
            {
                var btnOk = new ButtonElement2D(manager, uiFont)
                {
                    Label = "OK"
                };
                btnOk.AutoSize(Game.Renderer2D);
                btnOk.CalculatePosition += () =>
                {
                    btnOk.Position2D = new Vector2(Game.Width / 2 - (btnOk.Width / 2), Game.Height / 2 + 50);
                };
                btnOk.Clicked += () => manager.Dialog = null;
                dlg.Add(btnOk);
            }
            else
            {
                var btnYes = new ButtonElement2D(manager, uiFont)
                {
                    Label = "Yes"
                };
                btnYes.AutoSize(Game.Renderer2D);
                btnYes.Clicked += yes;
                var btnNo = new ButtonElement2D(manager, uiFont)
                {
                    Label = "No"
                };
                btnNo.Width               = btnYes.Width;
                btnNo.Height              = btnYes.Height;
                btnNo.Clicked            += () => manager.Dialog = null;
                btnYes.CalculatePosition += () =>
                {
                    btnYes.Position2D = new Vector2(Game.Width / 2 - (btnYes.Width + btnNo.Width + 5) / 2, Game.Height / 2 + 50);
                };
                btnNo.CalculatePosition += () =>
                {
                    btnNo.Position2D = new Vector2(Game.Width / 2 + 5, Game.Height / 2 + 50);
                };
                dlg.Add(btnYes);
                dlg.Add(btnNo);
            }
            manager.Dialog = dlg;
        }
예제 #4
0
        void OptionsDialog()
        {
            var dlg = new List <UIElement>();

            dlg.Add(new PanelElement2D(manager)
            {
                FillColor = new Color4(0, 0, 0, 0.4f), Fullscreen = true
            });
            var bkg = new PanelElement2D(manager)
            {
                FillColor = Color4.White, Width = 300, Height = 300
            };

            bkg.CalculatePosition += () =>
            {
                bkg.Position2D = new Vector2(Game.Width / 2 - 150, Game.Height / 2 - 150);
            };
            dlg.Add(bkg);

            var lbl = new LabelElement2D(manager, uiFont)
            {
                Text = "Background Color:"
            };

            lbl.Position2D = new Vector2(10, 10);
            bkg.Children.Add(lbl);

            var sliderR = new SliderElement2D(manager, uiFont)
            {
                Label = "R:", BlackText = true, Minimum = 0, Value = renderer.NullColor.R, Maximum = 1
            };

            sliderR.AutoSize(Game.Renderer2D);
            sliderR.Position2D = new Vector2(10, 50);
            bkg.Children.Add(sliderR);

            var sliderG = new SliderElement2D(manager, uiFont)
            {
                Label = "G:", BlackText = true, Minimum = 0, Value = renderer.NullColor.G, Maximum = 1
            };

            sliderG.AutoSize(Game.Renderer2D);
            sliderG.Position2D = new Vector2(10, 100);
            bkg.Children.Add(sliderG);

            var sliderB = new SliderElement2D(manager, uiFont)
            {
                Label = "B:", BlackText = true, Minimum = 0, Value = renderer.NullColor.B, Maximum = 1
            };

            sliderB.AutoSize(Game.Renderer2D);
            sliderB.Position2D = new Vector2(10, 150);
            bkg.Children.Add(sliderB);

            var prev = new PanelElement2D(manager)
            {
                FillColor = renderer.NullColor
            };

            prev.Width              = prev.Height = sliderB.Height;
            prev.Position2D         = new Vector2(200, 10);
            prev.CalculatePosition += () =>
            {
                prev.FillColor = new Color4(sliderR.Value, sliderG.Value, sliderB.Value, 1f);
            };
            bkg.Children.Add(prev);

            var btnCancel = new ButtonElement2D(manager, uiFont)
            {
                Label = "Cancel"
            };

            btnCancel.AutoSize(Game.Renderer2D);

            var btnOk = new ButtonElement2D(manager, uiFont)
            {
                Label = "OK"
            };

            btnOk.Width    = btnCancel.Width;
            btnOk.Height   = btnCancel.Height;
            btnOk.Clicked += () =>
            {
                renderer.NullColor = new Color4(sliderR.Value, sliderG.Value, sliderB.Value, 1f);
                manager.Dialog     = null;
            };

            btnCancel.Clicked       += () => manager.Dialog = null;
            btnOk.CalculatePosition += () =>
            {
                btnOk.Position2D = new Vector2(Game.Width / 2 - (btnOk.Width + btnCancel.Width + 5) / 2, Game.Height / 2 + 50);
            };
            btnCancel.CalculatePosition += () =>
            {
                btnCancel.Position2D = new Vector2(Game.Width / 2 + 5, Game.Height / 2 + 50);
            };
            dlg.Add(btnOk);
            dlg.Add(btnCancel);

            manager.Dialog = dlg;
        }