public PlayerFrame(NetworkPlayer player, bool isOurPlayer, UDim2 position, UDim2 size, GUITheme theme)
                : base(position, size, Image.CreateBlank(Color.White))
            {
                Theme            = theme;
                NetPlayer        = player;
                this.isOurPlayer = isOurPlayer;

                nameLabel = new GUILabel(UDim2.Zero, UDim2.Fill, "", TextAlign.Left, theme)
                {
                    Parent = this
                };
                nameLabel.Font          = Theme.GetField <BMPFont>(null, "Leaderboard.PlayerLabel.Font");
                nameLabel.TextPadding.X = 6;

                scoreLabel = new GUILabel(UDim2.Zero, new UDim2(1f, -50, 1f, 0), "0", TextAlign.Right, theme)
                {
                    Parent = this
                };
                scoreLabel.Font          = Theme.GetField <BMPFont>(null, "Leaderboard.PlayerLabel.Font");
                scoreLabel.TextPadding.Z = 6;

                pingLabel = new GUILabel(UDim2.Zero, UDim2.Fill, "0ms", TextAlign.Right, theme)
                {
                    Parent = this
                };
                pingLabel.Font          = Theme.GetField <BMPFont>(null, "Leaderboard.PlayerLabel.Font");
                pingLabel.TextPadding.Z = 6;

                SetName(player.Name);
                SetScore(player.Score);
            }
        public ControlsWindow(GUISystem system, GUITheme theme)
            : base(system, UDim2.Zero, "Controls", theme)
        {
            labels = new List <GUILabel>();
            Setup();
            ZIndex = 100;

            font = theme.GetField <BMPFont>(null, "SmallFont");
        }
示例#3
0
        public GUIWindow(GUISystem system, UDim2 position, UDim2 size, string title, GUITheme theme,
                         bool closable = true, bool createTitleBar = true)
            : base(system, position, size)
        {
            Theme = theme;
            if (createTitleBar)
            {
                TitleBar = new GUILabel(UDim2.Zero, new UDim2(1f, 0, 0, 20), title,
                                        theme.GetField <Color>(Color.White, "Window.TitleBar.TextColor"), theme);
                TitleBar.CapturesMouseClicks = true;
                TitleBar.ZIndex          = 100;
                TitleBar.BackgroundImage = theme.GetField <Image>(Image.CreateBlank(new Color(40, 40, 40)), "Window.TitleBar.BackgroundImage");

                if (closable)
                {
                    ExitButton = new GUIButton(new UDim2(1f, -20, 0, 0), new UDim2(0, 20, 0, 20),
                                               theme.GetField <string>("X", "Window.TitleBar.CloseButton.Text"),
                                               TextAlign.Center,
                                               theme,
                                               theme.GetField <Image>(Image.CreateBlank(new Color(230, 0, 0)), "Window.TitleBar.CloseButton.NormalImage"),
                                               theme.GetField <Image>(Image.CreateBlank(new Color(255, 0, 0)), "Window.TitleBar.CloseButton.HoverImage"),
                                               theme.GetField <Image>(Image.CreateBlank(new Color(200, 0, 0)), "Window.TitleBar.CloseButton.ActiveImage"),
                                               null);
                    ExitButton.Parent        = TitleBar;
                    ExitButton.OnMouseClick += (btn, mbtn) =>
                    {
                        Visible = false;
                    };
                }
            }

            BackgroundFrame = new GUIFrame(new UDim2(0, 0, 0, createTitleBar ? 20 : 0), new UDim2(1f, 0, 1f, createTitleBar ? -20 : 0),
                                           theme.GetField <Image>(Image.CreateBlank(new Color(70, 70, 70, 200)), "Window.BackgroundImage"));
            BackgroundFrame.ZIndex = -100;

            if (createTitleBar)
            {
                SetDragHandle(TitleBar);
                AddTopLevel(TitleBar);
            }
            AddTopLevel(BackgroundFrame);
        }
