public void Draw(SpriteBatch spriteBatch, Texture2D img, Texture2D MenuBtn, SpriteFont font, GraphicsDeviceManager gfx, SpriteFont smallfont, int MenuType) { if (StartTimer) { StartTimer = false; tmr.Start(); } if (tmr.ElapsedMilliseconds > 250) { tmr.Stop(); tmr.Reset(); blnCanBind = true; } switch (MenuType) { //Draw PauseMenu case 1: Rectangle Rect = new Rectangle(0, 0, gfx.PreferredBackBufferWidth, gfx.PreferredBackBufferHeight); spriteBatch.Draw(img, Rect, Color.Black); int startposx = Convert.ToInt32(gfx.PreferredBackBufferWidth * .35); int width = Convert.ToInt32(gfx.PreferredBackBufferWidth * .25); int startposy = Convert.ToInt32(gfx.PreferredBackBufferHeight * .15); int height = Convert.ToInt32(gfx.PreferredBackBufferHeight * .10); if (DefaultPauseOpen) { if (mnuBtnResume == null) { mnuBtnResume = new MenuButton(); MnuBtnResumeBound = false; } if (mnuBtnExit == null) { mnuBtnExit = new MenuButton(); MnuBtnExitBound = false; } if (mnuBtnOptions == null) { mnuBtnOptions = new MenuButton(); mnuBtnOptionsBound = false; } if (!MnuBtnResumeBound) { mnuBtnResume.ButtonClicked += mnuBtnResume_Clicked; MnuBtnResumeBound = true; } if (!MnuBtnExitBound) { mnuBtnExit.ButtonClicked += mnuBtnExit_Clicked; MnuBtnExitBound = true; } if (!mnuBtnOptionsBound) { mnuBtnOptions.ButtonClicked += mnuBtnOptions_Clicked; mnuBtnOptionsBound = true; } mnuBtnResume.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy, width, height), "Resume", font); mnuBtnOptions.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .15), width, height), "Options", font); mnuBtnExit.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .30), width, height), "Exit", font); } else { if (blnVideoOpen) { if (mnuBtnCancel == null) { mnuBtnCancel = new MenuButton(); mnuBtnCancelBound = false; } if (mnuBtnAcceptChanges == null) { mnuBtnAcceptChanges = new MenuButton(); mnuBtnAcceptChangesBound = false; } if (chkYes == null) { chkYes = new CheckBox(); blnChkYesBound = false; } if (chkNo == null) { chkNo = new CheckBox(); chkNoBound = false; } if (blnIndexValues) { if (GlobalVariables.UserSetFullScreen) { chkYes.Check(); chkNo.Uncheck(); } else { chkNo.Check(); chkYes.Uncheck(); } double ht; double wdt; if (GlobalVariables.UserSetHeight > 0) { ht = Convert.ToDouble(GlobalVariables.UserSetHeight); } else { ht = Convert.ToDouble(GlobalVariables.ScreenHeight); } if (GlobalVariables.UserSetWidth > 0) { wdt = Convert.ToDouble(GlobalVariables.UserSetWidth); } else { wdt = Convert.ToDouble(GlobalVariables.ScreenWidth); } double dbl = (wdt / ht); string ratio = Convert.ToString(dbl); if (ratio.Contains("1.33333")) { slider1.Index = 0; } else if (ratio.Contains("1.77777")) { slider1.Index = 1; } else if (ratio.Contains("1.6")) { slider1.Index = 2; } string sliderRes = Convert.ToString(GlobalVariables.UserSetWidth) + " X " + Convert.ToString(GlobalVariables.UserSetHeight); int i = 0; foreach (string str in Resolution_43) { if (str == sliderRes) { slider.Index = i; } i += 1; } i = 0; foreach (string str in Resolution_169) { if (str == sliderRes) { slider.Index = i; } i += 1; } i = 0; foreach (string str in Resolution_1610) { if (str == sliderRes) { slider.Index = i; } i += 1; } blnIndexValues = false; } if (!chkNoBound) { chkNo.ClickedChecked += ChkNo_Checked; chkNoBound = true; } if (!blnChkYesBound) { chkYes.ClickedChecked += ChkYes_Checked; blnChkYesBound = true; } double TextWidth = font.MeasureString("Resolution").X; double TextHeight = font.MeasureString("Resolution").Y; int SliderWidth = (int)(gfx.PreferredBackBufferWidth * .3); int SliderHeight = (int)(gfx.PreferredBackBufferHeight * .005); spriteBatch.DrawString(font, "Aspect Ratio", new Vector2(startposx + ((float)(gfx.PreferredBackBufferWidth * .1) - (float)(TextWidth * .25)), startposy - (int)(gfx.PreferredBackBufferHeight * .05)), Color.Gray); slider1.Draw(spriteBatch, smallfont, gfx, MenuBtn, Ratios, SliderWidth, SliderHeight, startposx - (int)(gfx.PreferredBackBufferWidth * .025), startposy - (int)(gfx.PreferredBackBufferHeight * .01), Color.Black); string AspectRatio = slider1.ReturnValue(); if (AspectRatio.Contains("9")) { DesiredArray = Resolution_169; } else if (AspectRatio.Contains("10")) { DesiredArray = Resolution_1610; } else { DesiredArray = Resolution_43; } spriteBatch.DrawString(font, "Resolution", new Vector2(startposx + ((float)(gfx.PreferredBackBufferWidth * .1) - (float)(TextWidth * .25)), startposy + (int)(gfx.PreferredBackBufferHeight * .08)), Color.Gray); slider.Draw(spriteBatch, smallfont, gfx, MenuBtn, DesiredArray, SliderWidth, SliderHeight, startposx - (int)(gfx.PreferredBackBufferWidth * .025), startposy + (int)(gfx.PreferredBackBufferHeight * .12), Color.Black); string Resolution = slider.ReturnValue(); string[] Res = Resolution.Split('X'); GlobalVariables.NewWidth = Convert.ToInt32(Res[0].Trim()); GlobalVariables.NewHeight = Convert.ToInt32(Res[1].Trim()); if (!mnuBtnCancelBound) { mnuBtnCancel.ButtonClicked += mnuBtnCancel_Clicked; mnuBtnCancelBound = true; } if (!mnuBtnAcceptChangesBound) { mnuBtnAcceptChanges.ButtonClicked += mnuBtnAcceptChanges_Clicked; mnuBtnAcceptChangesBound = true; } spriteBatch.DrawString(font, "FullScreen", new Vector2(startposx + ((float)(gfx.PreferredBackBufferWidth * .1) - (float)(TextWidth * .25)), startposy + (int)(gfx.PreferredBackBufferHeight * .22)), Color.Gray); chkYes.draw(spriteBatch, MenuBtn, (int)((gfx.PreferredBackBufferWidth / 2) - gfx.PreferredBackBufferWidth * .10), (int)(gfx.PreferredBackBufferHeight * .45), (int)(gfx.PreferredBackBufferWidth * .01), (int)(gfx.PreferredBackBufferWidth * .01), "Yes", gfx); chkNo.draw(spriteBatch, MenuBtn, (int)((gfx.PreferredBackBufferWidth / 2) + gfx.PreferredBackBufferWidth * .05), (int)(gfx.PreferredBackBufferHeight * .45), (int)(gfx.PreferredBackBufferWidth * .01), (int)(gfx.PreferredBackBufferWidth * .01), "No", gfx); mnuBtnAcceptChanges.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .45), width, height), "Accept", font); mnuBtnCancel.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .60), width, height), "Back", font); } else if (blnAudioOpen) { } else if (blnGameplayOpen) { if (mnuGamePlayConfirm == null) { mnuGamePlayConfirm = new MenuButton(); mnuGamePlayConfirmBound = false; } if (mnuGamePlayCancel == null) { mnuGamePlayCancel = new MenuButton(); mnuGamePlayCancelBound = false; } if (!mnuGamePlayCancelBound) { mnuGamePlayCancel.ButtonClicked += mnuGamePlayCancel_Clicked; mnuGamePlayCancelBound = true; } if (!mnuGamePlayConfirmBound) { mnuGamePlayConfirm.ButtonClicked += mnuGamePlayConfirm_Clicked; mnuGamePlayConfirmBound = true; } if (chkShowItemNames == null) { chkShowItemNames = new CheckBox(); } if (chkShowEnemyBars == null) { chkShowEnemyBars = new CheckBox(); } if (chkShowEnemyNames == null) { chkShowEnemyNames = new CheckBox(); } if (chkShowEnemyDamage == null) { chkShowEnemyDamage = new CheckBox(); } SpriteFont setFont = GlobalVariables.LargeFont; chkShowItemNames.draw(spriteBatch, MenuBtn, (int)(gfx.PreferredBackBufferWidth / 2) + (int)(gfx.PreferredBackBufferWidth * .065), (int)(gfx.PreferredBackBufferHeight * .15), (int)(gfx.PreferredBackBufferWidth * .01), (int)(gfx.PreferredBackBufferWidth * .01), "Show Item Names", gfx, setFont); chkShowEnemyNames.draw(spriteBatch, MenuBtn, (int)(gfx.PreferredBackBufferWidth / 2) + (int)(gfx.PreferredBackBufferWidth * .065), (int)(gfx.PreferredBackBufferHeight * .25), (int)(gfx.PreferredBackBufferWidth * .01), (int)(gfx.PreferredBackBufferWidth * .01), "Show Enemy Names", gfx, setFont); chkShowEnemyBars.draw(spriteBatch, MenuBtn, (int)(gfx.PreferredBackBufferWidth / 2) + (int)(gfx.PreferredBackBufferWidth * .065), (int)(gfx.PreferredBackBufferHeight * .35), (int)(gfx.PreferredBackBufferWidth * .01), (int)(gfx.PreferredBackBufferWidth * .01), "Show Enemy HP Bars", gfx, setFont); chkShowEnemyDamage.draw(spriteBatch, MenuBtn, (int)(gfx.PreferredBackBufferWidth / 2) + (int)(gfx.PreferredBackBufferWidth * .065), (int)(gfx.PreferredBackBufferHeight * .45), (int)(gfx.PreferredBackBufferWidth * .01), (int)(gfx.PreferredBackBufferWidth * .01), "Show Enemy Damage", gfx, setFont); mnuGamePlayConfirm.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .45), width, height), "Confirm", font); mnuGamePlayCancel.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .60), width, height), "Back", font); if (blnIndexValues) { if (GlobalVariables.ShowItemNames) { chkShowItemNames.Check(); } else { chkShowItemNames.Uncheck(); } if (GlobalVariables.ShowEnemyBars) { chkShowEnemyBars.Check(); } else { chkShowEnemyBars.Uncheck(); } if (GlobalVariables.ShowEnemyNames) { chkShowEnemyNames.Check(); } else { chkShowEnemyNames.Uncheck(); } if (GlobalVariables.ShowEnemyDamage) { chkShowEnemyDamage.Check(); } else { chkShowEnemyDamage.Uncheck(); } } blnIndexValues = false; } else if (blnOptionsOpen) { if (mnuBtnVideo == null) { mnuBtnVideo = new MenuButton(); mnuBtnVideoBound = false; } if (mnuBtnAudio == null) { mnuBtnAudio = new MenuButton(); mnuBtnAudioBound = false; } if (mnuBtnGamePlay == null) { mnuBtnGamePlay = new MenuButton(); mnuBtnGamePlayBound = false; } if (mnuBtnBack == null) { mnuBtnBack = new MenuButton(); mnuBtnBackBound = false; } if (blnCanBind) { blnCanBind = false; if (!mnuBtnAudioBound) { mnuBtnAudio.ButtonClicked += mnuBtnAudio_Clicked; mnuBtnAudioBound = true; } } if (!mnuBtnVideoBound) { mnuBtnVideo.ButtonClicked += mnuBtnVideo_Clicked; mnuBtnVideoBound = true; } if (!mnuBtnGamePlayBound) { mnuBtnGamePlay.ButtonClicked += mnuBtnGamePlay_Clicked; mnuBtnGamePlayBound = true; } if (!mnuBtnBackBound) { mnuBtnBack.ButtonClicked += mnuBtnBack_Clicked; mnuBtnBackBound = true; } mnuBtnVideo.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy, width, height), "Video", font); mnuBtnAudio.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .15), width, height), "Audio", font); mnuBtnGamePlay.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .30), width, height), "Gameplay", font); mnuBtnBack.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(startposx, startposy + Convert.ToInt32(gfx.PreferredBackBufferHeight * .45), width, height), "Back", font); } } break; //Draw Confirmation of Resolution Menu case 2: oms = ms; ms = Mouse.GetState(); Rect = new Rectangle(((int)(gfx.PreferredBackBufferWidth / 2) - (int)(gfx.PreferredBackBufferWidth * .3)), ((int)(gfx.PreferredBackBufferHeight / 2) - (int)(gfx.PreferredBackBufferHeight * .25)), (int)(gfx.PreferredBackBufferWidth * .55), (int)(gfx.PreferredBackBufferHeight * .30)); spriteBatch.Draw(MenuBtn, Rect, Color.SlateGray); if (mnuBtnConfirm == null) { mnuBtnConfirm = new MenuButton(); mnuBtnConfirmBound = false; } if (mnuBtnRevert == null) { mnuBtnRevert = new MenuButton(); mnuBtnRevertBound = false; } if (!mnuBtnConfirmBound) { mnuBtnConfirm.ButtonClicked += mnuBtnConfirm_Clicked; mnuBtnConfirmBound = true; } if (!mnuBtnRevertBound) { mnuBtnRevert.ButtonClicked += mnuBtnRevert_Clicked; mnuBtnRevertBound = true; } spriteBatch.DrawString(font, "Keep Changes?", new Vector2((Rect.X + (int)(gfx.PreferredBackBufferWidth * .205)), ((Rect.Y) + (int)(gfx.PreferredBackBufferHeight * .02))), Color.WhiteSmoke); mnuBtnConfirm.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(Rect.X + (int)(gfx.PreferredBackBufferWidth * .1), Rect.Y + (int)(gfx.PreferredBackBufferHeight * .12), (int)(Rect.Width * .3), (int)(Rect.Height * .2)), "Confirm", font); mnuBtnRevert.Draw(spriteBatch, MenuBtn, gfx, new Rectangle(Rect.X + (int)(gfx.PreferredBackBufferWidth * .3), Rect.Y + (int)(gfx.PreferredBackBufferHeight * .12), (int)(Rect.Width * .3), (int)(Rect.Height * .2)), "Revert", font); break; } }
public Equipment(Item helmet, Item shoulders, Item chest, Item pants, Item rightweapon, Item leftweapon, Item gloves, Item boots, Item belt, Item leftring, Item rightring, HeroDisplay theHero, bool isNull = false) { if (isNull) { } else { Hero = theHero; Hero.txtRightWeapon = GlobalVariables.TheGame.CharWeapon; Hero.txtHero = GlobalVariables.TheGame.HeroTxt; Hero.Width = Convert.ToInt32(Hero.txtHero.Width / Hero.Columns); Hero.Height = Convert.ToInt32(Hero.txtHero.Height / Hero.Rows); Hero.RotateCounterBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .5), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .57), (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .03), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .03)); Hero.RotateClockBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .4), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .57), (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .03), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .03)); Hero.Direction = 0; Hero.RotateClock += RotateClock; Hero.RotateCounter += RotateCounter; if (btnOffense == null) { btnOffense = new MenuButton(); btnOffenseBound = false; } if (btnDefense == null) { btnDefense = new MenuButton(); btnDefenseBound = false; } if (btnUtility == null) { btnUtility = new MenuButton(); btnUtilityBound = false; } if (!btnOffenseBound) { btnOffense.ButtonClicked += btnOffense_Clicked; btnOffenseBound = true; } if (!btnDefenseBound) { btnDefense.ButtonClicked += btnDefense_Clicked; btnDefenseBound = true; } if (!btnUtilityBound) { btnUtility.ButtonClicked += btnUtility_Clicked; btnUtilityBound = true; } } if (GlobalVariables.TheGame == null) { return; } if (helmet != null) { Helmet = helmet; } if (shoulders != null) { Shoulders = shoulders; } if (chest != null) { Chest = chest; } if (pants != null) { Pants = pants; } if (rightweapon != null) { RightWeapon = rightweapon; } if (leftweapon != null) { LeftWeapon = leftweapon; } if (gloves != null) { Gloves = gloves; } if (boots != null) { Boots = boots; } if (belt != null) { Belt = belt; } if (leftring != null) { LeftRing = leftring; } if (rightring != null) { RightRing = rightring; } if (GlobalVariables.gfx != null) { if (Hero != null) { Hero.DrawLocation = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .395), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .25), (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .14), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .3675)); } Bounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .3), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .1), (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .6), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .6)); int width = (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .0628); int height = (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .0971); HelmBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .323425), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .25), width, height); ChestBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .323425), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .3525), width, height); RWeapbounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .323425), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .455), width, height); GlovesBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .323425), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .5565), width, height); ShouldersBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .544), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .25), width, height); PantsBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .544), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .3525), width, height); LWeapBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .544), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .455), width, height); BootsBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .544), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .5565), width, height); int beltwidth = (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .0954); int beltheight = (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .032); BeltBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .4175), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .6215), beltwidth, beltheight); int ringwidth = (int)(GlobalVariables.gfx.PreferredBackBufferWidth * .02); int ringheight = (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .032); LeftRingBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .3945), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .6215), ringwidth, ringheight); RightRingBounds = new Rectangle((int)(GlobalVariables.gfx.PreferredBackBufferWidth * .515), (int)(GlobalVariables.gfx.PreferredBackBufferHeight * .6215), ringwidth, ringheight); } }