예제 #1
0
        public StaticGui(MainWindow window, MasterRenderer renderer)
        {
            this.window   = window;
            this.renderer = renderer;

            gsys = renderer.Sprites.GUISystem;

            area = new GUIArea(gsys);
            renderer.Sprites.Add(area);

            BMPFont smallFont  = AssetManager.LoadFont("arial-bold-12");
            BMPFont normalFont = AssetManager.LoadFont("arial-bold-14");
            BMPFont bigFont    = AssetManager.LoadFont("arial-bold-20");
            BMPFont tinyFont   = AssetManager.LoadFont("arial-bold-10");

            GUITheme theme = AssetManager.CreateDefaultGameTheme();

            theme.SetField("SmallFont", smallFont);
            theme.SetField("Font", normalFont);
            theme.SetField("TinyFont", tinyFont);

            controls        = new ControlsWindow(gsys, theme);
            controls.ZIndex = 200;

            // Overlay
            fpsLabel     = new GUILabel(UDim2.Zero, UDim2.Zero, "FPS: --", TextAlign.TopLeft, theme);
            timeLabel    = new GUILabel(new UDim2(1f, 0, 0, 0), UDim2.Zero, "Time: --", TextAlign.TopRight, theme);
            versionLabel = new GUILabel(new UDim2(0, 0, 1f, 0), UDim2.Zero, GameVersion.Current.ToString(),
                                        TextAlign.BottomLeft, theme);
            fpsLabel.Font     = smallFont;
            timeLabel.Font    = smallFont;
            versionLabel.Font = bigFont;

            if (screenshots == null)
            {
                string[] mainMenuFiles = Directory.GetFiles("Content/Textures/MainMenu");
                screenshots = new List <Texture>();

                foreach (string file in mainMenuFiles)
                {
                    // Skip thumbs.db
                    if (file.EndsWith(".db"))
                    {
                        continue;
                    }

                    try { screenshots.Add(GLoader.LoadTexture(file, TextureMinFilter.Linear, TextureMagFilter.Linear, true)); }
                    catch (Exception e) { DashCMD.WriteError("Failed to load main menu background '{1}'. \n{0}", e, file); }
                }
            }

            background        = new GUIFrame(UDim2.Zero, new UDim2(1f, 0, 1f, 0), Image.Blank);
            background.ZIndex = -100;

            area.AddTopLevel(background, fpsLabel, timeLabel, versionLabel);
            gsys.Add(controls);
        }
예제 #2
0
        //bool showGameItems;

        public HUD(MasterRenderer renderer)
        {
            this.renderer = renderer;
            font          = AssetManager.LoadFont("karmasuture-26");

            feed           = new List <FeedItem>();
            hitIndications = new List <HitIndication>();

            if (palletTex == null)
            {
                palletTex = GLoader.LoadTexture("Textures/Gui/palette.png");
                Texture crosshairTex = GLoader.LoadTexture("Textures/Gui/crosshair.png");
                Texture hitmarkerTex = GLoader.LoadTexture("Textures/Gui/hitmarker.png");
                crosshairImage = new Image(crosshairTex);
                hitmarkerImage = new Image(hitmarkerTex);
                hurtRingTex    = GLoader.LoadTexture("Textures/Gui/hurt-ring.png");
                intelTex       = GLoader.LoadTexture("Textures/Gui/intel.png", TextureMinFilter.Nearest, TextureMagFilter.Nearest);
            }

            GUISystem gsys = renderer.Sprites.GUISystem;

            area        = new GUIArea(gsys);
            area.ZIndex = -1;

            theme = GUITheme.Basic;
            theme.SetField("Font", font);
            theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14"));
            theme.SetField("Label.TextColor", Color.White);
            theme.SetField("Label.TextShadowColor", new Color(0, 0, 0, 0.6f));

            healthLabel       = new GUILabel(new UDim2(0, 40, 1, -20), UDim2.Zero, "Health: --", TextAlign.BottomLeft, theme);
            ammoLabel         = new GUILabel(new UDim2(1, -50, 1, -25), UDim2.Zero, "", TextAlign.BottomRight, theme);
            crosshair         = new GUIFrame(new UDim2(0.5f, -28, 0.5f, -28), new UDim2(0, 56, 0, 56), crosshairImage);
            hitmarker         = new GUIFrame(new UDim2(0.5f, -43, 0.5f, -43), new UDim2(0, 86, 0, 86), hitmarkerImage);
            hitmarker.Visible = false;

            intelInHand = new GUIFrame(new UDim2(0.5f, -20, 0, 100), new UDim2(0, 40, 0, 40), new Image(intelTex));
            intelPickedUpNotification = new GUILabel(new UDim2(0.5f, 0, 0, 150), UDim2.Zero,
                                                     "You have picked up the intel!", TextAlign.TopCenter, theme);
            intelInHand.Visible = false;
            intelPickedUpNotification.Visible = false;

            crosshair.CapturesMouseClicks   = false;
            hitmarker.CapturesMouseClicks   = false;
            ammoLabel.CapturesMouseClicks   = false;
            healthLabel.CapturesMouseClicks = false;

            area.AddTopLevel(ammoLabel, healthLabel, crosshair, hitmarker, intelInHand, intelPickedUpNotification);
        }
        public SingleplayerScreen(MainWindow window)
            : base(window, "Singleplayer")
        {
            GUITheme theme = AssetManager.CreateDefaultGameTheme();

            theme.SetField("Font", AssetManager.LoadFont("arial-14"));

            menu           = new SingleplayerMenu(GUISystem, theme, Window);
            menu.OnClosed += Menu_OnClosed;

            GUISystem.Add(menu);
            Windows.Add(menu);
        }
