Beispiel #1
0
        /// <summary>
        /// Creates saveDialog Component. Expects ControlFactory for component creation.
        /// </summary>
        /// <param name="controlFactory">medja.UI object which is needed for control creation.</param>
        public SteSaveDialog(IControlFactory controlFactory, int inputLength)
        {
            _controlFactory = controlFactory;
            _inputLength    = inputLength;

            _config = new CryptoConfig();

            _firstColumnStack = GetVertStackPanel(140);
            _secColumnStack   = GetVertStackPanel(150);
            _thirdColumnStack = GetVertStackPanel(160);

            //Filler CREATION
            _pbeFill = new Control();

            CreateLabels();
            CreateInputs();
            CreateAndBindComboBoxes();
            CreateCheckBoxes();
            FillStackPanels();
            UpdateSectionVisibility(Sections.Encryption, Visibility.Visible);
            UpdateSectionVisibility(Sections.Pbe, Visibility.Collapsed);
            UpdateSectionVisibility(Sections.Integrity, Visibility.Collapsed);
            Content = CreateDockPanel();
            FocusManager.Default.SetFocus(_filenameInput);
        }
Beispiel #2
0
        public Menu(MainGame game) : base(game)
        {
            _verticalStackPanel = new VerticalStackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };
            var hostButton = new TextButton {
                Text = "Host", Width = 100, Height = 50
            };

            hostButton.Click += (o, e) => game.HostGame();
            _verticalStackPanel.Widgets.Add(hostButton);

            var joinButton = new TextButton {
                Text = "Join", Width = 100, Height = 50
            };

            joinButton.Click += async(o, e) =>
            {
                hostButton.Enabled = false;
                joinButton.Enabled = false;
                try
                {
                    await game.JoinGame();
                }
                catch
                {
                    hostButton.Enabled = true;
                    joinButton.Enabled = true;
                }
            };
            _verticalStackPanel.Widgets.Add(joinButton);
        }
Beispiel #3
0
        private void BuildUI()
        {
            Message      = new Label();
            Message.Text = "sample text";
            Message.Id   = "Message";

            Ok                     = new TextButton();
            Ok.Text                = "OK";
            Ok.MinWidth            = 70;
            Ok.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            Ok.Id                  = "Ok";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Spacing    = 10;
            verticalStackPanel1.Padding    = new Thickness(5);
            verticalStackPanel1.Background = new SolidBrush("#ADADADFF");
            verticalStackPanel1.Widgets.Add(Message);
            verticalStackPanel1.Widgets.Add(Ok);


            Title    = "NoisEvader";
            Left     = 430;
            Top      = 139;
            MinWidth = 200;
            Content  = verticalStackPanel1;
        }
Beispiel #4
0
        public void addIndicators()
        {
            // Bottom Left Panel
            HorizontalStackPanel bottomLeftPanel = new HorizontalStackPanel();

            bottomLeftPanel.HorizontalAlignment = HorizontalAlignment.Left;
            bottomLeftPanel.VerticalAlignment   = VerticalAlignment.Bottom;
            bottomLeftPanel.Spacing             = 8;

            Stylesheet.Current.VerticalProgressBarStyle.Background = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Gray);
            Stylesheet.Current.VerticalProgressBarStyle.Filler     = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Red);
            _healthIndicator         = new VerticalProgressBar();
            _healthIndicator.Width   = 64;
            _healthIndicator.Height  = 64;
            _healthIndicator.Minimum = 0;
            _healthIndicator.Maximum = 100;
            _healthIndicator.Value   = 100;
            bottomLeftPanel.Widgets.Add(_healthIndicator);

            Stylesheet.Current.VerticalProgressBarStyle.Background = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Transparent);
            Stylesheet.Current.VerticalProgressBarStyle.Filler     = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Blue);
            _kevlarIndicator         = new VerticalProgressBar();
            _kevlarIndicator.Width   = 64;
            _kevlarIndicator.Height  = 64;
            _kevlarIndicator.Minimum = 0;
            _kevlarIndicator.Maximum = 100;
            _kevlarIndicator.Value   = 0;
            bottomLeftPanel.Widgets.Add(_kevlarIndicator);

            _ui.Widgets.Add(bottomLeftPanel);
            // Bottom Panel
            VerticalStackPanel bottomPanel = new VerticalStackPanel();

            bottomPanel.HorizontalAlignment = HorizontalAlignment.Center;
            bottomPanel.VerticalAlignment   = VerticalAlignment.Bottom;

            //bottomPanel.Background = new TextureRegion(Resources.MenuBackground);

            _handsLabel      = new Label();
            _handsLabel.Text = "Hands";
            bottomPanel.Widgets.Add(_handsLabel);

            _handsImage = new Image();
            bottomPanel.Widgets.Add(_handsImage);

            _handsAmount      = new Label();
            _handsAmount.Text = "";
            bottomPanel.Widgets.Add(_handsAmount);

            Stylesheet.Current.HorizontalProgressBarStyle.Background = new ColoredRegion(DefaultAssets.WhiteRegion, Color.Transparent);
            Stylesheet.Current.HorizontalProgressBarStyle.Filler     = new ColoredRegion(DefaultAssets.WhiteRegion, Color.LimeGreen);
            _handsProgressIndicator        = new HorizontalProgressBar();
            _handsProgressIndicator.Height = 20;
            _handsProgressIndicator.Width  = 100;
            bottomPanel.Widgets.Add(_handsProgressIndicator);

            _ui.Widgets.Add(bottomPanel);
        }
Beispiel #5
0
        public HUD(GraphicsDevice graphics, Camera cam)
        {
            _playersPanel = GameMenu.PlayersPlanel();
            _deathPanel   = GameMenu.DeathPanel();

            overlayActive = false;
            _ui           = new Panel();
            addIndicators();
        }
Beispiel #6
0
        private void BuildUI()
        {
            _radioButtonGrid      = new RadioButton();
            _radioButtonGrid.Text = "Grid";
            _radioButtonGrid.Id   = "_radioButtonGrid";

            _radioButtonHorizontalStackPanel      = new RadioButton();
            _radioButtonHorizontalStackPanel.Text = "HorizontalStackPanel";
            _radioButtonHorizontalStackPanel.Id   = "_radioButtonHorizontalStackPanel";

            _radioButtonVerticalStackPanel      = new RadioButton();
            _radioButtonVerticalStackPanel.Text = "VerticalStackPanel";
            _radioButtonVerticalStackPanel.Id   = "_radioButtonVerticalStackPanel";

            _radioButtonPanel      = new RadioButton();
            _radioButtonPanel.Text = "Panel";
            _radioButtonPanel.Id   = "_radioButtonPanel";

            _radioButtonScrollViewer      = new RadioButton();
            _radioButtonScrollViewer.Text = "ScrollViewer";
            _radioButtonScrollViewer.Id   = "_radioButtonScrollViewer";

            _radioButtonHorizontalSplitPane      = new RadioButton();
            _radioButtonHorizontalSplitPane.Text = "HorizontalSplitPane";
            _radioButtonHorizontalSplitPane.Id   = "_radioButtonHorizontalSplitPane";

            _radioButtonVerticalSplitPane      = new RadioButton();
            _radioButtonVerticalSplitPane.Text = "VerticalSplitPane";
            _radioButtonVerticalSplitPane.Id   = "_radioButtonVerticalSplitPane";

            _radioButtonWindow      = new RadioButton();
            _radioButtonWindow.Text = "Window";
            _radioButtonWindow.Id   = "_radioButtonWindow";

            _radioButtonDialog      = new RadioButton();
            _radioButtonDialog.Text = "Dialog";
            _radioButtonDialog.Id   = "_radioButtonDialog";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(_radioButtonGrid);
            verticalStackPanel1.Widgets.Add(_radioButtonHorizontalStackPanel);
            verticalStackPanel1.Widgets.Add(_radioButtonVerticalStackPanel);
            verticalStackPanel1.Widgets.Add(_radioButtonPanel);
            verticalStackPanel1.Widgets.Add(_radioButtonScrollViewer);
            verticalStackPanel1.Widgets.Add(_radioButtonHorizontalSplitPane);
            verticalStackPanel1.Widgets.Add(_radioButtonVerticalSplitPane);
            verticalStackPanel1.Widgets.Add(_radioButtonWindow);
            verticalStackPanel1.Widgets.Add(_radioButtonDialog);


            Title   = "Choose Root Container";
            Left    = 431;
            Top     = 83;
            Content = verticalStackPanel1;
        }
Beispiel #7
0
        public LogView()
        {
            _logStack = new VerticalStackPanel
            {
                VerticalAlignment = VerticalAlignment.Bottom
            };


            InternalChild = _logStack;
        }
Beispiel #8
0
        public VerticalStackPanel ReturnTelaPrincipal()
        {
            verticalStackPanel = new VerticalStackPanel
            {
                Spacing = 1
            };

            verticalStackPanel.Proportions.Add(new Proportion {
                Type = ProportionType.Auto
            });
            verticalStackPanel.Proportions.Add(new Proportion {
                Type = ProportionType.Fill
            });

            var horizontalMenu = new HorizontalMenu
            {
                VerticalAlignment = VerticalAlignment.Stretch
            };
            var menuItem = new MenuItem
            {
                Text = "Criar Sala"
            };

            menuItem.Selected += (s, ea) =>
            {
                // chamar a tela de criar sala
                verticalStackPanel.Widgets.RemoveAt(1);
                verticalStackPanel.Widgets.Add(carregarCriarSalaWidget());
            };
            var menuItem2 = new MenuItem
            {
                Text = "Mostrar lista de salas"
            };

            menuItem2.Selected += (s, ea) =>
            {
                // chamar a tela de listar salas
                verticalStackPanel.Widgets.RemoveAt(1);
                verticalStackPanel.Widgets.Add(carregarListarSalasWidget());
            };
            horizontalMenu.Items.Add(menuItem);
            horizontalMenu.Items.Add(menuItem2);

            var label = new Label
            {
                Text = "Bem vindo",
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Id = "labelBemVindo"
            };

            verticalStackPanel.Widgets.Add(horizontalMenu);
            verticalStackPanel.Widgets.Add(label);
            return(verticalStackPanel);
        }
Beispiel #9
0
        /// <summary>
        /// Creates saveDialog Component. Expects ControlFactory for component creation.
        /// </summary>
        /// <param name="controlFactory"></param>
        public SteLoadDialog(IControlFactory controlFactory)
        {
            _controlFactory   = controlFactory;
            _firstColumnStack = GetStackPanel(120);
            _secColumnStack   = GetStackPanel(150);

            CreateInputs();
            FillStackPanels();

            Content = CreateDockPanel();
            FocusManager.Default.SetFocus(_filenameInput);
        }
