Exemplo n.º 1
0
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);

            var mainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect        = GuiRoot.RenderData.VirtualScreen,
                Padding     = new Margin(4, 4, 4, 4),
                Transparent = true
            });

            mainPanel.AddChild(new Gui.Widgets.Button
            {
                Text = "Close",
                Font = "font16",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    GameStateManager.PopState();
                },
                AutoLayout = AutoLayout.FloatBottomRight
            });

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

            var employeePanel = TabPanel.AddTab("Employees", new Gui.Widgets.EmployeePanel
            {
                Font    = "font10",
                Border  = "border-thin",
                Padding = new Margin(4, 4, 0, 0),
                World   = World,
            });

            var financePanel = TabPanel.AddTab("Finance", new Gui.Widgets.FinancePanel
            {
                Border  = "border-thin",
                Padding = new Margin(4, 4, 0, 0),
                Faction = World.PlayerFaction,
                World   = World
            });

            TabPanel.SelectedTab = 0;

            GuiRoot.RootItem.Layout();

            IsInitialized = true;
            base.OnEnter();
        }
Exemplo n.º 2
0
        public override void OnEnter()
        {
            // Clear the input queue... cause other states aren't using it and it's been filling up.
            DwarfGame.GumInputMapper.GetInputQueue();

            GuiRoot = new Gui.Root(DwarfGame.GumSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);

            var mainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect        = GuiRoot.RenderData.VirtualScreen,
                Padding     = new Margin(4, 4, 4, 4),
                Transparent = true
            });

            mainPanel.AddChild(new Gui.Widgets.Button
            {
                Text = "Close",
                Font = "font16",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    StateManager.PopState();
                },
                AutoLayout = AutoLayout.FloatBottomRight
            });

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

            var employeePanel = TabPanel.AddTab("Employees", new Gui.Widgets.EmployeePanel
            {
                Border  = "border-thin",
                Padding = new Margin(4, 4, 0, 0),
                Faction = World.PlayerFaction,
            });

            //var financePanel = tabPanel.AddTab("Finance", new Gui.Widgets.FinancePanel
            //{
            //    Border = "border-thin",
            //    Padding = new Margin(4, 4, 0, 0),
            //    Economy = World.PlayerEconomy
            //});

            TabPanel.AddTab("Available Goals", new Gui.Widgets.GoalPanel
            {
                GoalSource = World.GoalManager.EnumerateGoals().Where(g =>
                                                                      g.State == Goals.GoalState.Available),
                World   = World,
                OnShown = (sender) => World.GoalManager.ResetNewAvailableGoals()
            });

            TabPanel.AddTab("Active Goals", new Gui.Widgets.GoalPanel
            {
                GoalSource = World.GoalManager.EnumerateGoals().Where(g =>
                                                                      g.State == Goals.GoalState.Active && g.GoalType != Goals.GoalTypes.Achievement)
            });

            TabPanel.AddTab("Completed Goals", new Gui.Widgets.GoalPanel
            {
                GoalSource = World.GoalManager.EnumerateGoals().Where(g =>
                                                                      g.State == Goals.GoalState.Complete),
                OnShown = (sender) => World.GoalManager.ResetNewCompletedGoals()
            });

            TabPanel.GetTabButton(1).DrawIndicator = true;
            TabPanel.GetTabButton(3).DrawIndicator = true;

            TabPanel.SelectedTab = 0;

            GuiRoot.RootItem.Layout();

            IsInitialized = true;
            base.OnEnter();
        }
Exemplo n.º 3
0
        private void RebuildGui()
        {
            BuildingGUI = true;

            // Create and initialize GUI framework.
            GuiRoot = new Gui.Root(DwarfGame.GumSkin);
            GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0);
            var       screen    = GuiRoot.RenderData.VirtualScreen;
            float     scale     = 0.75f;
            float     newWidth  = System.Math.Min(System.Math.Max(screen.Width * scale, 640), screen.Width * scale);
            float     newHeight = System.Math.Min(System.Math.Max(screen.Height * scale, 480), screen.Height * scale);
            Rectangle rect      = new Rectangle((int)(screen.Width / 2 - newWidth / 2), (int)(screen.Height / 2 - newHeight / 2), (int)newWidth, (int)newHeight);

            // CONSTRUCT GUI HERE...
            MainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect        = rect,
                Padding     = new Margin(4, 4, 4, 4),
                Transparent = true,
                MinimumSize = new Point(640, 480),
                Font        = "font10"
            });

            MainPanel.AddChild(new Gui.Widgets.Button
            {
                Text = "Close",
                Font = "font16",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border  = "border-button",
                OnClick = (sender, args) =>
                {
                    // If changes, prompt before closing.
                    if (HasChanges)
                    {
                        var confirm = new Gui.Widgets.Confirm
                        {
                            Text       = "Apply changes?",
                            OkayText   = "Yes",
                            CancelText = "No",
                            OnClose    = (s2) =>
                            {
                                if ((s2 as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY)
                                {
                                    ConfirmSettings();
                                }
                                if (OnClosed != null)
                                {
                                    OnClosed();
                                }
                                StateManager.PopState();
                            }
                        };
                        GuiRoot.ShowModalPopup(confirm);
                    }
                    else
                    {
                        if (OnClosed != null)
                        {
                            OnClosed();
                        }
                        StateManager.PopState();
                    }
                },
                AutoLayout = AutoLayout.FloatBottomRight
            });

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

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

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

            TabPanel.SelectedTab = 0;

            GuiRoot.RootItem.Layout();

            LoadSettings();

            BuildingGUI = false;
        }