public override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _guiBatch    = new SpriteBatch(GraphicsDevice);

            ContentLoader.LoadFonts(Content);
            ContentLoader.LoadTextures(Content);
            ContentLoader.LoadShaders(Content);
            ContentLoader.LoadSounds(Content);

            Screen editorScreen = new Screen();

            guiManager.LoadScreen("editor_screen", editorScreen);
            guiManager.SetScreen("editor_screen");

            selectionButton          = new UIImageButton(new Vector2(8, 8), 32, 32);
            selectionButton.Image    = "textures/tools/selection_icon";
            selectionButton.IsOption = true;
            editorScreen.AddControl(selectionButton);
            selectionButton.IsChosenOption = true;

            selectionButton.MouseClickedEvent += SelectionButton_MouseClickedEvent;

            objectSelectionButton          = new UIImageButton(new Vector2(44, 8), 32, 32);
            objectSelectionButton.Image    = "textures/tools/object_selection_icon";
            objectSelectionButton.IsOption = true;
            editorScreen.AddControl(objectSelectionButton);

            UIFPSCounter fpsCounter = new UIFPSCounter();

            fpsCounter.Position.Y = 50;
            editorScreen.AddControl(fpsCounter);

            objectSelectionButton.MouseClickedEvent += ObjectSelectionButton_MouseClickedEvent;

            UpdateSelection();
        }
Esempio n. 2
0
        /// <inheritdoc />
        public override void InitializeGUI()
        {
            _client = IoCManager.Resolve <IBaseClient>();

            _uiScreen = new Screen();
            _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background");
            // UI screen is added in startup

            var imgTitle = new SimpleImage();

            imgTitle.Sprite        = "ss14_logo";
            imgTitle.Alignment     = ControlAlignments.Right;
            imgTitle.LocalPosition = new Vector2i(-550, 100);
            _uiScreen.AddControl(imgTitle);

            var txtConnect = new Textbox(100);

            txtConnect.Text          = ConfigurationManager.GetCVar <string>("net.server");
            txtConnect.Alignment     = ControlAlignments.Left | ControlAlignments.Bottom;
            txtConnect.LocalPosition = new Vector2i(10, 50);
            txtConnect.OnSubmit     += (sender, text) =>
            {
                if (_client.RunLevel == ClientRunLevel.Initialize)
                {
                    if (TryParseAddress(text, out var ip, out var port))
                    {
                        _client.ConnectToServer(ip, port);
                    }
                }
                //TODO: Else notify user that textbox address is not valid
            };
            imgTitle.AddControl(txtConnect);

            var btnConnect = new ImageButton();

            btnConnect.ImageNormal   = "connect_norm";
            btnConnect.ImageHover    = "connect_hover";
            btnConnect.Alignment     = ControlAlignments.Left | ControlAlignments.Bottom;
            btnConnect.LocalPosition = new Vector2i(0, 20);
            btnConnect.Clicked      += sender =>
            {
                if (_client.RunLevel == ClientRunLevel.Initialize)
                {
                    if (TryParseAddress(txtConnect.Text, out var ip, out var port))
                    {
                        _client.ConnectToServer(ip, port);
                    }
                }
            };
            txtConnect.AddControl(btnConnect);

            var btnOptions = new ImageButton();

            btnOptions.ImageNormal   = "options_norm";
            btnOptions.ImageHover    = "options_hover";
            btnOptions.Alignment     = ControlAlignments.Left | ControlAlignments.Bottom;
            btnOptions.LocalPosition = new Vector2i(0, 20);
            btnOptions.Clicked      += sender =>
            {
                if (_client.RunLevel <= ClientRunLevel.Initialize)
                {
                    StateManager.RequestStateChange <OptionsMenu>();
                }
            };
            btnConnect.AddControl(btnOptions);

            var btnExit = new ImageButton();

            btnExit.ImageNormal   = "exit_norm";
            btnExit.ImageHover    = "exit_hover";
            btnExit.Alignment     = ControlAlignments.Left | ControlAlignments.Bottom;
            btnExit.LocalPosition = new Vector2i(0, 20);
            btnExit.Clicked      += sender => CluwneLib.Stop();
            btnOptions.AddControl(btnExit);

            var fvi        = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var lblVersion = new Label("v. " + fvi.FileVersion, "CALIBRI");

            lblVersion.ForegroundColor = new Color(245, 245, 245);
            lblVersion.Alignment       = ControlAlignments.Right | ControlAlignments.Bottom;
            lblVersion.Resize         += (sender, args) => { lblVersion.LocalPosition = new Vector2i(-3 + -lblVersion.ClientArea.Width, -3 + -lblVersion.ClientArea.Height); };
            _uiScreen.AddControl(lblVersion);
        }