Beispiel #10
0
        /// <summary>
        /// In Game Pause Menu loader
        /// </summary>
        public static void GameMenu()
        {
            LoadUIStylesheet();
            Desktop.Widgets.Clear();

            mainPanel            = new Panel();
            mainPanel.Background = new TextureRegion(Resources.menuBackground);

            VerticalStackPanel grid = new VerticalStackPanel();

            grid.VerticalAlignment   = VerticalAlignment.Center;
            grid.HorizontalAlignment = HorizontalAlignment.Center;

            grid.Spacing = 8;

            Label title = new Label();

            title.Text                = "Paused";
            title.Padding             = new Thickness(0, 0, 0, 100);
            title.HorizontalAlignment = HorizontalAlignment.Center;
            grid.Widgets.Add(title);

            TextButton resumeBtn = new TextButton();

            resumeBtn.Text   = "Resume";
            resumeBtn.Click += (s, a) =>
            {
                GameEngine.setState(GameMain.tutorial != null ? GameState.Tutorial : GameState.Playing);
            };
            grid.Widgets.Add(resumeBtn);

            TextButton optionsBtn = new TextButton();

            optionsBtn.Text   = "Options";
            optionsBtn.Click += (s, a) =>
            {
                OptionsMenu(GameMenu);
            };
            grid.Widgets.Add(optionsBtn);

            TextButton quitBtn = new TextButton();

            quitBtn.Text   = "Quit";
            quitBtn.Click += (s, a) =>
            {
                MainMenu();
            };
            grid.Widgets.Add(quitBtn);

            mainPanel.Widgets.Add(grid);
            Desktop.Root = mainPanel;
        }
Beispiel #11
0
        private void BuildUI()
        {
            ThirtyTicks             = new CheckBox();
            ThirtyTicks.Text        = " Force 30 ticks/sec.";
            ThirtyTicks.TextColor   = Color.White;
            ThirtyTicks.ImageWidth  = 16;
            ThirtyTicks.ImageHeight = 16;
            ThirtyTicks.Id          = "ThirtyTicks";

            NaiveWarp             = new CheckBox();
            NaiveWarp.Text        = " Emulate Sdgr+ timewarp/spinrate calc.";
            NaiveWarp.TextColor   = Color.White;
            NaiveWarp.ImageWidth  = 16;
            NaiveWarp.ImageHeight = 16;
            NaiveWarp.Id          = "NaiveWarp";

            var horizontalSeparator1 = new HorizontalSeparator();

            horizontalSeparator1.Thickness = 2;
            horizontalSeparator1.Padding   = new Thickness(0, 5);

            InvertColors             = new CheckBox();
            InvertColors.Text        = " Invert colors";
            InvertColors.TextColor   = Color.White;
            InvertColors.ImageWidth  = 16;
            InvertColors.ImageHeight = 16;
            InvertColors.Id          = "InvertColors";

            Ok                     = new TextButton();
            Ok.Text                = "OK";
            Ok.TextColor           = Color.White;
            Ok.Margin              = new Thickness(0, 10, 0, 0);
            Ok.Padding             = new Thickness(5);
            Ok.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            Ok.Id                  = "Ok";

            MainPanel    = new VerticalStackPanel();
            MainPanel.Id = "MainPanel";
            MainPanel.Widgets.Add(ThirtyTicks);
            MainPanel.Widgets.Add(NaiveWarp);
            MainPanel.Widgets.Add(horizontalSeparator1);
            MainPanel.Widgets.Add(InvertColors);
            MainPanel.Widgets.Add(Ok);


            Title   = "Level Settings";
            Left    = 382;
            Top     = 107;
            Padding = new Thickness(10);
            Content = MainPanel;
        }
Beispiel #12
0
        public static void GameMenu()
        {
            Desktop.Widgets.Clear();

            Panel mainPanel = new Panel();

            mainPanel.Background = new TextureRegion(Resources.MenuBackground);

            VerticalStackPanel grid = new VerticalStackPanel();

            grid.HorizontalAlignment = HorizontalAlignment.Center;
            grid.VerticalAlignment   = VerticalAlignment.Center;

            grid.Spacing = 8;

            TextButton resumeBtn = new TextButton();

            resumeBtn.Text = "Resume";
            resumeBtn.HorizontalAlignment = HorizontalAlignment.Center;
            resumeBtn.Click += (s, a) =>
            {
                Engine.setState(GameState.Playing);
            };
            grid.Widgets.Add(resumeBtn);

            TextButton disconnectBtn = new TextButton();

            disconnectBtn.Text = "Disconnect";
            disconnectBtn.HorizontalAlignment = HorizontalAlignment.Center;
            disconnectBtn.Click += (s, a) =>
            {
                GameMain.Reset();
                Engine.networkClient.disconnect();
                MainMenu();
            };
            grid.Widgets.Add(disconnectBtn);

            TextButton optionsBtn = new TextButton();

            optionsBtn.Text = "Options";
            optionsBtn.HorizontalAlignment = HorizontalAlignment.Center;
            optionsBtn.Click += (s, a) =>
            {
                OptionsMenu(GameMenu);
            };
            grid.Widgets.Add(optionsBtn);

            mainPanel.Widgets.Add(grid);
            Desktop.Root = mainPanel;
        }
        public void OpenPlanetScreen(ViewController view, Desktop desktop, System system)
        {
            //Debug.WriteLine("planet in system " + systemId);
            //parentScreen.AddChildScreen(new PlanetScreen(2, "planetscreen", new PlanetScreenAlign(parentScreen, planetId), systemId, planetId));

            var PlanetWindow = new Window
            {
                Background = new TextureRegion(Assets.GetTexture("planetscreen"), new Rectangle(0, 0, 320, 294)),
                Title      = system.name + Constants.PlanetNames[planetId],
                Width      = 560,
                Height     = 560
            };

            var Panel = new Panel
            {
            };

            var PlanetInfoStack = new VerticalStackPanel
            {
                Spacing = 60
            };

            var Disposition = new Label
            {
                Text                = "Disposition ???/100",
                Border              = new SolidBrush(new Color(128, 128, 128)),
                BorderThickness     = new Thickness(4),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top
            };

            PlanetInfoStack.AddChild(Disposition);

            var PlanetTypeImage = new Image
            {
                Background          = new TextureRegion(Assets.PlanetTypeTextures[GetTypeTexture()]),
                Width               = 128,
                Height              = 128,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top
            };

            PlanetInfoStack.AddChild(PlanetTypeImage);

            Panel.AddChild(PlanetInfoStack);

            PlanetWindow.Content = Panel;
            PlanetWindow.ShowModal(desktop);
        }
Beispiel #14
0
        /// <summary>
        /// Game Over summary Menu loader
        /// </summary>
        public static void GameOverMenu()
        {
            LoadUIStylesheet();
            Desktop.Widgets.Clear();

            mainPanel            = new Panel();
            mainPanel.Background = new TextureRegion(Resources.menuBackground);

            VerticalStackPanel grid = new VerticalStackPanel();

            grid.VerticalAlignment   = VerticalAlignment.Center;
            grid.HorizontalAlignment = HorizontalAlignment.Center;

            grid.Spacing = 8;

            Label title = new Label();

            title.Text    = "(Game Over)";
            title.Padding = new Thickness(0, 0, 0, 100);
            grid.Widgets.Add(title);

            Label highscoreText = new Label();

            highscoreText.Text    = "High score: " + GameMain.globalStats.highScore;
            highscoreText.Font    = Resources.regularFont;
            highscoreText.Padding = new Thickness(0, 0, 0, 100);
            grid.Widgets.Add(highscoreText);

            Label detailsText = new Label();

            detailsText.Text    = GameMain.player.getStats().AsString();
            detailsText.Font    = Resources.regularFont;
            detailsText.Padding = new Thickness(0, 0, 0, 100);
            grid.Widgets.Add(detailsText);

            TextButton continueBtn = new TextButton();

            continueBtn.Text = "Continue";
            continueBtn.HorizontalAlignment = HorizontalAlignment.Center;
            continueBtn.Click += (s, a) =>
            {
                MainMenu();
            };
            grid.Widgets.Add(continueBtn);

            mainPanel.Widgets.Add(grid);
            Desktop.Root = mainPanel;
        }
Beispiel #15
0
        public void AddRemove()
        {
            var stackPanel = new VerticalStackPanel();
            var label1     = new Label();
            var label2     = new Label();
            var label3     = new Label();

            stackPanel.AddChild(label1);
            stackPanel.AddChild(label2);
            stackPanel.AddChild(label3);

            stackPanel.RemoveChild(label2);

            Assert.AreEqual(2, stackPanel.Widgets.Count);
            Assert.AreEqual(label1, stackPanel.Widgets[0]);
            Assert.AreEqual(label3, stackPanel.Widgets[1]);
        }
Beispiel #16
0
        public MainMenuScreen(NamelessGame game)
        {
            // Panel = new Panel(new Vector2(game.GetSettings().HudWidth(), game.GetActualCharacterHeight()), PanelSkin.Default, Anchor.Center);

            Panel = new Panel()
            {
                HorizontalAlignment = HorizontalAlignment.Center
            };
            var vPanel = new VerticalStackPanel();

            NewGame = new ImageTextButton()
            {
                Text = "New game", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center
            };
            LoadGame = new ImageTextButton()
            {
                Text = "Load", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center
            };;
            CreateTimeline = new ImageTextButton()
            {
                Text = "Create timeline", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center
            };
            Options = new ImageTextButton()
            {
                Text = "Options", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center
            };
            Exit = new ImageTextButton()
            {
                Text = "Exit", Width = 200, Height = 50, ContentHorizontalAlignment = HorizontalAlignment.Center, ContentVerticalAlignment = VerticalAlignment.Center
            };

            NewGame.Click        += (sender, args) => { SimpleActions.Add(MainMenuAction.NewGame); };
            LoadGame.Click       += (sender, args) => { SimpleActions.Add(MainMenuAction.LoadGame); };
            CreateTimeline.Click += (sender, args) => { SimpleActions.Add(MainMenuAction.GenerateNewTimeline); };
            Options.Click        += (sender, args) => { SimpleActions.Add(MainMenuAction.Options); };
            Exit.Click           += (sender, args) => { SimpleActions.Add(MainMenuAction.Exit); };

            vPanel.Widgets.Add(NewGame);
            vPanel.Widgets.Add(LoadGame);
            vPanel.Widgets.Add(CreateTimeline);
            vPanel.Widgets.Add(Options);
            vPanel.Widgets.Add(Exit);
            Panel.Widgets.Add(vPanel);
            game.Desktop.Widgets.Add(Panel);
        }