示例#4
0
        public void AddFeedItem(string left, string leftAssist, Color leftColor, string middle, string right, Color rightColor)
        {
            BMPFont font = theme.GetField <BMPFont>(null, "SmallFont");

            if (!string.IsNullOrWhiteSpace(leftAssist))
            {
                if (string.IsNullOrWhiteSpace(left))
                {
                    left = right + " + " + leftAssist;
                }
                else
                {
                    left = left + " + " + leftAssist;
                }
            }

            FeedItem item = new FeedItem(theme, 25, feed.Count,
                                         left, leftColor, middle, right, rightColor, font);

            feed.Add(item);
            area.AddTopLevel(item);
        }
        public MultiplayerScreen(MainWindow window)
            : base(window, "Multiplayer")
        {
            debugRenderer = Renderer.GetRenderer3D <DebugRenderer>();

            gamemodes = new Dictionary <GamemodeType, NetworkedGamemode>()
            {
                { GamemodeType.TDM, new TDMGamemode(this) },
                { GamemodeType.CTF, new CTFGamemode(this) }
            };

            // Build the UI elements
            theme = AssetManager.CreateDefaultGameTheme();
            font  = theme.GetField <BMPFont>(null, "SmallFont");

            hud                       = new HUD(Renderer);
            loadingBar                = new MultiplayerLoadingBar(GUISystem, theme);
            chat                      = new ChatBox(new UDim2(0, 40, 1f, -240), new UDim2(0, 350, 0, 165), theme, this);
            menu                      = new MultiplayerMenu(GUISystem, theme, Window);
            menu.OnClosed            += Menu_OnClosed;
            announcementLabel         = new GUILabel(new UDim2(0.5f, 0, 0.5f, 0), UDim2.Zero, "", TextAlign.Center, theme);
            announcementLabel.Font    = AssetManager.LoadFont("karmasuture-32");
            announcementLabel.Visible = false;

            // Add each UI element
            GUIArea.AddTopLevel(chat, announcementLabel);
            GUISystem.Add(loadingBar, menu);
            Windows.Add(loadingBar);
            Windows.Add(menu);

            // Setup default multiplayer cvars
            DashCMD.SetCVar("cl_impacts", false);
            DashCMD.SetCVar("cl_interp", 0.5f);               // Client interpolation with server position
            DashCMD.SetCVar("cl_interp_movement_smooth", 1f); // Client player movement smoothing (1f = no smoothing)
            DashCMD.SetCVar("cl_interp_rep", 20f);            // Replicated entities interpolation
            DashCMD.SetCVar("cl_max_error_dist", 12f);        // Max distance the client's position can be off from the server's
        }
        public Leaderboard(GUISystem gsys, GUITheme theme, NetPlayerComponent netPlayerComponent)
            : base(gsys, new UDim2(0.65f, 0, 0.65f, 0), "Leaderboard", theme, false, false)
        {
            MinSize = new UDim2(0, 300, 0, 400);

            this.netPlayerComponent = netPlayerComponent;
            IsDraggable             = false;

            playerFrames = new Dictionary <ushort, PlayerFrame>();
            orderedTeamA = new List <PlayerFrame>();
            orderedTeamB = new List <PlayerFrame>();

            bigFont = AssetManager.LoadFont("karmasuture-26");
            theme.SetField("Leaderboard.PlayerLabel.Font", AssetManager.LoadFont("arial-14"));

            teamAFrame  = new GUIFrame(UDim2.Zero, new UDim2(0.5f, 0, 1f, 0), image: null);
            teamBFrame  = new GUIFrame(new UDim2(0.5f, 0, 0, 0), new UDim2(0.5f, 0, 1f, 0), image: null);
            footerFrame = new GUIFrame(new UDim2(0, 0, 1f, -30), new UDim2(1f, 0, 0, 30), theme);

            gamemodeLabel = new GUILabel(UDim2.Zero, new UDim2(0.5f, 0, 1f, 0), "Current Gamemode: --", TextAlign.Left, theme)
            {
                Parent = footerFrame
            };
            gamemodeInfoLabel = new GUILabel(new UDim2(0.5f, 0, 0, 0), new UDim2(0.5f, 0, 1f, 0), "", TextAlign.Right, theme)
            {
                Parent = footerFrame
            };

            GUILabel teamALabel = new GUILabel(new UDim2(0, 0, 0, 0), new UDim2(1f, 0, 0, 40),
                                               "Red Team", TextAlign.Left, Theme)
            {
                Parent = teamAFrame
            };
            GUILabel teamBLabel = new GUILabel(new UDim2(0, 0, 0, 0), new UDim2(1f, 0, 0, 40),
                                               "Blue Team", TextAlign.Left, Theme)
            {
                Parent = teamBFrame
            };

            teamAScoreLabel = new GUILabel(new UDim2(1f, 0, 0, 0), new UDim2(0, 1, 0, 40),
                                           "0", TextAlign.Right, Theme)
            {
                Parent = teamAFrame
            };
            teamBScoreLabel = new GUILabel(new UDim2(1f, 0, 0, 0), new UDim2(0, 1, 0, 40),
                                           "0", TextAlign.Right, Theme)
            {
                Parent = teamBFrame
            };

            GUILabel teamAPlayerNameLabel = new GUILabel(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 20), "Name", TextAlign.Left, theme)
            {
                Parent = teamAFrame
            };
            GUILabel teamAPlayerScoreLabel = new GUILabel(new UDim2(0, 0, 0, 40), new UDim2(1f, -50, 0, 20), "Score", TextAlign.Right, theme)
            {
                Parent = teamAFrame
            };
            GUILabel teamAPlayerPingLabel = new GUILabel(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 20), "Ping", TextAlign.Right, theme)
            {
                Parent = teamAFrame
            };

            GUILabel teamBPlayerNameLabel = new GUILabel(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 20), "Name", TextAlign.Left, theme)
            {
                Parent = teamBFrame
            };
            GUILabel teamBPlayerScoreLabel = new GUILabel(new UDim2(0, 0, 0, 40), new UDim2(1f, -50, 0, 20), "Score", TextAlign.Right, theme)
            {
                Parent = teamBFrame
            };
            GUILabel teamBPlayerPingLabel = new GUILabel(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 20), "Ping", TextAlign.Right, theme)
            {
                Parent = teamBFrame
            };

            teamALabel.TextPadding.X      = 6;
            teamBLabel.TextPadding.X      = 6;
            teamAScoreLabel.TextPadding.Z = 6;
            teamBScoreLabel.TextPadding.Z = 6;

            teamAPlayerNameLabel.TextPadding.X  = 6;
            teamAPlayerScoreLabel.TextPadding.Z = 6;
            teamAPlayerPingLabel.TextPadding.Z  = 6;

            teamBPlayerNameLabel.TextPadding.X  = 6;
            teamBPlayerScoreLabel.TextPadding.Z = 6;
            teamBPlayerPingLabel.TextPadding.Z  = 6;

            teamALabel.BackgroundImage           = Image.CreateBlank(new Color(186, 52, 52, 127));
            teamBLabel.BackgroundImage           = Image.CreateBlank(new Color(39, 78, 194, 127));
            teamAPlayerNameLabel.BackgroundImage = theme.GetField <Image>(null, "Frame.Image");
            teamBPlayerNameLabel.BackgroundImage = theme.GetField <Image>(null, "Frame.Image");

            teamALabel.Font      = bigFont;
            teamBLabel.Font      = bigFont;
            teamAScoreLabel.Font = bigFont;
            teamBScoreLabel.Font = bigFont;

            teamAScoreLabel.ZIndex       = 1;
            teamBScoreLabel.ZIndex       = 1;
            teamAPlayerScoreLabel.ZIndex = 1;
            teamBPlayerScoreLabel.ZIndex = 1;
            teamAPlayerPingLabel.ZIndex  = 1;
            teamBPlayerPingLabel.ZIndex  = 1;

            AddTopLevel(teamAFrame, teamBFrame, footerFrame);
        }