/// <summary> /// Draw contents in window. /// </summary> /// <param name="canvas"> Canvas to draw. </param> public override void DoWindowContents(Rect canvas) { /* * || Buttons || * || Loadout Name Text Field || Category Button Image || * || Items in Loadout || Avaialable Items to Choose || * || Weight Bar || * */ if (Event.current.type == EventType.Layout) { return; } if (Find.Selector.SingleSelectedThing is Pawn pawn && pawn.IsColonist && !pawn.Dead) { if (pawn != _pawn) { _pawn = pawn; AwesomeInventoryLoadout loadout = _pawn.GetLoadout(); if (loadout == null) { this.Close(); return; } _currentLoadout = loadout; _resettables.ForEach(r => r.Reset()); } else { _currentLoadout = _pawn.GetLoadout(); } }
/// <summary> /// Initializes a new instance of the <see cref="Dialog_Costume"/> class. /// </summary> /// <param name="loadout"> loadout that getups are dervied from. </param> /// <param name="pawn"> The pawn who <paramref name="loadout"/> is assigned to. </param> public Dialog_Costume(AwesomeInventoryLoadout loadout, Pawn pawn) { ValidateArg.NotNull(loadout, nameof(loadout)); ValidateArg.NotNull(pawn, nameof(pawn)); if (loadout is AwesomeInventoryCostume costume) { _loadout = costume.Base; _costume = costume; } else { _loadout = loadout; } _apparelInLoadout = _loadout.ThingGroupSelectors .Where(t => t.AllowedThing.IsApparel) .OrderBy(t => t.LabelCapNoCount) .ToList(); _pawn = pawn; doCloseX = true; absorbInputAroundWindow = true; closeOnClickedOutside = true; resizeable = true; draggable = true; }
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(); } }
/// <summary> /// Initializes a new instance of the <see cref="Dialog_ManageLoadouts"/> class. /// </summary> /// <param name="loadout"> Selected loadout. </param> /// <param name="pawn"> Selected pawn. </param> public Dialog_ManageLoadouts(AwesomeInventoryLoadout loadout, Pawn pawn) { ValidateArg.NotNull(loadout, nameof(loadout)); _pawn = pawn ?? throw new ArgumentNullException(nameof(pawn)); float width = GenUI.GetWidthCached(UIText.TenCharsString.Times(11)); _initialSize = new Vector2(width, Verse.UI.screenHeight / 2f); _currentLoadout = loadout; _resettables.Add(this); _resettables.Add(new WhiteBlacklistView()); doCloseX = true; forcePause = true; absorbInputAroundWindow = false; closeOnClickedOutside = false; closeOnAccept = false; }
/// <summary> /// Make float menu options for creating empty loadout or loadout derived from equipped items. /// </summary> /// <param name="selPawn"> Selected pawn. </param> /// <returns> A list of options. </returns> public static List <FloatMenuOption> MakeActionableLoadoutOption(this Pawn selPawn) { ValidateArg.NotNull(selPawn, nameof(selPawn)); return(new List <FloatMenuOption>() { new FloatMenuOption( UIText.MakeEmptyLoadout.Translate(selPawn.NameShortColored) , () => { AwesomeInventoryLoadout emptyLoadout = AwesomeInventoryLoadout.MakeEmptyLoadout(selPawn); LoadoutManager.AddLoadout(emptyLoadout); selPawn.SetLoadout(emptyLoadout); Find.WindowStack.Add( AwesomeInventoryServiceProvider.MakeInstanceOf <Dialog_ManageLoadouts>(emptyLoadout, selPawn, true)); if (BetterPawnControlUtility.IsActive) { BetterPawnControlUtility.SaveState(new List <Pawn> { selPawn }); } }), new FloatMenuOption( UIText.MakeNewLoadout.Translate(selPawn.NameShortColored) , () => { AwesomeInventoryLoadout loadout = new AwesomeInventoryLoadout(selPawn); LoadoutManager.AddLoadout(loadout); selPawn.SetLoadout(loadout); Find.WindowStack.Add( AwesomeInventoryServiceProvider.MakeInstanceOf <Dialog_ManageLoadouts>(loadout, selPawn, true)); if (BetterPawnControlUtility.IsActive) { BetterPawnControlUtility.SaveState(new List <Pawn> { selPawn }); } }), }); }
/// <summary> /// Initializes a new instance of the <see cref="Dialog_Costume"/> class. /// </summary> /// <param name="loadout"> loadout that getups are dervied from. </param> /// <param name="pawn"> The pawn who <paramref name="loadout"/> is assigned to. </param> public Dialog_Costume(AwesomeInventoryLoadout loadout, Pawn pawn) { ValidateArg.NotNull(loadout, nameof(loadout)); ValidateArg.NotNull(pawn, nameof(pawn)); if (loadout is AwesomeInventoryCostume costume) { _loadout = costume.Base; _costume = costume; } else { _loadout = loadout; } _pawn = pawn; doCloseX = true; absorbInputAroundWindow = true; closeOnClickedOutside = true; resizeable = true; draggable = true; }
public Dialog_ManageLoadoutCE(AwesomeInventoryLoadout loadout, Pawn pawn, bool fixPawn) : base(loadout, pawn, fixPawn) { }
public override void Setup() { _pawn.apparel.WornApparel.Add(_pairs[3].MakeThingWithoutID() as Apparel); _loadout = new AwesomeInventoryLoadout(_pawn); _pawn.SetLoadout(_loadout); }