Beispiel #17
0
        private void BuildUI()
        {
            _imageCharacter    = new Image();
            _imageCharacter.Id = "_imageCharacter";

            _labelName      = new Label();
            _labelName.Text = "Estelle";
            _labelName.Id   = "_labelName";

            _labelText      = new Label();
            _labelText.Text = "Daddy's really late.";
            _labelText.Id   = "_labelText";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(_labelName);
            verticalStackPanel1.Widgets.Add(_labelText);


            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            Width      = 700;
            Height     = 220;
            Background = new SolidBrush("#0000007C");
            Widgets.Add(_imageCharacter);
            Widgets.Add(verticalStackPanel1);
        }
Beispiel #18
0
        private void BuildUI()
        {
            _radioSingleTileMap      = new RadioButton();
            _radioSingleTileMap.Text = "Single Tile Map";
            _radioSingleTileMap.Id   = "_radioSingleTileMap";

            _radioGeneratedMap      = new RadioButton();
            _radioGeneratedMap.Text = "Generated Map";
            _radioGeneratedMap.Id   = "_radioGeneratedMap";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(_radioSingleTileMap);
            verticalStackPanel1.Widgets.Add(_radioGeneratedMap);


            Title   = "New Map";
            Left    = 467;
            Top     = 191;
            Content = verticalStackPanel1;
        }
