private void DrawTabRow(Rect rect, Pawn pawn, PawnRowViewModel viewModel, ViewMode viewMode) { Rect nameRect = rect.ReplaceWidth(_pawnNameWidth).ReplaceHeight(GenUI.ListSpacing); Rect selectRect = nameRect.ReplaceHeight(GenUI.ListSpacing * 2); if (Widgets.ButtonInvisible(selectRect)) { Selector selector = Find.Selector; selector.ClearSelection(); selector.Select(pawn); } Widgets.DrawHighlightIfMouseover(selectRect); Widgets.Label(nameRect, pawn.NameFullColored); Widgets.Label(nameRect.ReplaceY(nameRect.yMax), pawn.LabelNoCountColored); rect = rect.ReplaceX(nameRect.xMax).ReplaceWidth((rect.width - _pawnNameWidth) / 2); if (viewMode == ViewMode.Loadout) { this.DrawLoadoutRow(rect, pawn, viewModel); } else if (viewMode == ViewMode.Inventory) { this.DrawInventoryRow(rect, pawn, viewModel); } }
private void DrawInventoryRow(Rect rect, Pawn pawn, PawnRowViewModel viewModel) { IEnumerable <Thing> equipped = pawn.equipment.AllEquipmentListForReading.Concat(pawn.apparel.WornApparel); this.DrawScrollableThings(rect, equipped, UIText.EquippedItems.TranslateSimple(), ref viewModel.EquippedViewWidth, ref viewModel.EquippedScrollPos); rect = rect.ReplaceX(rect.xMax + GenUI.Gap).ReplaceWidth(rect.width - GenUI.Gap); IEnumerable <Thing> items = pawn.inventory.innerContainer; this.DrawScrollableThings(rect, items, UIText.InventoryItems.TranslateSimple(), ref viewModel.InventoryViewWidth, ref viewModel.InventoryScrollPos); }
private void DrawLoadoutRow(Rect rect, Pawn pawn, PawnRowViewModel viewModel) { if (pawn.UseLoadout(out CompAwesomeInventoryLoadout comp)) { this.DrawScrollableLoadout(rect, pawn, comp, viewModel); rect = rect.ReplaceX(rect.xMax + GenUI.Gap).ReplaceWidth(rect.width - GenUI.Gap); this.DrawScrollableMissing(rect, pawn, comp, viewModel); } else { DrawMakeLoadout(rect, pawn); } }
private void DrawScrollableLoadout(Rect rect, Pawn pawn, CompAwesomeInventoryLoadout comp, PawnRowViewModel viewModel) { if (pawn.outfits.CurrentOutfit is AwesomeInventoryLoadout loadout) { // Loadout name button string loadoutName = loadout.label; WidgetRow widgetRow = new WidgetRow(rect.x, rect.y, UIDirection.RightThenDown); if (widgetRow.ButtonText(loadoutName)) { Dialog_ManageLoadouts dialog = AwesomeInventoryServiceProvider.MakeInstanceOf <Dialog_ManageLoadouts>(loadout, pawn, true); dialog.closeOnClickedOutside = true; Find.WindowStack.Add(dialog); } else if (widgetRow.ButtonIcon(TexResource.Copy)) { _copy = loadout; Messages.Message(string.Concat(UIText.CopyLoadout.TranslateSimple(), $" {_copy.label}"), MessageTypeDefOf.NeutralEvent); } else if (_copy != null && widgetRow.ButtonIcon(TexResource.Paste)) { pawn.SetLoadout(_copy); } // Loadout scroll view Rect loadoutItemRect = new Rect(rect.x, widgetRow.FinalY + GenUI.ListSpacing, rect.width, GenUI.ListSpacing + GenUI.ScrollBarWidth); Rect viewRect = loadoutItemRect.ReplaceHeight(GenUI.ListSpacing).ReplaceWidth(viewModel.LoadoutViewWidth); Widgets.ScrollHorizontal(loadoutItemRect, ref viewModel.LoadoutScrollPos, viewRect); Widgets.BeginScrollView(loadoutItemRect, ref viewModel.LoadoutScrollPos, viewRect); Rect iconRect = viewRect.ReplaceWidth(GenUI.SmallIconSize); foreach (ThingGroupSelector groupSelector in comp.Loadout .OrderByDescending(a => a.SingleThingSelectors.FirstOrDefault()?.ThingSample, new LoadoutUtility.ThingTypeComparer())) { if (groupSelector.SingleThingSelectors.FirstOrDefault() is SingleThingSelector selector) { this.DrawThingIcon(iconRect, pawn, selector.ThingSample, comp); this.DragItemToLoadout(iconRect, groupSelector); iconRect = iconRect.ReplaceX(iconRect.xMax); } } viewModel.LoadoutViewWidth = iconRect.x - rect.x; Widgets.EndScrollView(); } }
private void DrawScrollableMissing(Rect rect, Pawn pawn, CompAwesomeInventoryLoadout comp, PawnRowViewModel viewModel) { Rect labelRect = rect.ReplaceHeight(GenUI.ListSpacing); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(labelRect, UIText.MissingItems.TranslateSimple()); Text.Anchor = TextAnchor.UpperLeft; Rect missingItemsRect = new Rect(rect.x, rect.y + GenUI.ListSpacing, rect.width, GenUI.ListSpacing + GenUI.ScrollBarWidth); Rect viewRect = missingItemsRect.ReplaceHeight(GenUI.ListSpacing).ReplaceWidth(viewModel.MissingViewWidth); Widgets.ScrollHorizontal(missingItemsRect, ref viewModel.MissingScrollPos, viewRect); Widgets.BeginScrollView(missingItemsRect, ref viewModel.MissingScrollPos, viewRect); Rect iconRect = viewRect.ReplaceWidth(GenUI.SmallIconSize); foreach (Thing thing in comp.InventoryMargins .Where(pair => pair.Value < 0) .Select(pair => pair.Key.SingleThingSelectors.FirstOrDefault()?.ThingSample) .MakeThingGroup().OrderedList) { this.DrawThingIcon(iconRect, pawn, thing, comp); iconRect = iconRect.ReplaceX(iconRect.xMax); } viewModel.MissingViewWidth = iconRect.x - rect.x; Widgets.EndScrollView(); }