// xShift: how much to right to adjust the two bars private void TryDrawCEloadout(float xShift, float y, float width) { CompInventory comp = SelPawn.TryGetComp <CompInventory>(); if (comp == null) { return; } PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.FrameDisplayed); // adjust rects if comp found Rect weightRect = new Rect(_margin + xShift, y + _margin / 2, width, _barHeight); Rect bulkRect = new Rect(_margin + xShift, weightRect.yMax + _margin / 2, width, _barHeight); // draw bars Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CE_Bulk".Translate(), SelPawn.GetBulkTip()); Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CE_Weight".Translate(), SelPawn.GetWeightTip()); // draw text overlays on bars Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; string currentBulk = CE_StatDefOf.CarryBulk.ValueToString(comp.currentBulk, CE_StatDefOf.CarryBulk.toStringNumberSense); string capacityBulk = CE_StatDefOf.CarryBulk.ValueToString(comp.capacityBulk, CE_StatDefOf.CarryBulk.toStringNumberSense); Widgets.Label(bulkRect, currentBulk + "/" + capacityBulk); string currentWeight = comp.currentWeight.ToString("0.#"); string capacityWeight = CE_StatDefOf.CarryWeight.ValueToString(comp.capacityWeight, CE_StatDefOf.CarryWeight.toStringNumberSense); Widgets.Label(weightRect, currentWeight + "/" + capacityWeight); Text.Anchor = TextAnchor.UpperLeft; }
protected override void FillTab() { UpdateSize(); if (SelPawn == null) { return; } // PlayerKnowledgeDatabase.KnowledgeDemonstrated... Func <List <FloatMenuOption> > genderOptions = delegate { // once defs are added, update this to automatically grab gender defs from database List <FloatMenuOption> genders = new List <FloatMenuOption>(); // if enabled in mod options, add none gender genders.Add(new FloatMenuOption("male gender key", delegate { SelPawn.SetGender(Gender.Male); })); // todo: add extraPartOnGUI genders.Add(new FloatMenuOption("female gender key", delegate { SelPawn.SetGender(Gender.Female); })); return(genders); }; // todo }
private void SetAreaRestriction(Area area) { foreach (var pawn in SelPawn.GetLord().ownedPawns) { pawn.GetComp <CompGuest>().GuestArea = area; } }
protected override void FillTab() { if (Multiplayer.IsRunning) { Multiplayer.WatchBegin(); } Text.Font = GameFont.Small; Rect rect = new Rect(0f, 20f, size.x, size.y - 20).ContractedBy(10f); listingStandard.Begin(rect); { if (SelPawn.IsTrader()) { FillTabTrader(); } else { FillTabGuest(rect); } } listingStandard.End(); if (Multiplayer.IsRunning) { Multiplayer.WatchEnd(); } }
private void SetAreaShopping(Area area) { foreach (var pawn in SelPawn.GetLord().ownedPawns) { pawn.GetComp <CompGuest>().ShoppingArea = area; } }
private void FillTabGuest(Listing_Standard listingStandard, Rect rect) { //ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); var trust = SelPawn.RelativeTrust(); { var tryImprove = SelPawn.ImproveRelationship(); var tryRecruit = SelPawn.TryRecruit(); listingStandard.ColumnWidth = size.x - 20; var comp = SelPawn.GetComp <CompGuest>(); if (comp != null) { listingStandard.Gap(); CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref tryImprove); CheckboxLabeled(listingStandard, "ShouldTryToRecruit".Translate(), ref tryRecruit); comp.chat = tryImprove; comp.recruit = tryRecruit; listingStandard.Gap(50); DrawSetDefaultButton(rect); } if (SelPawn.Faction != null) { listingStandard.Label(txtRecruitmentPenalty + ": " + SelPawn.RecruitPenalty().ToString("##0")); listingStandard.Label(txtFactionGoodwill + ": " + SelPawn.Faction.PlayerGoodwill.ToString("##0")); } listingStandard.Gap(); // Will only have squadBrain while "checked in", becomes null again when guests leave var squadBrain = SelPawn.GetLord(); if (squadBrain != null) { listingStandard.Label(string.Format("{0}:", txtRecruitmentChance)); listingStandard.Slider(Mathf.Clamp(trust, 0, 100), 0, 100); if (trust < 50) { var color = GUI.color; GUI.color = Color.red; listingStandard.Label("TrustTooLow".Translate().AdjustedFor(SelPawn)); GUI.color = color; } var lordToil = squadBrain.CurLordToil as LordToil_VisitPoint; if (lordToil != null && SelPawn.Faction != null) { listingStandard.Label(txtHospitality + ":"); listingStandard.Slider(lordToil.GetVisitScore(SelPawn), 0f, 1f); } } } }
private void DrawSendHomeButton(Rect rect) { rect = new Rect(rect.xMax - sendHomeButtonSize.x - 20f - setDefaultButtonSize.x, 110f, sendHomeButtonSize.x, sendHomeButtonSize.y); if (Widgets.ButtonText(rect, txtSendAway)) { SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera(); SendHomeDialog(SelPawn.GetLord()); } }
protected override void UpdateSize() { base.UpdateSize(); if (SelPawn.CanHaveFoodPolicy()) { this.size.x = Math.Max(this.size.x, PawnPolicyCard.Size.x); this.size.y += PawnPolicyCard.Size.y; } }
protected override void UpdateSize() { base.UpdateSize(); size = GetSize(SelPawn?.GetComp <CompVehicle>()?.AllOccupants, PaneTopY, true); if (size.x + SpecificNeedsTabWidth > UI.screenWidth) { doNeeds = false; size = GetSize(SelPawn?.GetComp <CompVehicle>().AllOccupants, PaneTopY, false); } else { doNeeds = true; } size.y = Mathf.Max(size.y, NeedsCardUtility.FullSize.y); }
//[DetourMethod(typeof(ITab_Pawn_Needs), "FillTab")] protected override void FillTab() { NeedsCardUtility.DoNeedsMoodAndThoughts(new Rect(0, 0, this.size.x, RimWorld.NeedsCardUtility.GetSize(SelPawn).y), base.SelPawn, ref this.thoughtScrollPosition); //base.FillTab(); // ------ MOD ----------- if (SelPawn.CanHaveFoodPolicy()) { policyCardRect = new Rect(0, this.size.y - PawnPolicyCard.Size.y, PawnPolicyCard.Size.x, PawnPolicyCard.Size.y); //policyRect = new Rect(0, 0, PawnPolicyCard.RectSize.x, PawnPolicyCard.RectSize.y); PawnPolicyCard.Draw(policyCardRect, SelPawn); } // ------ MOD END ----------- }
protected override void FillTab() { Text.Font = GameFont.Small; Rect rect = new Rect(0f, 20f, size.x, size.y - 20).ContractedBy(10f); var listingStandard = new Listing_Standard(rect); { if (SelPawn.IsTrader()) { FillTabTrader(listingStandard); } else { FillTabGuest(listingStandard, rect); } } listingStandard.End(); }
private void DoAreaRestriction(Listing_Standard listingStandard, CompGuest comp) { var areaRect = listingStandard.GetRect(24); if (SelPawn.playerSettings == null) { var savedArea = comp.GuestArea; SelPawn.playerSettings = new Pawn_PlayerSettings(SelPawn) { AreaRestriction = savedArea }; } var oldArea = SelPawn.playerSettings.AreaRestriction = comp.GuestArea; AreaAllowedGUI.DoAllowedAreaSelectors(areaRect, SelPawn, AllowedAreaMode.Humanlike); Text.Anchor = TextAnchor.UpperLeft; if (SelPawn.playerSettings.AreaRestriction != oldArea) { SetAreaRestriction(SelPawn.GetLord(), SelPawn.playerSettings.AreaRestriction); } }
private void FillTabGuest(Rect rect) { //ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); var friends = SelPawn.GetFriendsInColony(); var friendsRequired = GuestUtility.FriendsRequired(SelPawn.MapHeld) + SelPawn.GetEnemiesInColony(); float friendPercentage = 100f * friends / friendsRequired; { var mayBuy = SelPawn.MayBuy(); var tryImprove = SelPawn.ImproveRelationship(); var tryRecruit = SelPawn.TryRecruit(); listingStandard.ColumnWidth = size.x - 20; var comp = SelPawn.GetComp <CompGuest>(); if (comp != null) { listingStandard.Gap(); DoAreaRestriction(listingStandard, comp); CheckboxLabeled(listingStandard, "MayBuy".Translate(), ref mayBuy); CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref tryImprove); CheckboxLabeled(listingStandard, "ShouldTryToRecruit".Translate(), ref tryRecruit); comp.mayBuy = mayBuy; comp.chat = tryImprove; comp.recruit = tryRecruit; listingStandard.Gap(50); DrawSetDefaultButton(rect); DrawSendHomeButton(rect); } if (SelPawn.Faction != null) { listingStandard.Label(txtRecruitmentPenalty + ": " + SelPawn.RecruitPenalty().ToString("##0")); listingStandard.Label(txtFactionGoodwill + ": " + SelPawn.Faction.PlayerGoodwill.ToString("##0")); } listingStandard.Gap(); listingStandard.Label(string.Format("{0}:", "FriendsRequirement".Translate(friends, friendsRequired))); listingStandard.Slider(Mathf.Clamp(friendPercentage, 0, 100), 0, 100); if (friendPercentage <= 99) { var color = GUI.color; GUI.color = Color.red; listingStandard.Label("NotEnoughFriends".Translate(SelPawn.GetMinRecruitOpinion()).AdjustedFor(SelPawn)); GUI.color = color; } else { listingStandard.Label("CanNowBeRecruited".Translate().AdjustedFor(SelPawn)); } // Will only have squadBrain while "checked in", becomes null again when guests leave var squadBrain = SelPawn.GetLord(); if (squadBrain != null) { var lordToil = squadBrain.CurLordToil as LordToil_VisitPoint; if (lordToil != null && SelPawn.Faction != null) { listingStandard.Label(txtHospitality + ":"); listingStandard.Slider(lordToil.GetVisitScore(SelPawn), 0f, 1f); } } } }
protected override void FillTab() { // get the inventory comp CompInventory comp = SelPawn.TryGetComp <CompInventory>(); // set up rects Rect listRect = new Rect( _margin, _topPadding, size.x - 2 * _margin, size.y - _topPadding - _margin); if (comp != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.FrameDisplayed); // adjust rects if comp found listRect.height -= (_margin / 2 + _barHeight) * 2; Rect weightRect = new Rect(_margin, listRect.yMax + _margin / 2, listRect.width, _barHeight); Rect bulkRect = new Rect(_margin, weightRect.yMax + _margin / 2, listRect.width, _barHeight); // draw bars Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CE_Bulk".Translate(), SelPawn.GetBulkTip()); Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CE_Weight".Translate(), SelPawn.GetWeightTip()); // draw text overlays on bars Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; string currentBulk = CE_StatDefOf.CarryBulk.ValueToString(comp.currentBulk, CE_StatDefOf.CarryBulk.toStringNumberSense); string capacityBulk = CE_StatDefOf.CarryBulk.ValueToString(comp.capacityBulk, CE_StatDefOf.CarryBulk.toStringNumberSense); Widgets.Label(bulkRect, currentBulk + "/" + capacityBulk); string currentWeight = comp.currentWeight.ToString("0.#"); string capacityWeight = CE_StatDefOf.CarryWeight.ValueToString(comp.capacityWeight, CE_StatDefOf.CarryWeight.toStringNumberSense); Widgets.Label(weightRect, currentWeight + "/" + capacityWeight); Text.Anchor = TextAnchor.UpperLeft; } // start drawing list (rip from ITab_Pawn_Gear) GUI.BeginGroup(listRect); Text.Font = GameFont.Small; GUI.color = Color.white; Rect outRect = new Rect(0f, 0f, listRect.width, listRect.height); Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, _scrollViewHeight); Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); float num = 0f; TryDrawComfyTemperatureRange(ref num, viewRect.width); if (ShouldShowOverallArmor(SelPawnForGear)) { Widgets.ListSeparator(ref num, viewRect.width, "OverallArmor".Translate()); TryDrawOverallArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Blunt, "ArmorBlunt".Translate(), " " + "CE_MPa".Translate()); TryDrawOverallArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Sharp, "ArmorSharp".Translate(), "CE_mmRHA".Translate()); TryDrawOverallArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Heat, "ArmorHeat".Translate(), "%"); } if (ShouldShowEquipment(SelPawnForGear)) { Widgets.ListSeparator(ref num, viewRect.width, "Equipment".Translate()); foreach (ThingWithComps current in SelPawnForGear.equipment.AllEquipmentListForReading) { DrawThingRow(ref num, viewRect.width, current); } } if (ShouldShowApparel(SelPawnForGear)) { Widgets.ListSeparator(ref num, viewRect.width, "Apparel".Translate()); foreach (Apparel current2 in from ap in SelPawnForGear.apparel.WornApparel orderby ap.def.apparel.bodyPartGroups[0].listOrder descending select ap) { DrawThingRow(ref num, viewRect.width, current2); } } if (ShouldShowInventory(SelPawnForGear)) { // get the loadout so we can make a decision to show a button. bool showMakeLoadout = false; Loadout curLoadout = SelPawnForGear.GetLoadout(); if (SelPawnForGear.IsColonist && (curLoadout == null || curLoadout.Slots.NullOrEmpty()) && (SelPawnForGear.inventory.innerContainer.Any() || SelPawnForGear.equipment?.Primary != null)) { showMakeLoadout = true; } if (showMakeLoadout) { num += 3; // Make a little room for the button. } float buttonY = num; // Could be accomplished with seperator being after the button... Widgets.ListSeparator(ref num, viewRect.width, "Inventory".Translate()); // only offer this button if the pawn has no loadout or has the default loadout and there are things/equipment... if (showMakeLoadout) { Rect loadoutButtonRect = new Rect(viewRect.width / 2, buttonY, viewRect.width / 2, 26f); // button is half the available width... if (Widgets.ButtonText(loadoutButtonRect, "CE_MakeLoadout".Translate())) { Loadout loadout = SelPawnForGear.GenerateLoadoutFromPawn(); LoadoutManager.AddLoadout(loadout); SelPawnForGear.SetLoadout(loadout); // Opening this window is the same way as if from the assign tab so should be correct. Find.WindowStack.Add(new Dialog_ManageLoadouts(SelPawnForGear.GetLoadout())); } } workingInvList.Clear(); workingInvList.AddRange(SelPawnForGear.inventory.innerContainer); for (int i = 0; i < workingInvList.Count; i++) { DrawThingRow(ref num, viewRect.width, workingInvList[i].GetInnerIfMinified(), true); } } if (Event.current.type == EventType.Layout) { _scrollViewHeight = num + 30f; } Widgets.EndScrollView(); GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }
protected override void FillTab() { // get the inventory comp CompInventory comp = SelPawn.TryGetComp <CompInventory>(); // set up rects Rect listRect = new Rect( _margin, _topPadding, size.x - 2 * _margin, size.y - _topPadding - _margin); if (comp != null) { // adjust rects if comp found listRect.height -= (_margin + _barHeight) * 2; Rect weightRect = new Rect(_margin, listRect.yMax + _margin, listRect.width, _barHeight); Rect bulkRect = new Rect(_margin, weightRect.yMax + _margin, listRect.width, _barHeight); Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CR.Bulk".Translate(), SelPawn.GetBulkTip()); Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CR.Weight".Translate(), SelPawn.GetWeightTip()); } // start drawing list (rip from ITab_Pawn_Gear) GUI.BeginGroup(listRect); Text.Font = GameFont.Small; GUI.color = Color.white; Rect outRect = new Rect(0f, 0f, listRect.width, listRect.height); Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, this._scrollViewHeight); Widgets.BeginScrollView(outRect, ref this._scrollPosition, viewRect); float curY = 0f; if (this.SelPawnForGear.equipment != null) { Widgets.ListSeparator(ref curY, viewRect.width, "Equipment".Translate()); foreach (ThingWithComps current in this.SelPawnForGear.equipment.AllEquipment) { this.DrawThingRow(ref curY, viewRect.width, current); } } if (this.SelPawnForGear.apparel != null) { Widgets.ListSeparator(ref curY, viewRect.width, "Apparel".Translate()); foreach (Apparel current2 in from ap in this.SelPawnForGear.apparel.WornApparel orderby ap.def.apparel.bodyPartGroups[0].listOrder descending select ap) { this.DrawThingRow(ref curY, viewRect.width, current2); } } if (this.SelPawnForGear.inventory != null) { Widgets.ListSeparator(ref curY, viewRect.width, "Inventory".Translate()); foreach (Thing current3 in this.SelPawnForGear.inventory.container) { this.DrawThingRow(ref curY, viewRect.width, current3); } } if (Event.current.type == EventType.Layout) { this._scrollViewHeight = curY + 30f; } Widgets.EndScrollView(); GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }
protected override void FillTab() { DoRows(size, SelPawn?.GetComp <CompVehicle>(), ref scrollPosition, ref scrollViewHeight, false, ref specificNeedsTabForPawn, doNeeds); }
protected override void FillTab() { // get the inventory comp CompInventory comp = SelPawn.TryGetComp <CompInventory>(); // set up rects Rect listRect = new Rect( _margin, _topPadding, size.x - 2 * _margin, size.y - _topPadding - _margin); if (comp != null) { // adjust rects if comp found listRect.height -= (_margin / 2 + _barHeight) * 2; Rect weightRect = new Rect(_margin, listRect.yMax + _margin / 2, listRect.width, _barHeight); Rect bulkRect = new Rect(_margin, weightRect.yMax + _margin / 2, listRect.width, _barHeight); Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CR.Bulk".Translate(), SelPawn.GetBulkTip()); Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CR.Weight".Translate(), SelPawn.GetWeightTip()); } // start drawing list (rip from ITab_Pawn_Gear) GUI.BeginGroup(listRect); Text.Font = GameFont.Small; GUI.color = Color.white; Rect outRect = new Rect(0f, 0f, listRect.width, listRect.height); Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, _scrollViewHeight); Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); float num = 0f; TryDrawComfyTemperatureRange(ref num, viewRect.width); if (SelPawnForGear.apparel != null) { bool flag = false; TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Blunt, "ArmorBlunt".Translate(), ref flag); TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Sharp, "ArmorSharp".Translate(), ref flag); TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Heat, "ArmorHeat".Translate(), ref flag); TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Electric, "ArmorElectric".Translate(), ref flag); } if (SelPawnForGear.equipment != null) { Widgets.ListSeparator(ref num, viewRect.width, "Equipment".Translate()); foreach (ThingWithComps current in SelPawnForGear.equipment.AllEquipment) { DrawThingRow(ref num, viewRect.width, current); } } if (SelPawnForGear.apparel != null) { Widgets.ListSeparator(ref num, viewRect.width, "Apparel".Translate()); foreach (Apparel current2 in from ap in SelPawnForGear.apparel.WornApparel orderby ap.def.apparel.bodyPartGroups[0].listOrder descending select ap) { DrawThingRow(ref num, viewRect.width, current2); } } if (SelPawnForGear.inventory != null) { Widgets.ListSeparator(ref num, viewRect.width, "Inventory".Translate()); workingInvList.Clear(); workingInvList.AddRange(SelPawnForGear.inventory.innerContainer); for (int i = 0; i < workingInvList.Count; i++) { DrawThingRow(ref num, viewRect.width, workingInvList[i].GetInnerIfMinified()); } } if (Event.current.type == EventType.Layout) { _scrollViewHeight = num + 30f; } Widgets.EndScrollView(); GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; // GUI.BeginGroup(listRect); // Text.Font = GameFont.Small; // GUI.color = Color.white; // Rect outRect = new Rect(0f, 0f, listRect.width, listRect.height); // Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, this._scrollViewHeight); // Widgets.BeginScrollView(outRect, ref this._scrollPosition, viewRect); // float curY = 0f; // if (this.SelPawnForGear.equipment != null) // { // Widgets.ListSeparator(ref curY, viewRect.width, "Equipment".Translate()); // foreach (ThingWithComps current in this.SelPawnForGear.equipment.AllEquipment) // { // this.DrawThingRow(ref curY, viewRect.width, current); // } // } // if (this.SelPawnForGear.apparel != null) // { // Widgets.ListSeparator(ref curY, viewRect.width, "Apparel".Translate()); // foreach (Apparel current2 in from ap in this.SelPawnForGear.apparel.WornApparel // orderby ap.def.apparel.bodyPartGroups[0].listOrder descending // select ap) // { // this.DrawThingRow(ref curY, viewRect.width, current2); // } // } // if (this.SelPawnForGear.inventory != null) // { // Widgets.ListSeparator(ref curY, viewRect.width, "Inventory".Translate()); // foreach (Thing current3 in this.SelPawnForGear.inventory.container) // { // this.DrawThingRow(ref curY, viewRect.width, current3); // } // } // if (Event.current.type == EventType.Layout) // { // this._scrollViewHeight = curY + 30f; // } // Widgets.EndScrollView(); // GUI.EndGroup(); // // GUI.color = Color.white; // Text.Anchor = TextAnchor.UpperLeft; }
private void DrawThingRowModded(ref float y, float width, Apparel apparel) { if (apparel == null) { DrawThingRowVanilla(ref y, width, null); return; } var rect = new Rect(0f, y, width, ThingRowHeight); if (Mouse.IsOver(rect)) { GUI.color = HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } GUI.color = ThingLabelColor; // LMB doubleclick if (Widgets.ButtonInvisible(rect)) { // Left Mouse Button Menu if (Event.current.button == 0) { Find.WindowStack.Add(new Window_Pawn_ApparelDetail(SelPawn, apparel)); } // RMB menu if (Event.current.button == 1) { var floatOptionList = new List <FloatMenuOption> { new FloatMenuOption( "ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(apparel)); }) }; if (CanControl) { floatOptionList.Add( new FloatMenuOption( "OutfitterComparer".Translate(), delegate { Find.WindowStack.Add( new Dialog_PawnApparelComparer(SelPawnForGear, apparel)); })); void DropApparel() { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(apparel); } void DropApparelHaul() { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDropHaul(apparel); } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), DropApparel)); floatOptionList.Add(new FloatMenuOption("DropThingHaul".Translate(), DropApparelHaul)); } var window = new FloatMenu(floatOptionList, string.Empty); Find.WindowStack.Add(window); } } if (apparel.def.DrawMatSingle != null && apparel.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y + 5f, ThingIconSize, ThingIconSize), apparel); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; var textRect = new Rect(ThingLeftX, y, width - ThingLeftX, ThingRowHeight - Text.LineHeight); var scoreRect = new Rect(ThingLeftX, textRect.yMax, width - ThingLeftX, Text.LineHeight); var conf = SelPawn.GetApparelStatCache(); var text = apparel.LabelCap; var textScore = Math.Round(conf.ApparelScoreRaw(apparel), 2).ToString("N2"); if (SelPawn.outfits != null && SelPawn.outfits.forcedHandler.IsForced(apparel)) { text = text + ", " + "ApparelForcedLower".Translate(); Widgets.Label(textRect, text); } else { GUI.color = new Color(0.75f, 0.75f, 0.75f); if (apparel.def.useHitPoints) { var x = apparel.HitPoints / (float)apparel.MaxHitPoints; if (x < 0.5f) { GUI.color = Color.yellow; } if (x < 0.2f) { GUI.color = Color.red; } } Widgets.Label(textRect, text); GUI.color = Color.white; Widgets.Label(scoreRect, textScore); } y += ThingRowHeight; }
private void FillTabGuest(Rect rect) { //ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); var title = SelPawn.royalty?.MostSeniorTitle; var isRoyal = title != null; var friends = isRoyal ? SelPawn.GetFriendsSeniorityInColony() : SelPawn.GetFriendsInColony(); var friendsRequired = isRoyal ? RequiredSeniority : RequiredFriends; var friendPercentage = 100f * friends / friendsRequired; var tryImprove = SelPawn.ImproveRelationship(); var tryMakeFriends = SelPawn.MakeFriends(); listingStandard.ColumnWidth = size.x - 20; var comp = SelPawn.GetComp <CompGuest>(); // If the lord is not on the map it's invalid! if (comp?.lord != null && comp.lord.ownedPawns.Contains(SelPawn) && SelPawn.Map.lordManager.lords.Contains(comp.lord)) { listingStandard.Gap(); string labelStay = "AreaToStay".Translate(); string labelBuy = "AreaToBuy".Translate(); var rectStayLabel = listingStandard.GetRect(Text.CalcHeight(labelStay, listingStandard.ColumnWidth)); var rectStay = listingStandard.GetRect(24); var rectBuyLabel = listingStandard.GetRect(Text.CalcHeight(labelBuy, listingStandard.ColumnWidth)); var rectBuy = listingStandard.GetRect(24); LabelWithTooltip(labelStay, "AreaToStayTooltip".Translate(), rectStayLabel); GenericUtility.DoAreaRestriction(SelPawn, rectStay, comp.GuestArea, SetAreaRestriction, AreaUtility.AreaAllowedLabel_Area); LabelWithTooltip(labelBuy, "AreaToBuyTooltip".Translate(), rectBuyLabel); GenericUtility.DoAreaRestriction(SelPawn, rectBuy, comp.ShoppingArea, SetAreaShopping, GenericUtility.GetShoppingLabel); var rectImproveRelationship = listingStandard.GetRect(Text.LineHeight); CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref tryImprove, rectImproveRelationship, false, txtImproveTooltip); var rectMakeFriends = listingStandard.GetRect(Text.LineHeight); CheckboxLabeled(listingStandard, "MakeFriends".Translate(), ref tryMakeFriends, rectMakeFriends, false, txtMakeFriendsTooltip); comp.SetEntertain(tryImprove); comp.SetMakeFriends(tryMakeFriends); listingStandard.Gap(50); var mayRecruitAtAll = !SelPawn.InMentalState && comp.arrived; var rectSetDefault = new Rect(rect.xMax - buttonSize.x - 10, 160, buttonSize.x, buttonSize.y); var rectSendHome = new Rect(rect.xMin - 10, 160, buttonSize.x, buttonSize.y); DrawButton(() => SetAllDefaults(SelPawn), txtMakeDefault, rectSetDefault, txtMakeDefaultTooltip); DrawButton(() => SendHomeDialog(SelPawn.GetLord()), txtSendAway, rectSendHome, txtSendAwayTooltip); if (mayRecruitAtAll) { var rectRecruitButton = new Rect(rect.xMin - 10 + 10 + buttonSize.x, 160, buttonSize.x, buttonSize.y); if (friends >= friendsRequired) { DrawButton(() => RecruitDialog(SelPawn, false), txtRecruit, rectRecruitButton, txtRecruitTooltip); } else if (!isRoyal) { DrawButton(() => RecruitDialog(SelPawn, true), txtForceRecruit, rectRecruitButton, txtForceRecruitTooltip); } } // Highlight defaults if (Mouse.IsOver(rectSetDefault)) { Widgets.DrawHighlight(rectStay); Widgets.DrawHighlight(rectStayLabel); Widgets.DrawHighlight(rectBuy); Widgets.DrawHighlight(rectBuyLabel); Widgets.DrawHighlight(rectImproveRelationship); Widgets.DrawHighlight(rectMakeFriends); } } if (SelPawn.Faction != null) { listingStandard.Label(txtRecruitmentPenalty.Translate(SelPawn.RecruitPenalty().ToString("##0"), SelPawn.ForcedRecruitPenalty().ToString("##0"))); listingStandard.Label(txtFactionGoodwill + ": " + SelPawn.Faction.PlayerGoodwill.ToString("##0")); } listingStandard.Gap(); if (isRoyal) { listingStandard.Label($"{"SeniorityRequirement".Translate(friends / 100, friendsRequired / 100)}:"); } else { listingStandard.Label($"{"FriendsRequirement".Translate(friends, friendsRequired)}:"); } listingStandard.Slider(Mathf.Clamp(friendPercentage, 0, 100), 0, 100); if (friendPercentage <= 99) { // Remove color from AdjustedFor and then Colorize listingStandard.Label(ColoredText.StripTags("NotEnoughFriends".Translate(SelPawn.GetMinRecruitOpinion()).AdjustedFor(SelPawn)).Colorize(Color.red)); } else { listingStandard.Label("CanNowBeRecruited".Translate().AdjustedFor(SelPawn)); } // Will only have score while "checked in", becomes 0 again when guest leaves if (SelPawn.GetVisitScore(out var score)) { listingStandard.Label(txtHospitality + ":"); listingStandard.Slider(score, 0f, 1f); } }
protected override void FillTab() { // Set up the rects. Rect rect = new Rect(0f, 10f, mainSize.x, mainSize.y); Rect mainView = rect.ContractedBy(10f); Rect logView = new Rect(rect.x + rect.width, rect.y, LOG_WIDTH, rect.height).ContractedBy(10f); // No idea what this does, but it sounds important. GUI.BeginGroup(mainView); // Set the defualts, in case they weren't properly reset elsewhere. Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; // Draw the header. Vector2 col1 = new Vector2(0f, 0f); if (SelPawn.GetMutationTracker(false) != null) { DrawMutTabHeader(ref col1, mainView.width); } // Set up scrolling area. Rect outRect = new Rect(col1.x, col1.y, mainView.width, mainView.height - col1.y - 10f); Rect viewRect = new Rect(col1.x, col1.y, mainView.width - 16f, mainScrollViewHeight - col1.y); Widgets.BeginScrollView(outRect, ref mainScrollPosition, viewRect, true); // Set up referance variables for the other two column's current xy position. Vector2 col2 = new Vector2(viewRect.width / 3, col1.y); Vector2 col3 = new Vector2(viewRect.width / 3 * 2, col2.y); float colWidth = viewRect.width / 3 - 10f; // Draw the headers for all three columns (labels are provided by the xml). DrawColumnHeader(ref col1, colWidth, "MorphsITabHeader".Translate()); DrawColumnHeader(ref col2, colWidth, "TraitsITabHeader".Translate()); DrawColumnHeader(ref col3, colWidth, "ProductionITabHeader".Translate()); // Draw the content of the columns. if (MorphUtilities.HybridsAreEnabledFor(PawnToShowMutationsFor.def)) { DrawMorphInfluenceList(ref col1, colWidth); } DrawMorphTraitsList(ref col2, colWidth); DrawMorphProductionList(ref col3, colWidth); // Set the scroll view height if (Event.current.type == EventType.Layout) { mainScrollViewHeight = Math.Max(col1.y, Math.Max(col2.y, col3.y)); } Widgets.EndScrollView(); // Ya, this thing is important for some reason, but IDK why. GUI.EndGroup(); // Boolean to dynamically resize the iTab and draw the log's content if necessary. if (toggleLog) { size.x = mainSize.x + LOG_WIDTH; DrawMutationLog(logView); } else { size.x = mainSize.x; } // Make sure everything was reset properly. Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; }
protected override void FillTab() { // get the inventory comp CompInventory comp = SelPawn.TryGetComp <CompInventory>(); // set up rects Rect listRect = new Rect( _margin, _topPadding, size.x - 2 * _margin, size.y - _topPadding - _margin); if (comp != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.FrameDisplayed); // adjust rects if comp found listRect.height -= (_margin / 2 + _barHeight) * 2; Rect weightRect = new Rect(_margin, listRect.yMax + _margin / 2, listRect.width, _barHeight); Rect bulkRect = new Rect(_margin, weightRect.yMax + _margin / 2, listRect.width, _barHeight); Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CE_Bulk".Translate(), SelPawn.GetBulkTip()); Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CE_Weight".Translate(), SelPawn.GetWeightTip()); } // start drawing list (rip from ITab_Pawn_Gear) GUI.BeginGroup(listRect); Text.Font = GameFont.Small; GUI.color = Color.white; Rect outRect = new Rect(0f, 0f, listRect.width, listRect.height); Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, _scrollViewHeight); Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); float num = 0f; TryDrawComfyTemperatureRange(ref num, viewRect.width); if (SelPawnForGear.apparel != null) { bool flag = false; TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Blunt, "ArmorBlunt".Translate(), ref flag); TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Sharp, "ArmorSharp".Translate(), ref flag); TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Heat, "ArmorHeat".Translate(), ref flag); TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Electric, "ArmorElectric".Translate(), ref flag); } if (SelPawnForGear.equipment != null) { Widgets.ListSeparator(ref num, viewRect.width, "Equipment".Translate()); foreach (ThingWithComps current in SelPawnForGear.equipment.AllEquipmentListForReading) { DrawThingRow(ref num, viewRect.width, current); } } if (SelPawnForGear.apparel != null) { Widgets.ListSeparator(ref num, viewRect.width, "Apparel".Translate()); foreach (Apparel current2 in from ap in SelPawnForGear.apparel.WornApparel orderby ap.def.apparel.bodyPartGroups[0].listOrder descending select ap) { DrawThingRow(ref num, viewRect.width, current2); } } if (SelPawnForGear.inventory != null) { // get the loadout so we can make a decision to show a button. bool showMakeLoadout = false; Loadout curLoadout = SelPawnForGear.GetLoadout(); if (SelPawnForGear.IsColonist && (curLoadout == null || curLoadout.Slots.NullOrEmpty()) && (SelPawnForGear.inventory.innerContainer.Any() || SelPawnForGear.equipment?.Primary != null)) { showMakeLoadout = true; } if (showMakeLoadout) { num += 3; // Make a little room for the button. } float buttonY = num; // Could be accomplished with seperator being after the button... Widgets.ListSeparator(ref num, viewRect.width, "Inventory".Translate()); // only offer this button if the pawn has no loadout or has the default loadout and there are things/equipment... if (showMakeLoadout) { Rect loadoutButtonRect = new Rect(viewRect.width / 2, buttonY, viewRect.width / 2, 26f); // button is half the available width... if (Widgets.ButtonText(loadoutButtonRect, "Make Loadout")) { Loadout loadout = SelPawnForGear.GenerateLoadoutFromPawn(); LoadoutManager.AddLoadout(loadout); SelPawnForGear.SetLoadout(loadout); // UNDONE ideally we'd open the assign (MainTabWindow_OutfitsAndLoadouts) tab as if the user clicked on it here. // (ProfoundDarkness) But I have no idea how to do that just yet. The attempts I made seem to put the RimWorld UI into a bit of a bad state. // ie opening the tab like the dialog below. // Need to understand how RimWorld switches tabs and see if something similar can be done here // (or just remove the unfinished marker). // Opening this window is the same way as if from the assign tab so should be correct. Find.WindowStack.Add(new Dialog_ManageLoadouts(SelPawnForGear.GetLoadout())); } } workingInvList.Clear(); workingInvList.AddRange(SelPawnForGear.inventory.innerContainer); for (int i = 0; i < workingInvList.Count; i++) { DrawThingRow(ref num, viewRect.width, workingInvList[i].GetInnerIfMinified(), true); } } if (Event.current.type == EventType.Layout) { _scrollViewHeight = num + 30f; } Widgets.EndScrollView(); GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; }
protected override void FillTab() { // main canvas Rect canvas = new Rect(0f, 0f, size.x, size.y).ContractedBy(20f); GUI.BeginGroup(canvas); Vector2 cur = Vector2.zero; // header Rect tempHeaderRect = new Rect(cur.x, cur.y, canvas.width, 30f); cur.y += 30f; Text.Anchor = TextAnchor.LowerLeft; Widgets.Label(tempHeaderRect, "PreferedTemperature".Translate()); Text.Anchor = TextAnchor.UpperLeft; // line GUI.color = Color.grey; Widgets.DrawLineHorizontal(cur.x, cur.y, canvas.width); GUI.color = Color.white; // some padding cur.y += 10f; // temperature slider ApparelStatCache pawnStatCache = SelPawn.GetApparelStatCache(); FloatRange targetTemps = pawnStatCache.TargetTemperatures; FloatRange minMaxTemps = ApparelStatsHelper.MinMaxTemperatureRange; Rect sliderRect = new Rect(cur.x, cur.y, canvas.width - 20f, 40f); Rect tempResetRect = new Rect(sliderRect.xMax + 4f, cur.y + 10f, 16f, 16f); cur.y += 60f; // includes padding // current temperature settings GUI.color = pawnStatCache.targetTemperaturesOverride ? Color.white : Color.grey; Widgets_FloatRange.FloatRange(sliderRect, 123123123, ref targetTemps, minMaxTemps, ToStringStyle.Temperature); GUI.color = Color.white; if (Math.Abs(targetTemps.min - SelPawn.GetApparelStatCache().TargetTemperatures.min) > 1e-4 || Math.Abs(targetTemps.max - SelPawn.GetApparelStatCache().TargetTemperatures.max) > 1e-4) { SelPawn.GetApparelStatCache().TargetTemperatures = targetTemps; } if (pawnStatCache.targetTemperaturesOverride) { if (Widgets.ImageButton(tempResetRect, resetButton)) { pawnStatCache.targetTemperaturesOverride = false; pawnStatCache.UpdateTemperatureIfNecessary(true); } TooltipHandler.TipRegion(tempResetRect, "TemperatureRangeReset".Translate()); } // header Rect statsHeaderRect = new Rect(cur.x, cur.y, canvas.width, 30f); cur.y += 30f; Text.Anchor = TextAnchor.LowerLeft; Text.Font = GameFont.Small; Widgets.Label(statsHeaderRect, "PreferredStats".Translate()); Text.Anchor = TextAnchor.UpperLeft; // add button Rect addStatRect = new Rect(statsHeaderRect.xMax - 16f, statsHeaderRect.yMin + 10f, 16f, 16f); if (Widgets.ImageButton(addStatRect, addButton)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (StatDef def in SelPawn.NotYetAssignedStatDefs()) { options.Add(new FloatMenuOption(def.LabelCap, delegate { SelPawn.GetApparelStatCache() .StatCache.Insert(0, new ApparelStatCache.StatPriority(def, 0f, StatAssignment.Manual)); })); } Find.WindowStack.Add(new FloatMenu(options)); } TooltipHandler.TipRegion(addStatRect, "StatPriorityAdd".Translate()); // line GUI.color = Color.grey; Widgets.DrawLineHorizontal(cur.x, cur.y, canvas.width); GUI.color = Color.white; // some padding cur.y += 10f; // main content in scrolling view Rect contentRect = new Rect(cur.x, cur.y, canvas.width, canvas.height - cur.y); Rect viewRect = contentRect; viewRect.height = SelPawn.GetApparelStatCache().StatCache.Count * 30f + 10f; if (viewRect.height > contentRect.height) { viewRect.width -= 20f; } Widgets.BeginScrollView(contentRect, ref _scrollPosition, viewRect); GUI.BeginGroup(viewRect); cur = Vector2.zero; // none label if (!SelPawn.GetApparelStatCache().StatCache.Any()) { Rect noneLabel = new Rect(cur.x, cur.y, viewRect.width, 30f); GUI.color = Color.grey; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(noneLabel, "None".Translate()); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; cur.y += 30f; } else { // legend kind of thingy. Rect legendRect = new Rect(cur.x + (viewRect.width - 24) / 2, cur.y, (viewRect.width - 24) / 2, 20f); Text.Font = GameFont.Tiny; GUI.color = Color.grey; Text.Anchor = TextAnchor.LowerLeft; Widgets.Label(legendRect, "-10"); Text.Anchor = TextAnchor.LowerRight; Widgets.Label(legendRect, "10"); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; GUI.color = Color.white; cur.y += 15f; // stat weight sliders foreach (ApparelStatCache.StatPriority stat in SelPawn.GetApparelStatCache().StatCache) { bool stop_UI; ApparelStatCache.DrawStatRow(ref cur, viewRect.width, stat, SelPawn, out stop_UI); if (stop_UI) { // DrawStatRow can change the StatCache, invalidating the loop. So if it does that, stop looping - we'll redraw on the next tick. break; } } } GUI.EndGroup(); Widgets.EndScrollView(); GUI.EndGroup(); }