private void RebuildPanel() { // Update schedule data int selectedSchedule = (sensor != null) ? sensor.scheduleIndex : 0; int selectedGroup = (sensor != null) ? sensor.blockTypeIndex : 0; schedules = new List <StringListOption>(); var slist = ScheduleManager.Instance.GetSchedules(); foreach (Schedule s in slist) { schedules.Add(new StringListOption(s.name)); } if (selectedSchedule < 0 || selectedSchedule >= schedules.Count) { selectedSchedule = 0; if (sensor != null) { sensor.scheduleIndex = selectedSchedule; } } groups = new List <StringListOption>(); var glist = Db.Get().ScheduleGroups.allGroups; foreach (ScheduleGroup g in glist) { groups.Add(new StringListOption(g.Name)); } if (selectedGroup < 0 || selectedGroup >= groups.Count) { selectedGroup = 0; if (sensor != null) { sensor.blockTypeIndex = selectedGroup; } } // Rebuild UI if (ContentContainer != null) { Destroy(ContentContainer); ContentContainer = null; } var margin = new RectOffset(8, 8, 8, 8); var baseLayout = gameObject.GetComponent <BoxLayoutGroup>(); if (baseLayout != null) { baseLayout.Params = new BoxLayoutParams() { Margin = margin, Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperCenter, Spacing = 8 }; } var mainPanel = new PPanel(); var scheduleRow = new PPanel("Schedule Select") { FlexSize = Vector2.right, Alignment = TextAnchor.MiddleCenter, Spacing = 10, Direction = PanelDirection.Horizontal, Margin = margin }; scheduleRow.AddChild(new PLabel("Schedule") { TextAlignment = TextAnchor.MiddleRight, ToolTip = "TODO: Schedule Label Tooltip", Text = "Schedule", TextStyle = PUITuning.Fonts.TextDarkStyle }); var scb = new PeterHan.PLib.UI.PComboBox <StringListOption>("Schedule Select") { Content = schedules, MinWidth = 100, InitialItem = schedules[selectedSchedule], ToolTip = "TODO: Schedule Select Tooltip", TextStyle = PUITuning.Fonts.TextLightStyle, TextAlignment = TextAnchor.MiddleLeft, OnOptionSelected = SetSchedule }; scb.OnRealize += (obj) => { scheduleCombo = obj; }; scheduleRow.AddChild(scb); mainPanel.AddChild(scheduleRow); var groupRow = new PPanel("Group Select") { FlexSize = Vector2.right, Alignment = TextAnchor.MiddleCenter, Spacing = 10, Direction = PanelDirection.Horizontal, Margin = margin }; groupRow.AddChild(new PLabel("Group") { TextAlignment = TextAnchor.MiddleRight, ToolTip = "TODO: Group Label Tooltip", Text = "Group", TextStyle = PUITuning.Fonts.TextDarkStyle }); var bcb = new PComboBox <StringListOption>("Group Select") { Content = groups, MinWidth = 100, InitialItem = groups[selectedGroup], ToolTip = "TODO: Group Select Tooltip", TextStyle = PUITuning.Fonts.TextLightStyle, TextAlignment = TextAnchor.MiddleLeft, OnOptionSelected = SetGroup }; bcb.OnRealize += (obj) => { groupCombo = obj; }; groupRow.AddChild(bcb); mainPanel.AddChild(groupRow); ContentContainer = mainPanel.Build(); ContentContainer.SetParent(gameObject); if (scheduleCombo != null) { PComboBox <StringListOption> .SetSelectedItem(scheduleCombo, schedules[selectedSchedule]); } if (groupCombo != null) { PComboBox <StringListOption> .SetSelectedItem(groupCombo, groups[selectedGroup]); } }
private void RebuildPanel() { // Rebuild UI if (ContentContainer != null) { Destroy(ContentContainer); ContentContainer = null; } var margin = new RectOffset(8, 8, 8, 8); var baseLayout = gameObject.GetComponent <BoxLayoutGroup>(); if (baseLayout != null) { baseLayout.Params = new BoxLayoutParams() { Margin = margin, Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperCenter, Spacing = 8 }; } var mainPanel = new PPanel(); if (engine != null) { var efficiencyRow = new PPanel("EfficiencyRow") { FlexSize = Vector2.right, Alignment = TextAnchor.MiddleCenter, Spacing = 10, Direction = PanelDirection.Horizontal, Margin = margin }; efficiencyRow.AddChild(new PLabel("Efficiency") { TextAlignment = TextAnchor.MiddleRight, ToolTip = "Indicates the percentage of input heat that is currently being converted to power.", Text = $"Current Efficiency: {(engine.currentEfficiency * 100f):F0} %", TextStyle = PUITuning.Fonts.TextDarkStyle }); mainPanel.AddChild(efficiencyRow); var powerRow = new PPanel("PowerRow") { FlexSize = Vector2.right, Alignment = TextAnchor.MiddleCenter, Spacing = 10, Direction = PanelDirection.Horizontal, Margin = margin }; powerRow.AddChild(new PLabel("Power") { TextAlignment = TextAnchor.MiddleRight, ToolTip = "Indicates the amount of power currently being output into the circuit.", Text = $"Estimated Power Output: {engine.currentGeneratedPower:F0} W", TextStyle = PUITuning.Fonts.TextDarkStyle }); mainPanel.AddChild(powerRow); var heatRow = new PPanel("HeatRow") { FlexSize = Vector2.right, Alignment = TextAnchor.MiddleCenter, Spacing = 10, Direction = PanelDirection.Horizontal, Margin = margin }; heatRow.AddChild(new PLabel("Heat") { TextAlignment = TextAnchor.MiddleRight, ToolTip = "Indicates the amount of heat currently being added to the building temperature.", Text = $"Estimated Heat Output: {engine.currentGeneratedHeat:F0} DTU/s", TextStyle = PUITuning.Fonts.TextDarkStyle }); mainPanel.AddChild(heatRow); ContentContainer = mainPanel.Build(); ContentContainer.SetParent(gameObject); } }
private void BuildPanel() { if (ContentContainer != null) { Destroy(ContentContainer); ContentContainer = null; } var margin = new RectOffset(8, 8, 8, 8); var baseLayout = gameObject.GetComponent <BoxLayoutGroup>(); if (baseLayout != null) { baseLayout.Params = new BoxLayoutParams() { Margin = margin, Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperCenter, Spacing = 8 }; } var mainPanel = new PPanel(); var mainRow = new PPanel("Toggle Lock") { FlexSize = Vector2.right, Alignment = TextAnchor.MiddleCenter, Spacing = 10, Direction = PanelDirection.Horizontal, Margin = margin }; var lockBtn = new PButton("LockButton") { Text = "Lock" }; lockBtn.SetKleiBlueStyle(); lockBtn.OnClick = (obj) => { if (curtain == null) { return; } curtain.QueueStateChange(Curtain.ControlState.Locked); }; var unlockBtn = new PButton("UnlockButton") { Text = "Auto" }; unlockBtn.SetKleiBlueStyle(); unlockBtn.OnClick = (obj) => { if (curtain == null) { return; } curtain.QueueStateChange(Curtain.ControlState.Auto); }; var openBtn = new PButton("OpenButton") { Text = "Open" }; openBtn.SetKleiBlueStyle(); openBtn.OnClick = (obj) => { if (curtain == null) { return; } curtain.QueueStateChange(Curtain.ControlState.Open); }; mainRow.AddChild(lockBtn); mainRow.AddChild(unlockBtn); mainRow.AddChild(openBtn); mainPanel.AddChild(mainRow); ContentContainer = mainPanel.Build(); ContentContainer.SetParent(gameObject); }