public static void OnCreate_PauseMenu(PauseMenu self, Manager mgr)
 {
     if (!GnomanEmpire.Instance.IsGameOver())
     {
         var panel = typeof(PauseMenu)
             .GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
             .Single(f => f.FieldType == typeof(Panel))
             .GetValue(self)
             as Panel;
         var lastBtn = panel.Controls.Last();
         Button button = new Button(mgr);
         button.Init();
         button.Width = 200;
         button.Top = lastBtn.Top + lastBtn.Height + lastBtn.Margins.Bottom + button.Margins.Top - lastBtn.Margins.Top; //yea, lastMarginTop is excluded between save buttons
         button.Left = (panel.Width - button.Width) / 2;
         //button.Margins = new Margins(0, 2, 0, 2);
         button.Text = "Exit (no Save)";
         button.Click += new Game.GUI.Controls.EventHandler((sender, args) =>
         {
             GnomanEmpire.Instance.MoveToMainMenu();
         });
         panel.Height = button.Top + button.Height;
         panel.Add(button);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create a checkbox for a particular squad
        /// </summary>
        private static CheckBox CreateCheckbox(Manager manager, string text, int squadIndex)
        {
            CheckBox checkBox = new CheckBox(manager);
            checkBox.Init();
            checkBox.Margins = new Margins(3);
            checkBox.Width = 232;
            checkBox.Height = 20;
            checkBox.Text = text;
            checkBox.Tag = squadIndex;
            checkBox.Checked = true;
            checkBox.Anchor = Anchors.Top | Anchors.Horizontal;

            return checkBox;
        }
Exemplo n.º 3
0
        public ModsMenu(Manager manager, IModManager modManager)
            : base(manager)
        {
            this.Init();
            this.Width = this.Manager.ScreenWidth;
            this.Height = this.Manager.ScreenHeight;
            this.Color = Color.Transparent;
            GnomanEmpire.Instance.GuiManager.Add(this);
            GnomanEmpire.Instance.Graphics.DeviceReset += (sender, args) =>
            {
                Width = manager.ScreenWidth;
                Height = manager.ScreenHeight;

                SetPosition();
            };
            _raisedPanel = new RaisedPanel(manager);
            _raisedPanel.Init();
            Add(_raisedPanel);
            AboutModsPanel aboutModsPanel = new AboutModsPanel(_raisedPanel, modManager);

            Button button = new Button(this.Manager);
            button.Init();
            button.Width = 100;
            button.Left = button.Margins.Left;
            button.Top = aboutModsPanel.ModListBox.Top + aboutModsPanel.ModListBox.Height + aboutModsPanel.ModListBox.Margins.Bottom + button.Margins.Top;
            button.Text = "Back";
            button.Click += (sender, args) => GnomanEmpire.Instance.GuiManager.MenuStack.PopWindow();
            this._raisedPanel.Add(button);

            this._raisedPanel.Width = aboutModsPanel.ModInfoPanel.Left + aboutModsPanel.ModInfoPanel.Width + this._raisedPanel.ClientMargins.Horizontal + aboutModsPanel.ModListBox.Margins.Right;
            this._raisedPanel.Height = button.Top + button.Height + button.Margins.Bottom + this._raisedPanel.ClientMargins.Vertical;
            SetPosition();
        }
Exemplo n.º 4
0
        public ModDialogUI(Manager manager, IModManager modManager)
            : base(manager)
        {
            Text = "Mods";
            Width = 750;
            Height = 500;
            Resizable = false;
            Center();
            if (s_Position.X < 0f || s_Position.Y < 0f || s_Position.X + s_Width >= Manager.ScreenWidth || s_Position.Y + s_Height >= Manager.ScreenHeight)
            {
                s_Width = this.Width;
                s_Height = this.Height;
                s_Position.X = this.Left;
                s_Position.Y = this.Top;
            }
            AddPage("About", new GnomodiaPanelUI(this.Manager, modManager));
            Width = s_Width;
            Height = s_Height;
            Left = (int)s_Position.X;
            Top = (int)s_Position.Y;

            Resize += (sender, args) =>
            {
                s_Width = Width;
                s_Height = Height;
                s_Position.X = this.Left;
                s_Position.Y = this.Top;
            };

            Move += (sender, args) =>
            {
                s_Position.X = this.Left;
                s_Position.Y = this.Top;
            };
        }
Exemplo n.º 5
0
 public GnomodiaPanelUI(Manager manager, IModManager modManager)
     : base(manager)
 {
     _modManager = modManager;
 }
Exemplo n.º 6
0
        public void SetGnomodiaLogo(MainMenuWindow mainMenu, Manager manager)
        {
            Panel buttonPanel = (Panel)MainMenuWindowPanelField.GetValue(mainMenu);

            ImageBox logo;
            if (!buttonPanel.FindControlRecursive(out logo))
                return;

            Stream logoStream = typeof(ModDialog).Assembly.GetManifestResourceStream("Gnomodia.Images.Gnomodia.png");
            Texture2D logoTexture = Texture2D.FromStream(GnomanEmpire.Instance.GraphicsDevice, logoStream);
            logo.Image = logoTexture;

            logo.SizeMode = SizeMode.Stretched;
            logo.Width = logoTexture.Width * 3;
            logo.Height = logoTexture.Height * 3;

            logo.Left = (buttonPanel.Width - logo.Width) / 2;

            Button[] buttons;
            buttonPanel.FindControlsRecursive(out buttons, b => !string.IsNullOrEmpty(b.Text));
            foreach (var button in buttons)
            {
                button.Top += 76;
            }
        }
Exemplo n.º 7
0
        public void AddMainMenuModButton(MainMenuWindow mainMenu, Manager manager)
        {
            Panel buttonPanel = (Panel)MainMenuWindowPanelField.GetValue(mainMenu);

            Button exitButton;
            if (!buttonPanel.FindControlRecursive(out exitButton, b => b.Text == "Exit"))
                return;

            Button modsButton = new Button(manager);
            modsButton.Init();
            modsButton.Width = 200;
            modsButton.Top = exitButton.Top;
            modsButton.Left = (buttonPanel.Width - modsButton.Width) / 2;
            modsButton.Margins = new Margins(0, 2, 0, 2);
            modsButton.Text = "Mods";
            buttonPanel.Height += modsButton.Height + 4;
            modsButton.Click += MainMenuModsButtonClick;
            buttonPanel.Add(modsButton);

            exitButton.Top = modsButton.Top + modsButton.Height + modsButton.Margins.Bottom + exitButton.Margins.Top;

            if (!mainMenu.FindControlRecursive(out _gnomoriaVersionLabel, l => l.Text.StartsWith("v")))
                return;

            _gnomoriaVersionLabel.Text = "Gnomoria " + _gnomoriaVersionLabel.Text;

            _gnomodiaVersionLabel = new Label(manager);
            _gnomodiaVersionLabel.Init();
            _gnomodiaVersionLabel.Alignment = Alignment.MiddleRight;
            _gnomodiaVersionLabel.Text = "Gnomodia v" + typeof(ModDialog).Assembly.GetInformationalVersion();
            mainMenu.Add(_gnomodiaVersionLabel);

            Reset(mainMenu, null, null);
        }