Esempio n. 3
0
        public override void InitializeGUI()
        {
            //TODO: This needs to go in BaseClient
            NetworkManager.RegisterNetMessage <MsgPlayerListReq>(MsgPlayerListReq.NAME, (int)MsgPlayerListReq.ID, message =>
                                                                 Logger.Error($"[SRV] Unhandled NetMessage type: {message.MsgId}"));

            NetworkManager.RegisterNetMessage <MsgPlayerList>(MsgPlayerList.NAME, (int)MsgPlayerList.ID, HandlePlayerList);

            _uiScreen = new Screen();
            _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background");
            // UI screen is added in startup

            var imgMainBg = new SimpleImage();

            imgMainBg.Sprite    = "lobby_mainbg";
            imgMainBg.Alignment = Align.HCenter | Align.VCenter;
            _uiScreen.AddControl(imgMainBg);

            var imgStatus = new SimpleImage();

            imgStatus.Sprite        = "lobby_statusbar";
            imgStatus.LocalPosition = new Vector2i(10, 63);
            imgMainBg.AddControl(imgStatus);

            var lblServer = new Label("SERVER: ", "MICROGME");

            lblServer.ForegroundColor = new Color(245, 245, 245);
            lblServer.LocalPosition   = new Vector2i(5, 2);
            imgStatus.AddControl(lblServer);

            _lblServerInfo = new Label("LLJK#1", "MICROGME");
            _lblServerInfo.ForegroundColor = new Color(139, 0, 0);
            _lblServerInfo.FixedWidth      = 100;
            _lblServerInfo.Alignment       = Align.Right;
            lblServer.AddControl(_lblServerInfo);

            var lblMode = new Label("GAMEMODE: ", "MICROGME");

            lblMode.ForegroundColor = new Color(245, 245, 245);
            lblMode.Alignment       = Align.Right;
            lblMode.LocalPosition   = new Vector2i(10, 0);
            _lblServerInfo.AddControl(lblMode);

            _lblModeInfo = new Label("SECRET", "MICROGME");
            _lblModeInfo.ForegroundColor = new Color(139, 0, 0);
            _lblModeInfo.FixedWidth      = 90;
            _lblModeInfo.Alignment       = Align.Right;
            lblMode.AddControl(_lblModeInfo);

            var lblPlayers = new Label("PLAYERS: ", "MICROGME");

            lblPlayers.ForegroundColor = new Color(245, 245, 245);
            lblPlayers.Alignment       = Align.Right;
            lblPlayers.LocalPosition   = new Vector2i(10, 0);
            _lblModeInfo.AddControl(lblPlayers);

            _lblPlayersInfo = new Label("17/32", "MICROGME");
            _lblPlayersInfo.ForegroundColor = new Color(139, 0, 0);
            _lblPlayersInfo.FixedWidth      = 60;
            _lblPlayersInfo.Alignment       = Align.Right;
            lblPlayers.AddControl(_lblPlayersInfo);

            var lblPort = new Label("PORT: ", "MICROGME");

            lblPort.ForegroundColor = new Color(245, 245, 245);
            lblPort.Alignment       = Align.Right;
            lblPort.LocalPosition   = new Vector2i(10, 0);
            _lblPlayersInfo.AddControl(lblPort);

            _lblPortInfo = new Label(MainScreen.DefaultPort.ToString(), "MICROGME");
            _lblPortInfo.ForegroundColor = new Color(139, 0, 0);
            _lblPortInfo.FixedWidth      = 50;
            _lblPortInfo.Alignment       = Align.Right;
            lblPort.AddControl(_lblPortInfo);

            _tabs               = new TabbedMenu();
            _tabs.TopSprite     = "lobby_tab_top";
            _tabs.MidSprite     = "lobby_tab_mid";
            _tabs.BotSprite     = "lobby_tab_bot";
            _tabs.TabOffset     = new Vector2i(-8, 300);
            _tabs.LocalPosition = new Vector2i(5, 90);
            imgMainBg.AddControl(_tabs);

            var tabCharacter = new TabContainer(new Vector2i(793, 350));

            tabCharacter.TabSpriteName = "lobby_tab_person";
            _tabs.AddTab(tabCharacter);

            var tabObserve = new TabContainer(new Vector2i(793, 350));

            tabObserve.TabSpriteName = "lobby_tab_eye";
            _tabs.AddTab(tabObserve);

            var tabServer = new PlayerListTab(new Vector2i(793, 350));

            tabServer.TabSpriteName = "lobby_tab_info";
            _tabs.AddTab(tabServer);
            _tabs.SelectTab(tabServer);

            var imgChatBg = new SimpleImage();

            imgChatBg.Sprite    = "lobby_chatbg";
            imgChatBg.Alignment = Align.HCenter | Align.Bottom;
            imgChatBg.Resize   += (sender, args) => { imgChatBg.LocalPosition = new Vector2i(0, -9 + -imgChatBg.Height); };
            imgMainBg.AddControl(imgChatBg);

            _lobbyChat           = new Chatbox(new Vector2i(780, 225));
            _lobbyChat.Alignment = Align.HCenter | Align.VCenter;
            imgChatBg.AddControl(_lobbyChat);

            var btnReady = new ImageButton();

            btnReady.ImageNormal = "lobby_ready";
            btnReady.ImageHover  = "lobby_ready_green";
            btnReady.Alignment   = Align.Right;
            btnReady.Resize     += (sender, args) => { btnReady.LocalPosition = new Vector2i(-5 + -btnReady.Width, -5 + -btnReady.Height); };
            imgChatBg.AddControl(btnReady);
            btnReady.Clicked += _btnReady_Clicked;

            var btnBack = new ImageButton();

            btnBack.ImageNormal = "lobby_back";
            btnBack.ImageHover  = "lobby_back_green";
            btnBack.Resize     += (sender, args) => { btnBack.LocalPosition = new Vector2i(-5 + -btnBack.Width, 0); };
            btnReady.AddControl(btnBack);
            btnBack.Clicked += _btnBack_Clicked;
        }
