private void UpdateGUIPosition() { const int SECTION_PADDING = 50; const int OPTION_PADDING = 10; const int LABEL_PADDING = 3; _lblTitle.Position = new Vector2i(_boundingArea.Left + 10, _boundingArea.Top + 10); _lblTitle.Update(0); _lstResolution.Position = new Vector2i(_boundingArea.Left + SECTION_PADDING, _lblTitle.Position.Y + _lblTitle.ClientArea.Height + SECTION_PADDING); _lstResolution.Update(0); _chkFullscreen.Position = new Vector2i(_lstResolution.Position.X, _lstResolution.Position.Y + _lstResolution.ClientArea.Height + SECTION_PADDING); _chkFullscreen.Update(0); _lblFullscreen.Position = new Vector2i(_chkFullscreen.Position.X + _chkFullscreen.ClientArea.Width + LABEL_PADDING, _chkFullscreen.Position.Y); _lblFullscreen.Update(0); _chkVsync.Position = new Vector2i(_lblFullscreen.Position.X, _lblFullscreen.Position.Y + _lblFullscreen.ClientArea.Height + OPTION_PADDING); _chkVsync.Update(0); _lblVsync.Position = new Vector2i(_chkVsync.Position.X + _chkVsync.ClientArea.Width + LABEL_PADDING, _chkVsync.Position.Y); _lblVsync.Update(0); _btnApply.Position = new Vector2i((_boundingArea.Left + _boundingArea.Width) - (_btnApply.ClientArea.Width + SECTION_PADDING), (_boundingArea.Top + _boundingArea.Height) - (_btnApply.ClientArea.Height + SECTION_PADDING)); _btnApply.Update(0); _btnBack.Position = new Vector2i(_btnApply.Position.X - (_btnBack.ClientArea.Width + OPTION_PADDING), _btnApply.Position.Y); _btnBack.Update(0); }
public OptionsMenu(IDictionary <Type, object> managers) : base(managers) { _background = ResourceManager.GetSprite("mainbg"); // _background.Smoothing = Smoothing.Smooth; _lblFullscreen = new Label("Fullscreen", "CALIBRI", ResourceManager); _chkFullscreen = new Checkbox(ResourceManager); _chkFullscreen.Value = ConfigurationManager.GetFullscreen(); _chkFullscreen.ValueChanged += _chkfullscreen_ValueChanged; _lblVsync = new Label("Vsync", "CALIBRI", ResourceManager); _chkVsync = new Checkbox(ResourceManager); _chkVsync.Value = ConfigurationManager.GetVsync(); _chkVsync.ValueChanged += _chkvsync_ValueChanged; _lstResolution = new Listbox(250, 150, ResourceManager); _lstResolution.ItemSelected += _reslistbox_ItemSelected; IOrderedEnumerable <VideoMode> modes = from v in SFML.Window.VideoMode.FullscreenModes where (v.Height > 748 && v.Width > 1024) //GOSH I HOPE NOONES USING 16 BIT COLORS. OR RUNNING AT LESS THAN 59 hz orderby v.Height * v.Width ascending select v; if (!modes.Any()) { //No compatible videomodes at all. It is likely the game is being run on a calculator. TODO handle this. Application.Exit(); } foreach (VideoMode vm in modes) { if (!vmList.ContainsKey(GetVmString(vm))) { vmList.Add(GetVmString(vm), vm); _lstResolution.AddItem(GetVmString(vm)); } } if ( vmList.Any( x => x.Value.Width == CluwneLib.Screen.Size.X && x.Value.Height == CluwneLib.Screen.Size.Y)) { KeyValuePair <string, VideoMode> curr = vmList.FirstOrDefault( x => x.Value.Width == CluwneLib.Screen.Size.X && x.Value.Height == CluwneLib.Screen.Size.Y); _lstResolution.SelectItem(curr.Key, false); } else { //No match due to different refresh rate in windowed mode. Just pick first resolution based on size only. KeyValuePair <string, VideoMode> curr = vmList.FirstOrDefault( x => x.Value.Width == CluwneLib.Screen.Size.X && x.Value.Height == CluwneLib.Screen.Size.Y); _lstResolution.SelectItem(curr.Key, false); } _ticketBg = ResourceManager.GetSprite("ticketoverlay"); _btnMainMenu = new Label("Main Menu", "CALIBRI", ResourceManager); _btnMainMenu.DrawBorder = true; _btnMainMenu.Clicked += _mainmenubtt_Clicked; _btnApply = new Label("Apply", "CALIBRI", ResourceManager); _btnApply.DrawBorder = true; _btnApply.Clicked += _applybtt_Clicked; _lstResolution.Position = new Point(45, (int)(CluwneLib.Screen.Size.Y / 2.5f)); _lstResolution.Update(0); _chkFullscreen.Position = new Point(_lstResolution.Position.X, _lstResolution.Position.Y + _lstResolution.ClientArea.Height + 10); _chkFullscreen.Update(0); _chkVsync.Position = new Point(_chkFullscreen.Position.X, _chkFullscreen.Position.Y + _chkFullscreen.ClientArea.Height + 10); _chkVsync.Update(0); _lblFullscreen.Position = new Point(_chkFullscreen.Position.X + _chkFullscreen.ClientArea.Width + 3, _chkFullscreen.Position.Y + (int)(_chkFullscreen.ClientArea.Height / 2f) - (int)(_lblFullscreen.ClientArea.Height / 2f)); _lblFullscreen.Update(0); _lblVsync.Position = new Point(_chkVsync.Position.X + _chkVsync.ClientArea.Width + 3, _chkVsync.Position.Y + (int)(_chkVsync.ClientArea.Height / 2f) - (int)(_chkVsync.ClientArea.Height / 2f)); _lblVsync.Update(0); _btnMainMenu.Position = new Point(_lstResolution.Position.X + 650, _lstResolution.Position.Y); _btnMainMenu.Update(0); _btnApply.Position = new Point(_btnMainMenu.Position.X, _btnMainMenu.Position.Y + _btnMainMenu.ClientArea.Height + 5); _btnApply.Update(0); }
public override void Update(GameTime gametime) { a.Update(); base.Update(gametime); }