示例#1
0
 private void MakeMenuItem(Gum.Widget Menu, string Name, string Tooltip, Action <Gum.Widget, Gum.InputEventArgs> OnClick)
 {
     Menu.AddChild(new Gum.Widget
     {
         AutoLayout          = Gum.AutoLayout.DockTop,
         Border              = "border-thin",
         Text                = Name,
         OnClick             = OnClick,
         Tooltip             = Tooltip,
         TextHorizontalAlign = Gum.HorizontalAlign.Center,
         TextVerticalAlign   = Gum.VerticalAlign.Center
     });
 }
示例#2
0
        private void RebuildGui()
        {
            // Create and initialize GUI framework.
            GuiRoot = new Gum.Root(new Point(640, 480), DwarfGame.GumSkin);
            GuiRoot.MousePointer = new Gum.MousePointer("mouse", 4, 0);

            // CONSTRUCT GUI HERE...
            MainPanel = GuiRoot.RootItem.AddChild(new Gum.Widget
            {
                Rect        = GuiRoot.VirtualScreen,
                Padding     = new Margin(4, 4, 4, 4),
                Transparent = true
            });

            MainPanel.AddChild(new Widget
            {
                Text = "CLOSE",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    // If changes, prompt before closing.
                    if (HasChanges)
                    {
                        var confirm = new NewGui.Confirm
                        {
                            Text       = "Apply changes?",
                            OkayText   = "YES",
                            CancelText = "NO",
                            OnClose    = (s2) =>
                            {
                                if ((s2 as NewGui.Confirm).DialogResult == NewGui.Confirm.Result.OKAY)
                                {
                                    ApplySettings();
                                }
                                StateManager.PopState();
                            }
                        };
                        GuiRoot.ShowPopup(confirm, false);
                    }
                    else
                    {
                        StateManager.PopState();
                    }
                },
                AutoLayout = AutoLayout.FloatBottomRight
            });

            MainPanel.AddChild(new Widget
            {
                Text = "APPLY",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    ApplySettings();
                },
                AutoLayout = AutoLayout.FloatBottomRight,
                OnLayout   = s => s.Rect.X -= 128 // Hack to keep it from floating over the other button.
            });

            TabPanel = MainPanel.AddChild(new Gum.Widgets.TabPanel
            {
                AutoLayout       = AutoLayout.DockFill,
                TextSize         = 2,
                SelectedTabColor = new Vector4(1, 0, 0, 1),
                OnLayout         = (sender) => sender.Rect.Height -= 36 // Keep it from overlapping bottom buttons.
            }) as Gum.Widgets.TabPanel;

            CreateGameplayTab();
            CreateAudioTab();
            CreateKeysTab();
            CreateGraphicsTab();

            TabPanel.SelectedTab = 0;

            GuiRoot.RootItem.Layout();

            LoadSettings();
        }
示例#3
0
        private void BuildTab(Gum.Widgets.TabPanel TabPanel, String TabName, IEnumerable <BuildableItem> ItemSource,
                              Action <BuildableItem, Gum.Widget, Gum.Widget> BuildDescriptionPanel)
        {
            var panel = TabPanel.AddTab(TabName, new Widget
            {
                Border  = "border-thin",
                Padding = new Margin(4, 4, 0, 0)
            });

            Gum.Widgets.WidgetListView list = null;
            Gum.Widget descriptionPanel     = null;
            Gum.Widget buildButton          = null;

            list = panel.AddChild(new Gum.Widgets.WidgetListView
            {
                ItemHeight             = 32,
                MinimumSize            = new Point(256, 0),
                AutoLayout             = Gum.AutoLayout.DockLeft,
                OnSelectedIndexChanged = (sender) =>
                {
                    var selectedItem = (sender as Gum.Widgets.WidgetListView).SelectedItem;
                    if (selectedItem != null)
                    {
                        descriptionPanel.Clear();
                        buildButton.Hidden = false;
                        BuildDescriptionPanel(selectedItem.Tag as BuildableItem, descriptionPanel, buildButton);
                        descriptionPanel.Layout();
                        buildButton.Invalidate();
                    }
                }
            }) as Gum.Widgets.WidgetListView;

            var bottomRow = panel.AddChild(new Widget
            {
                MinimumSize = new Point(0, 32),
                AutoLayout  = Gum.AutoLayout.DockBottom
            });

            buildButton = bottomRow.AddChild(new Widget
            {
                Text = "BUILD",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border = "border-button",
                //OnClick = (sender, args) => BuildClicked(list.SelectedItem.Tag as BuildableItem),
                AutoLayout = AutoLayout.DockRight
            });

            descriptionPanel = panel.AddChild(new Widget
            {
                AutoLayout = Gum.AutoLayout.DockFill,
                OnLayout   = (sender) => sender.Rect.Height -= 36
            });

            foreach (var buildableItem in ItemSource)
            {
                var row = new Gum.Widget
                {
                    Background = new TileReference("basic", 0),
                    Tag        = buildableItem
                };

                list.AddItem(row);

                if (buildableItem.Icon != null)
                {
                    row.AddChild(new Gum.Widget
                    {
                        MinimumSize = new Point(32, 32),
                        Background  = buildableItem.Icon,
                        AutoLayout  = Gum.AutoLayout.DockLeft
                    });
                }

                row.AddChild(new Gum.Widget
                {
                    Text       = buildableItem.Name,
                    AutoLayout = Gum.AutoLayout.DockFill
                });
            }

            list.SelectedIndex = 0;
        }