public DebugInfo() { Button doneButton = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width / 2 - (WidgetsMap.EnabledButton.RegionWidth), MainGame.GlobalGraphicsDevice.Viewport.Height - 50, WidgetsMap.EnabledButton.RegionWidth * 2, WidgetsMap.EnabledButton.RegionHeight * 2), "Done", true); doneButton.Clicked += () => MainGame.manager.PushScreen(GameScreens.MAIN); Label TitleLabel = new Label("CatchLabel", "Here's some debug info :)", new Vector2(16, 10), Color.Gray); Label MC2DVer = new Label("MC2DVer", "* Minecraft 2D Version: " + MainGame.GameVersion.ToString(), new Vector2(20, 46), Color.Gray); Label NETVer = new Label("NETVer", "* .NET Version: " + Assembly .GetExecutingAssembly() .GetReferencedAssemblies() .Where(x => x.Name == "System.Core").First().Version.ToString(3), new Vector2(20, 62), Color.Gray); Label BlockCount = new Label("BlockCount", "* Total Loaded Blocks: " + PresetBlocks.TilesList.Count, new Vector2(20, 78), Color.Gray); Label WorkingDirectory = new Label("WorkingDirectory", "* Current Directory: " + Environment.CurrentDirectory, new Vector2(20, 94), Color.Gray); Label OSInfo = new Label("OSINFO", $"* OS Info: {Environment.OSVersion.Platform} {Environment.OSVersion.VersionString} 64 Bit: {Environment.Is64BitOperatingSystem}", new Vector2(20, 86 + 24), Color.Gray); #if DEBUG Label DEBUG = new Label("DEBUG", $"#if DEBUG defined", new Vector2(20, 86 + 48), Color.Gray); Label AboutDebugControls = new Label("AboutDebugControls", "When running in Debug, you can use the following controls for cool stuff\nF2: Screenshot\nF3: Toggle Debug Info\nF4: Toggle Lights\nAlt + F2: Screenshot w/out Lights", new Vector2(20, 86 + 48 + 24), Color.White); #endif //Label GPU = new Label("GPU", $"* GPU: ", new Vector2(20, 86 + 14 + 14), Color.Gray); AddControl(doneButton); AddControl(TitleLabel); AddControl(MC2DVer); AddControl(NETVer); AddControl(BlockCount); AddControl(WorkingDirectory); AddControl(OSInfo); #if DEBUG AddControl(DEBUG); AddControl(AboutDebugControls); #endif //AddControl(GPU); }
public TitleScreen() { ExitButton = new Button ( new Rectangle(MainGame.GlobalGraphicsDeviceManager.PreferredBackBufferWidth / 2 - (WidgetsMap.EnabledButton.RegionWidth), MainGame.GlobalGraphicsDeviceManager.PreferredBackBufferHeight - 120, WidgetsMap.EnabledButton.RegionWidth * 2, WidgetsMap.EnabledButton.RegionHeight * 2), "Exit" ); OptionsButton = new Button(new Rectangle(MainGame.GlobalGraphicsDeviceManager.PreferredBackBufferWidth / 2 - (WidgetsMap.EnabledButton.RegionWidth), MainGame.GlobalGraphicsDeviceManager.PreferredBackBufferHeight - 190, WidgetsMap.EnabledButton.RegionWidth * 2, WidgetsMap.EnabledButton.RegionHeight * 2), "Options"); PlayButton = new Button(new Rectangle(MainGame.GlobalGraphicsDeviceManager.PreferredBackBufferWidth / 2 - (WidgetsMap.EnabledButton.RegionWidth), MainGame.GlobalGraphicsDeviceManager.PreferredBackBufferHeight - 260, WidgetsMap.EnabledButton.RegionWidth * 2, WidgetsMap.EnabledButton.RegionHeight * 2), Directory.Exists(Path.Combine(MainGame.GameSaveDirectory, "World0")) ? "Load Saved World" : "Create New World"); PlayButton.Name = "PlayButton"; OptionsButton.Enabled = true; ExitButton.Clicked += ExitButton_Clicked; PlayButton.Clicked += () => { MainGame.manager.PushScreen(GameScreens.GAME, Directory.Exists(Path.Combine(MainGame.GameSaveDirectory, "World0")) ? 0 : -1); }; OptionsButton.Name = "OptionsButton"; OptionsButton.Clicked += () => { if (OptionsButton.ButtonText == "Options") MainGame.manager.PushScreen(GameScreens.OPTIONS); else MainGame.manager.PushScreen(GameScreens.DEBUGINFO); }; AddControl(ExitButton); AddControl(OptionsButton); AddControl(PlayButton); ran.Next(0, splashMessages.Length); ran.Next(0, splashMessages.Length); splashIndex = ran.Next(0, splashMessages.Length); }
/// <summary> /// Do NOT add labels with this /// </summary> /// <param name="ctrl1"></param> /// <param name="label"></param> public void AddButtonWithLabel(Button ctrl1, Label label) { ControlsList.Add(ctrl1); label.Position = new Rectangle(((Button)ctrl1).Position.X, ((Button)ctrl1).Position.Y - 20, label.Position.Width, label.Position.Height); ControlsList.Add(label); }
public OptionsScreen() { Button doneButton = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width / 2 - (WidgetsMap.EnabledButton.RegionWidth), MainGame.GlobalGraphicsDevice.Viewport.Height - 50, WidgetsMap.EnabledButton.RegionWidth * 2, WidgetsMap.EnabledButton.RegionHeight * 2), "Done", true); doneButton.Clicked += () => { Control f = ControlsList.Find(x => x.Name == "usrnametb"); if(f != null) { if(!String.IsNullOrEmpty(((TextBox)f).Content)) MainGame.GameOptions.Username = ((TextBox)f).Content.Trim(); else if(String.IsNullOrEmpty(MainGame.GameOptions.Username)) { MainGame.GameOptions.Username = $"Player{MainGame.RandomGenerator.Next(1000, 9000)}"; } } MainGame.manager.PushScreen(GameScreens.MAIN); }; #region Key mapping Button MoveLeftMod = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 580, MainGame.GlobalGraphicsDevice.Viewport.Height - 440, (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.MoveLeft.ToString()); MoveLeftMod.Clicked += () => { new Thread(()=> { while (MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys().Length == 0) { MoveLeftMod.ButtonText = "<waiting>"; } if (MainGame.GlobalInputHelper.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) MainGame.GameOptions.MoveLeft = Microsoft.Xna.Framework.Input.Keys.None; else { MainGame.GameOptions.MoveLeft = MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys()[0]; } MoveLeftMod.ButtonText = MainGame.GameOptions.MoveLeft.ToString(); }).Start(); }; Button MoveRightMod = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 380, MainGame.GlobalGraphicsDevice.Viewport.Height - 440, (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.MoveRight.ToString()); MoveRightMod.Clicked += () => { new Thread(() => { while (MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys().Length == 0) { MoveRightMod.ButtonText = "<waiting>"; } if (MainGame.GlobalInputHelper.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) MainGame.GameOptions.MoveRight = Microsoft.Xna.Framework.Input.Keys.None; else { MainGame.GameOptions.MoveRight = MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys()[0]; } MoveRightMod.ButtonText = MainGame.GameOptions.MoveRight.ToString(); }).Start(); }; Button MoveDownMod = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 580, MainGame.GlobalGraphicsDevice.Viewport.Height - 370, (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.MoveDown.ToString()); MoveDownMod.Clicked += () => { new Thread(() => { while (MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys().Length == 0) { MoveDownMod.ButtonText = "<waiting>"; } if (MainGame.GlobalInputHelper.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) MainGame.GameOptions.MoveDown = Microsoft.Xna.Framework.Input.Keys.None; else { MainGame.GameOptions.MoveDown = MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys()[0]; } MoveDownMod.ButtonText = MainGame.GameOptions.MoveDown.ToString(); }).Start(); }; Button MoveUpMod = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 380, MainGame.GlobalGraphicsDevice.Viewport.Height - 370, (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.MoveUp.ToString()); MoveUpMod.Clicked += () => { new Thread(() => { while (MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys().Length == 0) { MoveUpMod.ButtonText = "<waiting>"; } if (MainGame.GlobalInputHelper.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) MainGame.GameOptions.MoveUp = Microsoft.Xna.Framework.Input.Keys.None; else { MainGame.GameOptions.MoveUp = MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys()[0]; } MoveUpMod.ButtonText = MainGame.GameOptions.MoveUp.ToString(); }).Start(); }; Button JumpMod = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 470, MainGame.GlobalGraphicsDevice.Viewport.Height - 300, (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.JumpKey.ToString()); JumpMod.Clicked += () => { new Thread(() => { while (MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys().Length == 0) { JumpMod.ButtonText = "<waiting>"; } if (MainGame.GlobalInputHelper.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) MainGame.GameOptions.JumpKey = Microsoft.Xna.Framework.Input.Keys.None; else { MainGame.GameOptions.JumpKey = MainGame.GlobalInputHelper.CurrentKeyboardState.GetPressedKeys()[0]; } JumpMod.ButtonText = MainGame.GameOptions.JumpKey.ToString(); }).Start(); }; #endregion TextBox usernameTextBox = new TextBox(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 580, MainGame.GlobalGraphicsDevice.Viewport.Height - 230, 32 * 11, 32), true); usernameTextBox.Content = MainGame.GameOptions.Username; usernameTextBox.Name = "usrnametb"; Button FullscreenButton = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 580, MainGame.GlobalGraphicsDevice.Viewport.Height - (230 - 70), (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.Fullscreen.ToString()); //MainGame.GlobalGraphicsDevice.Viewport.Width - 580 //Button FullscreenButton = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 470, // MainGame.GlobalGraphicsDevice.Viewport.Height - (230 - 70), (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), MainGame.GameOptions.Fullscreen.ToString()); FullscreenButton.Clicked += () => { MainGame.GlobalGraphicsDeviceManager.IsFullScreen = !MainGame.GlobalGraphicsDeviceManager.IsFullScreen; MainGame.GlobalGraphicsDeviceManager.ApplyChanges(); MainGame.GameOptions.Fullscreen = MainGame.GlobalGraphicsDeviceManager.IsFullScreen; FullscreenButton.ButtonText = MainGame.GameOptions.Fullscreen.ToString(); }; //MainGame.GlobalGraphicsDevice.Viewport.Width - 380 Button DiscordButton = new Button(new Rectangle(MainGame.GlobalGraphicsDevice.Viewport.Width - 380, MainGame.GlobalGraphicsDevice.Viewport.Height - (230 - 70), (WidgetsMap.EnabledButton.RegionWidth * 2) - 256, WidgetsMap.EnabledButton.RegionHeight * 2), "Discord"); DiscordButton.Enabled = false; DiscordButton.Clicked += ()=> { usernameTextBox.IsPasswordField = !usernameTextBox.IsPasswordField; }; AddControl(doneButton); AddButtonWithLabel(MoveLeftMod, new Label(name: "lbl", text: "Move Left", pos: Vector2.Zero, tnt: Color.Gray)); AddButtonWithLabel(MoveRightMod, new Label(name: "lbl", text: "Move Right", pos: Vector2.Zero, tnt: Color.Gray)); AddButtonWithLabel(MoveUpMod, new Label(name: "lbl", text: "Move Up", pos: Vector2.Zero, tnt: Color.Gray)); AddButtonWithLabel(MoveDownMod, new Label(name: "lbl", text: "Move Down", pos: Vector2.Zero, tnt: Color.Gray)); AddButtonWithLabel(JumpMod, new Label(name: "lbl", text: "Jump", pos: Vector2.Zero, tnt: Color.Gray)); AddButtonWithLabel(FullscreenButton, new Label(name: "lbl", text: "Fullscreen", pos: Vector2.Zero, tnt: Color.Gray)); AddButtonWithLabel(DiscordButton, new Label(name: "lbl", text: "Coming soon!", pos: Vector2.Zero, tnt: Color.Gray)); AddTextBoxWithLabel(usernameTextBox, new Label(name: "lbl", text: "Username", pos: Vector2.Zero, tnt: Color.Gray)); }