public override void Resize(Rect rect) { base.Resize(rect); float panelPadding = 12; float fieldPadding = 4; float fieldHeight = 28; Vector2 SizeRandomize = new Vector2(22, 22); Vector2 SizeInfo = new Vector2(24, 24); RectRandomize = new Rect(PanelRect.width - panelPadding - SizeRandomize.y, PanelRect.HalfHeight() - SizeRandomize.y * 0.5f, SizeRandomize.x, SizeRandomize.y); RectInfo = new Rect(panelPadding, PanelRect.HalfHeight() - SizeInfo.HalfY(), SizeInfo.x, SizeInfo.y); float availableSpace = PanelRect.width - (panelPadding * 2) - RectInfo.width - RectRandomize.width - fieldPadding; float firstMinWidth = 80; float nickMinWidth = 90; float lastMinWidth = 90; float fieldsMinWidth = firstMinWidth + nickMinWidth + lastMinWidth + (fieldPadding * 2); float extraSpace = availableSpace - fieldsMinWidth; float extraForField = Mathf.Floor(extraSpace / 3); float top = PanelRect.HalfHeight() - fieldHeight * 0.5f; RectFirstName = new Rect(RectInfo.xMax, top, firstMinWidth + extraForField, fieldHeight); RectNickName = new Rect(RectFirstName.xMax + fieldPadding, top, nickMinWidth + extraForField, fieldHeight); RectLastName = new Rect(RectNickName.xMax + fieldPadding, top, lastMinWidth + extraForField, fieldHeight); // Shift the info button to the left a bit to making the spacing look better. RectInfo.x -= 6; }
public override void Resize(Rect rect) { base.Resize(rect); Vector2 available = PanelRect.size - Style.SizePanelPadding; float arrowPadding = 1; float arrowWidth = Textures.TextureButtonNext.width; float bioWidth = 32; float chronoWidth = 48; float extendedArrowSize = arrowPadding + arrowWidth; float extendedFieldSize = extendedArrowSize * 2; float usedSpace = (extendedFieldSize * 2) + bioWidth + chronoWidth; float availableSpace = PanelRect.width - usedSpace; float spacing = availableSpace / 3; float idealSpace = 15; float extraFieldWidth = 0; if (spacing > idealSpace) { float extra = (spacing - idealSpace) * 3; extraFieldWidth += Mathf.Floor(extra / 2); spacing = idealSpace; } else { spacing = Mathf.Floor(spacing); } float fieldHeight = 28; GameFont saveFont = Text.Font; Text.Font = GameFont.Tiny; Vector2 bioLabelSize = Text.CalcSize("EdB.PC.Panel.Age.Biological".Translate()); Vector2 chronoLabelSize = Text.CalcSize("EdB.PC.Panel.Age.Chronological".Translate()); Text.Font = saveFont; float labelHeight = Mathf.Max(bioLabelSize.y, chronoLabelSize.y); float contentHeight = labelHeight + fieldHeight; float top = PanelRect.HalfHeight() - (contentHeight * 0.5f); float fieldTop = top + labelHeight; RectBiologicalAgeField = new Rect(spacing + extendedArrowSize, fieldTop, bioWidth + extraFieldWidth, fieldHeight); RectChronologicalAgeField = new Rect(RectBiologicalAgeField.xMax + extendedArrowSize + spacing + extendedArrowSize, fieldTop, chronoWidth + extraFieldWidth, fieldHeight); RectBiologicalAgeLabel = new Rect(RectBiologicalAgeField.MiddleX() - bioLabelSize.x / 2, RectBiologicalAgeField.y - bioLabelSize.y, bioLabelSize.x, bioLabelSize.y); RectChronologicalAgeLabel = new Rect(RectChronologicalAgeField.MiddleX() - chronoLabelSize.x / 2, RectChronologicalAgeField.y - chronoLabelSize.y, chronoLabelSize.x, chronoLabelSize.y); }
protected void DrawLoadingProgress() { Rect progressBarRect = new Rect(PanelRect.HalfWidth() - ProgressBarSize.x * 0.5f, PanelRect.HalfHeight() - ProgressBarSize.y * 0.5f, ProgressBarSize.x, ProgressBarSize.y); var progress = providerEquipment.LoadingProgress; GUI.color = Color.gray; Widgets.DrawBox(progressBarRect); if (progress.defCount > 0) { int totalCount = progress.defCount * 2; int processed = progress.stuffProcessed + progress.thingsProcessed; float percent = (float)processed / (float)totalCount; float barWidth = progressBarRect.width * percent; Widgets.DrawRectFast(new Rect(progressBarRect.x, progressBarRect.y, barWidth, progressBarRect.height), Color.green); } GUI.color = Style.ColorText; Text.Font = GameFont.Tiny; string label = "EdB.PC.Equipment.LoadingProgress.Initializing".Translate(); if (progress.phase == EquipmentDatabase.LoadingPhase.ProcessingStuff) { label = "EdB.PC.Equipment.LoadingProgress.StuffDefs".Translate(); } else if (progress.phase == EquipmentDatabase.LoadingPhase.ProcessingThings) { label = "EdB.PC.Equipment.LoadingProgress.ThingDefs".Translate(); } else if (progress.phase == EquipmentDatabase.LoadingPhase.Loaded) { label = "EdB.PC.Equipment.LoadingProgress.Finished".Translate(); } Widgets.Label(new Rect(progressBarRect.x, progressBarRect.yMax + 2, progressBarRect.width, 20), label); Text.Font = GameFont.Small; GUI.color = Color.white; }
public override void Resize(Rect rect) { base.Resize(rect); Vector2 padding = new Vector2(12, 12); RectDropdownTypes = new Rect(padding.x, padding.y, 140, 28); RectDropdownMaterials = new Rect(RectDropdownTypes.xMax + 8, RectDropdownTypes.yMin, 160, 28); Vector2 sizeInfoButton = new Vector2(24, 24); Vector2 sizeAddButton = new Vector2(160, 34); RectAddButton = new Rect(PanelRect.HalfWidth() - sizeAddButton.HalfX(), PanelRect.height - padding.y - sizeAddButton.y, sizeAddButton.x, sizeAddButton.y); Vector2 listSize = new Vector2(); listSize.x = rect.width - padding.x * 2; listSize.y = rect.height - RectDropdownTypes.yMax - (padding.y * 3) - RectAddButton.height; float listHeaderHeight = 20; float listBodyHeight = listSize.y - listHeaderHeight; Rect rectTable = new Rect(padding.x, padding.y + RectDropdownTypes.yMax, listSize.x, listSize.y); RectListHeader = new Rect(padding.x, RectDropdownTypes.yMax + 4, listSize.x, listHeaderHeight); RectListBody = new Rect(padding.x, RectListHeader.yMax, listSize.x, listBodyHeight); RectColumnHeaderName = new Rect(RectListHeader.x + 64, RectListHeader.y, 240, RectListHeader.height); RectColumnHeaderCost = new Rect(RectListHeader.xMax - 100, RectListHeader.y, 100, RectListHeader.height); RectScrollFrame = RectListBody; RectScrollView = new Rect(0, 0, RectScrollFrame.width, RectScrollFrame.height); RectRow = new Rect(0, 0, RectScrollView.width, 42); RectItem = new Rect(10, 2, 38, 38); Vector2 nameOffset = new Vector2(10, 0); float columnWidthInfo = 36; float columnWidthIcon = 42; float columnWidthCost = 100; float columnWidthName = RectRow.width - columnWidthInfo - columnWidthIcon - columnWidthCost - 10; if (providerEquipment == null) { providerEquipment = new ProviderEquipmentTypes(); } if (!providerEquipment.DatabaseReady) { return; } foreach (var type in providerEquipment.Types) { if (!equipmentViews.ContainsKey(type)) { WidgetTable <EquipmentRecord> table = new WidgetTable <EquipmentRecord>(); table.Rect = rectTable; table.BackgroundColor = Style.ColorPanelBackgroundDeep; table.RowColor = Style.ColorTableRow1; table.AlternateRowColor = Style.ColorTableRow2; table.SelectedRowColor = Style.ColorTableRowSelected; table.SupportSelection = true; table.RowHeight = 42; table.ShowHeader = true; table.SortAction = DoSort; table.SelectedAction = (EquipmentRecord entry) => { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); }; table.DoubleClickAction = (EquipmentRecord entry) => { SoundDefOf.Tick_High.PlayOneShotOnCamera(); EquipmentAdded(entry); }; table.AddColumn(new WidgetTable <EquipmentRecord> .Column() { Width = columnWidthInfo, Name = ColumnNameInfo, DrawAction = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => { Rect infoRect = new Rect(columnRect.MiddleX() - sizeInfoButton.HalfX(), columnRect.MiddleY() - sizeInfoButton.HalfY(), sizeInfoButton.x, sizeInfoButton.y); Style.SetGUIColorForButton(infoRect); GUI.DrawTexture(infoRect, Textures.TextureButtonInfo); if (Widgets.ButtonInvisible(infoRect)) { if (entry.animal) { Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.thing)); } else if (entry.stuffDef != null) { Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.def, entry.stuffDef)); } else { Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.def)); } } GUI.color = Color.white; } }); table.AddColumn(new WidgetTable <EquipmentRecord> .Column() { Width = columnWidthIcon, Name = ColumnNameIcon, DrawAction = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => { WidgetEquipmentIcon.Draw(columnRect, entry); } }); table.AddColumn(new WidgetTable <EquipmentRecord> .Column() { Width = columnWidthName, Name = ColumnNameName, Label = "Name", AdjustForScrollbars = true, AllowSorting = true, DrawAction = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => { columnRect = columnRect.InsetBy(nameOffset.x, 0, 0, 0); GUI.color = Style.ColorText; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(columnRect, entry.Label); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } }); table.AddColumn(new WidgetTable <EquipmentRecord> .Column() { Width = columnWidthCost, Name = ColumnNameCost, Label = "Cost", AdjustForScrollbars = false, AllowSorting = true, DrawAction = (EquipmentRecord entry, Rect columnRect, WidgetTable <EquipmentRecord> .Metadata metadata) => { GUI.color = Style.ColorText; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(new Rect(columnRect.x, columnRect.y, columnRect.width, columnRect.height), "" + entry.cost); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }, Alignment = TextAnchor.LowerRight }); table.SetSortState(ColumnNameName, 1); ViewEquipmentList view = new ViewEquipmentList() { Table = table, List = providerEquipment.AllEquipmentOfType(type).ToList() }; SortByName(view, 1); equipmentViews.Add(type, view); } } }
public override void Resize(Rect rect) { base.Resize(rect); Vector2 padding = new Vector2(12, 12); Vector2 sizeInfoButton = new Vector2(24, 24); Vector2 sizeButton = new Vector2(160, 34); RectRemoveButton = new Rect(PanelRect.HalfWidth() - sizeButton.HalfX(), PanelRect.height - padding.y - sizeButton.y, sizeButton.x, sizeButton.y); Vector2 listSize = new Vector2(); listSize.x = rect.width - padding.x * 2; listSize.y = rect.height - padding.y * 3 - RectRemoveButton.height; float listHeaderHeight = 20; float listBodyHeight = listSize.y - listHeaderHeight; Rect rectTable = new Rect(padding.x, padding.y, listSize.x, listSize.y); RectRow = new Rect(0, 0, rectTable.width, 42); Vector2 nameOffset = new Vector2(10, 0); float columnWidthInfo = 36; float columnWidthIcon = 42; float columnWidthCount = 112; float columnWidthName = RectRow.width - columnWidthInfo - columnWidthIcon - columnWidthCount; table = new WidgetTable <EquipmentSelection>(); table.Rect = rectTable; table.BackgroundColor = Style.ColorPanelBackgroundDeep; table.RowColor = Style.ColorTableRow1; table.AlternateRowColor = Style.ColorTableRow2; table.SelectedRowColor = Style.ColorTableRowSelected; table.SupportSelection = true; table.RowHeight = 42; table.SelectedAction = (EquipmentSelection entry) => { SoundDefOf.TickTiny.PlayOneShotOnCamera(); }; table.DoubleClickAction = (EquipmentSelection entry) => { SoundDefOf.TickHigh.PlayOneShotOnCamera(); if (entry.Count > 0) { EquipmentCountUpdated(entry, entry.Count - 1); } else { EquipmentRemoved(entry); } }; table.AddColumn(new WidgetTable <EquipmentSelection> .Column() { Width = columnWidthInfo, Name = "Info", DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => { Rect infoRect = new Rect(columnRect.MiddleX() - sizeInfoButton.HalfX(), columnRect.MiddleY() - sizeInfoButton.HalfY(), sizeInfoButton.x, sizeInfoButton.y); Style.SetGUIColorForButton(infoRect); GUI.DrawTexture(infoRect, Textures.TextureButtonInfo); if (Widgets.ButtonInvisible(infoRect)) { if (entry.StuffDef != null) { Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.ThingDef, entry.StuffDef)); } else { Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.ThingDef)); } } GUI.color = Color.white; } }); table.AddColumn(new WidgetTable <EquipmentSelection> .Column() { Width = columnWidthIcon, Name = "Icon", DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => { WidgetEquipmentIcon.Draw(columnRect, entry.Record); } }); table.AddColumn(new WidgetTable <EquipmentSelection> .Column() { Width = columnWidthName, Name = "Name", Label = "Name", DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => { columnRect = columnRect.InsetBy(nameOffset.x, 0, 0, 0); GUI.color = Style.ColorText; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(columnRect, entry.Record.Label); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } }); table.AddColumn(new WidgetTable <EquipmentSelection> .Column() { Width = columnWidthCount, Name = "Count", Label = "Count", AdjustForScrollbars = true, DrawAction = (EquipmentSelection entry, Rect columnRect, WidgetTable <EquipmentSelection> .Metadata metadata) => { Rect fieldRect = new Rect(columnRect.x + 17, columnRect.y + 7, 60, 28); Widgets.DrawAtlas(fieldRect, Textures.TextureFieldAtlas); if (metadata.rowIndex <= numberFields.Count) { numberFields.Add(new WidgetNumberField() { MaxValue = 100000 }); } WidgetNumberField field = numberFields[metadata.rowIndex]; field.UpdateAction = (int value) => { EquipmentCountUpdated(entry, value); }; field.Draw(fieldRect, entry.Count); } }); }