Esempio n. 4
0
        /// <inheritdoc />
        public override void InitializeGUI()
        {
            _uiScreen = new Screen();
            _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background");
            // added to interface manager in startup

            _bgPanel = new Panel();
            _bgPanel.BackgroundImage = ResourceCache.GetResource <SpriteResource>(@"Textures/UserInterface/TicketOverlay.png");
            _bgPanel.BackgroundColor = new Color(128, 128, 128, 128);
            _bgPanel.Alignment       = ControlAlignments.HCenter | ControlAlignments.VCenter;
            _bgPanel.Layout         += (sender, args) =>
            {
                _bgPanel.Width  = (int)(_uiScreen.Width * 0.85f);
                _bgPanel.Height = (int)(_uiScreen.Height * 0.85f);
            };
            _uiScreen.AddControl(_bgPanel);

            _lblTitle = new Label("Options", "CALIBRI", 48);
            _lblTitle.LocalPosition = new Vector2i(10, 10);
            _bgPanel.AddControl(_lblTitle);

            _lstResolution               = new Listbox(250, 150);
            _lstResolution.Alignment     = ControlAlignments.Bottom;
            _lstResolution.LocalPosition = new Vector2i(50, 50);
            _lstResolution.ItemSelected += _lstResolution_ItemSelected;
            PopulateAvailableVideoModes(_lstResolution);
            _lblTitle.AddControl(_lstResolution);

            _chkFullScreen               = new Checkbox();
            _chkFullScreen.Value         = ConfigurationManager.GetCVar <bool>("display.fullscreen");
            _chkFullScreen.ValueChanged += _chkFullScreen_ValueChanged;
            _chkFullScreen.Alignment     = ControlAlignments.Bottom;
            _chkFullScreen.LocalPosition = new Vector2i(0, 50);
            _lstResolution.AddControl(_chkFullScreen);

            _lblFullScreen               = new Label("Fullscreen", "CALIBRI");
            _lblFullScreen.Alignment     = ControlAlignments.Right;
            _lblFullScreen.LocalPosition = new Vector2i(3, 0);
            _chkFullScreen.AddControl(_lblFullScreen);

            _chkVSync               = new Checkbox();
            _chkVSync.Value         = ConfigurationManager.GetCVar <bool>("display.vsync");
            _chkVSync.ValueChanged += _chkVSync_ValueChanged;
            _chkVSync.Alignment     = ControlAlignments.Bottom;
            _chkVSync.LocalPosition = new Vector2i(0, 3);
            _chkFullScreen.AddControl(_chkVSync);

            _lblVSync               = new Label("Vsync", "CALIBRI");
            _lblVSync.Alignment     = ControlAlignments.Right;
            _lblVSync.LocalPosition = new Vector2i(3, 0);
            _chkVSync.AddControl(_lblVSync);

            _btnApply           = new Button("Apply Settings");
            _btnApply.Clicked  += _btnApply_Clicked;
            _btnApply.Alignment = ControlAlignments.Bottom | ControlAlignments.Right;
            _btnApply.Resize   += (sender, args) => { _btnApply.LocalPosition = new Vector2i(-10 + -_btnApply.ClientArea.Width, -10 + -_btnApply.ClientArea.Height); };
            _bgPanel.AddControl(_btnApply);

            _btnBack          = new Button("Back");
            _btnBack.Clicked += _btnBack_Clicked;
            _btnBack.Resize  += (sender, args) => { _btnBack.LocalPosition = new Vector2i(-10 + -_btnBack.ClientArea.Width, 0); };
            _btnApply.AddControl(_btnBack);
        }
