public override void Construct() { Border = "border-fancy"; OnConstruct = (sender) => { sender.Root.RegisterForUpdate(sender); var topRow = AddChild(new Widget { AutoLayout = AutoLayout.DockTop, MinimumSize = new Point(0, 24) }); topRow.AddChild(new Widget { AutoLayout = AutoLayout.DockRight, MinimumSize = new Point(32, 0), Text = "Default Priorities", ChangeColorOnHover = true, Border = "border-button", OnClick = (btn, args) => { var screen = sender.Root.RenderData.VirtualScreen; sender.Root.ShowModalPopup(new DefaultTaskPriority { Overworld = World.Overworld, MinimumSize = new Point(256, 512), Border = "border-fancy", Rect = new Rectangle(screen.Center.X - 128, screen.Center.Y - 256, 256, 512) }); } }); FilterBox = topRow.AddChild(new EditableTextField { AutoLayout = AutoLayout.DockFill, MinimumSize = new Point(0, 24), Text = "" }) as EditableTextField; ListView = AddChild(new WidgetListView { AutoLayout = AutoLayout.DockFill, SelectedItemForegroundColor = new Vector4(0, 0, 0, 1), Border = null, ItemHeight = 16 }) as WidgetListView; ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used. }; OnUpdate = (sender, time) => { if (sender.Hidden) { return; } var upperFilter = FilterBox.Text.ToUpperInvariant(); var tasksToDisplay = World.TaskManager.EnumerateTasks() .Where(t => !t.Hidden) .Where(t => String.IsNullOrEmpty(FilterBox.Text) ? true : t.Name.ToUpperInvariant().Contains(upperFilter)); ListView.ClearItems(); foreach (var task in tasksToDisplay) { var tag = task.GuiTag as Widget; var lambdaCopy = task; if (tag != null) { ListView.AddItem(tag); } else { #region Create gui row tag = Root.ConstructWidget(new Widget { Text = task.Name, MinimumSize = new Point(0, 16), Padding = new Margin(0, 0, 4, 4), TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { var loc = lambdaCopy.GetCameraZoomLocation(); if (loc.HasValue) { World.Renderer.Camera.SetZoomTarget(loc.Value); } } }); tag.AddChild(new Widget { Text = "CANCEL", AutoLayout = AutoLayout.DockRight, MinimumSize = new Point(16, 0), TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { World.TaskManager.CancelTask(lambdaCopy); } }); Widget priorityDisplay = null; tag.AddChild(new Gui.Widget { Background = new TileReference("round-buttons", 3), MinimumSize = new Point(16, 16), MaximumSize = new Point(16, 16), AutoLayout = AutoLayout.DockRightCentered, OnClick = (_sender, args) => { lambdaCopy.Priority = (TaskPriority)(Math.Min(4, (int)lambdaCopy.Priority + 1)); priorityDisplay.Text = lambdaCopy.Priority.ToString(); priorityDisplay.Invalidate(); }, OnMouseEnter = (_sender, args) => { _sender.BackgroundColor = GameSettings.Current.Colors.GetColor("Highlight", Color.DarkRed).ToVector4(); _sender.Invalidate(); }, OnMouseLeave = (_sender, args) => { _sender.BackgroundColor = Vector4.One; _sender.Invalidate(); } }); priorityDisplay = tag.AddChild(new Gui.Widget { AutoLayout = AutoLayout.DockRight, MinimumSize = new Point(64, 0), Text = lambdaCopy.Priority.ToString(), TextHorizontalAlign = HorizontalAlign.Center, TextVerticalAlign = VerticalAlign.Center }); tag.AddChild(new Gui.Widget { Background = new TileReference("round-buttons", 7), MinimumSize = new Point(16, 16), MaximumSize = new Point(16, 16), AutoLayout = AutoLayout.DockRightCentered, OnClick = (_sender, args) => { lambdaCopy.Priority = (TaskPriority)(Math.Max(0, (int)lambdaCopy.Priority - 1)); priorityDisplay.Text = lambdaCopy.Priority.ToString(); priorityDisplay.Invalidate(); }, OnMouseEnter = (_sender, args) => { _sender.BackgroundColor = GameSettings.Current.Colors.GetColor("Highlight", Color.DarkRed).ToVector4(); _sender.Invalidate(); }, OnMouseLeave = (_sender, args) => { _sender.BackgroundColor = Vector4.One; _sender.Invalidate(); } }); #endregion task.GuiTag = tag; ListView.AddItem(tag); } tag.Text = task.Name; tag.Tooltip = task.FailureRecord.FormatTooltip(); } ListView.Invalidate(); }; base.Construct(); }
public override void Construct() { Border = "border-one"; Font = "font10"; OnConstruct = (sender) => { sender.Root.RegisterForUpdate(sender); AddChild(new Widget { AutoLayout = AutoLayout.DockBottom, MinimumSize = new Point(0, 32), Text = "CLOSE", ChangeColorOnHover = true, OnClick = (sender1, args) => sender.Close() }); ComponentProperties = AddChild(new Widget { AutoLayout = AutoLayout.DockBottom, MinimumSize = new Point(0, 128), }); ListView = AddChild(new WidgetListView { AutoLayout = AutoLayout.DockFill, SelectedItemForegroundColor = new Vector4(0, 0, 0, 1), ChangeColorOnSelected = false, Border = null, ItemHeight = 24 }) as WidgetListView; ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used. }; OnUpdate = (sender, time) => { if (sender.Hidden) { return; } if (SelectedEntity == null) { SelectedComponent = null; ListView.ClearItems(); return; } var components = SelectedEntity.EnumerateAll(); int i = 0; ListView.ClearItems(); foreach (var component in components) { i++; var tag = component.GuiTag as Widget; var lambdaCopy = component; if (tag != null) { ListView.AddItem(tag); } else { #region Create gui row tag = Root.ConstructWidget(new Widget { Text = component.GetType().Name, MinimumSize = new Point(0, 16), Padding = new Margin(0, 0, 4, 4), TextVerticalAlign = VerticalAlign.Center, Tag = lambdaCopy }); tag.OnClick = (sender1, args) => { if (tag.IsAnyParentHidden()) { return; } SelectedComponent = lambdaCopy; }; #endregion component.GuiTag = tag; ListView.AddItem(tag); } } ListView.Invalidate(); if (SelectedComponent != null) { Drawer3D.DrawBox(SelectedComponent.GetBoundingBox(), Color.White, 0.1f, true); ComponentProperties.Text = SelectedComponent.GetType().Name + "\n" + SelectedComponent.Position.ToString() + "\nBB Extents: " + SelectedComponent.BoundingBoxSize.ToString() + "\nBB Offset: " + SelectedComponent.LocalBoundingBoxOffset.ToString(); } else { ComponentProperties.Text = ""; } }; base.Construct(); }
public void UpdateList(CreatureAI Employee) { var tasksToDisplay = Employee.Tasks; ListView.ClearItems(); foreach (var task in tasksToDisplay) { var tag = task.GuiTag as Widget; var lambdaCopy = task; if (tag != null) { ListView.AddItem(tag); } else { #region Create gui row tag = Root.ConstructWidget(new Widget { Text = task.Name, MinimumSize = new Point(0, 16), Padding = new Margin(0, 0, 4, 4), TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { var loc = lambdaCopy.GetCameraZoomLocation(); if (loc.HasValue) { Employee.World.Renderer.Camera.SetZoomTarget(loc.Value); } } }); tag.AddChild(new Widget { Text = "CANCEL", AutoLayout = AutoLayout.DockRight, MinimumSize = new Point(16, 0), TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { Employee.World.TaskManager.CancelTask(lambdaCopy); } }); Widget priorityDisplay = null; tag.AddChild(new Gui.Widget { Background = new TileReference("round-buttons", 3), MinimumSize = new Point(16, 16), MaximumSize = new Point(16, 16), AutoLayout = AutoLayout.DockRightCentered, OnClick = (_sender, args) => { lambdaCopy.Priority = (TaskPriority)(Math.Min(4, (int)lambdaCopy.Priority + 1)); priorityDisplay.Text = lambdaCopy.Priority.ToString(); priorityDisplay.Invalidate(); }, OnMouseEnter = (_sender, args) => { _sender.BackgroundColor = GameSettings.Current.Colors.GetColor("Highlight", Color.DarkRed).ToVector4(); _sender.Invalidate(); }, OnMouseLeave = (_sender, args) => { _sender.BackgroundColor = Vector4.One; _sender.Invalidate(); } }); priorityDisplay = tag.AddChild(new Gui.Widget { AutoLayout = AutoLayout.DockRight, MinimumSize = new Point(64, 0), Text = lambdaCopy.Priority.ToString(), TextHorizontalAlign = HorizontalAlign.Center, TextVerticalAlign = VerticalAlign.Center }); tag.AddChild(new Gui.Widget { Background = new TileReference("round-buttons", 7), MinimumSize = new Point(16, 16), MaximumSize = new Point(16, 16), AutoLayout = AutoLayout.DockRightCentered, OnClick = (_sender, args) => { lambdaCopy.Priority = (TaskPriority)(Math.Max(0, (int)lambdaCopy.Priority - 1)); priorityDisplay.Text = lambdaCopy.Priority.ToString(); priorityDisplay.Invalidate(); }, OnMouseEnter = (_sender, args) => { _sender.BackgroundColor = GameSettings.Current.Colors.GetColor("Highlight", Color.DarkRed).ToVector4(); _sender.Invalidate(); }, OnMouseLeave = (_sender, args) => { _sender.BackgroundColor = Vector4.One; _sender.Invalidate(); } }); #endregion task.GuiTag = tag; ListView.AddItem(tag); } tag.Text = task.Name; } ListView.Invalidate(); }
public override void Construct() { Border = "border-fancy"; Font = "font10"; OnConstruct = (sender) => { sender.Root.RegisterForUpdate(sender); FilterBox = AddChild(new EditableTextField { AutoLayout = AutoLayout.DockTop, MinimumSize = new Point(0, 24), Text = "" }) as EditableTextField; ListView = AddChild(new WidgetListView { AutoLayout = AutoLayout.DockFill, SelectedItemForegroundColor = new Vector4(0, 0, 0, 1), ChangeColorOnSelected = false, Border = null, ItemHeight = 24 }) as WidgetListView; ListView.Border = null; // Can't make WidgetListView stop defaulting its border without breaking everywhere else its used. }; OnUpdate = (sender, time) => { if (sender.Hidden) { return; } var roomsToDisplay = World.EnumerateZones().Where(r => !String.IsNullOrEmpty(FilterBox.Text) ? r.ID.Contains(FilterBox.Text) : true); int i = 0; ListView.ClearItems(); foreach (var room in roomsToDisplay) { i++; var tag = room.GuiTag as Widget; var lambdaCopy = room; if (tag != null) { ListView.AddItem(tag); } else { #region Create gui row tag = Root.ConstructWidget(new Widget { Text = room.GetDescriptionString(), MinimumSize = new Point(0, 16), Padding = new Margin(0, 0, 4, 4), TextVerticalAlign = VerticalAlign.Center, Background = new TileReference("basic", 0), BackgroundColor = i % 2 == 0 ? new Vector4(0.0f, 0.0f, 0.0f, 0.1f) : new Vector4(0, 0, 0, 0.25f) }); tag.OnUpdate = (sender1, args) => { if (tag.IsAnyParentHidden()) { return; } if (sender1.ComputeBoundingChildRect().Contains(Root.MousePosition)) { Drawer3D.DrawBox(lambdaCopy.GetBoundingBox(), Color.White, 0.1f, true); } }; Root.RegisterForUpdate(tag); tag.AddChild(new Button { Text = "Destroy", AutoLayout = AutoLayout.DockRight, MinimumSize = new Point(16, 0), ChangeColorOnHover = true, TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { World.UserInterface.Gui.ShowModalPopup(new Gui.Widgets.Confirm { Text = "Do you want to destroy this " + lambdaCopy.Type.Name + "?", OnClose = (_sender2) => DestroyZoneTool.DestroyRoom((_sender2 as Gui.Widgets.Confirm).DialogResult, lambdaCopy, World) }); } }); tag.AddChild(new Widget { MinimumSize = new Point(4, 0), AutoLayout = AutoLayout.DockRight }); tag.AddChild(new Button { Text = "Go to", AutoLayout = AutoLayout.DockRight, ChangeColorOnHover = true, MinimumSize = new Point(16, 0), TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { World.Renderer.Camera.SetZoomTarget(lambdaCopy.GetBoundingBox().Center()); } }); if (lambdaCopy is Stockpile stock && stock.SupportsFilters) { tag.AddChild(new Button { Text = "Resources...", AutoLayout = AutoLayout.DockRight, ChangeColorOnHover = true, MinimumSize = new Point(16, 0), TextVerticalAlign = VerticalAlign.Center, OnClick = (_sender, args) => { var savePaused = World.Paused; World.Paused = true; Root.ShowModalPopup(new StockpilePropertiesDialog { Stockpile = lambdaCopy as Stockpile, OnClose = (_sen2) => World.Paused = savePaused }); } }); } #endregion room.GuiTag = tag; ListView.AddItem(tag); } tag.Text = room.GetDescriptionString(); } ListView.Invalidate(); }; base.Construct(); }