Beispiel #19
0
        public static VerticalStackPanel DeathPanel()
        {
            VerticalStackPanel mainPanel = new VerticalStackPanel();

            mainPanel.VerticalAlignment   = VerticalAlignment.Center;
            mainPanel.HorizontalAlignment = HorizontalAlignment.Center;
            mainPanel.Background          = new TextureRegion(Resources.MenuBackground);

            Label deathLabel = new Label();

            deathLabel.Text = "You are dead";
            mainPanel.Widgets.Add(deathLabel);

            TextButton respawnBtn = new TextButton();

            respawnBtn.Text   = "Respawn";
            respawnBtn.Click += (s, a) => { ClientSenderV2.SendSpawnRequest(); };
            mainPanel.Widgets.Add(respawnBtn);

            return(mainPanel);
        }
        public override void LoadContent()
        {
            this._font = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\GameFont");

            this._engineIdle = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Engine").CreateInstance();
            this._carScreech = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\pop").CreateInstance();
            this._carHorn = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Horn").CreateInstance();

            this.Logo = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racer");
            this._car = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\car");
            this._raceFlags = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racerflags");

            _textureMap.Add(TilePiece.Grass, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\grass"));
            _textureMap.Add(TilePiece.TopLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl"));
            _textureMap.Add(TilePiece.TopRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tr"));
            _textureMap.Add(TilePiece.BottomLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\bl"));
            _textureMap.Add(TilePiece.BottomRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\br"));
            _textureMap.Add(TilePiece.Horizontal, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\h"));
            _textureMap.Add(TilePiece.Vertical, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\v"));
            _textureMap.Add(TilePiece.Start, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl"));

            this.Assets.Add(_engineIdle);
            this.Assets.Add(_carScreech);
            this.Assets.Add(_carHorn);
            this.Assets.Add(Logo);
            this.Assets.Add(_car);
            this.Assets.Add(_raceFlags);

            foreach (IDisposable asset in _textureMap.Values)
            {
                this.Assets.Add(asset);
            }

            this._engineIdle.Volume = this._carScreech.Volume = this._carHorn.Volume = 0.5f;
            this._engineIdle.IsLooped = true;

            _mapPanel.Bounds = new Rectangle(0, 0, 800, 480);

            int mapCount = 0;
            HorizontalStackPanel panel = null;

            foreach (string mapName in MapNames)
            {
                string mapData = this.GameManager.Game.Content.Load<string>(@"RacerMaps\" + mapName).Trim();
                LoadedMaps.Add(mapName, mapData);

                if (null == panel)
                {
                    panel = new HorizontalStackPanel();
                    panel.VerticalAlignment = VerticalAlignment.Middle;
                    panel.FixedSize = false;
                    panel.Bounds = new Rectangle(0, 0, 800, 180);

                    _mapPanel.AddChild(panel);
                }

                VerticalStackPanel vertPanel = new VerticalStackPanel();
                vertPanel.Bounds = new Rectangle(0, 0, 200, 150);

                XnaRaceTrackTile tile = new XnaRaceTrackTile(_textureMap, mapName, mapData);
                tile.Tag = tile;
                tile.Bounds = new Rectangle(0, 0, 200, 120);
                tile.Click += new EventHandler(mapTile_Click);

                XnaButton button = new XnaButton(new Rectangle(0, 0, 250, 30));
                button.Tag = tile;
                button.Text = mapName;
                button.FontZoom = 0.5f;
                button.Click += new EventHandler(mapTile_Click);

                if (FingerGames.IsTrial && mapCount > 2)
                {
                    button.Color = new Color(110, 110, 110);
                }

                vertPanel.AddChild(tile);
                vertPanel.AddChild(button);

                panel.AddChild(vertPanel);

                mapCount++;

                if ((mapCount % 3) == 0)
                {
                    panel = null;
                }
            }
            _mapPanel.ForceLayout();

            float maxX = 0;
            for (int i = 0; i < 10; ++i)
            {
                maxX = Math.Max(maxX, _font.MeasureString(i.ToString()).X);
            }

            _decimalWidth = maxX * 1.05f / 2;

            this._timePanel.Bounds = new Rectangle(0, 10, 800, 470);
            this._timePanel.FixedSize = true;

            XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height));
            XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90));
            completedLabel.BackColor = new Color(0, 0, 0, 150);
            completedLabel.FontZoom = 1.5f;
            completedLabel.Text = "Race Completed!";

            this._timePanel.AddChild(flagsImage);
            this._timePanel.AddChild(completedLabel);
            this._timePanel.AddChild(_timeLabel);

            base.LoadContent();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "NamelessRogue.log4net.config";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                XmlConfigurator.Configure(LogManager.CreateRepository("NamelessRogue"), stream);
            }

            Log = LogManager.GetLogger(typeof(NamelessGame));

            Log.Info("Application started");


            SaveManager.Init();

            CurrentGame = new GameInstance();
            DebugDevice = this.GraphicsDevice;
            //TODO: move to config later
            int width  = 40;
            int height = 30;


            var commanderEntity = new Entity();

            Commander = new Commander();
            commanderEntity.AddComponent(Commander);

            settings = new GameSettings(width, height);
            graphics.PreferredBackBufferWidth  = (int)(GetActualCharacterWidth() + settings.HudWidth());
            graphics.PreferredBackBufferHeight = GetActualCharacterHeight();

            graphics.IsFullScreen                   = false;
            graphics.PreferMultiSampling            = false;
            graphics.SynchronizeWithVerticalRetrace = true;

            MyraEnvironment.Game = this;

            RenderTarget = new RenderTarget2D(
                GraphicsDevice,
                GraphicsDevice.PresentationParameters.BackBufferWidth,
                GraphicsDevice.PresentationParameters.BackBufferHeight,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24, 4, RenderTargetUsage.PlatformContents);


            graphics.ApplyChanges();

            //12345 123
            worldSettings = new WorldSettings(4, WorldGenConstants.Resolution, WorldGenConstants.Resolution);

            TerrainFurnitureFactory.CreateFurnitureEntities(this);

            ContextFactory.InitAllContexts(this);



            var viewportEntity = RenderFactory.CreateViewport(settings);

            CameraEntity = viewportEntity;

            TimelineEntity = TimelineFactory.CreateTimeline(this);


            var libraries   = new Entity();
            var ammoLibrary = new AmmoLibrary();

            ammoLibrary.AmmoTypes.Add(new AmmoType()
            {
                Name = "Revolver ammo"
            });
            libraries.AddComponent(ammoLibrary);

            var timelinEntity = TimelineEntity;
            var timeline      = timelinEntity.GetComponentOfType <TimeLine>();

            WorldTile firsTile = null;

            foreach (var worldBoardWorldTile in timeline.CurrentTimelineLayer.WorldTiles)
            {
                if (worldBoardWorldTile.Settlement != null)
                {
                    firsTile = worldBoardWorldTile;
                    break;
                }
            }
            int x, y;

            if (firsTile != null)
            {
                //place everything at the center of newly generated settlement;
                x = firsTile.Settlement.Concrete.Center.X;
                y = firsTile.Settlement.Concrete.Center.Y;
            }
            else
            {
                x = WorldGenConstants.Resolution / 2;
                y = WorldGenConstants.Resolution / 2;
            }
            var player = CharacterFactory.CreateSimplePlayerCharacter(x, y, this);

            PlayerEntity = player;

            FollowedByCameraEntity = player;

            ChunkManagementSystem chunkManagementSystem = new ChunkManagementSystem();

            //initialize reality bubble
            chunkManagementSystem.Update(0, this);
            //for (int i = 1; i < 10; i++)
            //{
            //    for (int j = 1; j < 10; j++)
            //    {
            //        Entities.Add(CharacterFactory.CreateBlankNpc(x - i,
            //            y - j));
            //    }
            //}

            CharacterFactory.CreateBlankNpc(x - 6,
                                            y, this);
            //Entities.Add(CharacterFactory.CreateBlankNpc(x - 3,
            //    y));
            //Entities.Add(CharacterFactory.CreateBlankNpc(x - 5,
            //    y));
            //Entities.Add(CharacterFactory.CreateBlankNpc(x - 7,
            //    y));


            for (int i = 0; i < 2; i++)
            {
                var sword = ItemFactory.CreateSword(x - 2,
                                                    y, i, this);;
            }

            var platemail = ItemFactory.CreatePlateMail(x - 2, y, 1, this);

            var pants = ItemFactory.CreatePants(x - 2, y, 1, this);

            var boots = ItemFactory.CreateBoots(x - 2, y, 1, this);

            var cape = ItemFactory.CreateCape(x - 2, y, 1, this);

            var ring = ItemFactory.CreateRing(x - 2, y, 1, this);

            var shield = ItemFactory.CreateShield(x - 2, y, 1, this);

            var helmet = ItemFactory.CreateHelmet(x - 2, y, 1, this);


            var ammo1 = ItemFactory.CreateLightAmmo(x - 1, y, 1, 20, this, ammoLibrary);


            var ammo2 = ItemFactory.CreateLightAmmo(x - 1, y + 1, 1, 20, this, ammoLibrary);


            var revolver = ItemFactory.CreateRevolver(x + 2, y + 1, 1, this, ammoLibrary);


            var pArmor = ItemFactory.CreatePowerArmor(x - 2, y, 1, this);


            Point worldRiverPosition = new Point();
            bool  anyRivers          = false;

            foreach (var worldBoardWorldTile in timeline.CurrentTimelineLayer.WorldTiles)
            {
                var pos     = worldBoardWorldTile.WorldBoardPosiiton;
                var isWater = timeline.CurrentTimelineLayer.InlandWaterConnectivity[pos.X][pos.Y].isWater;
                if (isWater)
                {
                    anyRivers          = true;
                    worldRiverPosition = pos;
                    break;
                }
            }

            if (anyRivers)
            {
                //move player to some river
                PlayerEntity.GetComponentOfType <Position>().Point = new Point(worldRiverPosition.X * Constants.ChunkSize, worldRiverPosition.Y * Constants.ChunkSize);
                chunkManagementSystem.Update(0, this);
            }

            CursorEntity = GameInitializer.CreateCursor();


            //Paragraph.BaseSize = 1.175f;
            //UserInterface.Initialize(Content, "custom");
            //UserInterface.Active.UseRenderTarget = true;
            CurrentContext = ContextFactory.GetMainMenuContext(this);
            CurrentContext.ContextScreen.Show();
            this.IsMouseVisible = true;
            // UserInterface.Active.ShowCursor = false;
            spriteBatch = new SpriteBatch(GraphicsDevice);


            fpsLabel = new Label();
            fpsLabel.HorizontalAlignment = HorizontalAlignment.Right;
            ContextFactory.GetIngameContext(this).ContextScreen.Panel.Widgets.Add(fpsLabel);

            var stackPanel = new VerticalStackPanel();

            stackPanel.Widgets.Add(fpsLabel);

            // Desktop.Widgets.Add(stackPanel);


            // Inform Myra that external text input is available
            // So it stops translating Keys to chars


            _desktop.HasExternalTextInput = true;

            // Provide that text input
            Window.TextInput += (s, a) =>
            {
                _desktop.OnChar(a.Character);
            };
        }
Beispiel #22
0
        private void BuildUI()
        {
            _mapViewContainer    = new Panel();
            _mapViewContainer.Id = "_mapViewContainer";

            var horizontalSeparator1 = new HorizontalSeparator();

            _buttonUse       = new TextButton();
            _buttonUse.Text  = "\\c[green]E\\c[white]|Use";
            _buttonUse.Width = 100;
            _buttonUse.Id    = "_buttonUse";

            _buttonCharacter       = new TextButton();
            _buttonCharacter.Text  = "\\c[green]C\\c[white]haracter";
            _buttonCharacter.Width = 100;
            _buttonCharacter.Id    = "_buttonCharacter";

            _buttonInventory       = new TextButton();
            _buttonInventory.Text  = "\\c[green]I\\c[white]nventory";
            _buttonInventory.Width = 100;
            _buttonInventory.Id    = "_buttonInventory";

            _buttonAbilities       = new TextButton();
            _buttonAbilities.Text  = "\\c[green]A\\c[white]bilities";
            _buttonAbilities.Width = 100;
            _buttonAbilities.Id    = "_buttonAbilities";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Widgets.Add(_buttonUse);
            horizontalStackPanel1.Widgets.Add(_buttonCharacter);
            horizontalStackPanel1.Widgets.Add(_buttonInventory);
            horizontalStackPanel1.Widgets.Add(_buttonAbilities);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(_mapViewContainer);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel1);

            var verticalSeparator1 = new VerticalSeparator();

            _labelHp      = new Label();
            _labelHp.Text = "HP: 50/100";
            _labelHp.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelHp.Id = "_labelHp";

            var verticalSeparator2 = new VerticalSeparator();

            _labelMana      = new Label();
            _labelMana.Text = "MA: 50/100";
            _labelMana.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelMana.Id = "_labelMana";

            var verticalSeparator3 = new VerticalSeparator();

            _labelStamina      = new Label();
            _labelStamina.Text = "ST: 50/100";
            _labelStamina.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _labelStamina.Id = "_labelStamina";

            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            horizontalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel2.Widgets.Add(_labelHp);
            horizontalStackPanel2.Widgets.Add(verticalSeparator2);
            horizontalStackPanel2.Widgets.Add(_labelMana);
            horizontalStackPanel2.Widgets.Add(verticalSeparator3);
            horizontalStackPanel2.Widgets.Add(_labelStamina);

            var horizontalSeparator2 = new HorizontalSeparator();

            _mapContainer        = new Panel();
            _mapContainer.Height = 247;
            _mapContainer.Id     = "_mapContainer";

            var horizontalSeparator3 = new HorizontalSeparator();

            _logContainer    = new Panel();
            _logContainer.Id = "_logContainer";

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Widgets.Add(horizontalStackPanel2);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(_mapContainer);
            verticalStackPanel2.Widgets.Add(horizontalSeparator3);
            verticalStackPanel2.Widgets.Add(_logContainer);


            Proportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Part,
                Value = 2,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            Widgets.Add(verticalStackPanel1);
            Widgets.Add(verticalSeparator1);
            Widgets.Add(verticalStackPanel2);
        }
Beispiel #23
0
        private void BuildUI()
        {
            _menuFileNew              = new MenuItem();
            _menuFileNew.Text         = "&New";
            _menuFileNew.ShortcutText = "Ctrl+N";
            _menuFileNew.Id           = "_menuFileNew";

            _menuFileOpen              = new MenuItem();
            _menuFileOpen.Text         = "&Open";
            _menuFileOpen.ShortcutText = "Ctrl+O";
            _menuFileOpen.Id           = "_menuFileOpen";

            _menuFileReload              = new MenuItem();
            _menuFileReload.Text         = "&Reload";
            _menuFileReload.ShortcutText = "Ctrl+R";
            _menuFileReload.Id           = "_menuFileReload";

            _menuFileSave              = new MenuItem();
            _menuFileSave.Text         = "&Save";
            _menuFileSave.ShortcutText = "Ctrl+S";
            _menuFileSave.Id           = "_menuFileSave";

            _menuFileSaveAs      = new MenuItem();
            _menuFileSaveAs.Text = "Save &As...";
            _menuFileSaveAs.Id   = "_menuFileSaveAs";

            _menuFileExportToCS              = new MenuItem();
            _menuFileExportToCS.Text         = "&Export To C#...";
            _menuFileExportToCS.ShortcutText = "Ctrl+E";
            _menuFileExportToCS.Id           = "_menuFileExportToCS";

            var menuSeparator1 = new MenuSeparator();

            _menuFileLoadStylesheet      = new MenuItem();
            _menuFileLoadStylesheet.Text = "&Load Stylesheet";
            _menuFileLoadStylesheet.Id   = "_menuFileLoadStylesheet";

            _menuFileResetStylesheet      = new MenuItem();
            _menuFileResetStylesheet.Text = "Rese&t Stylesheet";
            _menuFileResetStylesheet.Id   = "_menuFileResetStylesheet";

            var menuSeparator2 = new MenuSeparator();

            _menuFileDebugOptions      = new MenuItem();
            _menuFileDebugOptions.Text = "&UI Debug Options";
            _menuFileDebugOptions.Id   = "_menuFileDebugOptions";

            var menuSeparator3 = new MenuSeparator();

            _menuFileQuit              = new MenuItem();
            _menuFileQuit.Text         = "&Quit";
            _menuFileQuit.ShortcutText = "Ctrl+Q";
            _menuFileQuit.Id           = "_menuFileQuit";

            _menuFile      = new MenuItem();
            _menuFile.Text = "&File";
            _menuFile.Id   = "_menuFile";
            _menuFile.Items.Add(_menuFileNew);
            _menuFile.Items.Add(_menuFileOpen);
            _menuFile.Items.Add(_menuFileReload);
            _menuFile.Items.Add(_menuFileSave);
            _menuFile.Items.Add(_menuFileSaveAs);
            _menuFile.Items.Add(_menuFileExportToCS);
            _menuFile.Items.Add(menuSeparator1);
            _menuFile.Items.Add(_menuFileLoadStylesheet);
            _menuFile.Items.Add(_menuFileResetStylesheet);
            _menuFile.Items.Add(menuSeparator2);
            _menuFile.Items.Add(_menuFileDebugOptions);
            _menuFile.Items.Add(menuSeparator3);
            _menuFile.Items.Add(_menuFileQuit);

            _menuItemSelectAll              = new MenuItem();
            _menuItemSelectAll.Text         = "Select &All";
            _menuItemSelectAll.ShortcutText = "Ctrl+A";
            _menuItemSelectAll.Id           = "_menuItemSelectAll";

            _menuItemCopy              = new MenuItem();
            _menuItemCopy.Text         = "&Copy";
            _menuItemCopy.ShortcutText = "Ctrl+Insert, Ctrl+C";
            _menuItemCopy.Id           = "_menuItemCopy";

            _menuItemPaste              = new MenuItem();
            _menuItemPaste.Text         = "&Paste";
            _menuItemPaste.ShortcutText = "Shift+Insert, Ctrl+V";
            _menuItemPaste.Id           = "_menuItemPaste";

            var menuSeparator4 = new MenuSeparator();

            _menuEditFormatSource              = new MenuItem();
            _menuEditFormatSource.Text         = "&Format Source";
            _menuEditFormatSource.ShortcutText = "Ctrl+F";
            _menuEditFormatSource.Id           = "_menuEditFormatSource";

            var menuItem1 = new MenuItem();

            menuItem1.Text = "&Edit";
            menuItem1.Items.Add(_menuItemSelectAll);
            menuItem1.Items.Add(_menuItemCopy);
            menuItem1.Items.Add(_menuItemPaste);
            menuItem1.Items.Add(menuSeparator4);
            menuItem1.Items.Add(_menuEditFormatSource);

            _menuHelpAbout      = new MenuItem();
            _menuHelpAbout.Text = "&About";
            _menuHelpAbout.Id   = "_menuHelpAbout";

            var menuItem2 = new MenuItem();

            menuItem2.Text = "&Help";
            menuItem2.Items.Add(_menuHelpAbout);

            _mainMenu    = new HorizontalMenu();
            _mainMenu.Id = "_mainMenu";
            _mainMenu.Items.Add(_menuFile);
            _mainMenu.Items.Add(menuItem1);
            _mainMenu.Items.Add(menuItem2);

            _projectHolder    = new Panel();
            _projectHolder.Id = "_projectHolder";

            _textSource                   = new TextBox();
            _textSource.Multiline         = true;
            _textSource.Wrap              = true;
            _textSource.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Stretch;
            _textSource.GridRow           = 2;
            _textSource.Id                = "_textSource";

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.Content = _textSource;

            _leftSplitPane    = new VerticalSplitPane();
            _leftSplitPane.Id = "_leftSplitPane";
            _leftSplitPane.Widgets.Add(_projectHolder);
            _leftSplitPane.Widgets.Add(scrollViewer1);

            var horizontalSeparator1 = new HorizontalSeparator();

            _textStatus      = new Label();
            _textStatus.Text = "Reloading...";
            _textStatus.Id   = "_textStatus";

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(_leftSplitPane);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(_textStatus);

            _propertyGridPane         = new ScrollViewer();
            _propertyGridPane.Content = null;
            _propertyGridPane.Id      = "_propertyGridPane";

            var horizontalSeparator2 = new HorizontalSeparator();

            _textLocation      = new Label();
            _textLocation.Text = "Line: 1, Column: 2, Indent: 3";
            _textLocation.Id   = "_textLocation";

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel2.Widgets.Add(_propertyGridPane);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(_textLocation);

            _topSplitPane    = new HorizontalSplitPane();
            _topSplitPane.Id = "_topSplitPane";
            _topSplitPane.Widgets.Add(verticalStackPanel1);
            _topSplitPane.Widgets.Add(verticalStackPanel2);


            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            Widgets.Add(_mainMenu);
            Widgets.Add(_topSplitPane);
        }
        private void BuildUI()
        {
            var label1 = new Label();

            label1.Text   = "Yetiface";
            label1.Margin = new Thickness(0, 10);
            label1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            label1.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            label1.GridRow             = 1;

            GameLogo        = new Image();
            GameLogo.Width  = 284;
            GameLogo.Height = 64;
            GameLogo.Margin = new Thickness(0, 0, 0, 50);
            GameLogo.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            GameLogo.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Bottom;
            GameLogo.Id = "GameLogo";

            MenuSinglePlayer      = new ImageTextButton();
            MenuSinglePlayer.Text = "Single Player";
            MenuSinglePlayer.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MenuSinglePlayer.Margin              = new Thickness(0, 0, 0, 10);
            MenuSinglePlayer.Padding             = new Thickness(10);
            MenuSinglePlayer.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MenuSinglePlayer.Background          = new SolidBrush("#8d697a");
            MenuSinglePlayer.OverBackground      = new SolidBrush("#544e68");
            MenuSinglePlayer.FocusedBackground   = new SolidBrush("#203c56");
            MenuSinglePlayer.Id = "MenuSinglePlayer";

            MenuMultiPlayer      = new ImageTextButton();
            MenuMultiPlayer.Text = "Multiplayer";
            MenuMultiPlayer.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MenuMultiPlayer.Margin              = new Thickness(0, 0, 0, 10);
            MenuMultiPlayer.Padding             = new Thickness(10);
            MenuMultiPlayer.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MenuMultiPlayer.Background          = new SolidBrush("#8d697a");
            MenuMultiPlayer.OverBackground      = new SolidBrush("#544e68");
            MenuMultiPlayer.FocusedBackground   = new SolidBrush("#203c56");
            MenuMultiPlayer.Id = "MenuMultiPlayer";

            MenuSettings      = new ImageTextButton();
            MenuSettings.Text = "Settings";
            MenuSettings.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MenuSettings.Margin              = new Thickness(0, 0, 0, 10);
            MenuSettings.Padding             = new Thickness(10);
            MenuSettings.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MenuSettings.Background          = new SolidBrush("#8d697a");
            MenuSettings.OverBackground      = new SolidBrush("#544e68");
            MenuSettings.FocusedBackground   = new SolidBrush("#203c56");
            MenuSettings.Id = "MenuSettings";

            MenuQuit      = new ImageTextButton();
            MenuQuit.Text = "Quit";
            MenuQuit.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MenuQuit.Padding             = new Thickness(10);
            MenuQuit.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MenuQuit.Background          = new SolidBrush("#8d697a");
            MenuQuit.OverBackground      = new SolidBrush("#544e68");
            MenuQuit.FocusedBackground   = new SolidBrush("#203c56");
            MenuQuit.Id = "MenuQuit";

            MainPanel = new VerticalStackPanel();
            MainPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MainPanel.Width   = 200;
            MainPanel.Padding = new Thickness(10);
            MainPanel.Id      = "MainPanel";
            MainPanel.Widgets.Add(MenuSinglePlayer);
            MainPanel.Widgets.Add(MenuMultiPlayer);
            MainPanel.Widgets.Add(MenuSettings);
            MainPanel.Widgets.Add(MenuQuit);

            StartGameNewGame      = new ImageTextButton();
            StartGameNewGame.Text = "New Game";
            StartGameNewGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            StartGameNewGame.Margin              = new Thickness(0, 0, 0, 10);
            StartGameNewGame.Padding             = new Thickness(10);
            StartGameNewGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            StartGameNewGame.Background          = new SolidBrush("#8d697a");
            StartGameNewGame.OverBackground      = new SolidBrush("#544e68");
            StartGameNewGame.FocusedBackground   = new SolidBrush("#203c56");
            StartGameNewGame.Id = "StartGameNewGame";

            StartGameLoadGame      = new ImageTextButton();
            StartGameLoadGame.Text = "Load Game";
            StartGameLoadGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            StartGameLoadGame.Margin              = new Thickness(0, 0, 0, 10);
            StartGameLoadGame.Padding             = new Thickness(10);
            StartGameLoadGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            StartGameLoadGame.Background          = new SolidBrush("#8d697a");
            StartGameLoadGame.OverBackground      = new SolidBrush("#544e68");
            StartGameLoadGame.FocusedBackground   = new SolidBrush("#203c56");
            StartGameLoadGame.Id = "StartGameLoadGame";

            StartGameBack      = new ImageTextButton();
            StartGameBack.Text = "Back";
            StartGameBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            StartGameBack.Padding             = new Thickness(10);
            StartGameBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            StartGameBack.Background          = new SolidBrush("#8d697a");
            StartGameBack.OverBackground      = new SolidBrush("#544e68");
            StartGameBack.FocusedBackground   = new SolidBrush("#203c56");
            StartGameBack.Id = "StartGameBack";

            StartGamePanel = new VerticalStackPanel();
            StartGamePanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            StartGamePanel.Width   = 200;
            StartGamePanel.Padding = new Thickness(10);
            StartGamePanel.Visible = false;
            StartGamePanel.Id      = "StartGamePanel";
            StartGamePanel.Widgets.Add(StartGameNewGame);
            StartGamePanel.Widgets.Add(StartGameLoadGame);
            StartGamePanel.Widgets.Add(StartGameBack);

            CreateMultiplayerGamePortTextBox                   = new TextBox();
            CreateMultiplayerGamePortTextBox.Text              = "25565";
            CreateMultiplayerGamePortTextBox.HintText          = "Port";
            CreateMultiplayerGamePortTextBox.Margin            = new Thickness(0, 0, 0, 10);
            CreateMultiplayerGamePortTextBox.Padding           = new Thickness(10);
            CreateMultiplayerGamePortTextBox.Background        = new SolidBrush("#8d697a");
            CreateMultiplayerGamePortTextBox.OverBackground    = new SolidBrush("#544e68");
            CreateMultiplayerGamePortTextBox.FocusedBackground = new SolidBrush("#203c56");
            CreateMultiplayerGamePortTextBox.Id                = "CreateMultiplayerGamePortTextBox";

            CreateMultiplayerGameCreateGame      = new ImageTextButton();
            CreateMultiplayerGameCreateGame.Text = "Create Game";
            CreateMultiplayerGameCreateGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            CreateMultiplayerGameCreateGame.Margin              = new Thickness(0, 0, 0, 10);
            CreateMultiplayerGameCreateGame.Padding             = new Thickness(10);
            CreateMultiplayerGameCreateGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            CreateMultiplayerGameCreateGame.Background          = new SolidBrush("#8d697a");
            CreateMultiplayerGameCreateGame.OverBackground      = new SolidBrush("#544e68");
            CreateMultiplayerGameCreateGame.FocusedBackground   = new SolidBrush("#203c56");
            CreateMultiplayerGameCreateGame.Id = "CreateMultiplayerGameCreateGame";

            CreateMultiplayerGamePanel = new VerticalStackPanel();
            CreateMultiplayerGamePanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            CreateMultiplayerGamePanel.Padding             = new Thickness(10);
            CreateMultiplayerGamePanel.Visible             = false;
            CreateMultiplayerGamePanel.Id = "CreateMultiplayerGamePanel";
            CreateMultiplayerGamePanel.Widgets.Add(CreateMultiplayerGamePortTextBox);
            CreateMultiplayerGamePanel.Widgets.Add(CreateMultiplayerGameCreateGame);

            MultiPlayerCreateGame      = new ImageTextButton();
            MultiPlayerCreateGame.Text = "Create Game";
            MultiPlayerCreateGame.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MultiPlayerCreateGame.Margin              = new Thickness(0, 0, 0, 10);
            MultiPlayerCreateGame.Padding             = new Thickness(10);
            MultiPlayerCreateGame.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MultiPlayerCreateGame.Background          = new SolidBrush("#8d697a");
            MultiPlayerCreateGame.OverBackground      = new SolidBrush("#544e68");
            MultiPlayerCreateGame.FocusedBackground   = new SolidBrush("#203c56");
            MultiPlayerCreateGame.Id = "MultiPlayerCreateGame";

            MultiPlayerJoinByIp      = new ImageTextButton();
            MultiPlayerJoinByIp.Text = "Join by IP";
            MultiPlayerJoinByIp.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MultiPlayerJoinByIp.Margin              = new Thickness(0, 0, 0, 10);
            MultiPlayerJoinByIp.Padding             = new Thickness(10);
            MultiPlayerJoinByIp.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MultiPlayerJoinByIp.Background          = new SolidBrush("#8d697a");
            MultiPlayerJoinByIp.OverBackground      = new SolidBrush("#544e68");
            MultiPlayerJoinByIp.FocusedBackground   = new SolidBrush("#203c56");
            MultiPlayerJoinByIp.Id = "MultiPlayerJoinByIp";

            MultiPlayerJoinBySteam      = new ImageTextButton();
            MultiPlayerJoinBySteam.Text = "Join by Steam";
            MultiPlayerJoinBySteam.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MultiPlayerJoinBySteam.Margin              = new Thickness(0, 0, 0, 10);
            MultiPlayerJoinBySteam.Padding             = new Thickness(10);
            MultiPlayerJoinBySteam.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MultiPlayerJoinBySteam.Background          = new SolidBrush("#8d697a");
            MultiPlayerJoinBySteam.OverBackground      = new SolidBrush("#544e68");
            MultiPlayerJoinBySteam.FocusedBackground   = new SolidBrush("#203c56");
            MultiPlayerJoinBySteam.Id = "MultiPlayerJoinBySteam";

            MultiPlayerBack      = new ImageTextButton();
            MultiPlayerBack.Text = "Back";
            MultiPlayerBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MultiPlayerBack.Padding             = new Thickness(10);
            MultiPlayerBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            MultiPlayerBack.Background          = new SolidBrush("#8d697a");
            MultiPlayerBack.OverBackground      = new SolidBrush("#544e68");
            MultiPlayerBack.FocusedBackground   = new SolidBrush("#203c56");
            MultiPlayerBack.Id = "MultiPlayerBack";

            MultiPlayerPanel = new VerticalStackPanel();
            MultiPlayerPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            MultiPlayerPanel.Width   = 200;
            MultiPlayerPanel.Padding = new Thickness(10);
            MultiPlayerPanel.Visible = false;
            MultiPlayerPanel.Id      = "MultiPlayerPanel";
            MultiPlayerPanel.Widgets.Add(MultiPlayerCreateGame);
            MultiPlayerPanel.Widgets.Add(MultiPlayerJoinByIp);
            MultiPlayerPanel.Widgets.Add(MultiPlayerJoinBySteam);
            MultiPlayerPanel.Widgets.Add(MultiPlayerBack);

            SettingsBack      = new ImageTextButton();
            SettingsBack.Text = "Back";
            SettingsBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            SettingsBack.Padding             = new Thickness(10);
            SettingsBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            SettingsBack.Background          = new SolidBrush("#8d697a");
            SettingsBack.OverBackground      = new SolidBrush("#544e68");
            SettingsBack.FocusedBackground   = new SolidBrush("#203c56");
            SettingsBack.Id = "SettingsBack";

            SettingsPanel = new VerticalStackPanel();
            SettingsPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            SettingsPanel.Width   = 200;
            SettingsPanel.Padding = new Thickness(10);
            SettingsPanel.Visible = false;
            SettingsPanel.Id      = "SettingsPanel";
            SettingsPanel.Widgets.Add(SettingsBack);

            IpAddressTextBox                   = new TextBox();
            IpAddressTextBox.HintText          = "IP Address";
            IpAddressTextBox.Margin            = new Thickness(0, 0, 0, 10);
            IpAddressTextBox.Padding           = new Thickness(10);
            IpAddressTextBox.Background        = new SolidBrush("#8d697a");
            IpAddressTextBox.OverBackground    = new SolidBrush("#544e68");
            IpAddressTextBox.FocusedBackground = new SolidBrush("#203c56");
            IpAddressTextBox.Id                = "IpAddressTextBox";

            PortTextBox                   = new TextBox();
            PortTextBox.Text              = "25565";
            PortTextBox.HintText          = "Port";
            PortTextBox.Margin            = new Thickness(0, 0, 0, 10);
            PortTextBox.Padding           = new Thickness(10);
            PortTextBox.Background        = new SolidBrush("#8d697a");
            PortTextBox.OverBackground    = new SolidBrush("#544e68");
            PortTextBox.FocusedBackground = new SolidBrush("#203c56");
            PortTextBox.Id                = "PortTextBox";

            JoinByIpJoin      = new ImageTextButton();
            JoinByIpJoin.Text = "Join";
            JoinByIpJoin.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            JoinByIpJoin.Margin              = new Thickness(0, 0, 0, 10);
            JoinByIpJoin.Padding             = new Thickness(10);
            JoinByIpJoin.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            JoinByIpJoin.Background          = new SolidBrush("#8d697a");
            JoinByIpJoin.OverBackground      = new SolidBrush("#544e68");
            JoinByIpJoin.FocusedBackground   = new SolidBrush("#203c56");
            JoinByIpJoin.Id = "JoinByIpJoin";

            JoinByIpBack      = new ImageTextButton();
            JoinByIpBack.Text = "Back";
            JoinByIpBack.ContentHorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            JoinByIpBack.Padding             = new Thickness(10);
            JoinByIpBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            JoinByIpBack.Background          = new SolidBrush("#8d697a");
            JoinByIpBack.OverBackground      = new SolidBrush("#544e68");
            JoinByIpBack.FocusedBackground   = new SolidBrush("#203c56");
            JoinByIpBack.Id = "JoinByIpBack";

            JoinByIpPanel = new VerticalStackPanel();
            JoinByIpPanel.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            JoinByIpPanel.Width   = 200;
            JoinByIpPanel.Padding = new Thickness(10);
            JoinByIpPanel.Visible = false;
            JoinByIpPanel.Id      = "JoinByIpPanel";
            JoinByIpPanel.Widgets.Add(IpAddressTextBox);
            JoinByIpPanel.Widgets.Add(PortTextBox);
            JoinByIpPanel.Widgets.Add(JoinByIpJoin);
            JoinByIpPanel.Widgets.Add(JoinByIpBack);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.GridRow = 1;
            verticalStackPanel1.Widgets.Add(MainPanel);
            verticalStackPanel1.Widgets.Add(StartGamePanel);
            verticalStackPanel1.Widgets.Add(CreateMultiplayerGamePanel);
            verticalStackPanel1.Widgets.Add(MultiPlayerPanel);
            verticalStackPanel1.Widgets.Add(SettingsPanel);
            verticalStackPanel1.Widgets.Add(JoinByIpPanel);

            var grid1 = new Grid();

            grid1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            grid1.Widgets.Add(GameLogo);
            grid1.Widgets.Add(verticalStackPanel1);


            Padding = new Thickness(10);
            Widgets.Add(label1);
            Widgets.Add(grid1);
        }
Beispiel #25
0
        private void CreateServerCreation()
        {
            serverCreation = new Window {
                Title = "Create Server"
            };

            Panel panel = new Panel {
                Background = new SolidBrush(new Color(0f, 0f, 0f, 0.5f))
            };

            VerticalStackPanel verticalStackPanel = new VerticalStackPanel {
                Spacing = 8
            };

            Grid serverSettings = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                ShowGridLines = true,
                Padding       = new Thickness(4)
            };

            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label maxPlayersLabel = new Label {
                Text       = "Max Players:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 0
            };

            serverSettings.Widgets.Add(maxPlayersLabel);
            TextBox maxPlayersInput = new TextBox {
                Text       = NetConstants.MAX_PLAYERS.ToString(),
                Width      = 50,
                GridColumn = 1,
                GridRow    = 0
            };

            maxPlayersInput.TextChangedByUser += (s, a) => {
                if (int.TryParse(maxPlayersInput.Text, out int players) && players >= 2 && players <= 8)
                {
                    maxPlayersInput.TextColor = Color.White;
                }
                else
                {
                    maxPlayersInput.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(maxPlayersInput);
            Label maxPlayersHintLabel = new Label {
                Text       = "Must be in between 2 and 8.",
                TextAlign  = TextAlign.Center,
                GridColumn = 2,
                GridRow    = 0
            };

            serverSettings.Widgets.Add(maxPlayersHintLabel);

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label portLabel = new Label {
                Text       = "Port:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 1
            };

            serverSettings.Widgets.Add(portLabel);
            TextBox portTextBox = new TextBox {
                Text       = "1337",
                TextColor  = Color.White,
                GridColumn = 1,
                GridRow    = 1
            };

            portTextBox.TextChangedByUser += (s, a) => {
                if (int.TryParse(portTextBox.Text, out int port) && port > 200 && port < 65536)
                {
                    portTextBox.TextColor = Color.White;
                }
                else
                {
                    portTextBox.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(portTextBox);
            Label portHintLabel = new Label {
                Text       = "Must be in between 201 and 65535.",
                TextAlign  = TextAlign.Center,
                GridColumn = 2,
                GridRow    = 1
            };

            serverSettings.Widgets.Add(portHintLabel);

            verticalStackPanel.Widgets.Add(serverSettings);

            HorizontalStackPanel horizontalStackPanel = new HorizontalStackPanel {
                Spacing = 8
            };
            TextButton buttonCreate = new TextButton {
                Text = "Create Server",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonCreate.Click += (s, a) => {
                // start server here
                if (portTextBox.TextColor == Color.White && maxPlayersInput.TextColor == Color.White)
                {
                    int port = int.Parse(portTextBox.Text);

                    game.ScreenManager.SetScreen(new ServerLevelScreen(game, nameTextBox.Text, port));

                    MasterServerConnector.Instance.StartListingServer(port, nameTextBox.Text, int.Parse(maxPlayersInput.Text));
                }
                else
                {
                    Window window = new Window {
                        Title = "Something isn't correct in the settings!"
                    };

                    window.ShowModal(desktop);
                }
            };
            horizontalStackPanel.Widgets.Add(buttonCreate);
            TextButton buttonCancel = new TextButton {
                Text = "Cancel",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonCancel.Click += (s, a) => {
                serverCreation.Close();
            };
            horizontalStackPanel.Widgets.Add(buttonCancel);

            verticalStackPanel.Widgets.Add(horizontalStackPanel);

            panel.Widgets.Add(verticalStackPanel);

            serverCreation.Content = panel;
        }
Beispiel #26
0
        private void CreateServerBrowser()
        {
            // create a new window for the server browser
            serverBrowser = new Window {
                Title = "Server Browser"
            };

            // create a new panel with the whole width and height of the game window
            Panel panel = new Panel {
                Width      = game.Window.ClientBounds.Width,
                Height     = game.Window.ClientBounds.Height,
                Background = new SolidBrush(new Color(0f, 0f, 0f, 0.5f))
            };

            // new vertical stack panel
            VerticalStackPanel verticalStackPanel = new VerticalStackPanel {
                Spacing = 8
            };

            // new horizontal stack panel
            HorizontalStackPanel horizontalStackPanel = new HorizontalStackPanel {
                Spacing = 8
            };

            // create a button for creating a server
            TextButton buttonCreate = new TextButton {
                Text = "Create Server"
            };

            buttonCreate.Click += (s, a) => {
                serverCreation.ShowModal(desktop);
            };
            horizontalStackPanel.Widgets.Add(buttonCreate);

            // create a button for creating a server
            TextButton buttonDirectConnect = new TextButton {
                Text = "Direct Connect"
            };

            buttonDirectConnect.Click += (s, a) => {
                directConnect.ShowModal(desktop);
            };
            horizontalStackPanel.Widgets.Add(buttonDirectConnect);

            // create a button for refreshing the server list
            TextButton buttonRefresh = new TextButton {
                Text = "Refresh List"
            };

            buttonRefresh.Click += (s, a) => {
                // get server list from master server
                MasterServerConnector.Instance.RequestServerList();
            };
            horizontalStackPanel.Widgets.Add(buttonRefresh);

            verticalStackPanel.Widgets.Add(horizontalStackPanel);


            // create the server list
            serverList = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                ShowGridLines = true,
                Padding       = new Thickness(4)
            };

            // add row for column names
            serverList.RowsProportions.Add(new Proportion(ProportionType.Auto));
            string[] columnNames = { "Name", "Players", "Ping" };
            int[]    columnWidth = { (int)(game.Window.ClientBounds.Width * 0.77f), 0, 0 };
            for (int i = 0; i < columnNames.Length; i++)
            {
                serverList.ColumnsProportions.Add(new Proportion(columnWidth[i] != 0 ? ProportionType.Pixels : ProportionType.Auto, columnWidth[i]));
                Label field = new Label {
                    Text       = columnNames[i],
                    Background = new SolidBrush(Color.White),
                    TextColor  = Color.Black,
                    GridColumn = i,
                    GridRow    = 0
                };
                serverList.Widgets.Add(field);
            }

            var scrollView = new ScrollViewer();

            scrollView.Content = serverList;

            verticalStackPanel.Widgets.Add(scrollView);

            panel.Widgets.Add(verticalStackPanel);

            serverBrowser.Content = panel;
        }
Beispiel #27
0
        private void BuildUI()
        {
            _textNameLeft      = new Label();
            _textNameLeft.Text = "player";
            _textNameLeft.Id   = "_textNameLeft";

            _textGoldLeft      = new Label();
            _textGoldLeft.Text = "Gold: 1000";
            _textGoldLeft.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _textGoldLeft.Id = "_textGoldLeft";

            var panel1 = new Panel();

            panel1.Widgets.Add(_textNameLeft);
            panel1.Widgets.Add(_textGoldLeft);

            var horizontalSeparator1 = new HorizontalSeparator();

            var label1 = new Label();

            label1.Text       = "iron rations(5)";
            label1.GridColumn = 1;

            var label2 = new Label();

            label2.Text = "5";
            label2.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            label2.GridColumn          = 2;

            var label3 = new Label();

            label3.Text       = "canteen";
            label3.GridColumn = 1;
            label3.GridRow    = 1;

            var label4 = new Label();

            label4.Text       = "7";
            label4.GridColumn = 2;
            label4.GridRow    = 1;

            _gridLeft = new Grid();
            _gridLeft.ColumnSpacing        = 8;
            _gridLeft.RowSpacing           = 4;
            _gridLeft.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridLeft.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 16,
            });
            _gridLeft.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _gridLeft.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridLeft.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridLeft.Id = "_gridLeft";
            _gridLeft.Widgets.Add(label1);
            _gridLeft.Widgets.Add(label2);
            _gridLeft.Widgets.Add(label3);
            _gridLeft.Widgets.Add(label4);

            var scrollViewer1 = new ScrollViewer();

            scrollViewer1.Content = _gridLeft;

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(panel1);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(scrollViewer1);

            _textGoldTransfer      = new Label();
            _textGoldTransfer.Text = "500";
            _textGoldTransfer.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _textGoldTransfer.Id = "_textGoldTransfer";

            _panelArrow        = new Panel();
            _panelArrow.Height = 20;
            _panelArrow.Id     = "_panelArrow";

            _gridGoldTransfer = new VerticalStackPanel();
            _gridGoldTransfer.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _gridGoldTransfer.Id = "_gridGoldTransfer";
            _gridGoldTransfer.Widgets.Add(_textGoldTransfer);
            _gridGoldTransfer.Widgets.Add(_panelArrow);

            _textNameRight      = new Label();
            _textNameRight.Text = "merchant";
            _textNameRight.Id   = "_textNameRight";

            _textGoldRight      = new Label();
            _textGoldRight.Text = "Gold: 50000";
            _textGoldRight.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            _textGoldRight.Id = "_textGoldRight";

            var panel2 = new Panel();

            panel2.Widgets.Add(_textNameRight);
            panel2.Widgets.Add(_textGoldRight);

            var horizontalSeparator2 = new HorizontalSeparator();

            var label5 = new Label();

            label5.Text       = "iron rations(100)";
            label5.GridColumn = 1;

            var label6 = new Label();

            label6.Text = "10";
            label6.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            label6.GridColumn          = 2;

            var label7 = new Label();

            label7.Text       = "canteen";
            label7.GridColumn = 1;
            label7.GridRow    = 1;

            var label8 = new Label();

            label8.Text       = "15";
            label8.GridColumn = 2;
            label8.GridRow    = 1;

            var label9 = new Label();

            label9.Text       = "barrel";
            label9.GridColumn = 1;
            label9.GridRow    = 2;

            var label10 = new Label();

            label10.Text       = "25";
            label10.GridColumn = 2;
            label10.GridRow    = 2;

            var label11 = new Label();

            label11.Text       = "short sword";
            label11.GridColumn = 1;
            label11.GridRow    = 3;

            var label12 = new Label();

            label12.Text       = "50";
            label12.GridColumn = 2;
            label12.GridRow    = 3;

            var label13 = new Label();

            label13.Text       = "leather armor";
            label13.GridColumn = 1;
            label13.GridRow    = 4;

            var label14 = new Label();

            label14.Text       = "40";
            label14.GridColumn = 2;
            label14.GridRow    = 4;

            var label15 = new Label();

            label15.Text       = "leather leggings";
            label15.GridColumn = 1;
            label15.GridRow    = 5;

            var label16 = new Label();

            label16.Text       = "30";
            label16.GridColumn = 2;
            label16.GridRow    = 5;

            var label17 = new Label();

            label17.Text       = "small shield";
            label17.GridColumn = 1;
            label17.GridRow    = 6;

            var label18 = new Label();

            label18.Text       = "25";
            label18.GridColumn = 2;
            label18.GridRow    = 6;

            _gridRight = new Grid();
            _gridRight.ColumnSpacing        = 8;
            _gridRight.RowSpacing           = 4;
            _gridRight.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridRight.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 16,
            });
            _gridRight.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _gridRight.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridRight.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridRight.Id = "_gridRight";
            _gridRight.Widgets.Add(label5);
            _gridRight.Widgets.Add(label6);
            _gridRight.Widgets.Add(label7);
            _gridRight.Widgets.Add(label8);
            _gridRight.Widgets.Add(label9);
            _gridRight.Widgets.Add(label10);
            _gridRight.Widgets.Add(label11);
            _gridRight.Widgets.Add(label12);
            _gridRight.Widgets.Add(label13);
            _gridRight.Widgets.Add(label14);
            _gridRight.Widgets.Add(label15);
            _gridRight.Widgets.Add(label16);
            _gridRight.Widgets.Add(label17);
            _gridRight.Widgets.Add(label18);

            var scrollViewer2 = new ScrollViewer();

            scrollViewer2.Content = _gridRight;

            var verticalStackPanel2 = new VerticalStackPanel();

            verticalStackPanel2.Widgets.Add(panel2);
            verticalStackPanel2.Widgets.Add(horizontalSeparator2);
            verticalStackPanel2.Widgets.Add(scrollViewer2);

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Spacing = 8;
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Pixels,
                Value = 100,
            });
            horizontalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Part,
            });
            horizontalStackPanel1.Widgets.Add(verticalStackPanel1);
            horizontalStackPanel1.Widgets.Add(_gridGoldTransfer);
            horizontalStackPanel1.Widgets.Add(verticalStackPanel2);

            var horizontalSeparator3 = new HorizontalSeparator();

            _textDescription      = new Label();
            _textDescription.Text = "short sword - weapon, damage: 3-8";
            _textDescription.Id   = "_textDescription";

            var verticalStackPanel3 = new VerticalStackPanel();

            verticalStackPanel3.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel3.Width   = 800;
            verticalStackPanel3.Height  = 400;
            verticalStackPanel3.Padding = new Thickness(0, 16);
            verticalStackPanel3.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel3.Widgets.Add(horizontalSeparator3);
            verticalStackPanel3.Widgets.Add(_textDescription);


            Title         = "Trade";
            DragDirection = DragDirection.None;
            Left          = 190;
            Content       = verticalStackPanel3;
        }