Esempio n. 5
0
        /// <inheritdoc />
        public override void InitializeGUI()
        {
            _uiScreen = new Screen();
            _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background");
            // UI screen is added in startup

            var imgTitle = new SimpleImage();

            imgTitle.Sprite        = "ss14_logo";
            imgTitle.Alignment     = Align.Right;
            imgTitle.LocalPosition = new Vector2i(-550, 100);
            _uiScreen.AddControl(imgTitle);

            var txtConnect = new Textbox(100);

            txtConnect.Text          = ConfigurationManager.GetCVar <string>("net.server");
            txtConnect.Alignment     = Align.Left | Align.Bottom;
            txtConnect.LocalPosition = new Vector2i(10, 50);
            txtConnect.OnSubmit     += (sender, text) => { StartConnect(text); };
            imgTitle.AddControl(txtConnect);

            var btnConnect = new ImageButton();

            btnConnect.ImageNormal   = "connect_norm";
            btnConnect.ImageHover    = "connect_hover";
            btnConnect.Alignment     = Align.Left | Align.Bottom;
            btnConnect.LocalPosition = new Vector2i(0, 20);
            btnConnect.Clicked      += sender =>
            {
                if (!_isConnecting)
                {
                    StartConnect(txtConnect.Text);
                }
                else
                {
                    _isConnecting = false;
                    NetworkManager.ClientDisconnect("Client disconnected from game.");
                }
            };
            txtConnect.AddControl(btnConnect);

            var btnOptions = new ImageButton();

            btnOptions.ImageNormal   = "options_norm";
            btnOptions.ImageHover    = "options_hover";
            btnOptions.Alignment     = Align.Left | Align.Bottom;
            btnOptions.LocalPosition = new Vector2i(0, 20);
            btnOptions.Clicked      += sender =>
            {
                if (_isConnecting)
                {
                    _isConnecting = false;
                    NetworkManager.ClientDisconnect("Client disconnected from game.");
                }

                StateManager.RequestStateChange <OptionsMenu>();
            };
            btnConnect.AddControl(btnOptions);

            var btnExit = new ImageButton();

            btnExit.ImageNormal   = "exit_norm";
            btnExit.ImageHover    = "exit_hover";
            btnExit.Alignment     = Align.Left | Align.Bottom;
            btnExit.LocalPosition = new Vector2i(0, 20);
            btnExit.Clicked      += sender => CluwneLib.Stop();
            btnOptions.AddControl(btnExit);

            var fvi        = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var lblVersion = new Label("v. " + fvi.FileVersion, "CALIBRI");

            lblVersion.ForegroundColor = new Color(245, 245, 245);
            lblVersion.Alignment       = Align.Right | Align.Bottom;
            lblVersion.Resize         += (sender, args) => { lblVersion.LocalPosition = new Vector2i(-3 + -lblVersion.ClientArea.Width, -3 + -lblVersion.ClientArea.Height); };
            _uiScreen.AddControl(lblVersion);

#if uiDev
            var chat = new Chatbox(new Vector2i(400, 200));
            chat.LocalPosition = new Vector2i(25, 25);
            _uiScreen.AddControl(chat);

            var listPanel = new ListPanel();
            listPanel.Size          = new Vector2i(200, 200);
            listPanel.LocalPosition = new Vector2i(450, 250);
            _uiScreen.AddControl(listPanel);

            for (var i = 0; i < 5; i++)
            {
                var label = new Label($"Label: {i}", "CALIBRI");
                listPanel.AddControl(label);
            }
            var rtp = new RichTextPanel();
            rtp.Size            = new Vector2i(400, 200);
            rtp.LocalPosition   = new Vector2i(25, 250);
            rtp.BackgroundColor = Color4.DarkGray;
            rtp.ForegroundColor = new Color4(230, 230, 230, 255);
            rtp.DrawBorder      = true;
            rtp.DrawBackground  = true;
            _uiScreen.AddControl(rtp);

            rtp.Text.Append("Textbox says, \"Oh, my, God Becky, look at the image.\"\n");
            rtp.Text.Append("Textbox says, \"It is so big, it looks like, one of those buttons' girlfriends.\"\n");
            rtp.Text.Append("Textbox says, \"I mean, the image, is just so big. I can't believe it's just so square, it's like out there.\"\n");
            rtp.Text.Append("Textbox says, \"I mean gross, look. It's just so, black!\"\n");
#endif
        }
