示例#1
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);
        }
示例#2
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;
        }
示例#3
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;
        }
示例#4
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
        }
示例#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);
        }