Beispiel #28
0
        private void BuildUI(TileObject tile)
        {
            var label1 = new Label();

            label1.Text = "Name";

            propertyName          = new TextBox();
            propertyName.Text     = "PropertyName";
            propertyName.Left     = 10;
            propertyName.MinWidth = 100;
            propertyName.MaxWidth = 100;
            propertyName.Id       = "propertyName";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.Widgets.Add(label1);
            horizontalStackPanel1.Widgets.Add(propertyName);

            var label2 = new Label();

            label2.Text = "IsCollidable";

            isCollidable      = new CheckBox();
            isCollidable.Left = 10;

            isCollidable.Id = "isCollidable";

            isCollidable.IsPressed = tile.isCollidable;
            isCollidable.Click    += (s, a) => {
                tile.isCollidable = isCollidable.IsPressed;
            };

            var label3 = new Label();

            label3.Text = "isFloor";
            label3.Left = 30;

            isFloor           = new CheckBox();
            isFloor.Left      = 40;
            isFloor.Id        = "isFloor";
            isFloor.IsPressed = tile.isFloor;
            isFloor.Click    += (s, a) => {
                tile.isFloor = isFloor.IsPressed;
            };

            var label4 = new Label();

            label4.Text = "IsBrakeable";
            label4.Left = 60;

            isBrakable        = new CheckBox();
            isBrakable.Left   = 70;
            isBrakable.Id     = "isBrakable";
            isBrakable.Click += (s, a) => {
                //tile.i=isBrakable.IsPressed;
            };

            var label5 = new Label();

            label5.Text = "isMoving";
            label5.Left = 90;

            isMoving        = new CheckBox();
            isMoving.Left   = 100;
            isMoving.Id     = "isMoving";
            isMoving.Click += (s, a) => {
                tile.isMoving = isMoving.IsPressed;
            };
            var horizontalStackPanel2 = new HorizontalStackPanel();

            horizontalStackPanel2.Widgets.Add(label2);
            horizontalStackPanel2.Widgets.Add(isCollidable);
            horizontalStackPanel2.Widgets.Add(label3);
            horizontalStackPanel2.Widgets.Add(isFloor);
            horizontalStackPanel2.Widgets.Add(label4);
            horizontalStackPanel2.Widgets.Add(isBrakable);
            horizontalStackPanel2.Widgets.Add(label5);
            horizontalStackPanel2.Widgets.Add(isMoving);

            var label6 = new Label();

            label6.Text = "Add new Properties";

            var label7 = new Label();

            label7.Text = "Key";
            label7.Left = 20;

            properyKey          = new TextBox();
            properyKey.Text     = "Key propery";
            properyKey.Left     = 30;
            properyKey.MinWidth = 50;
            properyKey.MaxWidth = 100;
            properyKey.Id       = "properyKey";

            var label8 = new Label();

            label8.Text = "Value";
            label8.Left = 100;

            propertyValue          = new TextBox();
            propertyValue.Text     = "Value property";
            propertyValue.Left     = 110;
            propertyValue.MinWidth = 50;
            propertyValue.MaxWidth = 100;
            propertyValue.Id       = "propertyValue";

            addProperty        = new TextButton();
            addProperty.Text   = "Add";
            addProperty.Left   = 140;
            addProperty.Id     = "addProperty";
            addProperty.Click += (s, a) => {
                int x = 0;
                Int32.TryParse(propertyValue.Text, out x);
                tile.extraParameters.Add(properyKey.Text, x);
            };

            var horizontalStackPanel3 = new HorizontalStackPanel();

            horizontalStackPanel3.Widgets.Add(label6);
            horizontalStackPanel3.Widgets.Add(label7);
            horizontalStackPanel3.Widgets.Add(properyKey);
            horizontalStackPanel3.Widgets.Add(label8);
            horizontalStackPanel3.Widgets.Add(propertyValue);
            horizontalStackPanel3.Widgets.Add(addProperty);

            saveProperties      = new TextButton();
            saveProperties.Text = "Save";
            saveProperties.Id   = "saveProperties";

            var horizontalStackPanel4 = new HorizontalStackPanel();

            horizontalStackPanel4.Widgets.Add(saveProperties);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(horizontalStackPanel1);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel2);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel3);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel4);


            Title     = "Tile Properties";
            Left      = 123;
            Top       = 7;
            MinWidth  = 700;
            MaxWidth  = 700;
            MinHeight = 500;
            MaxHeight = 600;
            Content   = verticalStackPanel1;
        }