Esempio n. 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            guiBatch    = new SpriteBatch(GraphicsDevice);



            ContentLoader.LoadTextures(Content);
            ContentLoader.LoadFonts(Content);
            ContentLoader.LoadShaders(Content);
            ContentLoader.LoadSounds(Content);

            debugScreen = new Screen();
            fadeTest    = new Screen();

            guiManager = new GUIManager();
            guiManager.LoadScreen("debug_screen", debugScreen);
            guiManager.LoadScreen("fade_screen", fadeTest);

            UIButton pcoibutton = new UIButton(new Vector2(0, 50), 20, 20);

            pcoibutton.ButtonTextBlock.Text = "pcoi";
            pcoibutton.MouseClickedEvent   += PCOIButtonClick;

            debugScreen.AddControl(pcoibutton);


            UIGrid grid = new UIGrid();

            UIButton button = new UIButton(new Vector2(200, 200), 200, 200);

            button.ButtonTextBlock.Text = "Scale Test";
            button.ScaleToText          = false;


            grid.AddCell(button, 0.25d, 0.25d, 0.5d, 0.5d);

            debugScreen.AddControl(grid);

            UIFPSCounter fpsCounter = new UIFPSCounter();

            fpsCounter.HorizontalAlignment = EnumHorizontalAlignment.RIGHT;

            debugScreen.AddControl(fpsCounter);

            // TEST SCREEN FOR FADING
            UIGrid grid2 = new UIGrid();

            UIButton button2 = new UIButton(new Vector2(200, 200), 200, 200);

            button2.ButtonTextBlock.Text = "Faded";
            button2.ScaleToText          = false;

            grid2.AddCell(button2, 0.1d, 0.1d, 0.5d, 0.5d);

            fadeTest.AddControl(grid2);

            // Set default screen
            guiManager.SetScreen("debug_screen");
        }
