private void editEnum_ItemSelected(Label item, Listbox sender) { var field = (FieldInfo)sender.UserData; object state = Enum.Parse(field.FieldType, item.Text.Text, true); if (field.IsInitOnly || field.IsLiteral) { return; } field.SetValue(assigned, state); }
private void _lstOverride_ItemSelected(Label item, Listbox sender) { var pMan = (PlacementManager)_placementManager; if (pMan.CurrentMode != null) { var newObjInfo = new PlacementInformation { PlacementOption = item.Text.Text, EntityType = pMan.CurrentPermission.EntityType, Range = -1, IsTile = pMan.CurrentPermission.IsTile }; _placementManager.Clear(); _placementManager.BeginPlacing(newObjInfo); } }
private GuiComponent CreateEditField(object o, FieldInfo field) { if (o is String || o is string) { var editStr = new Textbox(100, _resourceManager); editStr.ClearOnSubmit = false; editStr.UserData = field; editStr.Text = ((string)o); editStr.OnSubmit += editStr_OnSubmit; return(editStr); } else if (o is Enum) { var editEnum = new Listbox(100, 100, _resourceManager, Enum.GetNames(o.GetType()).ToList()); editEnum.UserData = field; editEnum.SelectItem(o.ToString()); editEnum.ItemSelected += editEnum_ItemSelected; return(editEnum); } else if (o is float || o is int || o is Int16 || o is Int32 || o is Int64 || o is double || o is Double || o is decimal || o is Decimal || o is Single) { var editNum = new Textbox(100, _resourceManager); editNum.ClearOnSubmit = false; editNum.UserData = field; editNum.Text = o.ToString(); editNum.OnSubmit += editNum_OnSubmit; return(editNum); } else if (o is bool || o is Boolean) { var editBool = new Checkbox(_resourceManager); editBool.UserData = field; editBool.Value = ((Boolean)o); editBool.ValueChanged += editBool_ValueChanged; return(editBool); } return(null); }
public EntitySpawnPanel(Size size, IResourceManager resourceManager, IPlacementManager placementManager) : base("Entity Spawn Panel", size, resourceManager) { _resourceManager = resourceManager; _placementManager = placementManager; _entityList = new ScrollableContainer("entspawnlist", new Size(200, 400), _resourceManager) {Position = new Point(5, 5)}; components.Add(_entityList); var searchLabel = new Label("Entity Search:", "CALIBRI", _resourceManager) {Position = new Point(210, 0)}; components.Add(searchLabel); _entSearchTextbox = new Textbox(125, _resourceManager) {Position = new Point(210, 20)}; _entSearchTextbox.OnSubmit += entSearchTextbox_OnSubmit; components.Add(_entSearchTextbox); _clearLabel = new Label("[Clear Filter]", "CALIBRI", _resourceManager) { DrawBackground = true, DrawBorder = true, Position = new Point(210, 55) }; _overLabel = new Label("Override Placement:", "CALIBRI", _resourceManager) { Position = _clearLabel.Position + new Size(0, _clearLabel.ClientArea.Height + 15) }; components.Add(_overLabel); var initOpts = new List<string>(); initOpts.AddRange(new[] { "None", "AlignNone", "AlignFree", "AlignSimilar", "AlignTileAny", "AlignTileEmpty", "AlignTileNonSolid", "AlignTileSolid", "AlignWall", "AlignWallTops" }); _lstOverride = new Listbox(150, 125, resourceManager, initOpts); _lstOverride.SelectItem("None"); _lstOverride.ItemSelected += _lstOverride_ItemSelected; _lstOverride.Position = _overLabel.Position + new Size(0, _overLabel.ClientArea.Height); components.Add(_lstOverride); _clearLabel.Clicked += ClearLabelClicked; _clearLabel.BackgroundColor = Color.Gray; components.Add(_clearLabel); _eraserButton = new ImageButton { ImageNormal = "erasericon", Position = new Point(_clearLabel.Position.X + _clearLabel.ClientArea.Width + 5, _clearLabel.Position.Y) }; //eraserButton.Position = new Point(clearLabel.ClientArea.Right + 5, clearLabel.ClientArea.Top); Clientarea not updating properly. FIX THIS _eraserButton.Clicked += EraserButtonClicked; components.Add(_eraserButton); BuildEntityList(); Position = new Point((int) (CluwneLib.CurrentRenderTarget.Size.X/2f) - (int) (ClientArea.Width/2f), (int) (CluwneLib.CurrentRenderTarget.Size.Y/2f) - (int) (ClientArea.Height/2f)); _placementManager.PlacementCanceled += PlacementManagerPlacementCanceled; }
private void _lstOverride_ItemSelected(Label item, Listbox sender) { var pMan = (PlacementManager) _placementManager; if (pMan.CurrentMode != null) { var newObjInfo = new PlacementInformation { PlacementOption = item.Text.Text, EntityType = pMan.CurrentPermission.EntityType, Range = -1, IsTile = pMan.CurrentPermission.IsTile }; _placementManager.Clear(); _placementManager.BeginPlacing(newObjInfo); } }
public EntitySpawnPanel(Vector2i size, IResourceManager resourceManager, IPlacementManager placementManager) : base("Entity Spawn Panel", size, resourceManager) { _resourceManager = resourceManager; _placementManager = placementManager; _entityList = new ScrollableContainer("entspawnlist", new Vector2i(200, 400), _resourceManager) { Position = new Vector2i(5, 5) }; components.Add(_entityList); var searchLabel = new Label("Entity Search:", "CALIBRI", _resourceManager) { Position = new Vector2i(210, 0) }; components.Add(searchLabel); _entSearchTextbox = new Textbox(125, _resourceManager) { Position = new Vector2i(210, 20) }; _entSearchTextbox.OnSubmit += entSearchTextbox_OnSubmit; components.Add(_entSearchTextbox); _clearLabel = new Label("[Clear Filter]", "CALIBRI", _resourceManager) { DrawBackground = true, DrawBorder = true, Position = new Vector2i(210, 55) }; _overLabel = new Label("Override Placement:", "CALIBRI", _resourceManager) { Position = _clearLabel.Position + new Vector2i(0, _clearLabel.ClientArea.Height + 15) }; components.Add(_overLabel); var initOpts = new List <string>(); initOpts.AddRange(new[] { "None", "AlignNone", "AlignFree", "AlignSimilar", "AlignTileAny", "AlignTileEmpty", "AlignTileNonSolid", "AlignTileSolid", "AlignWall", "AlignWallTops" }); _lstOverride = new Listbox(150, 125, resourceManager, initOpts); _lstOverride.SelectItem("None"); _lstOverride.ItemSelected += _lstOverride_ItemSelected; _lstOverride.Position = _overLabel.Position + new Vector2i(0, _overLabel.ClientArea.Height); components.Add(_lstOverride); _clearLabel.Clicked += ClearLabelClicked; _clearLabel.BackgroundColor = new SFML.Graphics.Color(128, 128, 128); components.Add(_clearLabel); _eraserButton = new ImageButton { ImageNormal = "erasericon", Position = new Vector2i(_clearLabel.Position.X + _clearLabel.ClientArea.Width + 5, _clearLabel.Position.Y) }; //eraserButton.Position = new Vector2i(clearLabel.ClientArea.Right + 5, clearLabel.ClientArea.Top); Clientarea not updating properly. FIX THIS _eraserButton.Clicked += EraserButtonClicked; components.Add(_eraserButton); BuildEntityList(); Position = new Vector2i((int)(CluwneLib.CurrentRenderTarget.Size.X / 2f) - (int)(ClientArea.Width / 2f), (int)(CluwneLib.CurrentRenderTarget.Size.Y / 2f) - (int)(ClientArea.Height / 2f)); _placementManager.PlacementCanceled += PlacementManagerPlacementCanceled; }
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.Camera.ViewSize.X && x.Value.Height == CluwneLib.Camera.ViewSize.Y )) { KeyValuePair<string, VideoMode> curr = vmList.FirstOrDefault( x => x.Value.Width == CluwneLib.Camera.ViewSize.X && x.Value.Height == CluwneLib.Camera.ViewSize.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.Camera.ViewSize.X && x.Value.Height == CluwneLib.Camera.ViewSize.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.Camera.ViewSize.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); }
private void _reslistbox_ItemSelected(Label item, Listbox sender) { if (vmList.ContainsKey(item.Text.Text)) { VideoMode sel = vmList[item.Text.Text]; ConfigurationManager.SetResolution((uint) sel.Width, (uint) sel.Height); } }
private GuiComponent CreateEditField(object o, FieldInfo field) { if (o is String || o is string) { var editStr = new Textbox(100, _resourceManager); editStr.ClearOnSubmit = false; editStr.UserData = field; editStr.Text = ((string) o); editStr.OnSubmit += editStr_OnSubmit; return editStr; } else if (o is Enum) { var editEnum = new Listbox(100, 100, _resourceManager, Enum.GetNames(o.GetType()).ToList()); editEnum.UserData = field; editEnum.SelectItem(o.ToString()); editEnum.ItemSelected += editEnum_ItemSelected; return editEnum; } else if (o is float || o is int || o is Int16 || o is Int32 || o is Int64 || o is double || o is Double || o is decimal || o is Decimal || o is Single) { var editNum = new Textbox(100, _resourceManager); editNum.ClearOnSubmit = false; editNum.UserData = field; editNum.Text = o.ToString(); editNum.OnSubmit += editNum_OnSubmit; return editNum; } else if (o is bool || o is Boolean) { var editBool = new Checkbox(_resourceManager); editBool.UserData = field; editBool.Value = ((Boolean) o); editBool.ValueChanged += editBool_ValueChanged; return editBool; } return null; }
private void editEnum_ItemSelected(Label item, Listbox sender) { var field = (FieldInfo) sender.UserData; object state = Enum.Parse(field.FieldType, item.Text.Text, true); if (field.IsInitOnly || field.IsLiteral) return; field.SetValue(assigned, state); }