public float DrawCustomBodyPart(float cursor, CustomBodyPart customPart, Field field) { bool willScroll = scrollView.ScrollbarsVisible; Rect entryRect = RectItem; entryRect.y = entryRect.y + cursor; entryRect.width = entryRect.width - (willScroll ? 16 : 0); GUI.color = Style.ColorPanelBackgroundItem; GUI.DrawTexture(entryRect, BaseContent.WhiteTex); // Draw background box. GUI.BeginGroup(entryRect); // Draw field Rect fieldRect = RectField; fieldRect.width = fieldRect.width - (willScroll ? 16 : 0); field.Rect = fieldRect; if (customPart.BodyPartRecord != null) { field.Label = labelTrimmer.TrimLabelIfNeeded(new HealthPanelLabelProvider(customPart.PartName, customPart.ChangeName, customPart.LabelColor)); field.Color = Color.white; } else { field.Label = labelTrimmer.TrimLabelIfNeeded(customPart.ChangeName); field.Color = customPart.LabelColor; } if (customPart.HasTooltip) { field.Tip = customPart.Tooltip; } else { field.Tip = null; } field.Draw(); // Delete the option. Rect deleteRect = RectButtonDelete; if (willScroll) { deleteRect.x = deleteRect.x - 16; } Style.SetGUIColorForButton(deleteRect); GUI.DrawTexture(deleteRect, Textures.TextureButtonDelete); if (Widgets.ButtonInvisible(deleteRect, false)) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); partRemovalList.Add(customPart); } GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); return(cursor + RectItem.height + HeightEntrySpacing); }
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.Tick_Tiny.PlayOneShotOnCamera(); }; table.DoubleClickAction = (EquipmentSelection entry) => { SoundDefOf.Tick_High.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.record.animal) { Find.WindowStack.Add((Window) new Dialog_InfoCard(entry.record.thing)); } else 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); } }); }
public override void Resize(Rect rect) { base.Resize(rect); if (marketValueStatDef == null) { marketValueStatDef = StatDefOf.MarketValue; } 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.def)); } 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); //Widgets.Label(columnRect, entry.def.defName); 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; string costString = GenText.ToStringByStyle((float)entry.cost, ToStringStyle.FloatTwo); Widgets.Label(new Rect(columnRect.x, columnRect.y, columnRect.width, columnRect.height), costString); 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); } } }
protected Vector2 DrawRelationship(Vector2 cursor, CustomRelationship relationship) { if (cursor.x + SizeRelationship.x > RectScrollView.width) { cursor.x = 0; cursor.y += (SizeRelationship.y + SizeRelationshipSpacing.y); } Rect relationshipRect = new Rect(cursor, SizeRelationship); Rect sourcePawnRect = new Rect(cursor, SizePawn); GUI.color = ColorPawnSource; GUI.DrawTexture(sourcePawnRect, BaseContent.WhiteTex); GUI.color = Color.white; Rect sourcePawnName = new Rect(sourcePawnRect.x, sourcePawnRect.yMax - 34, sourcePawnRect.width, 26); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; GUI.color = Style.ColorText; Widgets.Label(sourcePawnName, relationship.source.ShortName); GUI.color = Color.white; Rect sourceProfessionName = new Rect(sourcePawnRect.x, sourcePawnRect.yMax - 18, sourcePawnRect.width, 18); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerCenter; GUI.color = Style.ColorText; Widgets.Label(sourceProfessionName, GetProfessionLabel(relationship.source)); GUI.color = Color.white; DrawPortrait(sourcePawnRect, relationship.source); TooltipHandler.TipRegion(sourcePawnRect, GetTooltipText(relationship.source)); // Delete button. Rect deleteRect = new Rect(sourcePawnRect.xMax - 16, sourcePawnRect.y + 4, 12, 12); Style.SetGUIColorForButton(deleteRect); GUI.DrawTexture(deleteRect, Textures.TextureButtonDelete); if (Widgets.ButtonInvisible(deleteRect)) { relationshipsToDelete.Add(relationship); } Rect targetPawnRect = new Rect(cursor.x + SizeRelationship.x - SizePawn.x, cursor.y, SizePawn.x, SizePawn.y); GUI.color = ColorPawnTarget; GUI.DrawTexture(targetPawnRect, BaseContent.WhiteTex); GUI.color = Color.white; Rect targetPawnName = new Rect(targetPawnRect.x, targetPawnRect.yMax - 34, targetPawnRect.width, 26); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; GUI.color = Style.ColorText; Widgets.Label(targetPawnName, relationship.target.ShortName); GUI.color = Color.white; Rect targetProfessionName = new Rect(targetPawnRect.x, targetPawnRect.yMax - 18, targetPawnRect.width, 18); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerCenter; GUI.color = Style.ColorText; Widgets.Label(targetProfessionName, GetProfessionLabel(relationship.target)); GUI.color = Color.white; DrawPortrait(targetPawnRect, relationship.target); TooltipHandler.TipRegion(targetPawnRect, GetTooltipText(relationship.target)); Rect sourceRelLabelRect = new Rect(sourcePawnRect.xMax, sourcePawnRect.y + SizeLabelSpacing.y, targetPawnRect.x - sourcePawnRect.xMax, HeightLabel); sourceRelLabelRect.width -= (SizeArrow.x + SizeLabelSpacing.x); GUI.color = ColorPawnSource; GUI.DrawTexture(sourceRelLabelRect, BaseContent.WhiteTex); Rect sourceRelArrowRect = new Rect(sourceRelLabelRect.xMax, sourceRelLabelRect.MiddleY() - SizeArrow.HalfY(), SizeArrow.x, SizeArrow.y); GUI.DrawTexture(sourceRelArrowRect, Textures.TextureArrowRight); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; GUI.color = Style.ColorText; Widgets.Label(sourceRelLabelRect.OffsetBy(0, 1), relationship.inverseDef.GetGenderSpecificLabelCap(relationship.source.Pawn)); Rect targetRelLabelRect = new Rect(sourcePawnRect.xMax, targetPawnRect.yMax - SizeLabelSpacing.y - HeightLabel, targetPawnRect.x - sourcePawnRect.xMax, HeightLabel); targetRelLabelRect.width -= (SizeArrow.x + SizeLabelSpacing.x); targetRelLabelRect.x += (SizeArrow.x + SizeLabelSpacing.x); GUI.color = ColorPawnTarget; GUI.DrawTexture(targetRelLabelRect, BaseContent.WhiteTex); Rect targetRelArrowRect = new Rect(targetRelLabelRect.xMin - SizeArrow.x, targetRelLabelRect.MiddleY() - SizeArrow.HalfY(), SizeArrow.x, SizeArrow.y); GUI.DrawTexture(targetRelArrowRect, Textures.TextureArrowLeft); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; GUI.color = Style.ColorText; Widgets.Label(targetRelLabelRect.OffsetBy(0, 1), relationship.def.GetGenderSpecificLabelCap(relationship.target.Pawn)); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; GUI.color = Color.white; cursor.x += SizeRelationship.x + SizeRelationshipSpacing.x; return(cursor); }