Esempio n. 7
0
        public override void InitializeGUI()
        {
            _uiScreen = new Screen();
            _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background");
            // UI screen is added in startup

            var imgMainBg = new SimpleImage();

            imgMainBg.Sprite    = "lobby_mainbg";
            imgMainBg.Alignment = ControlAlignments.HCenter | ControlAlignments.VCenter;
            _uiScreen.AddControl(imgMainBg);

            var imgStatus = new SimpleImage();

            imgStatus.Sprite        = "lobby_statusbar";
            imgStatus.LocalPosition = new Vector2i(10, 63);
            imgMainBg.AddControl(imgStatus);

            var lblServer = new Label("SERVER: ", "MICROGME");

            lblServer.ForegroundColor = new Color(245, 245, 245);
            lblServer.LocalPosition   = new Vector2i(5, 2);
            imgStatus.AddControl(lblServer);

            _lblServerInfo = new Label("------", "MICROGME");
            _lblServerInfo.ForegroundColor = new Color(139, 0, 0);
            _lblServerInfo.FixedWidth      = 100;
            _lblServerInfo.Alignment       = ControlAlignments.Right;
            lblServer.AddControl(_lblServerInfo);

            var lblMode = new Label("GAMEMODE: ", "MICROGME");

            lblMode.ForegroundColor = new Color(245, 245, 245);
            lblMode.Alignment       = ControlAlignments.Right;
            lblMode.LocalPosition   = new Vector2i(10, 0);
            _lblServerInfo.AddControl(lblMode);

            _lblModeInfo = new Label("------", "MICROGME");
            _lblModeInfo.ForegroundColor = new Color(139, 0, 0);
            _lblModeInfo.FixedWidth      = 90;
            _lblModeInfo.Alignment       = ControlAlignments.Right;
            lblMode.AddControl(_lblModeInfo);

            var lblPlayers = new Label("PLAYERS: ", "MICROGME");

            lblPlayers.ForegroundColor = new Color(245, 245, 245);
            lblPlayers.Alignment       = ControlAlignments.Right;
            lblPlayers.LocalPosition   = new Vector2i(10, 0);
            _lblModeInfo.AddControl(lblPlayers);

            _lblPlayersInfo = new Label("--/--", "MICROGME");
            _lblPlayersInfo.ForegroundColor = new Color(139, 0, 0);
            _lblPlayersInfo.FixedWidth      = 60;
            _lblPlayersInfo.Alignment       = ControlAlignments.Right;
            lblPlayers.AddControl(_lblPlayersInfo);

            var lblPort = new Label("PORT: ", "MICROGME");

            lblPort.ForegroundColor = new Color(245, 245, 245);
            lblPort.Alignment       = ControlAlignments.Right;
            lblPort.LocalPosition   = new Vector2i(10, 0);
            _lblPlayersInfo.AddControl(lblPort);

            _lblPortInfo = new Label("----", "MICROGME");
            _lblPortInfo.ForegroundColor = new Color(139, 0, 0);
            _lblPortInfo.FixedWidth      = 50;
            _lblPortInfo.Alignment       = ControlAlignments.Right;
            lblPort.AddControl(_lblPortInfo);

            _tabs               = new TabbedMenu();
            _tabs.TopSprite     = "lobby_tab_top";
            _tabs.MidSprite     = "lobby_tab_mid";
            _tabs.BotSprite     = "lobby_tab_bot";
            _tabs.TabOffset     = new Vector2i(-8, 300);
            _tabs.LocalPosition = new Vector2i(5, 90);
            imgMainBg.AddControl(_tabs);

            var tabCharacter = new TabContainer(new Vector2i(793, 350));

            tabCharacter.TabSpriteName = "lobby_tab_person";
            _tabs.AddTab(tabCharacter);

            var tabObserve = new TabContainer(new Vector2i(793, 350));

            tabObserve.TabSpriteName = "lobby_tab_eye";
            _tabs.AddTab(tabObserve);

            _tabServer = new PlayerListTab(new Vector2i(793, 350));
            _tabServer.TabSpriteName = "lobby_tab_info";
            _tabs.AddTab(_tabServer);
            _tabs.SelectTab(_tabServer);

            var imgChatBg = new SimpleImage();

            imgChatBg.Sprite    = "lobby_chatbg";
            imgChatBg.Alignment = ControlAlignments.HCenter | ControlAlignments.Bottom;
            imgChatBg.Resize   += (sender, args) => { imgChatBg.LocalPosition = new Vector2i(0, -9 + -imgChatBg.Height); };
            imgMainBg.AddControl(imgChatBg);

            _lobbyChat                   = new Chatbox(new Vector2i(780, 225));
            _lobbyChat.Alignment         = ControlAlignments.HCenter | ControlAlignments.VCenter;
            _lobbyChat.DefaultChatFormat = "ooc \"{0}\"";
            imgChatBg.AddControl(_lobbyChat);

            var btnReady = new ImageButton();

            btnReady.ImageNormal = "lobby_ready";
            btnReady.ImageHover  = "lobby_ready_green";
            btnReady.Alignment   = ControlAlignments.Right;
            btnReady.Resize     += (sender, args) => { btnReady.LocalPosition = new Vector2i(-5 + -btnReady.Width, -5 + -btnReady.Height); };
            imgChatBg.AddControl(btnReady);
            btnReady.Clicked += _btnReady_Clicked;

            var btnBack = new ImageButton();

            btnBack.ImageNormal = "lobby_back";
            btnBack.ImageHover  = "lobby_back_green";
            btnBack.Resize     += (sender, args) => { btnBack.LocalPosition = new Vector2i(-5 + -btnBack.Width, 0); };
            btnReady.AddControl(btnBack);
            btnBack.Clicked += _btnBack_Clicked;
        }
