Esempio n. 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
            });
        }
Esempio n. 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;
        }