//private float transitionElapsedTime; public OptionsScreen(MainMenuScreen s, Rectangle dimensions) { this.r = dimensions; this.mmscreen = s; base.IsPopup = true; base.TransitionOnTime = TimeSpan.FromSeconds(0.25); base.TransitionOffTime = TimeSpan.FromSeconds(0.25); this.ModeToSet = Game1.Instance.CurrentMode; }
public OptionsScreen(UniverseScreen s, GameplayMMScreen gpmmscreen, Rectangle dimensions) { this.gpmmscreen = gpmmscreen; this.uScreen = s; this.fade = false; base.IsPopup = true; this.FromGame = true; base.TransitionOnTime = TimeSpan.FromSeconds(0); base.TransitionOffTime = TimeSpan.FromSeconds(0); this.r = dimensions; this.ModeToSet = Game1.Instance.CurrentMode; }
public override void HandleInput(InputState input) { this.currentMouse = input.CurrentMouseState; Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y); this.GamespeedCap.HandleInput(input); this.ForceFullSim.HandleInput(input); this.pauseOnNotification.HandleInput(input); this.KeyboardArc.HandleInput(input); this.IconSize.HandleInput(input); GlobalStats.IconSize = (int)this.IconSize.amountRange; this.memoryLimit.HandleInput(input); GlobalStats.MemoryLimiter = this.memoryLimit.amountRange; this.ShipLimiter.HandleInput(input); GlobalStats.ShipCountLimit = (int)this.ShipLimiter.amountRange; this.FreighterLimiter.HandleInput(input); GlobalStats.freighterlimit = (int)this.FreighterLimiter.amountRange; if (!this.ResolutionDropDown.Open)// && !this.AntiAliasingDD.Open) { this.MusicVolumeSlider.HandleInput(input); GlobalStats.Config.MusicVolume = this.MusicVolumeSlider.amount; base.ScreenManager.musicCategory.SetVolume(this.MusicVolumeSlider.amount); base.ScreenManager.racialMusic.SetVolume(this.MusicVolumeSlider.amount); base.ScreenManager.combatMusic.SetVolume(this.MusicVolumeSlider.amount); this.EffectsVolumeSlider.HandleInput(input); GlobalStats.Config.EffectsVolume = this.EffectsVolumeSlider.amount; base.ScreenManager.weaponsCategory.SetVolume(this.EffectsVolumeSlider.amount); base.ScreenManager.defaultCategory.SetVolume(this.EffectsVolumeSlider.amount *.5f); if (this.EffectsVolumeSlider.amount == 0 && this.MusicVolumeSlider.amount == 0) base.ScreenManager.GlobalCategory.SetVolume(0); else base.ScreenManager.GlobalCategory.SetVolume(1); } if (!this.ResolutionDropDown.Open) { if (!HelperFunctions.CheckIntersection(this.FullScreen.ClickableArea, MousePos)) { this.FullScreen.highlighted = false; } else { if (!this.FullScreen.highlighted) { AudioManager.PlayCue("sd_ui_mouseover"); } this.FullScreen.highlighted = true; if (input.InGameSelect) { AudioManager.PlayCue("blip_click"); ++this.ModeToSet; if (this.ModeToSet > Game1.WindowMode.Borderless) this.ModeToSet = Game1.WindowMode.Fullscreen; this.FullScreen.Value = (object)((object)this.ModeToSet).ToString(); } } } if (input.Escaped || input.RightMouseClick) { this.ExitScreen(); } for (int i = 0; i < this.Buttons.Count; i++) { UIButton b = this.Buttons[i]; if (b != null) { if (!HelperFunctions.CheckIntersection(b.Rect, MousePos)) { b.State = UIButton.PressState.Normal; } else { b.State = UIButton.PressState.Hover; if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed) { b.State = UIButton.PressState.Pressed; } if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released) { string launches = b.Launches; if (launches != null && launches == "Apply Settings") { this.ApplySettings(); } } } } } this.ResolutionDropDown.HandleInput(input); this.previousMouse = input.LastMouseState; base.HandleInput(input); }
private void CancelChanges(object sender, EventArgs e1) { Game1.Instance.graphics.PreferredBackBufferWidth = this.startingx; Game1.Instance.graphics.PreferredBackBufferHeight = this.startingy; Game1.Instance.graphics.SynchronizeWithVerticalRetrace = false; Game1.Instance.SetWindowMode(this.StartingMode, this.startingx, this.startingy); this.ModeToSet = this.StartingMode; base.Setup(); if (this.FromGame) { this.uScreen.LoadGraphics(); this.gpmmscreen.LoadGraphics(); this.LoadGraphics(); } else { this.mmscreen.Buttons.Clear(); this.mmscreen.LoadContent(); } this.MainOptionsRect = new Rectangle(this.r.X + 20, this.r.Y + 175, 300, 375); this.SecondaryOptionsRect = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width, this.MainOptionsRect.Y, 210, 305); this.GamespeedCap = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + 300)), Localizer.Token(2206), new Ref<bool>(() => GlobalStats.LimitSpeed, (bool x) => GlobalStats.LimitSpeed = x), Fonts.Arial12Bold) { Tip_Token = 2205 }; this.Resolution = new OptionsScreen.Option() { Name = string.Concat(Localizer.Token(9), ": "), NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + 20)) }; string xResolution = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth.ToString(); string yResolution = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight.ToString(); this.xtoApply = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; this.ytoApply = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; string reso = string.Concat(xResolution, " x ", yResolution); this.Resolution.ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(reso).X, Fonts.Arial20Bold.LineSpacing); this.Resolution.Value = reso; this.Resolution.highlighted = false; this.FullScreen = new OptionsScreen.Option() { Name = string.Concat(Localizer.Token(10), ": "), NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + Fonts.Arial20Bold.LineSpacing * 2 + 2 + 20)), Value = Game1.Instance.CurrentMode, ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.FullScreen.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(this.FullScreen.Value.ToString()).X, Fonts.Arial20Bold.LineSpacing) }; Rectangle ftlRect = new Rectangle(this.MainOptionsRect.X + 20, (int)this.FullScreen.NamePosition.Y + 40, 270, 50); this.MusicVolumeSlider = new FloatSlider(ftlRect, "Music Volume"); this.MusicVolumeSlider.SetAmount(GlobalStats.Config.MusicVolume); this.MusicVolumeSlider.amount = GlobalStats.Config.MusicVolume; ftlRect = new Rectangle(this.MainOptionsRect.X + 20, (int)ftlRect.Y + 50, 270, 50); this.EffectsVolumeSlider = new FloatSlider(ftlRect, "Effects Volume"); this.EffectsVolumeSlider.SetAmount(GlobalStats.Config.EffectsVolume); this.EffectsVolumeSlider.amount = GlobalStats.Config.EffectsVolume; Vector2 Cursor = new Vector2((float)(this.SecondaryOptionsRect.X + 10), (float)(this.SecondaryOptionsRect.Y + 10)); this.ResolutionOptions.Clear(); this.ResolutionDropDown = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y + 3, 105, 18)); foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { if (mode.Width < 1280) { continue; } OptionsScreen.Option reso1 = new OptionsScreen.Option(); //{ reso1.x = mode.Width; reso1.y = mode.Height; reso1.Name = string.Concat(reso1.x.ToString(), " x ", reso1.y.ToString()); reso1.NamePosition = Cursor; reso1.ClickableArea = new Rectangle((int)reso1.NamePosition.X, (int)reso1.NamePosition.Y, (int)Fonts.Arial12Bold.MeasureString(reso1.Name).X, Fonts.Arial12Bold.LineSpacing); //}; bool oktoadd = true; foreach (OptionsScreen.Option opt in this.ResolutionOptions) { if (opt.x != reso1.x || opt.y != reso1.y) { continue; } oktoadd = false; } if (!oktoadd) { continue; } this.ResolutionDropDown.AddOption(reso1.Name, reso1); this.ResolutionOptions.Add(reso1); Cursor.Y = Cursor.Y + (float)Fonts.Arial12Bold.LineSpacing; } foreach (OptionsScreen.Option resolut in this.ResolutionOptions) { if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth != resolut.x || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight != resolut.y) { continue; } foreach (Entry e in this.ResolutionDropDown.Options) { if ((e.ReferencedObject as OptionsScreen.Option).Name != resolut.Name) { continue; } this.ResolutionDropDown.ActiveIndex = this.ResolutionDropDown.Options.IndexOf(e); } } Cursor = new Vector2((float)this.SecondaryOptionsRect.X, (float)(this.SecondaryOptionsRect.Y + this.SecondaryOptionsRect.Height + 15)); this.Apply.Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height); this.Apply.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"]; this.Apply.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"]; this.Apply.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"]; this.Apply.Text = Localizer.Token(13); }
public void SetWindowMode(Game1.WindowMode mode, int width, int height) { if (width <= 0 || height <= 0) { width = 800; height = 600; } Form form = (Form)Control.FromHandle(base.Window.Handle); #if DEBUG if (mode == WindowMode.Fullscreen) mode = WindowMode.Borderless; #endif switch (mode) { case Game1.WindowMode.Fullscreen: { if (!this.graphics.IsFullScreen) { this.graphics.ToggleFullScreen(); } this.graphics.PreferredBackBufferWidth = width; this.graphics.PreferredBackBufferHeight = height; this.graphics.ApplyChanges(); this.CurrentMode = Game1.WindowMode.Fullscreen; GlobalStats.Config.WindowMode = 0; return; } case Game1.WindowMode.Windowed: { if (this.graphics.IsFullScreen) { this.graphics.ToggleFullScreen(); } this.graphics.PreferredBackBufferWidth = width; this.graphics.PreferredBackBufferHeight = height; this.graphics.ApplyChanges(); form.WindowState = FormWindowState.Normal; form.FormBorderStyle = FormBorderStyle.Fixed3D; form.ClientSize = new Size(width, height); Size size = Screen.PrimaryScreen.WorkingArea.Size; int num = size.Width / 2 - width / 2; Size size1 = Screen.PrimaryScreen.WorkingArea.Size; form.Location = new System.Drawing.Point(num, size1.Height / 2 - height / 2); this.CurrentMode = Game1.WindowMode.Windowed; GlobalStats.Config.WindowMode = 1; return; } case Game1.WindowMode.Borderless: { if (this.graphics.IsFullScreen) { this.graphics.ToggleFullScreen(); } this.graphics.PreferredBackBufferWidth = width; this.graphics.PreferredBackBufferHeight = height; this.graphics.ApplyChanges(); form.FormBorderStyle = FormBorderStyle.None; form.WindowState = FormWindowState.Normal; form.ClientSize = new Size(width, height); Size size2 = Screen.PrimaryScreen.WorkingArea.Size; int num1 = size2.Width / 2 - width / 2; Size size3 = Screen.PrimaryScreen.WorkingArea.Size; form.Location = new System.Drawing.Point(num1, size3.Height / 2 - height / 2); this.CurrentMode = Game1.WindowMode.Borderless; GlobalStats.Config.WindowMode = 2; return; } default: { return; } } }