Esempio n. 8
0
        /// <inheritdoc />
        public override void InitializeGUI()
        {
            _uiScreen = new Screen();
            _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background");
            // UI screen is added in startup

            var imgTitle = new SimpleImage();

            imgTitle.Sprite        = "ss14_logo";
            imgTitle.Alignment     = Align.Right;
            imgTitle.LocalPosition = new Vector2i(-550, 100);
            _uiScreen.AddControl(imgTitle);

            var txtConnect = new Textbox(100);

            txtConnect.Text          = ConfigurationManager.GetCVar <string>("net.server");
            txtConnect.Alignment     = Align.Left | Align.Bottom;
            txtConnect.LocalPosition = new Vector2i(10, 50);
            txtConnect.OnSubmit     += (sender, text) => { StartConnect(text); };
            imgTitle.AddControl(txtConnect);

            var btnConnect = new ImageButton();

            btnConnect.ImageNormal   = "connect_norm";
            btnConnect.ImageHover    = "connect_hover";
            btnConnect.Alignment     = Align.Left | Align.Bottom;
            btnConnect.LocalPosition = new Vector2i(0, 20);
            btnConnect.Clicked      += sender =>
            {
                if (!_isConnecting)
                {
                    StartConnect(txtConnect.Text);
                }
                else
                {
                    _isConnecting = false;
                    NetworkManager.ClientDisconnect("Client disconnected from game.");
                }
            };
            txtConnect.AddControl(btnConnect);

            var btnOptions = new ImageButton();

            btnOptions.ImageNormal   = "options_norm";
            btnOptions.ImageHover    = "options_hover";
            btnOptions.Alignment     = Align.Left | Align.Bottom;
            btnOptions.LocalPosition = new Vector2i(0, 20);
            btnOptions.Clicked      += sender =>
            {
                if (_isConnecting)
                {
                    _isConnecting = false;
                    NetworkManager.ClientDisconnect("Client disconnected from game.");
                }

                StateManager.RequestStateChange <OptionsMenu>();
            };
            btnConnect.AddControl(btnOptions);

            var btnExit = new ImageButton();

            btnExit.ImageNormal   = "exit_norm";
            btnExit.ImageHover    = "exit_hover";
            btnExit.Alignment     = Align.Left | Align.Bottom;
            btnExit.LocalPosition = new Vector2i(0, 20);
            btnExit.Clicked      += sender => CluwneLib.Stop();
            btnOptions.AddControl(btnExit);

            var fvi        = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
            var lblVersion = new Label("v. " + fvi.FileVersion, "CALIBRI");

            lblVersion.ForegroundColor = new Color(245, 245, 245);
            lblVersion.Alignment       = Align.Right | Align.Bottom;
            lblVersion.Resize         += (sender, args) => { lblVersion.LocalPosition = new Vector2i(-3 + -lblVersion.ClientArea.Width, -3 + -lblVersion.ClientArea.Height); };
            _uiScreen.AddControl(lblVersion);
        }