예제 #4
0
        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);
        }
        public static GUITheme CreateDefaultGameTheme()
        {
            GUITheme theme      = GUITheme.Basic;
            string   guiPalette = "Textures/Gui/gui-palette.png";

            theme.SetField("Button.NormalImage", new BorderedImage(GLoader.LoadTexture(guiPalette), new Rectangle(0, 0, 66, 66)));
            theme.SetField("Button.HoverImage", new BorderedImage(GLoader.LoadTexture(guiPalette), new Rectangle(66, 0, 66, 66)));
            theme.SetField("Button.ActiveImage", new BorderedImage(GLoader.LoadTexture(guiPalette), new Rectangle(132, 0, 66, 66)));
            theme.SetField("Button.ToggledImage", Image.CreateBlank(new Color(194, 37, 37)));
            theme.SetField("Button.TextColor", Color.White);
            theme.SetField("TextField.NormalImage", new BorderedImage(GLoader.LoadTexture(guiPalette), new Rectangle(0, 66, 66, 66)));
            theme.SetField("TextField.HoverImage", new BorderedImage(GLoader.LoadTexture(guiPalette), new Rectangle(66, 66, 66, 66)));
            theme.SetField("TextField.ActiveImage", new BorderedImage(GLoader.LoadTexture(guiPalette), new Rectangle(132, 66, 66, 66)));
            theme.SetField("Label.TextColor", Color.White);
            theme.SetField("Label.TextShadowColor", new Color(0, 0, 0, 0.6f));
            theme.SetField("Frame.Image", Image.CreateBlank(new Color(30, 30, 30, 240)));
            theme.SetField("Window.BackgroundImage", Image.CreateBlank(new Color(30, 30, 30, 200)));
            theme.SetField("Window.TitleBar.BackgroundImage", Image.CreateBlank(new Color(31, 47, 70)));
            theme.SetField("Window.TitleBar.CloseButton.NormalImage", Image.CreateBlank(new Color(152, 34, 34)));
            theme.SetField("Window.TitleBar.CloseButton.HoverImage", Image.CreateBlank(new Color(135, 15, 15)));
            theme.SetField("Window.TitleBar.CloseButton.ActiveImage", Image.CreateBlank(new Color(188, 84, 84)));
            theme.SetField("SmallFont", LoadFont("arial-bold-12"));
            theme.SetField("Font", LoadFont("arial-14"));
            theme.SetField("BigFont", LoadFont("arial-18"));

            return(theme);
        }
        public MainMenuScreen(MainWindow mainWindow)
            : base(mainWindow, "MainMenu")
        {
            theme = AssetManager.CreateDefaultGameTheme();
            theme.SetField("SmallFont", AssetManager.LoadFont("arial-bold-14"));
            theme.SetField("Font", AssetManager.LoadFont("arial-16"));
            theme.SetField("BigFont", AssetManager.LoadFont("arial-20"));

            popup         = new MessageWindow(GUISystem, theme, new UDim2(0.1f, 0, 0.3f, 0), "Alert!");
            popup.MinSize = new UDim2(0, 215, 0, 200);
            popup.MaxSize = new UDim2(1f, 0, 0, 275);

            connectWindow                   = new ConnectWindow(GUISystem, theme, new UDim2(1f, 0, 1f, 0));
            connectWindow.MinSize           = new UDim2(0, 375, 0, 200);
            connectWindow.MaxSize           = new UDim2(0, 700, 0, 200);
            connectWindow.OnConnectPressed += ConnectWindow_OnConnectPressed;

            GUIFrame title = new GUIFrame(new UDim2(0.5f, -260, 0.2f, -40), new UDim2(0, 520, 0, 80),
                                          new Image(GLoader.LoadTexture("Textures/title.png")));

            GUIFrame btnFrame = new GUIFrame(new UDim2(0.5f, -200, 0.5f, -50), new UDim2(0, 400, 0, 110), theme);

            btnFrame.Image = null;

            GUIButton connectBtn = new GUIButton(new UDim2(0, 0, 0, 0), new UDim2(1f, 0, 0, 30), "Connect to a Server",
                                                 TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            connectBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    connectWindow.Visible = true;
                }
            };

            GUIButton controlsBtn = new GUIButton(new UDim2(0, 0, 0, 40), new UDim2(1f, 0, 0, 30), "View Controls",
                                                  TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            controlsBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Window.StaticGui.ToggleControlsWindow(true);
                }
            };

            GUIButton spBtn = new GUIButton(new UDim2(0, 0, 0, 80), new UDim2(1f, 0, 0, 30), "Start Singleplayer Test",
                                            TextAlign.Center, theme)
            {
                Parent = btnFrame
            };

            spBtn.OnMouseClick += (btn, mbtn) =>
            {
                if (mbtn == MouseButton.Left)
                {
                    Window.SwitchScreen("Singleplayer");
                }
            };

            GUIButton randomImageButton = new GUIButton(new UDim2(1f, -160, 1f, -40), new UDim2(0, 150, 0, 30),
                                                        "Random Image", theme);

            randomImageButton.OnMouseClick += (btn, mbtn) => { Window.StaticGui.ShowRandomBackgroundImage(); };

            GUIArea.AddTopLevel(title, randomImageButton, btnFrame);
            GUISystem.Add(connectWindow, popup);
            Windows.Add(connectWindow);
            Windows.Add(popup);
        }