void Do_SaveOptionsPress(object sender, EventArgs e) { //refreshes the LastSave values TimeValueIndexSelected_LastSave = TimeValueIndexSelected; if (rbnEasy.IsChecked) { DifficultyLevel_LastSave = rbnEasy.Name; } else if (rbnMedium.IsChecked) { DifficultyLevel_LastSave = rbnMedium.Name; } else { DifficultyLevel_LastSave = rbnHard.Name; } ResolutionValueIndexSelected_LastSave = ResolutionValueIndexSelected; if (rbnFullScreenOn.IsChecked) { FullScreenState_LastSave = "On"; } else { FullScreenState_LastSave = "Off"; } VolumeValue_LastSave = VolumeValueSprite.FrameNumber; if (rbnSoundOn.IsChecked) { SoundState_LastSave = "On"; } else { SoundState_LastSave = "Off"; } CameraSpeed_LastState = CameraSpeedValueSprite.FrameNumber; Hide(); Show(); //Launches the OnSaveOptions Event CommandCenterEventArgs args = new CommandCenterEventArgs(ResolutionValueIndexSelected_LastSave, FullScreenState_LastSave, TimeValueIndexSelected_LastSave, DifficultyLevel_LastSave, VolumeValue_LastSave, SoundState_LastSave, CameraSpeed_LastState); args.ResolutionValue = ResolutionValues[ResolutionValueIndexSelected_LastSave]; args.AutosaveTimeValue = TimeValues[TimeValueIndexSelected_LastSave]; //OnSaveOptions(this, new CommandCenterEventArgs(ResolutionValues[ResolutionValueIndexSelected],FullScreenCurrentState)); OnSaveOptions(this, args); }
/// <summary> /// Sets the text displayed after clicking the Parameters Button for a zone /// </summary> public void SetZoneParameters(List <CommandCenterEventArgs> zonesParameters) { for (int i = 0; i < zonesParameters.Count; i++) { CommandCenterEventArgs zone = zonesParameters[i]; zones[i].ParametersString = zones[i].Name + "\n Parameters\n\n"; zones[i].ParametersString += "\n Energy " + ((int)zone.Energy_Quantum).ToString() + "%"; zones[i].ParametersString += "\n Education " + ((int)zone.Education_Quantum).ToString() + "%"; zones[i].ParametersString += "\n Economy " + ((int)zone.Economy_Quantum).ToString() + "%"; zones[i].ParametersString += "\n Environment " + ((int)zone.Environment_Quantum).ToString() + "%"; zones[i].ParametersString += "\n Health " + ((int)zone.Health_Quantum).ToString() + "%"; zones[i].ParametersString += "\n Food " + ((int)zone.Food_Quantum).ToString() + "%"; } }
/// <summary> /// Sets the LastSave values, considering they are loaded from an xml, for a certain /// profile, and they will be the default ones /// </summary> public void SetLastSaveValues(CommandCenterEventArgs settings) { //refreshes the LastSave values TimeValueIndexSelected_LastSave = settings.TimeValueIndex; DifficultyLevel_LastSave = settings.DifficultyLevel; ResolutionValueIndexSelected_LastSave = settings.ResolutionIndex; FullScreenState_LastSave = settings.FullScreen; VolumeValue_LastSave = settings.VolumeValue; SoundState_LastSave = settings.SoundState; CameraSpeed_LastState = CameraSpeedValueSprite.FrameNumber; //When this method is called, the commandCenter has just loaded //and the Options Panel is hidden. When the Options button is clicked //the Show method is called and , from it, the ResetOptions method, //so that the graphics reflect the exact settings }
public CommandCenterOptionsPanel(Game game, int DrawOrder) : base(game) { graphicsCollection = (GraphicsCollection)Game.Services.GetService(typeof(GraphicsCollection)); generalButtons = new List <List <CommandCenterGeneralButton> >(); sublistGame = new List <CommandCenterGeneralButton>(); sublistVideo = new List <CommandCenterGeneralButton>(); sublistAudio = new List <CommandCenterGeneralButton>(); sublistControls = new List <CommandCenterGeneralButton>(); //------------------------------ //--Setting Default Options (will be used when initializing objects, in the next instructions) DefaultOptions = new CommandCenterEventArgs(1); //everything is set to a GENERAL default //------------------------------ //---SaveSettings Options Button----- btnSaveOptions = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveOptions")), DrawOrder); btnSaveOptions.Position = new Point(390, 675); btnSaveOptions.OnPress += new EventHandler <ButtonEventArgs>(Do_SaveOptionsPress); btnSaveOptions.OnRelease += new EventHandler <ButtonEventArgs>(Do_SaveOptionsRelease); AddChild(btnSaveOptions); //--------------------------- //-----Primary Buttons------- btnGame = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Game")), DrawOrder); btnGame.Position = new Point(70, 150); btnGame.OnPress += new EventHandler <ButtonEventArgs>(Do_GeneralBtnPressed); btnGame.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseOver); btnGame.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnGame); sublistGame.Add(btnGame); btnVideo = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Video")), DrawOrder); btnVideo.Position = new Point(70, 300); btnVideo.OnPress += new EventHandler <ButtonEventArgs>(Do_GeneralBtnPressed); btnVideo.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseOver); btnVideo.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnVideo); sublistVideo.Add(btnVideo); btnAudio = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Audio")), DrawOrder); btnAudio.Position = new Point(70, 440); btnAudio.OnPress += new EventHandler <ButtonEventArgs>(Do_GeneralBtnPressed); btnAudio.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseOver); btnAudio.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnAudio); sublistAudio.Add(btnAudio); btnControls = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Controls")), DrawOrder); btnControls.Position = new Point(70, 580); btnControls.OnPress += new EventHandler <ButtonEventArgs>(Do_GeneralBtnPressed); btnControls.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseOver); btnControls.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnControls); sublistControls.Add(btnControls); //---GAME Submenu Buttons------- btnGame_SaveGame = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveGame")), DrawOrder); btnGame_SaveGame.Position = new Point(260, 128); btnGame_SaveGame.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnGame_SaveGame.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnGame_SaveGame.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnGame_SaveGame); sublistGame.Add(btnGame_SaveGame); btnGame_Difficulty = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Difficulty")), DrawOrder); btnGame_Difficulty.Position = new Point(260, 181); btnGame_Difficulty.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnGame_Difficulty.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnGame_Difficulty.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnGame_Difficulty); sublistGame.Add(btnGame_Difficulty); //---Submenu button SaveGame Options----- btnSave = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveBtn")), DrawOrder); btnSave.Position = new Point(454, 126); btnSave.OnRelease += new EventHandler <ButtonEventArgs>(Do_BtnSaveMouseRelease); AddChild(btnSave); AutosaveSprite = new Sprite(game, graphicsCollection.GetPack("Autosave")); AutosaveSprite.StackOrder = DrawOrder; AutosaveSprite.XRelative = 567; AutosaveSprite.YRelative = 133; AddChild(AutosaveSprite); positions = new int [6] { 746, 127, 705, 127, 820, 127 }; AutosaveScrollbar = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("AutosaveTimeDisplay")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarLeftArrow")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarRightArrow")), DrawOrder, positions); AutosaveScrollbar.OnScrollUp += new EventHandler(Do_AutosaveScrollbar_LeftScroll); AutosaveScrollbar.OnScrollDown += new EventHandler(Do_AutosaveScrollbar_RightScroll); AddChild(AutosaveScrollbar); AutosaveTime = new SpriteText(game, FontsCollection.GetPack("Courier New 10").Font); AutosaveTime.XRelative = 754; AutosaveTime.YRelative = 133; TimeValueIndexSelected = DefaultOptions.TimeValueIndex;//by default, autosave every 30 min AutosaveTime.Text = TimeValues[TimeValueIndexSelected].ToString() + " min"; AutosaveTime.Tint = Color.LightGray; AddChild(AutosaveTime); DefaultOptions.AutosaveTimeValue = TimeValues[TimeValueIndexSelected]; //--------------------------------------- //---Submenu button Difficulty Options--- positions = new int[4] { 443, 185, 508, 180 }; rbnEasy = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Easy")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnEasy.AllowDirectUncheck = false; rbnEasy.OnCheck += new EventHandler(Do_DifficultyRadioChecked); rbnEasy.Name = "Easy"; AddChild(rbnEasy); DifficultyRadioGroup.Add(rbnEasy); positions = new int[4] { 558, 185, 651, 180 }; rbnMedium = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Medium")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnMedium.AllowDirectUncheck = false; rbnMedium.OnCheck += new EventHandler(Do_DifficultyRadioChecked); rbnMedium.Name = "Medium"; AddChild(rbnMedium); DifficultyRadioGroup.Add(rbnMedium); positions = new int[4] { 703, 185, 773, 180 }; rbnHard = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Hard")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions);; rbnHard.AllowDirectUncheck = false; rbnHard.OnCheck += new EventHandler(Do_DifficultyRadioChecked); rbnHard.Name = "Hard"; AddChild(rbnHard); DifficultyRadioGroup.Add(rbnHard); DifficultyLevelCurrentlySelected = DefaultOptions.DifficultyLevel; switch (DifficultyLevelCurrentlySelected) { case "Easy": rbnEasy.Check(); break; case "Medium": rbnMedium.Check(); break; case "Hard": rbnHard.Check(); break; default: rbnEasy.Check(); break; } //--------------------------------------- //------------------------------ //---VIDEO Submenu Buttons------ btnVideo_Resolution = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Resolution")), DrawOrder); btnVideo_Resolution.Position = new Point(260, 276); btnVideo_Resolution.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnVideo_Resolution.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnVideo_Resolution.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnVideo_Resolution); sublistVideo.Add(btnVideo_Resolution); btnVideo_FullScreen = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("FullScreen")), DrawOrder); btnVideo_FullScreen.Position = new Point(260, 326); btnVideo_FullScreen.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnVideo_FullScreen.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnVideo_FullScreen.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnVideo_FullScreen); sublistVideo.Add(btnVideo_FullScreen); //---Submenu button ResolutionIndex Options------- Resolution = new SpriteText(Game, FontsCollection.GetPack("Courier New 10").Font); Resolution.XRelative = 617; Resolution.YRelative = 280; Resolution.Tint = Color.LightGray; ResolutionValueIndexSelected = DefaultOptions.ResolutionIndex; DefaultOptions.ResolutionValue = ResolutionValues[ResolutionValueIndexSelected]; Resolution.Text = ResolutionValues[ResolutionValueIndexSelected].X.ToString() + " X " + ResolutionValues[ResolutionValueIndexSelected].Y.ToString(); AddChild(Resolution); positions = new int[6] { 592, 275, 550, 275, 738, 275 }; ResolutionIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("ResolutionDisplay")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarLeftArrow")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarRightArrow")), DrawOrder, positions); ResolutionIndicator.OnScrollUp += new EventHandler(Do_ResolutionIndicator_LeftScroll); ResolutionIndicator.OnScrollDown += new EventHandler(Do_ResolutionIndicator_RightScroll); AddChild(ResolutionIndicator); //------------------------------ //---Submenu button FullScreen Options------- positions = new int[4] { 465, 330, 505, 322 }; rbnFullScreenOn = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("On")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnFullScreenOn.AllowDirectUncheck = false; rbnFullScreenOn.OnCheck += new EventHandler(Do_FullScreenRadioOnChecked); AddChild(rbnFullScreenOn); positions = new int[4] { 575, 330, 625, 322 }; rbnFullScreenOff = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Off")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnFullScreenOff.AllowDirectUncheck = false; rbnFullScreenOff.OnCheck += new EventHandler(Do_FullScreenRadioOffChecked); AddChild(rbnFullScreenOff); FullScreenCurrentState = DefaultOptions.FullScreen;//"Off" by default; switch (FullScreenCurrentState) { case "On": rbnFullScreenOn.Check(); break; case "Off": rbnFullScreenOff.Check(); break; default: rbnFullScreenOff.Check(); break; } //------------------------------ //------------------------------ //---AUDIO Submenu Buttons------ btnAudio_Volume = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Volume")), DrawOrder); btnAudio_Volume.Position = new Point(260, 411); btnAudio_Volume.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnAudio_Volume.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnAudio_Volume.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnAudio_Volume); sublistAudio.Add(btnAudio_Volume); btnAudio_Sound = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Sound")), DrawOrder); btnAudio_Sound.Position = new Point(260, 461); btnAudio_Sound.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnAudio_Sound.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnAudio_Sound.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnAudio_Sound); sublistAudio.Add(btnAudio_Sound); //---Submenu button Volume Options------- VolumeValueSprite = new Sprite(game, graphicsCollection.GetPack("Increment")); VolumeValueSprite.StackOrder = DrawOrder; VolumeValueSprite.XRelative = 457; VolumeValueSprite.YRelative = 417; VolumeValueSprite.FrameNumber = DefaultOptions.VolumeValue;//0 by default AddChild(VolumeValueSprite); positions = new int[6] { 450, 410, 410, 410, 545, 410 }; VolumeIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("PlusMinusDisplay")), new Sprite(Game, graphicsCollection.GetPack("Minus")), new Sprite(Game, graphicsCollection.GetPack("Plus")), DrawOrder, positions); VolumeIndicator.OnScrollUp += new EventHandler(Do_VolumeIndicatorLeftScroll); VolumeIndicator.OnScrollDown += new EventHandler(Do_VolumeIndicatorRightScroll); AddChild(VolumeIndicator); //--------------------------------------- //---Submenu button Sound Options------- positions = new int[4] { 395, 465, 435, 459 }; rbnSoundOn = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("On")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnSoundOn.AllowDirectUncheck = false; rbnSoundOn.OnCheck += new EventHandler(Do_SoundRadioOnChecked); AddChild(rbnSoundOn); positions = new int[4] { 507, 465, 557, 459 }; rbnSoundOff = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Off")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnSoundOff.AllowDirectUncheck = false; rbnSoundOff.OnCheck += new EventHandler(Do_SoundRadioOffChecked); AddChild(rbnSoundOff); rbnSoundOn.Check(); SoundCurrentState = DefaultOptions.SoundState;//"On" by default switch (SoundCurrentState) { case "On": rbnSoundOn.Check(); break; case "Off": rbnSoundOff.Check(); break; default: rbnSoundOn.Check(); break; } //------------------------------ //------------------------------ //---CONTROLS Submenu Buttons--- btnControls_Mouse = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("MouseOptions")), DrawOrder); btnControls_Mouse.Position = new Point(260, 546); btnControls_Mouse.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnControls_Mouse.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnControls_Mouse.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnControls_Mouse); sublistControls.Add(btnControls_Mouse); btnControls_Keyboard = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("KeyboardOptions")), DrawOrder); btnControls_Keyboard.Position = new Point(260, 601); btnControls_Keyboard.OnPress += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnPressed); btnControls_Keyboard.OnMouseOver += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnControls_Keyboard.OnMouseLeave += new EventHandler <ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnControls_Keyboard); sublistControls.Add(btnControls_Keyboard); //---Submenu button CameraSpeed Options----- CameraSpeedSprite = new Sprite(game, graphicsCollection.GetPack("CameraSpeed")); CameraSpeedSprite.XRelative = 400; CameraSpeedSprite.YRelative = 550; AddChild(CameraSpeedSprite); CameraSpeedValueSprite = new Sprite(game, graphicsCollection.GetPack("Increment")); CameraSpeedValueSprite.XRelative = 637; CameraSpeedValueSprite.YRelative = 550; CameraSpeedValueSprite.FrameNumber = DefaultOptions.CameraSpeed;//0 by default AddChild(CameraSpeedValueSprite); positions = new int[6] { 630, 543, 590, 543, 727, 543 }; CameraSpeedIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("PlusMinusDisplay")), new Sprite(Game, graphicsCollection.GetPack("Minus")), new Sprite(Game, graphicsCollection.GetPack("Plus")), DrawOrder, positions); CameraSpeedIndicator.OnScrollUp += new EventHandler(Do_CameraSpeedIndicator_LeftScroll); CameraSpeedIndicator.OnScrollDown += new EventHandler(Do_CameraSpeedIndicator_RightScroll); AddChild(CameraSpeedIndicator); //--------------------------------------- //---Submenu button KeyShortcuts Options----- btnKeyShortcuts = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("KeyShortcuts")), DrawOrder); btnKeyShortcuts.Position = new Point(440, 600); btnKeyShortcuts.OnMousePress += new EventHandler <MouseEventArgs>(Do_BtnKeyShortcutsPressed); btnKeyShortcuts.OnMouseRelease += new EventHandler <MouseEventArgs>(Do_BtnKeyShortcutsReleased); AddChild(btnKeyShortcuts); KeyShortcutsPanel = new Sprite(game, graphicsCollection.GetPack("KeyShortcutsPanel")); KeyShortcutsPanel.XRelative = 52; KeyShortcutsPanel.YRelative = 125; KeyShortcutsPanel.StackOrder = DrawOrder + 2; KeyShortcutsPanel.Enabled = false; AddChild(KeyShortcutsPanel); btnKeyShortcutsPanel_Back = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("btnKeyShortcutsPanel_Back")), DrawOrder + 3); btnKeyShortcutsPanel_Back.Position = new Point(855, 150); btnKeyShortcutsPanel_Back.OnMouseRelease += new EventHandler <MouseEventArgs>(Do_BtnKeyShortcutsPanel_BackReleased); btnKeyShortcutsPanel_Back.Enabled = false; AddChild(btnKeyShortcutsPanel_Back); //--------------------------------------- //------------------------------ //------------------------------ //--Saving/Setting LastSave Options (which are the Default values, at this point) TimeValueIndexSelected_LastSave = TimeValueIndexSelected; if (rbnEasy.IsChecked) { DifficultyLevel_LastSave = rbnEasy.Name; } else if (rbnMedium.IsChecked) { DifficultyLevel_LastSave = rbnMedium.Name; } else { DifficultyLevel_LastSave = rbnHard.Name; } ResolutionValueIndexSelected_LastSave = ResolutionValueIndexSelected; if (rbnFullScreenOn.IsChecked) { FullScreenState_LastSave = "On"; } else { FullScreenState_LastSave = "Off"; } VolumeValue_LastSave = VolumeValueSprite.FrameNumber; if (rbnSoundOn.IsChecked) { SoundState_LastSave = "On"; } else { SoundState_LastSave = "Off"; } CameraSpeed_LastState = CameraSpeedValueSprite.FrameNumber; //------------------------------ generalButtons.Add(sublistGame); generalButtons.Add(sublistVideo); generalButtons.Add(sublistAudio); generalButtons.Add(sublistControls); this.StackOrder = DrawOrder; }
void Do_SaveOptionsPress(object sender, EventArgs e) { //refreshes the LastSave values TimeValueIndexSelected_LastSave = TimeValueIndexSelected; if (rbnEasy.IsChecked) DifficultyLevel_LastSave = rbnEasy.Name; else if (rbnMedium.IsChecked) DifficultyLevel_LastSave = rbnMedium.Name; else DifficultyLevel_LastSave = rbnHard.Name; ResolutionValueIndexSelected_LastSave = ResolutionValueIndexSelected; if (rbnFullScreenOn.IsChecked) FullScreenState_LastSave = "On"; else FullScreenState_LastSave = "Off"; VolumeValue_LastSave = VolumeValueSprite.FrameNumber; if (rbnSoundOn.IsChecked) SoundState_LastSave = "On"; else SoundState_LastSave = "Off"; CameraSpeed_LastState = CameraSpeedValueSprite.FrameNumber; Hide(); Show(); //Launches the OnSaveOptions Event CommandCenterEventArgs args = new CommandCenterEventArgs(ResolutionValueIndexSelected_LastSave, FullScreenState_LastSave, TimeValueIndexSelected_LastSave, DifficultyLevel_LastSave, VolumeValue_LastSave, SoundState_LastSave, CameraSpeed_LastState); args.ResolutionValue = ResolutionValues[ResolutionValueIndexSelected_LastSave]; args.AutosaveTimeValue = TimeValues[TimeValueIndexSelected_LastSave]; //OnSaveOptions(this, new CommandCenterEventArgs(ResolutionValues[ResolutionValueIndexSelected],FullScreenCurrentState)); OnSaveOptions(this, args); }
public CommandCenterOptionsPanel(Game game, int DrawOrder): base(game) { graphicsCollection = (GraphicsCollection)Game.Services.GetService(typeof(GraphicsCollection)); generalButtons = new List<List<CommandCenterGeneralButton>>(); sublistGame = new List<CommandCenterGeneralButton>(); sublistVideo = new List<CommandCenterGeneralButton>(); sublistAudio = new List<CommandCenterGeneralButton>(); sublistControls = new List<CommandCenterGeneralButton>(); //------------------------------ //--Setting Default Options (will be used when initializing objects, in the next instructions) DefaultOptions = new CommandCenterEventArgs(1); //everything is set to a GENERAL default //------------------------------ //---SaveSettings Options Button----- btnSaveOptions = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveOptions")), DrawOrder); btnSaveOptions.Position = new Point(390, 675); btnSaveOptions.OnPress +=new EventHandler<ButtonEventArgs>(Do_SaveOptionsPress); btnSaveOptions.OnRelease += new EventHandler<ButtonEventArgs>(Do_SaveOptionsRelease); AddChild(btnSaveOptions); //--------------------------- //-----Primary Buttons------- btnGame = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Game")), DrawOrder); btnGame.Position = new Point(70, 150); btnGame.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed); btnGame.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver); btnGame.OnMouseLeave+= new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnGame); sublistGame.Add(btnGame); btnVideo = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Video")), DrawOrder); btnVideo.Position = new Point(70, 300); btnVideo.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed); btnVideo.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver); btnVideo.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnVideo); sublistVideo.Add(btnVideo); btnAudio = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Audio")), DrawOrder); btnAudio.Position = new Point(70, 440); btnAudio.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed); btnAudio.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver); btnAudio.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnAudio); sublistAudio.Add(btnAudio); btnControls = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Options_Controls")), DrawOrder); btnControls.Position = new Point(70, 580); btnControls.OnPress += new EventHandler<ButtonEventArgs>(Do_GeneralBtnPressed); btnControls.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseOver); btnControls.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_GeneralBtnMouseLeave); AddChild(btnControls); sublistControls.Add(btnControls); //---GAME Submenu Buttons------- btnGame_SaveGame = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveGame")), DrawOrder); btnGame_SaveGame.Position = new Point(260, 128); btnGame_SaveGame.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnGame_SaveGame.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnGame_SaveGame.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnGame_SaveGame); sublistGame.Add(btnGame_SaveGame); btnGame_Difficulty = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Difficulty")), DrawOrder); btnGame_Difficulty.Position = new Point(260, 181); btnGame_Difficulty.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnGame_Difficulty.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnGame_Difficulty.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnGame_Difficulty); sublistGame.Add(btnGame_Difficulty); //---Submenu button SaveGame Options----- btnSave = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("SaveBtn")), DrawOrder); btnSave.Position = new Point(454,126); btnSave.OnRelease += new EventHandler<ButtonEventArgs>(Do_BtnSaveMouseRelease); AddChild(btnSave); AutosaveSprite = new Sprite(game, graphicsCollection.GetPack("Autosave")); AutosaveSprite.StackOrder = DrawOrder; AutosaveSprite.XRelative = 567; AutosaveSprite.YRelative = 133; AddChild(AutosaveSprite); positions = new int [6]{746,127,705,127,820,127}; AutosaveScrollbar = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("AutosaveTimeDisplay")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarLeftArrow")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarRightArrow")), DrawOrder, positions); AutosaveScrollbar.OnScrollUp+=new EventHandler(Do_AutosaveScrollbar_LeftScroll); AutosaveScrollbar.OnScrollDown += new EventHandler(Do_AutosaveScrollbar_RightScroll); AddChild(AutosaveScrollbar); AutosaveTime = new SpriteText(game, FontsCollection.GetPack("Courier New 10").Font); AutosaveTime.XRelative = 754; AutosaveTime.YRelative = 133; TimeValueIndexSelected = DefaultOptions.TimeValueIndex;//by default, autosave every 30 min AutosaveTime.Text = TimeValues[TimeValueIndexSelected].ToString() + " min"; AutosaveTime.Tint = Color.LightGray; AddChild(AutosaveTime); DefaultOptions.AutosaveTimeValue = TimeValues[TimeValueIndexSelected]; //--------------------------------------- //---Submenu button Difficulty Options--- positions = new int[4] { 443, 185, 508, 180 }; rbnEasy = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Easy")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnEasy.AllowDirectUncheck = false; rbnEasy.OnCheck += new EventHandler(Do_DifficultyRadioChecked); rbnEasy.Name = "Easy"; AddChild(rbnEasy); DifficultyRadioGroup.Add(rbnEasy); positions = new int[4] { 558, 185, 651, 180 }; rbnMedium = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Medium")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnMedium.AllowDirectUncheck = false; rbnMedium.OnCheck += new EventHandler(Do_DifficultyRadioChecked); rbnMedium.Name = "Medium"; AddChild(rbnMedium); DifficultyRadioGroup.Add(rbnMedium); positions = new int[4] { 703, 185, 773, 180 }; rbnHard = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Diff_Hard")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); ; rbnHard.AllowDirectUncheck = false; rbnHard.OnCheck += new EventHandler(Do_DifficultyRadioChecked); rbnHard.Name = "Hard"; AddChild(rbnHard); DifficultyRadioGroup.Add(rbnHard); DifficultyLevelCurrentlySelected = DefaultOptions.DifficultyLevel; switch (DifficultyLevelCurrentlySelected) { case "Easy": rbnEasy.Check(); break; case "Medium": rbnMedium.Check(); break; case "Hard": rbnHard.Check(); break; default: rbnEasy.Check(); break; } //--------------------------------------- //------------------------------ //---VIDEO Submenu Buttons------ btnVideo_Resolution = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Resolution")), DrawOrder); btnVideo_Resolution.Position = new Point(260, 276); btnVideo_Resolution.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnVideo_Resolution.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnVideo_Resolution.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnVideo_Resolution); sublistVideo.Add(btnVideo_Resolution); btnVideo_FullScreen = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("FullScreen")), DrawOrder); btnVideo_FullScreen.Position = new Point(260, 326); btnVideo_FullScreen.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnVideo_FullScreen.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnVideo_FullScreen.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnVideo_FullScreen); sublistVideo.Add(btnVideo_FullScreen); //---Submenu button ResolutionIndex Options------- Resolution = new SpriteText(Game, FontsCollection.GetPack("Courier New 10").Font); Resolution.XRelative = 617; Resolution.YRelative = 280; Resolution.Tint = Color.LightGray; ResolutionValueIndexSelected = DefaultOptions.ResolutionIndex; DefaultOptions.ResolutionValue = ResolutionValues[ResolutionValueIndexSelected]; Resolution.Text = ResolutionValues[ResolutionValueIndexSelected].X.ToString() + " X " + ResolutionValues[ResolutionValueIndexSelected].Y.ToString(); AddChild(Resolution); positions = new int[6] { 592, 275, 550, 275, 738, 275 }; ResolutionIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("ResolutionDisplay")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarLeftArrow")), new Sprite(Game, graphicsCollection.GetPack("ScrollBarRightArrow")), DrawOrder, positions); ResolutionIndicator.OnScrollUp += new EventHandler(Do_ResolutionIndicator_LeftScroll); ResolutionIndicator.OnScrollDown += new EventHandler(Do_ResolutionIndicator_RightScroll); AddChild(ResolutionIndicator); //------------------------------ //---Submenu button FullScreen Options------- positions = new int[4] {465, 330, 505, 322}; rbnFullScreenOn = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("On")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnFullScreenOn.AllowDirectUncheck = false; rbnFullScreenOn.OnCheck +=new EventHandler(Do_FullScreenRadioOnChecked); AddChild(rbnFullScreenOn); positions = new int[4] {575, 330, 625, 322 }; rbnFullScreenOff = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Off")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnFullScreenOff.AllowDirectUncheck = false; rbnFullScreenOff.OnCheck += new EventHandler(Do_FullScreenRadioOffChecked); AddChild(rbnFullScreenOff); FullScreenCurrentState = DefaultOptions.FullScreen;//"Off" by default; switch (FullScreenCurrentState) { case "On": rbnFullScreenOn.Check(); break; case "Off": rbnFullScreenOff.Check(); break; default: rbnFullScreenOff.Check(); break; } //------------------------------ //------------------------------ //---AUDIO Submenu Buttons------ btnAudio_Volume = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Volume")), DrawOrder); btnAudio_Volume.Position = new Point(260, 411); btnAudio_Volume.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnAudio_Volume.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnAudio_Volume.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnAudio_Volume); sublistAudio.Add(btnAudio_Volume); btnAudio_Sound = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("Sound")), DrawOrder); btnAudio_Sound.Position = new Point(260, 461); btnAudio_Sound.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnAudio_Sound.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnAudio_Sound.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnAudio_Sound); sublistAudio.Add(btnAudio_Sound); //---Submenu button Volume Options------- VolumeValueSprite = new Sprite(game, graphicsCollection.GetPack("Increment")); VolumeValueSprite.StackOrder = DrawOrder; VolumeValueSprite.XRelative = 457; VolumeValueSprite.YRelative = 417; VolumeValueSprite.FrameNumber = DefaultOptions.VolumeValue;//0 by default AddChild(VolumeValueSprite); positions = new int[6] {450, 410, 410, 410, 545, 410 }; VolumeIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("PlusMinusDisplay")), new Sprite(Game, graphicsCollection.GetPack("Minus")), new Sprite(Game, graphicsCollection.GetPack("Plus")), DrawOrder, positions); VolumeIndicator.OnScrollUp += new EventHandler(Do_VolumeIndicatorLeftScroll); VolumeIndicator.OnScrollDown += new EventHandler(Do_VolumeIndicatorRightScroll); AddChild(VolumeIndicator); //--------------------------------------- //---Submenu button Sound Options------- positions = new int[4] { 395, 465, 435, 459 }; rbnSoundOn = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("On")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnSoundOn.AllowDirectUncheck = false; rbnSoundOn.OnCheck +=new EventHandler(Do_SoundRadioOnChecked); AddChild(rbnSoundOn); positions = new int[4] { 507, 465, 557, 459 }; rbnSoundOff = new RadioButton(game, new Sprite(game, graphicsCollection.GetPack("Off")), new Sprite(Game, graphicsCollection.GetPack("Checkbox")), DrawOrder, positions); rbnSoundOff.AllowDirectUncheck = false; rbnSoundOff.OnCheck += new EventHandler(Do_SoundRadioOffChecked); AddChild(rbnSoundOff); rbnSoundOn.Check(); SoundCurrentState = DefaultOptions.SoundState;//"On" by default switch (SoundCurrentState) { case "On": rbnSoundOn.Check(); break; case "Off": rbnSoundOff.Check(); break; default: rbnSoundOn.Check(); break; } //------------------------------ //------------------------------ //---CONTROLS Submenu Buttons--- btnControls_Mouse = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("MouseOptions")), DrawOrder); btnControls_Mouse.Position = new Point(260, 546); btnControls_Mouse.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnControls_Mouse.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnControls_Mouse.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnControls_Mouse); sublistControls.Add(btnControls_Mouse); btnControls_Keyboard = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("KeyboardOptions")), DrawOrder); btnControls_Keyboard.Position = new Point(260, 601); btnControls_Keyboard.OnPress += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnPressed); btnControls_Keyboard.OnMouseOver += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseOver); btnControls_Keyboard.OnMouseLeave += new EventHandler<ButtonEventArgs>(Do_SubmenuBtnMouseLeave); AddChild(btnControls_Keyboard); sublistControls.Add(btnControls_Keyboard); //---Submenu button CameraSpeed Options----- CameraSpeedSprite = new Sprite(game, graphicsCollection.GetPack("CameraSpeed")); CameraSpeedSprite.XRelative = 400; CameraSpeedSprite.YRelative = 550; AddChild(CameraSpeedSprite); CameraSpeedValueSprite = new Sprite(game, graphicsCollection.GetPack("Increment")); CameraSpeedValueSprite.XRelative = 637; CameraSpeedValueSprite.YRelative = 550; CameraSpeedValueSprite.FrameNumber = DefaultOptions.CameraSpeed;//0 by default AddChild(CameraSpeedValueSprite); positions = new int[6] { 630, 543, 590, 543, 727, 543 }; CameraSpeedIndicator = new Scrollbar(game, new Sprite(game, graphicsCollection.GetPack("PlusMinusDisplay")), new Sprite(Game, graphicsCollection.GetPack("Minus")), new Sprite(Game, graphicsCollection.GetPack("Plus")), DrawOrder, positions); CameraSpeedIndicator.OnScrollUp += new EventHandler(Do_CameraSpeedIndicator_LeftScroll); CameraSpeedIndicator.OnScrollDown += new EventHandler(Do_CameraSpeedIndicator_RightScroll); AddChild(CameraSpeedIndicator); //--------------------------------------- //---Submenu button KeyShortcuts Options----- btnKeyShortcuts = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("KeyShortcuts")), DrawOrder); btnKeyShortcuts.Position = new Point(440, 600); btnKeyShortcuts.OnMousePress += new EventHandler<MouseEventArgs>(Do_BtnKeyShortcutsPressed); btnKeyShortcuts.OnMouseRelease += new EventHandler<MouseEventArgs>(Do_BtnKeyShortcutsReleased); AddChild(btnKeyShortcuts); KeyShortcutsPanel = new Sprite(game, graphicsCollection.GetPack("KeyShortcutsPanel")); KeyShortcutsPanel.XRelative = 52; KeyShortcutsPanel.YRelative = 125; KeyShortcutsPanel.StackOrder = DrawOrder + 2; KeyShortcutsPanel.Enabled = false; AddChild(KeyShortcutsPanel); btnKeyShortcutsPanel_Back = new CommandCenterGeneralButton(game, new Sprite(game, graphicsCollection.GetPack("btnKeyShortcutsPanel_Back")), DrawOrder+3); btnKeyShortcutsPanel_Back.Position = new Point(855, 150); btnKeyShortcutsPanel_Back.OnMouseRelease += new EventHandler<MouseEventArgs>(Do_BtnKeyShortcutsPanel_BackReleased); btnKeyShortcutsPanel_Back.Enabled = false; AddChild(btnKeyShortcutsPanel_Back); //--------------------------------------- //------------------------------ //------------------------------ //--Saving/Setting LastSave Options (which are the Default values, at this point) TimeValueIndexSelected_LastSave = TimeValueIndexSelected; if (rbnEasy.IsChecked) DifficultyLevel_LastSave = rbnEasy.Name; else if (rbnMedium.IsChecked) DifficultyLevel_LastSave = rbnMedium.Name; else DifficultyLevel_LastSave = rbnHard.Name; ResolutionValueIndexSelected_LastSave = ResolutionValueIndexSelected; if (rbnFullScreenOn.IsChecked) FullScreenState_LastSave = "On"; else FullScreenState_LastSave = "Off"; VolumeValue_LastSave = VolumeValueSprite.FrameNumber; if (rbnSoundOn.IsChecked) SoundState_LastSave = "On"; else SoundState_LastSave = "Off"; CameraSpeed_LastState = CameraSpeedValueSprite.FrameNumber; //------------------------------ generalButtons.Add(sublistGame); generalButtons.Add(sublistVideo); generalButtons.Add(sublistAudio); generalButtons.Add(sublistControls); this.StackOrder = DrawOrder; }
/// <summary> /// Saves the options to the Settings xml /// </summary> void CommandCenter_OnSaveOptions(object sender, CommandCenterEventArgs e) { //CommandCenter.OnSaveOptions -= new EventHandler<CommandCenterEventArgs>(CommandCenter_OnSaveOptions); ResetAutosaveTimer(e.AutosaveTimeValue); //sound float volume = (float)e.VolumeValue; if (volume > 0) volume /= 10; //maximum will be 0.9f SoundManager.GeneralSoundVolume = volume; if (e.SoundState == "On") SoundManager.SoundsOn = true; else SoundManager.SoundsOn = false; xmlData.SaveSettings(profilesFolder + "\\" + currentProfileFolder, e); }
/// <summary> /// Saves the current profile's time gate upgrades /// </summary> public void SaveGame(CommandCenterEventArgs timeGateUpgrades) { xmlData.SaveTimeGateUpgradeLevels(profilesFolder + "\\" + currentProfileFolder, timeGateUpgrades); }