private void PopulateAvailableVideoModes() { _lstResolution.ClearItems(); vmList.Clear(); 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()) { throw new Exception("No available video modes"); } 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); } }
void RefreshEditor() { if (chunk.objects == null) { return; } string[] chunkItems = new string[chunk.objects.Count]; for (int i = 0; i < chunkItems.Length; i++) { chunkItems[i] = chunk.objects[i].texture + "." + chunk.objects[i].id.ToString(); } ChunkItemList = new Listbox(chunkItems, "Items", new Rect(10, 480, 200, 140), 20); string[] savedChunks = CubeFile.CheckDirectory("SavedFiles/Chunks"); SavedChunksList = new Listbox(savedChunks, "SavedChunks", new Rect(10, 295, 200, 140), 20); foreach (var item in SavedChunksList.items) { item.action = window.LoadChunk; Debug.Log(item.content[0].text + " " + chunk.Name); if (item.content[0].text.Contains(chunk.Name)) { SavedChunksList.SelectItem(item.id); } } //chunk = new Chunk("NewChunk", new Rect(0, 0, 1, 1), 0, 0, new List<LevelObj>(), 0); }
private void PopulateAvailableVideoModes(Listbox resListBox) { resListBox.ClearItems(); _videoModeList.Clear(); var modes = VideoMode.FullscreenModes .Where(v => v.Height > 748 && v.Width > 1024) .OrderBy(v => v.Height * v.Width) .ToList(); if (!modes.Any()) { throw new InvalidOperationException("No available video modes"); } foreach (var vm in modes) { if (!_videoModeList.ContainsKey(GetVmString(vm))) { _videoModeList.Add(GetVmString(vm), vm); resListBox.AddItem(GetVmString(vm)); } } if (_videoModeList.Any(x => x.Value.Width == CluwneLib.Window.Viewport.Size.X && x.Value.Height == CluwneLib.Window.Viewport.Size.Y)) { var currentMode = _videoModeList.FirstOrDefault(x => x.Value.Width == CluwneLib.Window.Viewport.Size.X && x.Value.Height == CluwneLib.Window.Viewport.Size.Y); resListBox.SelectItem(currentMode.Key); } else { //No match due to different refresh rate in windowed mode. Just pick first resolution based on size only. var currentMode = _videoModeList.FirstOrDefault( x => x.Value.Width == CluwneLib.Window.Viewport.Size.X && x.Value.Height == CluwneLib.Window.Viewport.Size.Y); resListBox.SelectItem(currentMode.Key); } }
public void OnClick() { if (GUI.Button(boundryBox, "", GUIStyle.none)) { parent.SelectItem(id); if (action != null) { action.Invoke(content[0].text); } } }
private Control CreateEditField(object obj, FieldInfo field) { switch (obj) { case string s: var editStr = new Textbox(100); editStr.ClearOnSubmit = false; editStr.UserData = field; editStr.Text = s; editStr.OnSubmit += editStr_OnSubmit; return(editStr); case Enum _: var editEnum = new Listbox(100, 100, Enum.GetNames(obj.GetType()).ToList()); editEnum.UserData = field; editEnum.SelectItem(obj.ToString()); editEnum.ItemSelected += editEnum_ItemSelected; return(editEnum); default: if (obj is float || obj is int || obj is short || obj is long || obj is double || obj is decimal) { var editNum = new Textbox(100); editNum.ClearOnSubmit = false; editNum.UserData = field; editNum.Text = obj.ToString(); editNum.OnSubmit += editNum_OnSubmit; return(editNum); } else if (obj is bool) { var editBool = new Checkbox(); editBool.UserData = field; editBool.Value = (bool)obj; editBool.ValueChanged += editBool_ValueChanged; return(editBool); } break; } return(null); }
private Control CreateEditField(object o, FieldInfo field) { if (o is String || o is string) { var editStr = new Textbox(100); 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, 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); 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(); editBool.UserData = field; editBool.Value = ((Boolean)o); editBool.ValueChanged += editBool_ValueChanged; return(editBool); } return(null); }
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); }
void Object_MouseSelector() { if (Event.current.control) { Vector2 filteredMousePosition = new Vector2(HandleUtility.WorldToGUIPoint(Event.current.mousePosition).x - grid.rect.left, HandleUtility.WorldToGUIPoint(Event.current.mousePosition).y - grid.rect.top); filteredMousePosition /= gridScale; if (grid.rect.Contains(filteredMousePosition * gridScale + new Vector2(grid.rect.left, grid.rect.top))) { grabbedObj = new Rect(filteredMousePosition.x, filteredMousePosition.y, grabbedObj.width, grabbedObj.height); lastGrabbedObjScale = new Vector2(grabbedObj.width, grabbedObj.height); //GUI.DrawTexture (grabbedObj, Resources.Load<Texture> ("Objects/" + lst5.getSelectedItemContent ())); if (Event.current.button == 0 && Event.current.type == EventType.mouseDown) { if (chunk.objects.Count > 0) { Vector2 grabbedPosition = new Vector2((grid.FilterPosition(filteredMousePosition + new Vector2(hScroll + grid.rect.left, 0), gridScale).x), (grid.FilterPosition(filteredMousePosition + new Vector2(0, vScroll + grid.rect.top), gridScale).y)); foreach (LevelObj item in chunk.objects) { //if (item.position.left == grabbedPosition.x && item.position.top == grabbedPosition.y) { if (ChangeType(item.position).Contains(grabbedPosition)) { ChunkItemList.SelectItem(item.texture + "." + item.id); SelectItemOnScene(""); } } } } else if (Event.current.button == 0 && Event.current.type == EventType.mouseDrag) { if (selectedLevelObj.position.depth != 40 - ((activeLayer + 1) * 5)) { return; } if (dynamicSelection.objects.Count == 0) { if (selectedLevelObj != null) { if (chunk.objects.Count > 0) { Vector2 grabbedPosition = new Vector2((grid.FilterPosition(filteredMousePosition + new Vector2(hScroll + grid.rect.left, 0), gridScale).x), (grid.FilterPosition(filteredMousePosition + new Vector2(0, vScroll + grid.rect.top), gridScale).y)); selectedLevelObj.position = new ObjRect((int)grabbedPosition.x, (int)grabbedPosition.y, selectedLevelObj.position.width, selectedLevelObj.position.height, selectedLevelObj.position.depth); SelectItemOnScene(""); } } } } } } else { if (Event.current.button == 0 && Event.current.type == EventType.mouseDown) { objSelectorGrid.position = new ObjRect(0, 0, 0, 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; _reslistbox = new Listbox(250, 150, ResourceManager); _reslistbox.ItemSelected += _reslistbox_ItemSelected; IOrderedEnumerable <VideoMode> modes = from v in Gorgon.CurrentDriver.VideoModes where (v.Height > 748 && v.Width > 1024) && v.Format == BackBufferFormats.BufferRGB888 && v.RefreshRate >= 59 //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); _reslistbox.AddItem(GetVmString(vm)); } } if ( vmList.Any( x => x.Value.Width == Gorgon.CurrentVideoMode.Width && x.Value.Height == Gorgon.CurrentVideoMode.Height && x.Value.RefreshRate == (Gorgon.Screen.Windowed ? Gorgon.DesktopVideoMode.RefreshRate : Gorgon.CurrentVideoMode.RefreshRate))) { KeyValuePair <string, VideoMode> curr = vmList.FirstOrDefault( x => x.Value.Width == Gorgon.CurrentVideoMode.Width && x.Value.Height == Gorgon.CurrentVideoMode.Height && x.Value.RefreshRate == (Gorgon.Screen.Windowed ? Gorgon.DesktopVideoMode.RefreshRate : Gorgon.CurrentVideoMode.RefreshRate)); _reslistbox.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 == Gorgon.CurrentVideoMode.Width && x.Value.Height == Gorgon.CurrentVideoMode.Height); _reslistbox.SelectItem(curr.Key, false); } _ticketbg = ResourceManager.GetSprite("ticketoverlay"); _mainmenubtt = new Label("Main Menu", "CALIBRI", ResourceManager); _mainmenubtt.DrawBorder = true; _mainmenubtt.Clicked += _mainmenubtt_Clicked; _applybtt = new Label("Apply", "CALIBRI", ResourceManager); _applybtt.DrawBorder = true; _applybtt.Clicked += _applybtt_Clicked; }
public EntitySpawnWindow(Vector2i size) : base("Entity Spawn Panel", size) { _placementManager = IoCManager.Resolve <IPlacementManager>(); _entityList = new ScrollableContainer(new Vector2i(200, 400)); _entityList.LocalPosition = new Vector2i(5, 5); Container.AddControl(_entityList); var searchLabel = new Label("Entity Search:", "CALIBRI"); searchLabel.LocalPosition = new Vector2i(210, 0); Container.AddControl(searchLabel); var entSearchTextbox = new Textbox(125); entSearchTextbox.LocalPosition = new Vector2i(210, 20); entSearchTextbox.OnSubmit += entSearchTextbox_OnSubmit; Container.AddControl(entSearchTextbox); _clearLabel = new Label("[Clear Filter]", "CALIBRI"); _clearLabel.DrawBackground = true; _clearLabel.DrawBorder = true; _clearLabel.LocalPosition = new Vector2i(210, 55); _clearLabel.Clicked += ClearLabelClicked; _clearLabel.BackgroundColor = Color.Gray; Container.AddControl(_clearLabel); var overLabel = new Label("Override Placement:", "CALIBRI"); overLabel.LocalPosition = new Vector2i(0, 15); overLabel.Alignment = ControlAlignments.Bottom; _clearLabel.AddControl(overLabel); var initOpts = new List <string>(); initOpts.AddRange(new[] { "PlaceFree", "PlaceNearby", "SnapgridCenter", "SnapgridBorder", "AlignSimilar", "AlignTileAny", "AlignTileEmpty", "AlignTileNonSolid", "AlignTileSolid", "AlignWall", }); _lstOverride = new Listbox(140, 125, initOpts); _lstOverride.ItemSelected += _lstOverride_ItemSelected; _lstOverride.SelectItem("PlaceFree"); _lstOverride.LocalPosition = new Vector2i(0, 0); _lstOverride.Alignment = ControlAlignments.Bottom; overLabel.AddControl(_lstOverride); _eraserButton = new ImageButton(); _eraserButton.ImageNormal = "erasericon"; _eraserButton.LocalPosition = new Vector2i(5, 0); _eraserButton.Alignment = ControlAlignments.Right; _clearLabel.AddControl(_eraserButton); _eraserButton.Clicked += EraserButtonClicked; BuildEntityList(); _placementManager.PlacementCanceled += PlacementManagerPlacementCanceled; }