Beispiel #29
0
        private void BuildUI()
        {
            _buttonBack = new ImageButton();
            _buttonBack.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _buttonBack.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _buttonBack.Id = "_buttonBack";

            _buttonForward = new ImageButton();
            _buttonForward.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _buttonForward.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _buttonForward.GridColumn          = 1;
            _buttonForward.Id = "_buttonForward";

            _textFieldPath                   = new TextBox();
            _textFieldPath.Readonly          = true;
            _textFieldPath.VerticalAlignment = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _textFieldPath.GridColumn        = 2;
            _textFieldPath.Id                = "_textFieldPath";

            _buttonParent = new ImageButton();
            _buttonParent.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
            _buttonParent.VerticalAlignment   = Myra.Graphics2D.UI.VerticalAlignment.Center;
            _buttonParent.GridColumn          = 3;
            _buttonParent.Id = "_buttonParent";

            var grid1 = new Grid();

            grid1.ColumnSpacing = 4;
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            grid1.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid1.Widgets.Add(_buttonBack);
            grid1.Widgets.Add(_buttonForward);
            grid1.Widgets.Add(_textFieldPath);
            grid1.Widgets.Add(_buttonParent);

            _listBoxPlaces = new ListBox();
            _listBoxPlaces.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Stretch;
            _listBoxPlaces.ClipToBounds        = true;
            _listBoxPlaces.Id = "_listBoxPlaces";

            _gridFiles = new Grid();
            _gridFiles.ColumnSpacing = 4;
            _gridFiles.RowSpacing    = 4;
            _gridFiles.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridFiles.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            _gridFiles.GridSelectionMode = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridFiles.Id = "_gridFiles";

            _scrollPane = new ScrollViewer();
            _scrollPane.ShowHorizontalScrollBar = false;
            _scrollPane.Id      = "_scrollPane";
            _scrollPane.Content = _gridFiles;

            _splitPane    = new HorizontalSplitPane();
            _splitPane.Id = "_splitPane";
            _splitPane.Widgets.Add(_listBoxPlaces);
            _splitPane.Widgets.Add(_scrollPane);

            _textBlockFileName      = new Label();
            _textBlockFileName.Text = "File name";
            _textBlockFileName.Id   = "_textBlockFileName";

            _textFieldFileName            = new TextBox();
            _textFieldFileName.GridColumn = 1;
            _textFieldFileName.Id         = "_textFieldFileName";

            var grid2 = new Grid();

            grid2.ColumnSpacing = 4;
            grid2.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            grid2.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            grid2.Widgets.Add(_textBlockFileName);
            grid2.Widgets.Add(_textFieldFileName);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Spacing = 4;
            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            verticalStackPanel1.Proportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Fill,
            });
            verticalStackPanel1.Widgets.Add(grid1);
            verticalStackPanel1.Widgets.Add(_splitPane);
            verticalStackPanel1.Widgets.Add(grid2);


            Title   = "Open File...";
            Left    = 176;
            Top     = 18;
            Width   = 600;
            Height  = 400;
            Content = verticalStackPanel1;
        }
