public void checkMenuControlMouseClick(GameUpdateClassComponents curGameUpdateComponents) { bool _exitMenuClicked = false; bool _continueClicked = false; bool _exitGalaxyMenuClicked = false; bool _continueToFactionClicked = false; //Run through each Menu foreach (Controls.FancyMenuControl curMenu in activeStartMenuMenus) { if (!curMenu._isNull) { //Run through each Button foreach (Controls.FancyButtonControl curButton in curMenu.menuButtons) { if (!curButton._isNull) { if(curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnExitFactionMenu") {//Clicked Exit Faction form _exitMenuClicked = true; } if (curButton.ID == "btnExitSettings") {//Clicked Exit Faction form _exitMenuClicked = true; } if (curButton.ID == "btnExitGalaxyMenu") {//Clicked Exit Galaxy _exitGalaxyMenuClicked = true; } if (curButton.ID == "btnContinue") {//Clicked Exit Faction form _continueClicked = true; } if (curButton.ID == "btnExitUserName") {//Clicked Exit Faction form _exitMenuClicked = true; } if (curButton.ID == "btnContinueToSelectFaction") {//Clicked Continue to Faction form _continueToFactionClicked = true; } } } } //Run through each Radio Button Control foreach (Controls.FancyRadioButtonsControl curRadioButtonControl in curMenu.menuRadioButtonControls) { if (!curRadioButtonControl._isNull) { int buttonCount = curRadioButtonControl.strControlText.Count; float buttonX = curRadioButtonControl.vectorPos.X; float buttonY = curRadioButtonControl.vectorPos.Y; float pixelButtonPadding = curRadioButtonControl.pxlHeightBetweenButtons; int i = 0; foreach (KeyValuePair<string, string> kvp in curRadioButtonControl.strControlText) { if (curRadioButtonControl.mouseClicked(curGameUpdateComponents, buttonY)) { curRadioButtonControl._selectedIndex = i; curRadioButtonControl._selectedValue = kvp.Value; selectedFaction = kvp.Value; } //Bump Down the next button (If there is one!) buttonY += pixelButtonPadding + curRadioButtonControl.imgControlUnchecked.Height; i++; } } } } } if (_exitMenuClicked) { activeStartMenuMenus.Clear(); //_isOnStartScreen = true; //_txtEnterUserName = null; curGameUpdateComponents._Components.Remove(_txtEnterUserName); _txtEnterUserName = null; //Wrongidty Wrong wrong! You check this value again after this check dufus //_startMenu._isEnabled = true; enableStartMenu = true; } if (_continueClicked) { if (selectedFaction != "") { activeStartMenuMenus.Clear(); _startMenu.Hide(); startNewGame = true; } } if (_exitGalaxyMenuClicked) { activeStartMenuMenus.Clear(); } if (_continueToFactionClicked) { if (_txtEnterUserName.Text != "") { activeStartMenuMenus.Clear(); enteredUserName = _txtEnterUserName.Text; curGameUpdateComponents._Components.Remove(_txtEnterUserName); _txtEnterUserName = null; _startMenu._isEnabled = false; ///////////////////////////////// //Create Select Faction Menu ////////////////////////////////// Texture2D curTexture = curGameUpdateComponents._Content.Load<Texture2D>("300x300_Window"); Vector2 curVector = new Vector2(100, 100); Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.FancyMenuControl curMenuControl = new Controls.FancyMenuControl(); //Start Menu Button List List<Controls.FancyButtonControl> menuButtons = new List<Controls.FancyButtonControl>(); //Get Continue Button Settings Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnContinue", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Continue...")); //Add the Exit Button curButtonVector = new Vector2(260, 340); curButtonRect = new Rectangle(260, 340, 130, 50); menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnExitFactionMenu", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Exit")); ///////////////////////////////// //Create Radio Button List ////////////////////////////////// List<Controls.FancyRadioButtonsControl> menuRadioButtons = new List<Controls.FancyRadioButtonsControl>(); Texture2D curRadioUncheckedTexture = curGameUpdateComponents._Content.Load<Texture2D>("205x30_RadioButton_Unchecked"); Texture2D curRadioCheckedTexture = curGameUpdateComponents._Content.Load<Texture2D>("205x30_RadioButton_Checked"); Vector2 curRadioVector = new Vector2(110, 160); Rectangle curRadioRect = new Rectangle(100, 100, 205, 30); Dictionary<string, string> strFactionList = new Dictionary<string, string>(); strFactionList = Model.DataUtilities.getFactionsDictionaryFromXML(); Controls.FancyRadioButtonsControl curFRBC = new Controls.FancyRadioButtonsControl(); curFRBC = new Controls.FancyRadioButtonsControl("rdBtnFactionList", curRadioUncheckedTexture, curRadioCheckedTexture, 10, curRadioVector, curRadioRect, strFactionList); menuRadioButtons.Add(curFRBC); //Create the Menu Control curMenuControl = new GalacticConquest.Controls.FancyMenuControl("mnuSelectFaction", curTexture, curVector, curRect, "Select a Faction: ", "...Faction List Here...", menuButtons, menuRadioButtons); //Add menu control to list activeStartMenuMenus.Add(curMenuControl); } } }
public void checkMenuControlMouseClick(GameUpdateClassComponents curGameUpdateComponents) { bool _exitMenuClicked = false; bool _continueClicked = false; bool _exitGalaxyMenuClicked = false; bool _continueToFactionClicked = false; //Run through each Menu foreach (Controls.FancyMenuControl curMenu in activeStartMenuMenus) { if (!curMenu._isNull) { //Run through each Button foreach (Controls.FancyButtonControl curButton in curMenu.menuButtons) { if (!curButton._isNull) { if (curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnExitFactionMenu") {//Clicked Exit Faction form _exitMenuClicked = true; } if (curButton.ID == "btnExitSettings") {//Clicked Exit Faction form _exitMenuClicked = true; } if (curButton.ID == "btnExitGalaxyMenu") {//Clicked Exit Galaxy _exitGalaxyMenuClicked = true; } if (curButton.ID == "btnContinue") {//Clicked Exit Faction form _continueClicked = true; } if (curButton.ID == "btnExitUserName") {//Clicked Exit Faction form _exitMenuClicked = true; } if (curButton.ID == "btnContinueToSelectFaction") {//Clicked Continue to Faction form _continueToFactionClicked = true; } } } } //Run through each Radio Button Control foreach (Controls.FancyRadioButtonsControl curRadioButtonControl in curMenu.menuRadioButtonControls) { if (!curRadioButtonControl._isNull) { int buttonCount = curRadioButtonControl.strControlText.Count; float buttonX = curRadioButtonControl.vectorPos.X; float buttonY = curRadioButtonControl.vectorPos.Y; float pixelButtonPadding = curRadioButtonControl.pxlHeightBetweenButtons; int i = 0; foreach (KeyValuePair <string, string> kvp in curRadioButtonControl.strControlText) { if (curRadioButtonControl.mouseClicked(curGameUpdateComponents, buttonY)) { curRadioButtonControl._selectedIndex = i; curRadioButtonControl._selectedValue = kvp.Value; selectedFaction = kvp.Value; } //Bump Down the next button (If there is one!) buttonY += pixelButtonPadding + curRadioButtonControl.imgControlUnchecked.Height; i++; } } } } } if (_exitMenuClicked) { activeStartMenuMenus.Clear(); //_isOnStartScreen = true; //_txtEnterUserName = null; curGameUpdateComponents._Components.Remove(_txtEnterUserName); _txtEnterUserName = null; //Wrongidty Wrong wrong! You check this value again after this check dufus //_startMenu._isEnabled = true; enableStartMenu = true; } if (_continueClicked) { if (selectedFaction != "") { activeStartMenuMenus.Clear(); _startMenu.Hide(); startNewGame = true; } } if (_exitGalaxyMenuClicked) { activeStartMenuMenus.Clear(); } if (_continueToFactionClicked) { if (_txtEnterUserName.Text != "") { activeStartMenuMenus.Clear(); enteredUserName = _txtEnterUserName.Text; curGameUpdateComponents._Components.Remove(_txtEnterUserName); _txtEnterUserName = null; _startMenu._isEnabled = false; ///////////////////////////////// //Create Select Faction Menu ////////////////////////////////// Texture2D curTexture = curGameUpdateComponents._Content.Load <Texture2D>("300x300_Window"); Vector2 curVector = new Vector2(100, 100); Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.FancyMenuControl curMenuControl = new Controls.FancyMenuControl(); //Start Menu Button List List <Controls.FancyButtonControl> menuButtons = new List <Controls.FancyButtonControl>(); //Get Continue Button Settings Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnContinue", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Continue...")); //Add the Exit Button curButtonVector = new Vector2(260, 340); curButtonRect = new Rectangle(260, 340, 130, 50); menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnExitFactionMenu", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Exit")); ///////////////////////////////// //Create Radio Button List ////////////////////////////////// List <Controls.FancyRadioButtonsControl> menuRadioButtons = new List <Controls.FancyRadioButtonsControl>(); Texture2D curRadioUncheckedTexture = curGameUpdateComponents._Content.Load <Texture2D>("205x30_RadioButton_Unchecked"); Texture2D curRadioCheckedTexture = curGameUpdateComponents._Content.Load <Texture2D>("205x30_RadioButton_Checked"); Vector2 curRadioVector = new Vector2(110, 160); Rectangle curRadioRect = new Rectangle(100, 100, 205, 30); Dictionary <string, string> strFactionList = new Dictionary <string, string>(); strFactionList = Model.DataUtilities.getFactionsDictionaryFromXML(); Controls.FancyRadioButtonsControl curFRBC = new Controls.FancyRadioButtonsControl(); curFRBC = new Controls.FancyRadioButtonsControl("rdBtnFactionList", curRadioUncheckedTexture, curRadioCheckedTexture, 10, curRadioVector, curRadioRect, strFactionList); menuRadioButtons.Add(curFRBC); //Create the Menu Control curMenuControl = new GalacticConquest.Controls.FancyMenuControl("mnuSelectFaction", curTexture, curVector, curRect, "Select a Faction: ", "...Faction List Here...", menuButtons, menuRadioButtons); //Add menu control to list activeStartMenuMenus.Add(curMenuControl); } } }
////////////////////////////// //Methods for Checking Input ////////////////////////////// public void checkStartScreenMouseClick(GameUpdateClassComponents curGameUpdateComponents) { //Check Start Menu Menu popups first checkMenuControlMouseClick(curGameUpdateComponents); //Check Textboxes Second ??? // checks the first textbox to see if it has focus already. if (_txtEnterUserName != null) { if (!this._txtEnterUserName.HasFocus) { // it does not have focus, check to see the mouse position is contained with in the textbox. if (this._txtEnterUserName.onClick(new Point(curGameUpdateComponents._curMouseState.X, curGameUpdateComponents._curMouseState.Y))) { // it was contained, remove focus from other textboxes. //if (this._txtEnterUserName.HasFocus) //{ // this._txtEnterUserName.Blur(); //} //if (this._txtEnterUserName.HasFocus) //{ // this._txtEnterUserName.Blur(); //} } } } //Check Start Menu Buttons if (_startMenu._isEnabled) { //Run through each Button foreach (Controls.FancyButtonControl curButton in _startMenu.menuButtons) { if (!curButton._isNull) {//Was the button clicked? if(curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnNewGame") {//Clicked New Game this._txtEnterUserName = new Controls.Textbox.TextInput.TextboxInput(curGameUpdateComponents._this, "MessageBox", "Courier New"); this._txtEnterUserName.Position = new Vector2(125.0f, 200.0f); this._txtEnterUserName.TextboxMarginX = 25; this._txtEnterUserName.TextboxMarginY = 25; this._txtEnterUserName.Scale = new Vector2(0.6f); this._txtEnterUserName.TextScale = new Vector2(1.5f); this._txtEnterUserName.CursorOffset = new Vector2(-5 * this._txtEnterUserName.TextScale.X, -25 * this._txtEnterUserName.TextScale.Y); this._txtEnterUserName.MaxTextLength = 10; curGameUpdateComponents._Components.Add(this._txtEnterUserName); _startMenu._isEnabled = false; ///////////////////////////////// //Create Enter your Name Menu ////////////////////////////////// //Texture2D curTexture = Content.Load<Texture2D>("300x300_Window"); Vector2 curVector = new Vector2(100, 100); Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.FancyMenuControl curMenuControl = new Controls.FancyMenuControl(); //Start Menu Button List List<Controls.FancyButtonControl> menuButtons = new List<Controls.FancyButtonControl>(); //Get Continue Button Settings Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnContinueToSelectFaction", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Save")); //Add the Exit Button curButtonVector = new Vector2(260, 340); curButtonRect = new Rectangle(260, 340, 130, 50); menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnExitUserName", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Exit")); //Create the Menu Control curMenuControl = new GalacticConquest.Controls.FancyMenuControl("mnuEnterUsername", curGameUpdateComponents._staticTextureImages._imgMenu, curVector, curRect, "Enter your Username: "******"...Settings List Here...", menuButtons); //Add menu control to list activeStartMenuMenus.Add(curMenuControl); } if (curButton.ID == "btnGameSettings") {//Clicked Settings form _startMenu._isEnabled = false; ///////////////////////////////// //Create Settings Menu ////////////////////////////////// Texture2D curTexture = curGameUpdateComponents._Content.Load<Texture2D>("300x300_Window"); Vector2 curVector = new Vector2(100, 100); Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.FancyMenuControl curMenuControl = new Controls.FancyMenuControl(); //Start Menu Button List List<Controls.FancyButtonControl> menuButtons = new List<Controls.FancyButtonControl>(); //Get Continue Button Settings Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnSaveSettings", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Save")); //Add the Exit Button curButtonVector = new Vector2(260, 340); curButtonRect = new Rectangle(260, 340, 130, 50); menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnExitSettings", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Exit")); //Create the Menu Control curMenuControl = new GalacticConquest.Controls.FancyMenuControl("mnuSettings", curTexture, curVector, curRect, "Settings: ", "...Settings List Here...", menuButtons); //Add menu control to list activeStartMenuMenus.Add(curMenuControl); } if (curButton.ID == "btnExitGame") {//Clicked Exit Game curGameUpdateComponents._this.Exit(); } } } } } }
////////////////////////////// //Methods for Checking Input ////////////////////////////// public void checkStartScreenMouseClick(GameUpdateClassComponents curGameUpdateComponents) { //Check Start Menu Menu popups first checkMenuControlMouseClick(curGameUpdateComponents); //Check Textboxes Second ??? // checks the first textbox to see if it has focus already. if (_txtEnterUserName != null) { if (!this._txtEnterUserName.HasFocus) { // it does not have focus, check to see the mouse position is contained with in the textbox. if (this._txtEnterUserName.onClick(new Point(curGameUpdateComponents._curMouseState.X, curGameUpdateComponents._curMouseState.Y))) { // it was contained, remove focus from other textboxes. //if (this._txtEnterUserName.HasFocus) //{ // this._txtEnterUserName.Blur(); //} //if (this._txtEnterUserName.HasFocus) //{ // this._txtEnterUserName.Blur(); //} } } } //Check Start Menu Buttons if (_startMenu._isEnabled) { //Run through each Button foreach (Controls.FancyButtonControl curButton in _startMenu.menuButtons) { if (!curButton._isNull) {//Was the button clicked? if (curButton.mouseClicked(curGameUpdateComponents)) { if (curButton.ID == "btnNewGame") {//Clicked New Game this._txtEnterUserName = new Controls.Textbox.TextInput.TextboxInput(curGameUpdateComponents._this, "MessageBox", "Courier New"); this._txtEnterUserName.Position = new Vector2(125.0f, 200.0f); this._txtEnterUserName.TextboxMarginX = 25; this._txtEnterUserName.TextboxMarginY = 25; this._txtEnterUserName.Scale = new Vector2(0.6f); this._txtEnterUserName.TextScale = new Vector2(1.5f); this._txtEnterUserName.CursorOffset = new Vector2(-5 * this._txtEnterUserName.TextScale.X, -25 * this._txtEnterUserName.TextScale.Y); this._txtEnterUserName.MaxTextLength = 10; curGameUpdateComponents._Components.Add(this._txtEnterUserName); _startMenu._isEnabled = false; ///////////////////////////////// //Create Enter your Name Menu ////////////////////////////////// //Texture2D curTexture = Content.Load<Texture2D>("300x300_Window"); Vector2 curVector = new Vector2(100, 100); Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.FancyMenuControl curMenuControl = new Controls.FancyMenuControl(); //Start Menu Button List List <Controls.FancyButtonControl> menuButtons = new List <Controls.FancyButtonControl>(); //Get Continue Button Settings Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnContinueToSelectFaction", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Save")); //Add the Exit Button curButtonVector = new Vector2(260, 340); curButtonRect = new Rectangle(260, 340, 130, 50); menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnExitUserName", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Exit")); //Create the Menu Control curMenuControl = new GalacticConquest.Controls.FancyMenuControl("mnuEnterUsername", curGameUpdateComponents._staticTextureImages._imgMenu, curVector, curRect, "Enter your Username: "******"...Settings List Here...", menuButtons); //Add menu control to list activeStartMenuMenus.Add(curMenuControl); } if (curButton.ID == "btnGameSettings") {//Clicked Settings form _startMenu._isEnabled = false; ///////////////////////////////// //Create Settings Menu ////////////////////////////////// Texture2D curTexture = curGameUpdateComponents._Content.Load <Texture2D>("300x300_Window"); Vector2 curVector = new Vector2(100, 100); Rectangle curRect = new Rectangle(100, 100, 300, 300); Controls.FancyMenuControl curMenuControl = new Controls.FancyMenuControl(); //Start Menu Button List List <Controls.FancyButtonControl> menuButtons = new List <Controls.FancyButtonControl>(); //Get Continue Button Settings Vector2 curButtonVector = new Vector2(110, 340); Rectangle curButtonRect = new Rectangle(110, 340, 130, 50); //Add the Continue Button menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnSaveSettings", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Save")); //Add the Exit Button curButtonVector = new Vector2(260, 340); curButtonRect = new Rectangle(260, 340, 130, 50); menuButtons.Add(new GalacticConquest.Controls.FancyButtonControl("btnExitSettings", curGameUpdateComponents._staticTextureImages._buttonTexture, curButtonVector, curButtonRect, "Exit")); //Create the Menu Control curMenuControl = new GalacticConquest.Controls.FancyMenuControl("mnuSettings", curTexture, curVector, curRect, "Settings: ", "...Settings List Here...", menuButtons); //Add menu control to list activeStartMenuMenus.Add(curMenuControl); } if (curButton.ID == "btnExitGame") {//Clicked Exit Game curGameUpdateComponents._this.Exit(); } } } } } }