private void Button2_Pressed(object sender, System.EventArgs e) { if (_gui.Screen.Desktop.Children.Any(i => i.Name == "window")) { return; } var window = new GuiWindowControl { Name = "window", Bounds = new UniRectangle(new UniVector(new UniScalar(0.5f, -100), new UniScalar(0.5f, -60)), new UniVector(new UniScalar(200), new UniScalar(120))), Title = "Color picker", EnableDragging = true }; var choice1 = new GuiChoiceControl { Name = "choiceBlack", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 30), new UniScalar(10), new UniScalar(10)), Text = "Black", Selected = true }; var choice2 = new GuiChoiceControl { Name = "choiceGray", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 45), new UniScalar(10), new UniScalar(10)), Text = "Gray", Selected = false }; var choice3 = new GuiChoiceControl { Name = "choiceWhite", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 60), new UniScalar(10), new UniScalar(10)), Text = "White", Selected = false }; var button1 = new GuiButtonControl { Name = "confirm", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(1.0f, -40), new UniScalar(0f, 80), new UniScalar(0f, 30)), Text = "Confirm" }; var button2 = new GuiButtonControl { Name = "cancel", Bounds = new UniRectangle(new UniScalar(1.0f, -90), new UniScalar(1.0f, -40), new UniScalar(0f, 80), new UniScalar(0f, 30)), Text = "Cancel" }; button1.Pressed += DialogueConfirm_Pressed; button2.Pressed += DialogueCancel_Pressed; window.Children.Add(choice1); window.Children.Add(choice2); window.Children.Add(choice3); window.Children.Add(button1); window.Children.Add(button2); _gui.Screen.Desktop.Children.Add(window); }
public static GuiManager CreateHighScoresGui(GameCore game, GuiManager highScoresGui, InputListenerComponent inputManager) { //Create gui var guiInputService = new GuiInputService(inputManager); highScoresGui = new GuiManager(game.Services, guiInputService); highScoresGui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); highScoresGui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); //Create back button var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = (GameCore.WINDOW_HEIGHT - 70); var backButton = new GuiButtonControl { Name = "Back", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Back" }; backButton.Pressed += game.BackButtonPressed; highScoresGui.Screen.Desktop.Children.Add(backButton); highScoresGui.Initialize(); return(highScoresGui); }
protected override void Initialize() { base.Initialize(); // Create a GUI screen and attach it as a default to GuiManager. // That screen will also act as a root parent for every other control that we create. _gui.Screen = new GuiScreen(800, 480); _gui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); // Perform second-stage initialization _gui.Initialize(); // Create few controls. var button = new GuiButtonControl { Name = "button", Bounds = new UniRectangle(new UniScalar(0.0f, 20), new UniScalar(0.0f, 20), new UniScalar(0f, 120), new UniScalar(0f, 50)), Text = "Rotate logo" }; var button2 = new GuiButtonControl { Name = "button2", Bounds = new UniRectangle(new UniScalar(20), new UniScalar(80), new UniScalar(120), new UniScalar(50)), Text = "Open Window" }; // Attach relevant events button.Pressed += Button_Pressed; button2.Pressed += Button2_Pressed; // And finally, attach controls to the parent control. In this case, desktop screen. _gui.Screen.Desktop.Children.Add(button); _gui.Screen.Desktop.Children.Add(button2); }
private void Initialize() { this.Bounds = new UniRectangle(new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, 1.0f), new UniScalar(1.0f, 1.0f)); _mainMenuButton = new GuiButtonControl { Name = "MainMenuButton", Bounds = new UniRectangle(new UniScalar(0.9f, -30), new UniScalar(0.9f, 20), 100, 24), Text = "Main Menu" }; _mainMenuButton.Pressed += (sender, e) => { GameController.Instance.MainMenu(); }; _optionsButton = new GuiButtonControl { Name = "OptionsButton", Bounds = new UniRectangle(new UniScalar(0.9f, -30), new UniScalar(0.9f, -8), 100, 24), Text = "Options" }; _optionsButton.Pressed += Options; Children.Add(_mainMenuButton); Children.Add(_optionsButton); _optionsWindow = new GuiWindowControl() { Name = "OptionsWindow", Bounds = new UniRectangle( new UniScalar(0.3f, 0.0f), new UniScalar(0.3f, 0.0f), new UniScalar(0.3f, 0.0f), new UniScalar(0.3f, 0.0f)), Title = "Options" }; }
public MenuScene() { this.Bounds = new UniRectangle( new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); this.EnableDragging = false; this.Title = "Меню"; UniVector size = new UniVector( new UniScalar(0.8f, 0), new UniScalar(0.1f, 0)); UniVector location = new UniVector( new UniScalar(0.1f, 0), new UniScalar(0.6f, 0)); this.BtnStart = new GuiButtonControl { Name = "btnStart", Bounds = new UniRectangle(location, size), Text = "Новая игра" }; size = new UniVector( new UniScalar(0.8f, 0), new UniScalar(0.1f, 0)); location = new UniVector( new UniScalar(0.1f, 0), new UniScalar(0.1f, 0)); this.TbNickName = new GuiInputControl { Name = "tbNickName", Bounds = new UniRectangle(location, size), Text = NickPlaceholder }; size = new UniVector( new UniScalar(0.8f, 0), new UniScalar(0.1f, 0)); location = new UniVector( new UniScalar(0.1f, 0), new UniScalar(0.2f, 0)); this.BtnSaveNick = new GuiButtonControl { Name = "BtnSaveNick", Bounds = new UniRectangle(location, size), Text = "Сохранить" }; this.Children.Add(this.BtnStart); this.Children.Add(this.TbNickName); this.Children.Add(this.BtnSaveNick); }
public static GuiManager CreateTitleGui(GameCore game, GuiManager titleGui, InputListenerComponent inputManager) { //Create GUI var guiInputService = new GuiInputService(inputManager); titleGui = new GuiManager(game.Services, guiInputService); titleGui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); titleGui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); titleGui.Initialize(); //Create buttons var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = 200; var buttonDivider = 100; var StartButton = new GuiButtonControl { Name = "Start", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Start" }; var HighScoresButton = new GuiButtonControl { Name = "HighScores", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY + buttonDivider), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "High Scores" }; var ExitButton = new GuiButtonControl { Name = "Exit", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY + (buttonDivider * 2)), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Exit" }; //Add functon to pressed StartButton.Pressed += game.StartButtonPressed; HighScoresButton.Pressed += game.HighScoresButtonPressed; ExitButton.Pressed += game.ExitButtonPressed; //Add buttons to gui titleGui.Screen.Desktop.Children.Add(StartButton); titleGui.Screen.Desktop.Children.Add(HighScoresButton); titleGui.Screen.Desktop.Children.Add(ExitButton); return(titleGui); }
private void Initialize() { this.Bounds = new UniRectangle(new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, 1.0f), new UniScalar(1.0f, 1.0f)); _button = new GuiButtonControl { Name = "button", Bounds = new UniRectangle(new UniScalar(0.5f, -125), new UniScalar(0.5f, -60), 250, 120), Text = "Start Game" }; _button.Pressed += (sender, e) => { GameController.Instance.StartGame(); }; Children.Add(_button); }
public TitleState() { background = AppContentManager.Load <Texture2D>("Title/Title"); if (gui == null) { inputListener = new InputListenerComponent(GameApp); inputManager = new MonoGame.Extended.NuclexGui.GuiInputService(inputListener); gui = new GuiManager(GameApp.Services, inputManager); gui.Initialize(); } gui.Screen = new GuiScreen(); btnStartGame = new GuiButtonControl { Name = "Start Game", Bounds = new UniRectangle(new UniVector(new UniScalar(540), new UniScalar(200)), new UniVector(new UniScalar(200), new UniScalar(70))), Text = "Start Game" }; btnQuitGame = new GuiButtonControl { Name = "Quit Game", Bounds = new UniRectangle(new UniVector(new UniScalar(540), new UniScalar(300)), new UniVector(new UniScalar(200), new UniScalar(70))), Text = "Quit Game" }; btnQuitGame.Pressed += BtnQuitGame_Pressed; gui.Screen.Desktop.Children.Add(btnQuitGame); windowStarting = new GuiWindowControl() { Name = "Starting", Bounds = new UniRectangle(new UniVector(new UniScalar(240), new UniScalar(200)), new UniVector(new UniScalar(800), new UniScalar(100))), Title = "Starting Game..." }; btnStartGame.Pressed += OnStartGamePressed; gui.Screen.Desktop.Children.Add(btnStartGame); lblStatus = new GuiLabelControl() { Bounds = new UniRectangle(new UniVector(new UniScalar(10), new UniScalar(0)), new UniVector(new UniScalar(800), new UniScalar(100))), Text = "" }; windowStarting.Children.Add(lblStatus); }
/// <summary> /// Create a game interface from a given game /// </summary> /// <param name="Game">Game object that is being played</param> public GameState(Game.Game Game, Microsoft.Xna.Framework.Game MonogameGame) { this.G = Game; this.G.TellStory = ShowStory; MapTileSprites = AppContentManager.Load <Texture2D>("MapTiles"); PCSprites = AppContentManager.Load <Texture2D>("CharacterSprites"); MomentumSprite = AppContentManager.Load <Texture2D>("UiElements/MomentumMarker"); SpentMomentumSprite = AppContentManager.Load <Texture2D>("UiElements/SpentMomentumMarker"); HpSprite = AppContentManager.Load <Texture2D>("UiElements/HpMarker"); MovementArrowsSprite = AppContentManager.Load <Texture2D>("UiElements/Arrows"); MonsterDetailsFont = AppContentManager.Load <SpriteFont>("UiElements/MonsterDisplay"); StateFont = AppContentManager.Load <SpriteFont>("UiElements/TurnState"); arrowWidth = MovementArrowsSprite.Width / 9; arrowHeight = MovementArrowsSprite.Height / 3; minimap = new Minimap(Game, MonogameGame); minimap.showCrime = true; gui.Screen = new GuiScreen(); storyWindow = new GuiWindowControl() { Name = "StoryWindow", Bounds = new UniRectangle(new UniVector(new UniScalar(190), new UniScalar(200)), new UniVector(new UniScalar(900), new UniScalar(200))), }; storyText = new GuiLabelControl() { Name = "StoryText", Bounds = new UniRectangle(new UniVector(new UniScalar(10), new UniScalar(0)), new UniVector(new UniScalar(500), new UniScalar(120))), }; storyWindow.Children.Add(storyText); storyButton = new GuiButtonControl() { Bounds = new UniRectangle(new UniVector(new UniScalar(375), new UniScalar(120)), new UniVector(new UniScalar(150), new UniScalar(70))), Text = "Continue" }; storyWindow.Children.Add(storyButton); storyButton.Pressed += StoryButton_Pressed; G.StartGame(); }
public static GuiManager CreateInputHighScoreGui(GameCore game, GuiManager inputHighScoreGui, InputListenerComponent inputManager) { //Create gui var guiInputService = new GuiInputService(inputManager); inputHighScoreGui = new GuiManager(game.Services, guiInputService); inputHighScoreGui.Screen = new GuiScreen(GameCore.SCREEN_WIDTH, GameCore.SCREEN_HEIGHT); inputHighScoreGui.Screen.Desktop.Bounds = new UniRectangle(new UniScalar(0f, 0), new UniScalar(0f, 0), new UniScalar(1f, 0), new UniScalar(1f, 0)); //Create Submit button var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = (GameCore.WINDOW_HEIGHT - 200); var submitButton = new GuiButtonControl { Name = "Submit", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Submit" }; var inputWidth = 200; var inputHeight = 20; var inputX = (GameCore.WINDOW_WIDTH / 2) - (inputWidth / 2); var inputY = (GameCore.WINDOW_HEIGHT - 400); var textInput = new GuiInputControl { Name = "Text Input", Bounds = new UniRectangle(new UniScalar(inputX), new UniScalar(inputY), new UniScalar(inputWidth), new UniScalar(inputHeight)), Text = "Name" }; submitButton.Pressed += game.SubmitButtonPressed; inputHighScoreGui.Screen.Desktop.Children.Add(submitButton); inputHighScoreGui.Screen.Desktop.Children.Add(textInput); inputHighScoreGui.Initialize(); return(inputHighScoreGui); }
public void CreateTitleGui() { gui.Screen.Desktop.Children.Clear(); //Create buttons var buttonWidth = 150; var buttonHeight = 50; var buttonX = (GameCore.WINDOW_WIDTH / 2) - (buttonWidth / 2); var buttonY = 200; var buttonDivider = 100; var StartButton = new GuiButtonControl { Name = "Start", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Start" }; var HighScoresButton = new GuiButtonControl { Name = "HighScores", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY + buttonDivider), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "High Scores" }; var ExitButton = new GuiButtonControl { Name = "Exit", Bounds = new UniRectangle(new UniScalar(buttonX), new UniScalar(buttonY + (buttonDivider * 2)), new UniScalar(buttonWidth), new UniScalar(buttonHeight)), Text = "Exit" }; //Add functon to pressed StartButton.Pressed += StartButtonPressed; HighScoresButton.Pressed += HighScoresButtonPressed; ExitButton.Pressed += ExitButtonPressed; //Add buttons to gui gui.Screen.Desktop.Children.Add(StartButton); gui.Screen.Desktop.Children.Add(HighScoresButton); gui.Screen.Desktop.Children.Add(ExitButton); }
public MessageScene() { this.Bounds = new UniRectangle( new UniScalar(0.1f, 0), new UniScalar(0.2f, 0), new UniScalar(0.8f, 0), new UniScalar(0.6f, 0)); this.EnableDragging = true; this.Title = "Сообщение"; UniVector size = new UniVector( new UniScalar(0.8f, 0), new UniScalar(0.55f, 0)); UniVector location = new UniVector( new UniScalar(0.1f, 0), new UniScalar(0.15f, 0)); this.LbText = new GuiLabelControl { Name = "LbText", Bounds = new UniRectangle(location, size) }; size = new UniVector( new UniScalar(0.8f, 0), new UniScalar(0.2f, 0)); location = new UniVector( new UniScalar(0.1f, 0), new UniScalar(0.75f, 0)); this.BtnOk = new GuiButtonControl { Name = "btnOk", Bounds = new UniRectangle(location, size), Text = "OK" }; this.BtnOk.Pressed += (sender, e) => this.Close(); this.Children.Add(this.LbText); this.Children.Add(this.BtnOk); }
public DeadState(Game.Game g) { this.g = g; gui.Screen = new GuiScreen(); gui.Initialize(); btnTitle = new GuiButtonControl { Name = "Return to title", Bounds = new UniRectangle(new UniVector(new UniScalar(490), new UniScalar(600)), new UniVector(new UniScalar(300), new UniScalar(70))), Text = "Return to title" }; btnTitle.Pressed += BtnTitle_Pressed; gui.Screen.Desktop.Children.Add(btnTitle); if (g.DeadZulu) { background = AppContentManager.Load <Texture2D>("Title/Victory"); DeathText = $@"Zulu has fallen, and the denizens of New London are at peace once more. You slayed {g.DeadLackeys} of Zulu's lackeys. You slayed {g.DeadKnifes} of Zulu's cutters. You slayed {g.DeadBrutes} of Zulu's brutes. Zulu has been slain."; } else { background = AppContentManager.Load <Texture2D>("Title/Gameover"); DeathText = $@"Your vegeance was not satisfied. The city of New London remains under the criminal guard of Zulu. You slayed {g.DeadLackeys} of Zulu's lackeys. You slayed {g.DeadKnifes} of Zulu's cutters. You slayed {g.DeadBrutes} of Zulu's brutes. Zulu remains alive."; } DeathFont = AppContentManager.Load <SpriteFont>("GameOverFont"); }
private void Button3_Pressed(object sender, EventArgs e) { if (_gui.Screen.Desktop.Children.Any(i => i.Name == "window")) { return; } var window = new GuiWindowControl { Name = "window", Bounds = new UniRectangle(new UniVector(new UniScalar(0.5f, -100), new UniScalar(0.5f, -60)), new UniVector(new UniScalar(200), new UniScalar(160))), Title = "Labels with Styles", EnableDragging = true }; var labelTitle = new GuiLabelControl { Name = "label-title", Bounds = new UniRectangle(new UniScalar(10), new UniScalar(45), new UniScalar(10), new UniScalar(10)), Text = "Title", Style = "label-title" }; var label1 = new GuiLabelControl { Name = "label1", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 70), new UniScalar(10), new UniScalar(10)), Text = "Heading 1", Style = "label-h1", }; var label2 = new GuiLabelControl { Name = "label2", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 90), new UniScalar(10), new UniScalar(10)), Text = "Heading 2", Style = "label-h2", }; var label3 = new GuiLabelControl { Name = "label3", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(0.0f, 105), new UniScalar(10), new UniScalar(10)), Text = "Heading 3", Style = "label-h3" }; var button1 = new GuiButtonControl { Name = "confirm", Bounds = new UniRectangle(new UniScalar(0.0f, 10), new UniScalar(1.0f, -40), new UniScalar(0f, 80), new UniScalar(0f, 30)), Text = "Confirm" }; var button2 = new GuiButtonControl { Name = "cancel", Bounds = new UniRectangle(new UniScalar(1.0f, -90), new UniScalar(1.0f, -40), new UniScalar(0f, 80), new UniScalar(0f, 30)), Text = "Cancel" }; button1.Pressed += DialogueConfirm_Pressed; button2.Pressed += DialogueCancel_Pressed; window.Children.Add(labelTitle); window.Children.Add(label1); window.Children.Add(label2); window.Children.Add(label3); window.Children.Add(button1); window.Children.Add(button2); _gui.Screen.Desktop.Children.Add(window); }