Beispiel #30
0
        private void BuildUI()
        {
            var label1 = new Label();

            label1.Text = "Iron Ration";

            var label2 = new Label();

            label2.Text       = "10";
            label2.GridColumn = 1;

            var label3 = new Label();

            label3.Text    = "Sword";
            label3.GridRow = 1;

            var label4 = new Label();

            label4.Text       = "1";
            label4.GridColumn = 1;
            label4.GridRow    = 1;

            var label5 = new Label();

            label5.Text    = "Rhodochosite";
            label5.GridRow = 2;

            var label6 = new Label();

            label6.Text       = "5";
            label6.GridColumn = 1;
            label6.GridRow    = 2;

            _gridItems = new Grid();
            _gridItems.ColumnSpacing        = 8;
            _gridItems.DefaultRowProportion = new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            };
            _gridItems.ColumnsProportions.Add(new Proportion
            {
                Type  = Myra.Graphics2D.UI.ProportionType.Fill,
                Value = 150,
            });
            _gridItems.ColumnsProportions.Add(new Proportion
            {
                Type = Myra.Graphics2D.UI.ProportionType.Auto,
            });
            _gridItems.SelectionBackground      = new SolidBrush("#0379FFFF");
            _gridItems.SelectionHoverBackground = new SolidBrush("#666666FF");
            _gridItems.GridSelectionMode        = Myra.Graphics2D.UI.GridSelectionMode.Row;
            _gridItems.Id = "_gridItems";
            _gridItems.Widgets.Add(label1);
            _gridItems.Widgets.Add(label2);
            _gridItems.Widgets.Add(label3);
            _gridItems.Widgets.Add(label4);
            _gridItems.Widgets.Add(label5);
            _gridItems.Widgets.Add(label6);

            var horizontalSeparator1 = new HorizontalSeparator();

            _buttonTakeAll       = new TextButton();
            _buttonTakeAll.Text  = "\\c[green]T\\c[white]ake All";
            _buttonTakeAll.Width = 100;
            _buttonTakeAll.Id    = "_buttonTakeAll";

            var horizontalStackPanel1 = new HorizontalStackPanel();

            horizontalStackPanel1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Right;
            horizontalStackPanel1.Widgets.Add(_buttonTakeAll);

            var verticalStackPanel1 = new VerticalStackPanel();

            verticalStackPanel1.Widgets.Add(_gridItems);
            verticalStackPanel1.Widgets.Add(horizontalSeparator1);
            verticalStackPanel1.Widgets.Add(horizontalStackPanel1);


            Title   = "Take";
            Left    = 522;
            Top     = 212;
            Width   = 300;
            Content = verticalStackPanel1;
        }
