private void LoadUI() { components = new List <Control>(); // Load "Back to menu" button SpriteFont buttonFont = GameRoot.ContentMgr.Load <SpriteFont>("Fonts/DefaultFont"); ButtonPack buttonPack = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BackButton"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BackButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BackButtonSelected") }; int returnButtonMargin = 10; Vector2 returnButtonDimensions = new Vector2(80, 40); returnButton = new Button(isOriginAtCenter: false, buttonPack) { Text = "Back", Dimensions = returnButtonDimensions, Position = new Vector2(Constants.SCREEN_WIDTH - returnButtonDimensions.X - returnButtonMargin, returnButtonMargin) }; returnButton.Click += ReturnButton_Click; // Load Options Panel string panelTitle = "Options"; Vector2 panelAnchor = new Vector2(100, 50); Color panelFontColor = Color.White; Color panelBgColor = new Color(20, 20, 20); uiOptionsPanel = new PanelContainer(panelAnchor, panelTitle, panelFontColor, panelBgColor) { ControlMargin = 15, Padding = new Vector2(10, 10), Moveable = true }; ConstructButtons_OptionsPanel(buttonFont); ConstructLabels_OptionsPanel(); ConstructTextBox_OptionsPanel(buttonFont); ConstructCheckboxes_OptionsPanel(); // Load Node Details Panel panelTitle = "Node information"; panelAnchor = new Vector2(Constants.SCREEN_WIDTH - 220, 60); uiNodeInfoPanel = new PanelContainer(panelAnchor, panelTitle, panelFontColor, panelBgColor) { ControlMargin = 15, Padding = new Vector2(10, 10), Moveable = true }; ConstructLabels_NodeInfoPanel(); components.Add(uiOptionsPanel); components.Add(uiNodeInfoPanel); components.Add(returnButton); }
private void ConstructButtons_OptionsPanel(SpriteFont buttonFont) { ButtonPack buttonPack = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/Button"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/ButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/ButtonSelected") }; Button startPathfinder = new Button(isOriginAtCenter: false, buttonPack) { Text = BUTTON_STRINGS["start"] }; startPathfinder.Click += StartPathfinder_Click; Button resetPathfinder = new Button(isOriginAtCenter: false, buttonPack) { Text = BUTTON_STRINGS["reset"] }; resetPathfinder.Click += ResetPathfinder_Click; uiOptionsPanel.Add(startPathfinder); uiOptionsPanel.Add(resetPathfinder); }
private void ConstructButtons() { SpriteFont buttonFont = GameRoot.ContentMgr.Load <SpriteFont>("Fonts/DefaultFont"); ButtonPack buttonPackDefault = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/Button"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/ButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/ButtonSelected") }; ButtonPack buttonPackBig = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BigButton"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BigButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BigButtonSelected") }; Vector2 buttonsAnchor = new Vector2(Constants.SCREEN_WIDTH / 2, Constants.SCREEN_HEIGHT / 2); Button loadScenarioButton = new Button(isOriginAtCenter: true, buttonPackDefault) { Position = buttonsAnchor + new Vector2(0, -60), Dimensions = DEFAULT_BUTTON_SIZE, Text = BUTTON_STRINGS["load"] }; loadScenarioButton.Click += LoadScenarioButton_Click; Button scenarioEditorButton = new Button(isOriginAtCenter: true, buttonPackBig) { Position = buttonsAnchor + new Vector2(0, 0), Dimensions = DEFAULT_BUTTON_SIZE + new Vector2(0, 20), // Temporary +(0, 20) while it says "Coming Soon" Text = BUTTON_STRINGS["editor"] }; // Deactivated for v0.1.0 // scenarioEditorButton.Click += ScenarioEditorButton_Click; Button exitButton = new Button(isOriginAtCenter: true, buttonPackDefault) { Position = buttonsAnchor + new Vector2(0, 60), Dimensions = DEFAULT_BUTTON_SIZE, Text = BUTTON_STRINGS["exit"] }; exitButton.Click += ExitButton_Click; components = new List <Control>() { loadScenarioButton, scenarioEditorButton, exitButton }; }
public void LoadUI() { Texture = GameRoot.ContentMgr.Load <Texture2D>("Controls/PanelBackground"); ButtonPack buttonPack = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/SquareButton"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/SquareButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/SquareButtonSelected") }; pageLeft = new Button(isOriginAtCenter: true, buttonPack) { Text = "<", Position = new Vector2(Area.X + ButtonMargin, Area.Y + Area.Height - ButtonMargin), Dimensions = new Vector2(ButtonSize), IsEnabled = false }; pageLeft.Click += PageLeft_Click; pageRight = new Button(isOriginAtCenter: true, buttonPack) { Text = ">", Position = new Vector2(Area.X + Area.Width - ButtonMargin, Area.Y + Area.Height - ButtonMargin), Dimensions = new Vector2(ButtonSize), IsEnabled = false }; pageRight.Click += PageRight_Click; currentPageLabel = new Label("Page 1") { Position = new Vector2(Area.X + (Area.Width / 2), Area.Y + Area.Height - ButtonMargin) }; // Label needs to be constructed first, so that its dimensions get calculated internally currentPageLabel.Position -= new Vector2(currentPageLabel.Dimensions.X / 2, currentPageLabel.Dimensions.Y / 2); titleLabel = new Label("Select scenario") { Position = new Vector2(Area.X + TitleMargin, Area.Y + TitleMargin) }; components = new List <Control>() { pageLeft, pageRight, currentPageLabel, titleLabel }; }
private void LoadUI() { preview = new PreviewWindow(new Rectangle((Constants.SCREEN_WIDTH - PREVIEW_SPL_TOTAL_WIDTH) / 2, (Constants.SCREEN_HEIGHT - PREVIEW_SPL_HEIGHT) / 2, PREVIEW_WIDTH, PREVIEW_SPL_HEIGHT), Color.White); spl = new ScenarioPaginatedList(new Rectangle(preview.Area.X + preview.Area.Width, preview.Area.Y, SPL_WIDTH, PREVIEW_SPL_HEIGHT), Color.DimGray, loader); PaginatedListItem.ContainerArea = spl.Area; spl.ScenarioSelected += Spl_ScenarioSelected; preview.LoadRequested += Preview_LoadRequested; SpriteFont buttonFont = GameRoot.ContentMgr.Load <SpriteFont>("Fonts/DefaultFont"); ButtonPack buttonPack = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BackButton"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BackButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/BackButtonSelected") }; // Load "Back to menu" button int returnButtonMargin = 10; returnButton = new Button(isOriginAtCenter: false, buttonPack) { Text = BACK_STRING, Dimensions = BACK_BUTTON_SIZE, Position = new Vector2(Constants.SCREEN_WIDTH - BACK_BUTTON_SIZE.X - returnButtonMargin, returnButtonMargin) }; returnButton.Click += ReturnButton_Click; components = new List <Control> { returnButton }; }
private void LoadUI() { Texture = GameRoot.ContentMgr.Load <Texture2D>("Controls/PanelBackground"); SpriteFont font = GameRoot.ContentMgr.Load <SpriteFont>("Fonts/DefaultFont"); ButtonPack buttonPack = new ButtonPack() { TexDefault = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/Button"), TexHovered = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/ButtonHovered"), TexSelected = GameRoot.ContentMgr.Load <Texture2D>("Controls/Buttons/ButtonSelected") }; LoadButton = new Button(isOriginAtCenter: true, buttonPack) { Text = PREVIEW_STRINGS["load"], Position = new Vector2(Area.X + (Area.Width / 2) - (Button.DEFAULT_WIDTH / 2) - MarginSides, Area.Y + Area.Height - MarginBottom) }; LoadButton.Click += LoadButton_Click; DeleteButton = new Button(isOriginAtCenter: true, buttonPack) { Text = PREVIEW_STRINGS["delete"], Position = new Vector2(Area.X + (Area.Width / 2) + (Button.DEFAULT_WIDTH / 2) + MarginSides, Area.Y + Area.Height - MarginBottom) }; DeleteButton.Click += DeleteButton_Click; string labelStr = PREVIEW_STRINGS["previewInfo"]; PreviewLabel = new Label(labelStr) { Position = new Vector2(Area.X + (Area.Width / 2) - (font.MeasureString(labelStr).X / 2), Area.Y + (Area.Height / 2) - (font.MeasureString(labelStr).Y / 2) - MarginBottom), TextColor = Color.Black }; }