Beispiel #31
0
        private void CreateDirectConnectWindow()
        {
            directConnect = new Window {
                Title = "Direct Connect"
            };

            Panel panel = new Panel {
                Background = new SolidBrush(new Color(0f, 0f, 0f, 0.5f))
            };

            VerticalStackPanel verticalStackPanel = new VerticalStackPanel {
                Spacing = 8
            };

            Grid serverSettings = new Grid {
                RowSpacing    = 8,
                ColumnSpacing = 8,
                ShowGridLines = true,
                Padding       = new Thickness(4)
            };

            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));
            serverSettings.ColumnsProportions.Add(new Proportion(ProportionType.Auto));

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label ipAddressLabel = new Label {
                Text       = "IP Address:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 0
            };

            serverSettings.Widgets.Add(ipAddressLabel);
            TextBox ipAddressInput = new TextBox {
                Text       = "127.0.0.1",
                Width      = 192,
                GridColumn = 1,
                GridRow    = 0
            };

            ipAddressInput.TextChanged += (s, a) => {
                if (IPAddress.TryParse(ipAddressInput.Text, out IPAddress ip))
                {
                    ipAddressInput.TextColor = Color.White;
                }
                else
                {
                    ipAddressInput.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(ipAddressInput);

            serverSettings.RowsProportions.Add(new Proportion(ProportionType.Auto));
            Label portLabel = new Label {
                Text       = "Port:",
                TextAlign  = TextAlign.Center,
                GridColumn = 0,
                GridRow    = 1
            };

            serverSettings.Widgets.Add(portLabel);
            TextBox portTextBox = new TextBox {
                Text       = "1337",
                GridColumn = 1,
                GridRow    = 1
            };

            portTextBox.TextChanged += (s, a) => {
                if (int.TryParse(portTextBox.Text, out int port) && port > 200 && port < 65536)
                {
                    portTextBox.TextColor = Color.White;
                }
                else
                {
                    portTextBox.TextColor = Color.Red;
                }
            };
            serverSettings.Widgets.Add(portTextBox);

            verticalStackPanel.Widgets.Add(serverSettings);

            HorizontalStackPanel horizontalStackPanel = new HorizontalStackPanel {
                Spacing = 8
            };
            TextButton buttonConnect = new TextButton {
                Text = "Connect",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonConnect.Click += (s, a) => {
                // connect to server here
                if (IPAddress.TryParse(ipAddressInput.Text, out IPAddress ip) && int.TryParse(portTextBox.Text, out int port) && port > 200 && port < 65536)
                {
                    IPEndPoint endPoint = new IPEndPoint(ip, port);
                    game.ScreenManager.SetScreen(new ClientLevelScreen(game, endPoint, nameTextBox.Text));
                }
            };
            horizontalStackPanel.Widgets.Add(buttonConnect);
            TextButton buttonCancel = new TextButton {
                Text = "Cancel",
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonCancel.Click += (s, a) => {
                directConnect.Close();
            };
            horizontalStackPanel.Widgets.Add(buttonCancel);

            verticalStackPanel.Widgets.Add(horizontalStackPanel);

            panel.Widgets.Add(verticalStackPanel);

            directConnect.Content = panel;
        }