protected override void FillTab() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.GuiFrame); Rect rect = new Rect(0f, 0f, ITab_Bills_Alternate.WinSize.x, ITab_Bills_Alternate.WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); for (int i = 0; i < base.SelTable.def.AllRecipes.Count; i++) { RecipeDef recipe = base.SelTable.def.AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!Find.ListerPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill = recipe.MakeNewBill(); this.SelTable.billStack.AddBill(bill); }, MenuOptionPriority.Medium, null, null)); } return(list); }; Bill value = BillDrawer.DrawListing(base.SelTable.billStack, rect, recipeOptionsMaker, this.scrollView); this.mouseoverBillField.SetValue(this, value); }
protected override void FillTab() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; Rect position = new Rect(0f, 0f, this.size.x, this.size.y).ContractedBy(20f); bool isPrisonerOfColony = base.SelPawn.IsPrisonerOfColony; try { GUI.BeginGroup(position); float num = 10f; Rect rect = new Rect(10f, num, position.width - 20f, 32f); MedicalCareUtility.MedicalCareSetter(rect, ref base.SelPawn.playerSettings.medCare); num += 32f; num += 18f; Rect rect2 = new Rect(10f, num, position.width - 28f, position.height - num); bool getsFood = base.SelPawn.guest.GetsFood; num += WidgetDrawer.DrawLabeledCheckbox(rect2, "GetsFood".Translate(), ref getsFood); base.SelPawn.guest.GetsFood = getsFood; if (isPrisonerOfColony) { num += 6f; int length = Enum.GetValues(typeof(PrisonerInteractionMode)).Length; float height = (float)(length * 28 + 20); Rect rect3 = new Rect(0f, num, position.width, height); TabDrawer.DrawBox(rect3); Rect rect4 = rect3.ContractedBy(10f); rect4.height = 28f; IEnumerator enumerator = Enum.GetValues(typeof(PrisonerInteractionMode)).GetEnumerator(); while (enumerator.MoveNext()) { PrisonerInteractionMode prisonerInteractionMode = (PrisonerInteractionMode)((byte)enumerator.Current); if (WidgetDrawer.DrawLabeledRadioButton(rect4, prisonerInteractionMode.GetLabel(), base.SelPawn.guest.interactionMode == prisonerInteractionMode, true)) { base.SelPawn.guest.interactionMode = prisonerInteractionMode; } rect4.y += 28f; } Rect rect5 = new Rect(rect3.x, rect3.y + rect3.height + 5f, rect3.width - 4f, 28f); Text.Anchor = TextAnchor.UpperRight; Widgets.Label(rect5, "RecruitmentDifficulty".Translate() + ": " + base.SelPawn.guest.RecruitDifficulty.ToString("##0")); Text.Anchor = TextAnchor.UpperLeft; } } finally { GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; } if (this.PreferenceTabBrowseButtons != null && this.PreferenceTabBrowseButtons.Value) { Pawn selPawn = base.SelPawn; if (selPawn != null) { BrowseButtonDrawer.DrawBrowseButtons(this.size, selPawn); } } }
public override void PreOpen() { base.PreOpen(); ConceptDatabase.Save(); ShipCountdown.CancelCountdown(); this.anyWorldFiles = SavedWorldsDatabase.AllWorldFiles.Any <FileInfo>(); this.anyMapFiles = MapFilesUtility.AllMapFiles.Any <FileInfo>(); }
protected override void FillTab() { if (this.rightClicked != null && this.infoFloatMenu != null && Find.WindowStack.Top() != this.infoFloatMenu) { this.rightClicked = null; this.infoFloatMenu = null; } Text.Font = GameFont.Small; IPlantToGrowSettable plantToGrowSettable = (IPlantToGrowSettable)Find.Selector.SelectedObjects.First <object>(); Rect position = new Rect(ITab_Growing_Alternate.PaddingSize.x, ITab_Growing_Alternate.PaddingSize.y, ITab_Growing_Alternate.ContentSize.x, ITab_Growing_Alternate.ContentSize.y); GUI.BeginGroup(position); Rect viewRect = new Rect(0f, 0f, position.width, position.height); this.scrollView.Begin(viewRect); float num = 0f; int num2 = 0; foreach (ThingDef current in GenPlant.ValidPlantTypesForGrower(Find.Selector.SingleSelectedObject)) { float num3 = Text.CalcHeight(current.LabelCap, ITab_Growing_Alternate.ContentSize.x - 32f); if (num3 < 30f) { num3 = 30f; } GUI.color = Color.white; Rect rect = new Rect(0f, num + 1f, ITab_Growing_Alternate.ContentSize.x - 28f, num3); Rect position2 = new Rect(0f, rect.y - 1f, rect.width, rect.height + 2f); Vector2 mousePosition = Event.current.mousePosition; if (position2.Contains(mousePosition) && mousePosition.y > this.scrollView.Position.y && mousePosition.y < this.scrollView.Position.y + this.scrollView.ViewHeight) { GUI.DrawTexture(position2, TexUI.HighlightTex); } else if (num2 % 2 == 0) { GUI.DrawTexture(position2, TabDrawer.AlternateRowTexture); } rect.x += 6f; rect.y += 3f; rect.width -= 4f; Widgets.InfoCardButton(rect.x, rect.y, current); rect.x += 34f; rect.width -= 34f; if ((Widgets.InvisibleButton(new Rect(rect.x, rect.y, rect.width - 36f, rect.height)) || WidgetDrawer.DrawLabeledRadioButton(rect, current.LabelCap, current == plantToGrowSettable.GetPlantDefToGrow(), false)) && plantToGrowSettable.GetPlantDefToGrow() != current) { plantToGrowSettable.SetPlantDefToGrow(current); SoundDefOf.RadioButtonClicked.PlayOneShotOnCamera(); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total); } num += num3; num += 2f; num2++; } this.scrollView.End(num); TutorUIHighlighter.HighlightOpportunity("GrowingZoneSetPlant", new Rect(0f, 0f, ITab_Growing_Alternate.ContentSize.x, num)); GUI.EndGroup(); }
public static void Init() { if (!PlayDataLoader.loaded) { PlayDataLoader.LoadAllPlayData(false); } ConceptDatabase.Save(); ShipCountdown.CancelCountdown(); MainMenuDrawer.anyWorldFiles = SavedWorldsDatabase.AllWorldFiles.Any <FileInfo>(); MainMenuDrawer.anyMapFiles = MapFilesUtility.AllMapFiles.Any <FileInfo>(); }
protected override void FillTab() { ThingFilter allowances; ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.GuiFrame); ConceptDecider.TeachOpportunity(ConceptDefOf.StorageTabCategories, OpportunityType.GuiFrame); ConceptDecider.TeachOpportunity(ConceptDefOf.StoragePriority, OpportunityType.GuiFrame); allowances = ((Vehicle_Cart)Enumerable.First <object>(Find.Selector.SelectedObjects)).allowances; Rect position = GenUI.ContractedBy(new Rect(0.0f, 0.0f, Itab_Pawn_Vehicle_Storage.WinSize.x, Itab_Pawn_Vehicle_Storage.WinSize.y), 10f); GUI.BeginGroup(position); ThingFilterUI.DoThingFilterConfigWindow(new Rect(0.0f, 35f, position.width, position.height - 35f), ref this.scrollPosition, allowances, null); GUI.EndGroup(); }
protected void BaseDoWindowContents(Rect inRect) { if (this.Anchor == MainTabWindowAnchor.Left) { this.currentWindowRect.x = 0f; } else { this.currentWindowRect.x = (float)Screen.width - this.currentWindowRect.width; } this.currentWindowRect.y = (float)(Screen.height - 35) - this.currentWindowRect.height; if (this.def.concept != null) { ConceptDatabase.KnowledgeDemonstrated(this.def.concept, KnowledgeAmount.GuiFrame); } }
internal void Iterate() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; float num = 19f; Rect rect = new Rect(19f, num, this.windowRect.width - 38f, 100f); GUI.color = Color.white; Widgets.Label(rect, RoomStatsDrawer.GetRoomRoleLabel(this.room)); num += 25f; for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++) { RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i]; if (!roomStatDef.isHidden) { float stat = this.room.GetStat(roomStatDef); RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat); if (this.room.Role.IsStatRelated(roomStatDef)) { GUI.color = RoomStatsDrawer.RelatedStatColor; } else { GUI.color = Color.gray; } Rect rect2 = new Rect(rect.x, num, RoomStatsDrawer.statLabelColumnWidth, 23f); Widgets.Label(rect2, roomStatDef.LabelCap); Rect rect3 = new Rect(rect2.xMax + 35f, num, RoomStatsDrawer.scoreColumnWidth, 23f); string label; if (roomStatDef.displayRounded) { label = Mathf.RoundToInt(stat).ToString(); } else { label = stat.ToString("0.##"); } Widgets.Label(rect3, label); Rect rect4 = new Rect(rect3.xMax + 35f, num, RoomStatsDrawer.scoreStageLabelColumnWidth, 23f); Widgets.Label(rect4, scoreStage.label); num += 25f; } } GUI.color = Color.white; }
protected override void FillTab() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; var rect1 = new Rect(0.0f, 0.0f, this.size.x, this.size.y).ContractedBy(10f); var listingStandard = new Listing_Standard(rect1); { var getsFood = this.SelPawn.guest.GetsFood; listingStandard.DoLabelCheckbox("GetsFood".Translate(), ref getsFood, (string)null); this.SelPawn.guest.GetsFood = getsFood; var rect2 = listingStandard.GetRect(28f); rect2.width = 140f; MedicalCareUtility.MedicalCareSetter(rect2, ref this.SelPawn.playerSettings.medCare); listingStandard.DoGap(4f); listingStandard.DoLabel("RecruitmentDifficulty".Translate() + ": " + this.SelPawn.guest.RecruitDifficulty.ToString("##0")); if (Prefs.DevMode) { listingStandard.DoLabel("Dev: Prison break MTB days: " + (object)(int)PrisonBreakUtility.InitiatePrisonBreakMtbDays(this.SelPawn)); } var rect3 = listingStandard.GetRect(200f); Widgets.DrawMenuSection(rect3, true); var position = rect3.ContractedBy(10f); GUI.BeginGroup(position); { var rect4 = new Rect(0.0f, 0.0f, position.width, 30f); foreach (PrisonerInteractionMode mode in Enum.GetValues(typeof(PrisonerInteractionMode))) { if (Widgets.LabelRadioButton(rect4, mode.GetLabel(), this.SelPawn.guest.interactionMode == mode)) { this.SelPawn.guest.interactionMode = mode; } rect4.y += 28f; } if (Widgets.LabelRadioButton(rect4, "PI_Enslave".Translate(), this.SelPawn.guest.interactionMode == (PrisonerInteractionMode)Data.PIM_EnslavePrisoner)) { this.SelPawn.guest.interactionMode = (PrisonerInteractionMode)Data.PIM_EnslavePrisoner; } } GUI.EndGroup(); var compSlave = this.SelPawn.TryGetComp <CompSlave>(); if (compSlave != null) { listingStandard.DoGap(4f); var rect5 = listingStandard.GetRect(30f); if (!compSlave.ShouldBeTransfered) { if (Widgets.TextButton(rect5, "PI_TransferPrisoner".Translate())) { var list = this.GenOptions(); if ( (list.Count == 0) || ( (list.Count == 1) && (list[0].label == "PI_Prison_Cell".Translate()) && (this.SelPawn.GetRoom() == this.SelPawn.ownership.OwnedBed.GetRoom()) ) ) { list.Add(new FloatMenuOption("PI_InstallCamera".Translate(), (Action)null)); } Find.WindowStack.Add((Window) new FloatMenu(list, false)); } else { this.cached = null; } } else { if (Widgets.TextButton(rect5, "PI_CancelTransfer".Translate())) { compSlave.haulTarget = null; } listingStandard.DoGap(4f); var rect7 = listingStandard.GetRect(30f); var style = new GUIStyle(Text.CurTextFieldStyle); style.alignment = TextAnchor.MiddleCenter; string label = string.Empty; if (compSlave.haulTarget is Building_PrisonMarker) { label = ((Building_PrisonMarker)compSlave.haulTarget).markerName; } else if (compSlave.haulTarget is Building_Bed) { label = "PI_Prison_Cell".Translate(); } GUI.Label(rect7, label, style); } } } listingStandard.End(); }
internal static List <FloatMenuOption> ChoicesAtFor(Vector3 clickPos, Pawn pawn) { IntVec3 clickCell = IntVec3.FromVector3(clickPos); DangerUtility.NotifyDirectOrderingThisFrame(pawn); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (!clickCell.InBounds()) { return(list); } // ***** Beginning of drafted options ***** if (pawn.Drafted) { foreach (TargetInfo attackTarg in GenUI.TargetsAt(clickPos, TargetingParameters.ForAttackHostile(), true)) { // *** Fire at option *** if (pawn.equipment.Primary != null && !pawn.equipment.PrimaryEq.PrimaryVerb.verbProps.MeleeRange) { string str; Action rangedAct = FloatMenuUtility.GetRangedAttackAction(pawn, attackTarg, out str); string text = "FireAt".Translate(new object[] { attackTarg.Thing.LabelCap }); FloatMenuOption floatMenuOption = new FloatMenuOption(); floatMenuOption.priority = MenuOptionPriority.High; if (rangedAct == null) { text = text + " (" + str + ")"; } else { floatMenuOption.autoTakeable = true; floatMenuOption.action = new Action(delegate { MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f); rangedAct(); }); } floatMenuOption.label = text; list.Add(floatMenuOption); } // *** Melee attack option *** string str2; Action meleeAct = FloatMenuUtility.GetMeleeAttackAction(pawn, attackTarg, out str2); Pawn pawn2 = attackTarg.Thing as Pawn; string text2; if (pawn2 != null && pawn2.Downed) { text2 = "MeleeAttackToDeath".Translate(new object[] { attackTarg.Thing.LabelCap }); } else { text2 = "MeleeAttack".Translate(new object[] { attackTarg.Thing.LabelCap }); } Thing thing = attackTarg.Thing; FloatMenuOption floatMenuOption2 = new FloatMenuOption(string.Empty, null, MenuOptionPriority.High, null, thing); if (meleeAct == null) { text2 = text2 + " (" + str2 + ")"; } else { floatMenuOption2.action = new Action(delegate { MoteThrower.ThrowStatic(attackTarg.Thing.DrawPos, ThingDefOf.Mote_FeedbackAttack, 1f); meleeAct(); }); } floatMenuOption2.label = text2; list.Add(floatMenuOption2); } // *** Arrest option *** if (pawn.RaceProps.Humanlike && !pawn.Downed) { foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForArrest(pawn), true)) { TargetInfo dest = current2; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else if (!pawn.CanReserve(dest.Thing, 1)) { list.Add(new FloatMenuOption("CannotArrest".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Medium, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action = new Action(delegate { Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed); job.playerForced = true; job.maxNumToCarry = 1; pawn.drafter.TakeOrderedJob(job); TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies); }); List <FloatMenuOption> arg_3F1_0 = list; Thing thing = dest.Thing; arg_3F1_0.Add(new FloatMenuOption("TryToArrest".Translate(new object[] { dest.Thing.LabelCap }), action, MenuOptionPriority.Medium, null, thing)); } } } // *** Goto option *** int num = GenRadial.NumCellsInRadius(2.9f); for (int i = 0; i < num; i++) { IntVec3 curLoc = GenRadial.RadialPattern[i] + clickCell; if (curLoc.Standable()) { if (curLoc != pawn.Position) { if (!pawn.CanReach(curLoc, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { FloatMenuOption item = new FloatMenuOption("CannotGoNoPath".Translate(), null, MenuOptionPriority.Low, null, null); list.Add(item); } else { Action action2 = new Action(delegate { IntVec3 dest = Pawn_DraftController.BestGotoDestNear(curLoc, pawn); Job job = new Job(JobDefOf.Goto, dest); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); MoteThrower.ThrowStatic(dest, ThingDefOf.Mote_FeedbackGoto, 1f); }); list.Add(new FloatMenuOption("GoHere".Translate(), action2, MenuOptionPriority.Low, null, null) { autoTakeable = true }); } } break; } } } // *** End of drafted options *** // *** Beginning of humanlike options *** if (pawn.RaceProps.Humanlike) { int num2 = 0; if (pawn.story != null) { num2 = pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire); } // *** Consume option *** foreach (Thing current3 in clickCell.GetThingList()) { Thing t = current3; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { FloatMenuOption item2; if (t.def.ingestible.isPleasureDrug && num2 < 0) { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }) + " (" + "Teetotaler".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserve(t, 1)) { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(t, pawn.Faction).LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else { item2 = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelBaseShort }), new Action(delegate { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.maxNumToCarry = t.def.ingestible.maxNumToIngestAtOnce; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } list.Add(item2); } } // *** Rescue/Capture downed option *** foreach (TargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)current4.Thing; if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && !victim.IsPrisonerOfColony) { if ((victim.Faction == Faction.OfColony && victim.MentalStateDef == null) || (victim.Faction != Faction.OfColony && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfColony)))) { List <FloatMenuOption> arg_8E1_0 = list; Pawn victim2 = victim; arg_8E1_0.Add(new FloatMenuOption("Rescue".Translate(new object[] { victim2.LabelCap }), new Action(delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false); if (building_Bed == null) { string str; if (victim.RaceProps.Animal) { str = "NoAnimalBed".Translate(); } else { str = "NoNonPrisonerBed".Translate(); } Messages.Message("CannotRescue".Translate() + ": " + str, victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Rescue, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); }), MenuOptionPriority.Medium, null, victim2)); } if (victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfColony)) { List <FloatMenuOption> arg_962_0 = list; Pawn victim2 = victim; arg_962_0.Add(new FloatMenuOption("Capture".Translate(new object[] { victim2.LabelCap }), new Action(delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Capture, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); }), MenuOptionPriority.Medium, null, victim2)); } } } // *** Carry to cryosleep option *** foreach (TargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { TargetInfo targetInfo = current5; Pawn victim = (Pawn)targetInfo.Thing; if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null) { string label = "CarryToCryptosleepCasket".Translate(new object[] { targetInfo.Thing.LabelCap }); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action3 = new Action(delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn); if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(jDef, victim, building_CryptosleepCasket); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }); List <FloatMenuOption> arg_A80_0 = list; Pawn victim2 = victim; arg_A80_0.Add(new FloatMenuOption(label, action3, MenuOptionPriority.Medium, null, victim2)); } } // *** Strip option *** foreach (TargetInfo current6 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { TargetInfo stripTarg = current6; FloatMenuOption item3; if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item3 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { item3 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(stripTarg, pawn.Faction).LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else { item3 = new FloatMenuOption("Strip".Translate(new object[] { stripTarg.Thing.LabelCap }), new Action(delegate { stripTarg.Thing.SetForbidden(false, false); Job job = new Job(JobDefOf.Strip, stripTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } list.Add(item3); } // *** Equip option *** CompInventory compInventory = pawn.TryGetComp <CompInventory>(); // Need compInventory here for equip and wear options if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = clickCell.GetThingList(); for (int j = 0; j < thingList.Count; j++) { if (thingList[j].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[j]; break; } } if (equipment != null) { string eqLabel = GenLabel.ThingLabel(equipment.def, equipment.Stuff, 1); FloatMenuOption equipOption; if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserve(equipment, 1)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(equipment, pawn.Faction).LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else { // Added check for inventory space here int count; if (compInventory != null && !compInventory.CanFitInInventory(equipment, out count, true)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }) + " (" + "CR_InventoryFull".Translate() + ")", null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { equipment.SetForbidden(false, true); Job job = new Job(JobDefOf.Equip, equipment); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); MoteThrower.ThrowStatic(equipment.DrawPos, ThingDefOf.Mote_FeedbackEquip, 1f); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }), MenuOptionPriority.Medium, null, null); } } list.Add(equipOption); } } // *** Wear option *** if (pawn.apparel != null) { Apparel apparel = Find.ThingGrid.ThingAt <Apparel>(clickCell); if (apparel != null) { FloatMenuOption wearOption; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else if (!pawn.CanReserve(apparel, 1)) { Pawn pawn3 = Find.Reservations.FirstReserverOf(apparel, pawn.Faction); wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "ReservedBy".Translate(new object[] { pawn3.LabelBaseShort }) + ")", null, MenuOptionPriority.Medium, null, null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Medium, null, null); } else { // Added check for inventory capacity int count; if (compInventory != null && !compInventory.CanFitInInventory(apparel, out count, false, true)) { wearOption = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CR_InventoryFull".Translate() + ")", null); } else { wearOption = new FloatMenuOption("ForceWear".Translate(new object[] { apparel.LabelBaseShort }), new Action(delegate { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } } list.Add(wearOption); } } // *** NEW: Pick up option *** if (compInventory != null) { List <Thing> thingList = clickCell.GetThingList(); if (!thingList.NullOrEmpty <Thing>()) { Thing item = thingList.FirstOrDefault(thing => thing.def.alwaysHaulable && !(thing is Corpse)); if (item != null) { FloatMenuOption pickUpOption; int count = 0; if (!pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "NoPath".Translate() + ")", null); } else if (!pawn.CanReserve(item)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(item, pawn.Faction) }), null); } else if (!compInventory.CanFitInInventory(item, out count)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelBaseShort + " (" + "CR_InventoryFull".Translate() + ")", null); } else { pickUpOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelBaseShort, new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = 1 }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); } list.Add(pickUpOption); if (count > 1 && item.stackCount > 1) { int numToCarry = Math.Min(count, item.stackCount); FloatMenuOption pickUpStackOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelBaseShort + " x" + numToCarry.ToString(), new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = numToCarry }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); list.Add(pickUpStackOption); } } } } // *** Deposit/drop equipment options *** if (pawn.equipment != null && pawn.equipment.Primary != null) { Thing thing2 = Find.ThingGrid.ThingAt(clickCell, ThingDefOf.EquipmentRack); if (thing2 != null) { if (!pawn.CanReach(thing2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotDeposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing2.def.label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else { using (IEnumerator <IntVec3> enumerator7 = GenAdj.CellsOccupiedBy(thing2).GetEnumerator()) { while (enumerator7.MoveNext()) { IntVec3 c = enumerator7.Current; if (c.GetStorable() == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { Action action4 = new Action(delegate { ThingWithComps t; if (pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true)) { t.SetForbidden(false, true); Job job = new Job(JobDefOf.HaulToCell, t, c); job.haulMode = HaulMode.ToCellStorage; job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); } }); list.Add(new FloatMenuOption("Deposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing2.def.label }), action4, MenuOptionPriority.Medium, null, null)); break; } } } } } if (pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <TargetInfo>()) { Action action5 = new Action(delegate { ThingWithComps thingWithComps; pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true); pawn.drafter.TakeOrderedJob(new Job(JobDefOf.Wait, 20, false)); } ); list.Add(new FloatMenuOption("Drop".Translate(new object[] { pawn.equipment.Primary.LabelCap }), action5, MenuOptionPriority.Medium, null, null)); } } // *** Trade with option *** foreach (TargetInfo current7 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { TargetInfo dest2 = current7; if (!pawn.CanReach(dest2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { list.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else if (!pawn.CanReserve(dest2.Thing, 1)) { list.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); } else { Pawn pTarg = (Pawn)dest2.Thing; Action action6 = new Action(delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }); string str3 = string.Empty; if (pTarg.Faction != null) { str3 = " (" + pTarg.Faction.name + ")"; } List <FloatMenuOption> arg_142E_0 = list; Thing thing = dest2.Thing; arg_142E_0.Add(new FloatMenuOption("TradeWith".Translate(new object[] { pTarg.LabelBaseShort }) + str3, action6, MenuOptionPriority.Medium, null, thing)); } } foreach (Thing current8 in Find.ThingGrid.ThingsAt(clickCell)) { foreach (FloatMenuOption current9 in current8.GetFloatMenuOptions(pawn)) { list.Add(current9); } } } // *** End of humanlike options *** // *** Beginning of non-drafted options *** if (!pawn.Drafted) { bool flag = false; bool flag2 = false; foreach (Thing current10 in Find.ThingGrid.ThingsAt(clickCell)) { flag2 = true; if (pawn.CanReach(current10, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { flag = true; break; } } if (flag2 && !flag) { list.Add(new FloatMenuOption("(" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null)); return(list); } foreach (Thing current11 in Find.ThingGrid.ThingsAt(clickCell)) { Pawn pawn4 = Find.Reservations.FirstReserverOf(current11, pawn.Faction); if (pawn4 != null && pawn4 != pawn) { list.Add(new FloatMenuOption("IsReservedBy".Translate(new object[] { current11.LabelBaseShort.CapitalizeFirst(), pawn4.LabelBaseShort }), null, MenuOptionPriority.Medium, null, null)); } else { JobGiver_Work jobGiver_Work = pawn.thinker.TryGetMainTreeThinkNode <JobGiver_Work>(); if (jobGiver_Work != null) { foreach (WorkTypeDef current12 in DefDatabase <WorkTypeDef> .AllDefsListForReading) { for (int k = 0; k < current12.workGiversByPriority.Count; k++) { WorkGiver_Scanner workGiver_Scanner = current12.workGiversByPriority[k].Worker as WorkGiver_Scanner; if (workGiver_Scanner != null) { if (workGiver_Scanner.def.directOrderable) { if (!workGiver_Scanner.ShouldSkip(pawn)) { JobFailReason.Clear(); Job job; if (!workGiver_Scanner.HasJobOnThingForced(pawn, current11)) { job = null; } else { job = workGiver_Scanner.JobOnThingForced(pawn, current11); } if (workGiver_Scanner.PotentialWorkThingRequest.Accepts(current11) || (workGiver_Scanner.PotentialWorkThingsGlobal(pawn) != null && workGiver_Scanner.PotentialWorkThingsGlobal(pawn).Contains(current11))) { if (job == null) { if (JobFailReason.HaveReason) { string label2 = "CannotGenericWork".Translate(new object[] { workGiver_Scanner.def.verb, current11.LabelBaseShort }) + " (" + JobFailReason.Reason + ")"; list.Add(new FloatMenuOption(label2, null, MenuOptionPriority.Medium, null, null)); } } else { string label; WorkTypeDef workType = workGiver_Scanner.def.workType; Action action7 = null; PawnCapacityDef pawnCapacityDef = workGiver_Scanner.MissingRequiredCapacity(pawn); if (pawnCapacityDef != null) { label = "CannotMissingHealthActivities".Translate(new object[] { pawnCapacityDef.label }); } else if (pawn.jobs.curJob != null && pawn.jobs.curJob.JobIsSameAs(job)) { label = "CannotGenericAlreadyAm".Translate(new object[] { workType.gerundLabel, current11.LabelBaseShort }); } else if (pawn.workSettings.GetPriority(workType) == 0) { label = "CannotPrioritizeIsNotA".Translate(new object[] { pawn.NameStringShort, workType.pawnLabel }); } else if (job.def == JobDefOf.Research && current11 is Building_ResearchBench) { label = "CannotPrioritizeResearch".Translate(); } else if (current11.IsForbidden(pawn)) { label = "CannotPrioritizeForbidden".Translate(new object[] { current11.Label }); } else if (!pawn.CanReach(current11, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { label = current11.Label + ": " + "NoPath".Translate(); } else { label = "PrioritizeGeneric".Translate(new object[] { workGiver_Scanner.def.gerund, current11.Label }); Job localJob = job; WorkTypeDef localWorkTypeDef = workType; action7 = new Action(delegate { pawn.thinker.GetMainTreeThinkNode <JobGiver_Work>().TryStartPrioritizedWorkOn(pawn, localJob, localWorkTypeDef); }); } if (!list.Any(op => op.label == label)) { list.Add(new FloatMenuOption(label, action7, MenuOptionPriority.Medium, null, null)); } } } } } } } } } } } } // *** End of non-drafted options *** foreach (FloatMenuOption current13 in pawn.GetExtraFloatMenuOptionsFor(clickCell)) { list.Add(current13); } DangerUtility.DoneDirectOrdering(); return(list); }
protected override void FillTab() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.GuiFrame); ConceptDecider.TeachOpportunity(ConceptDefOf.StorageTabCategories, OpportunityType.GuiFrame); ConceptDecider.TeachOpportunity(ConceptDefOf.StoragePriority, OpportunityType.GuiFrame); IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent; StorageSettings settings = selStoreSettingsParent.GetStoreSettings(); Rect position = new Rect(0f, 0f, ITab_Storage_Enhanced.WinSize.x, ITab_Storage_Enhanced.WinSize.y).ContractedBy(10f); GUI.BeginGroup(position); Text.Font = GameFont.Small; Rect rect = new Rect(0f, 0f, 160f, 29f); if (Widgets.TextButton(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); IEnumerator enumerator = Enum.GetValues(typeof(StoragePriority)).GetEnumerator(); try { while (enumerator.MoveNext()) { StoragePriority storagePriority = (StoragePriority)((byte)enumerator.Current); if (storagePriority != StoragePriority.Unstored) { StoragePriority localPr = storagePriority; list.Add(new FloatMenuOption(localPr.Label(), delegate { settings.Priority = localPr; ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.StoragePriority, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, null)); } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } Find.WindowStack.Add(new FloatMenu(list, false)); } var clearSearchRect = new Rect(position.width - 33f, (29f - 14f) / 2f, 14f, 14f); var shouldClearSearch = (Widgets.ImageButton(clearSearchRect, Widgets.CheckboxOffTex)); var searchRect = new Rect(165f, 0f, position.width - 160f - 20f, 29f); var watermark = (searchText != string.Empty || isFocused) ? searchText : "Search"; var escPressed = (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape); var clickedOutside = (!Mouse.IsOver(searchRect) && Event.current.type == EventType.MouseDown); if (!isFocused) { GUI.color = new Color(1f, 1f, 1f, 0.6f); } GUI.SetNextControlName("StorageSearchInput"); var searchInput = Widgets.TextField(searchRect, watermark); GUI.color = Color.white; if (isFocused) { searchText = searchInput; } if ((GUI.GetNameOfFocusedControl() == "StorageSearchInput" || isFocused) && (escPressed || clickedOutside)) { GUIUtility.keyboardControl = 0; isFocused = false; } else if (GUI.GetNameOfFocusedControl() == "StorageSearchInput" && !isFocused) { isFocused = true; } if (shouldClearSearch) { searchText = string.Empty; } TutorUIHighlighter.HighlightOpportunity("StoragePriority", rect); ThingFilter parentFilter = null; if (selStoreSettingsParent.GetParentStoreSettings() != null) { parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter; } Rect rect2 = new Rect(0f, 35f, position.width, position.height - 35f); HelperThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, searchText); GUI.EndGroup(); }
protected override void FillTab() { Building_Storage storage = this.SelThing as Building_Storage; this.container = storage.TryGetComp <CompContainer>(); if (container == null) { Log.Error("No CompContainer included for this Building_Storage"); return; } List <Thing> list = container.itemsList; float fieldHeight = 30.0f; this.size = new Vector2(300f, 55f + container.compProps.itemsCap * fieldHeight); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; Rect innerRect = GenUI.ContractedBy(new Rect(0.0f, 0.0f, this.size.x, this.size.y), 10f); float innerRectX = innerRect.x; GUI.BeginGroup(innerRect); { Widgets.TextField(new Rect(0.0f, 0.0f, this.size.x - 40f, fieldHeight), GetTitle()); Rect thingIconRect = new Rect(10f, fieldHeight + 5f, 30f, fieldHeight); Rect thingLabelRect = new Rect(thingIconRect.x + 35f, thingIconRect.y + 5.0f, innerRect.width - 35f, fieldHeight); Rect thingButtonRect = new Rect(thingIconRect.x, thingIconRect.y, innerRect.width, fieldHeight); //float startY = 0.0f; //Widgets.ListSeparator(ref startY, innerRect.width, GetTitle()); foreach (var thing in list) { Widgets.ThingIcon(thingIconRect, thing); Widgets.Label(thingLabelRect, thing.Label); if (Widgets.InvisibleButton(thingButtonRect)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); options.Add(new FloatMenuOption("Container_Info".Translate(), () => { // NOTE ? Find.WindowStack.Add(new Dialog_InfoCard(thing)); })); options.Add(new FloatMenuOption("Container_Drop".Translate(), () => { IntVec3 bestSpot = IntVec3.Invalid; if (JobDriver_HaulToCell.TryFindPlaceSpotNear(storage.Position, thing, out bestSpot)) { thing.Position = bestSpot; } else { Log.Error("No free spot for " + thing); } })); Find.WindowStack.Add(new FloatMenu(options, "", false, false)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; thingButtonRect.y += fieldHeight; } } GUI.EndGroup(); }
private static bool TryDrawTrainableRow(Rect rect, Pawn pawn, TrainableDef td) { bool flag = pawn.training.IsCompleted(td); bool flag2; AcceptanceReport canTrain = pawn.training.CanAssignToTrain(td, out flag2); if (!flag2) { return(false); } Widgets.DrawHighlightIfMouseover(rect); Rect rect2 = rect; rect2.width -= 50f; rect2.xMin += (float)td.indent * 15f; Rect rect3 = rect; rect3.xMin = rect3.xMax - 50f + 17f; if (!flag) { bool wanted = pawn.training.GetWanted(td); bool flag3 = wanted; Widgets.LabelCheckbox(rect2, td.LabelCap, ref wanted, !canTrain.Accepted); if (wanted != flag3) { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.AnimalTraining, KnowledgeAmount.Total); TrainingCardUtility.SetWantedRecursive(td, pawn, wanted); } } else { Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect2, td.LabelCap); Text.Anchor = TextAnchor.UpperLeft; } if (flag) { GUI.color = Color.green; } Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect3, TrainingCardUtility.GetSteps(pawn.training, td) + " / " + td.steps); Text.Anchor = TextAnchor.UpperLeft; if (Game.GodMode && !pawn.training.IsCompleted(td)) { Rect rect4 = rect3; rect4.yMin = rect4.yMax - 10f; rect4.xMin = rect4.xMax - 10f; if (Widgets.TextButton(rect4, "+", true, false)) { pawn.training.Train(td, Find.ListerPawns.FreeColonistsSpawned.RandomElement <Pawn>()); } } TooltipHandler.TipRegion(rect, delegate { string text = td.LabelCap + "\n\n" + td.description; if (!canTrain.Accepted) { text = text + "\n\n" + canTrain.Reason; } else if (!td.prerequisites.NullOrEmpty <TrainableDef>()) { text += "\n"; for (int i = 0; i < td.prerequisites.Count; i++) { if (!pawn.training.IsCompleted(td.prerequisites[i])) { text = text + "\n" + "TrainingNeedsPrerequisite".Translate(new object[] { td.prerequisites[i].LabelCap }); } } } return(text); }, (int)(rect.y * 612f)); GUI.color = Color.white; return(true); }
internal static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c2 = IntVec3.FromVector3(clickPos); int num = 0; if (pawn.story != null) { num = pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire); } foreach (Thing current in c2.GetThingList()) { Thing t = current; if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow) { FloatMenuOption item; if (t.def.ingestible.isPleasureDrug && num < 0) { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }) + " (" + "Teetotaler".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserve(t, 1)) { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(t, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { item = new FloatMenuOption("ConsumeThing".Translate(new object[] { t.LabelShort }), delegate { t.SetForbidden(false, true); Job job = new Job(JobDefOf.Ingest, t); job.maxNumToCarry = FoodUtility.WillEatStackCountOf(pawn, t.def); pawn.drafter.TakeOrderedJob(job); }, MenuOptionPriority.Medium, null, null, 0f, null); } opts.Add(item); } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { Pawn victim = (Pawn)current2.Thing; if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && !victim.IsPrisonerOfColony) { if ((victim.Faction == Faction.OfPlayer && victim.MentalStateDef == null) || (victim.Faction != Faction.OfPlayer && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer)))) { Pawn victim2 = victim; opts.Add(new FloatMenuOption("Rescue".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false); if (building_Bed == null) { string str2; if (victim.RaceProps.Animal) { str2 = "NoAnimalBed".Translate(); } else { str2 = "NoNonPrisonerBed".Translate(); } Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Rescue, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, victim2, 0f, null)); } if (victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfPlayer)) { Pawn victim2 = victim; opts.Add(new FloatMenuOption("Capture".Translate(new object[] { victim.LabelCap }), delegate { Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false); if (building_Bed == null) { Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.Capture, victim, building_Bed); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, victim2, 0f, null)); } } } foreach (TargetInfo current3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) { TargetInfo targetInfo = current3; Pawn victim = (Pawn)targetInfo.Thing; if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null) { string label = "CarryToCryptosleepCasket".Translate(new object[] { targetInfo.Thing.LabelCap }); JobDef jDef = JobDefOf.CarryToCryptosleepCasket; Action action = delegate { Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn); if (building_CryptosleepCasket == null) { Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput); return; } Job job = new Job(jDef, victim, building_CryptosleepCasket); job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }; Pawn victim2 = victim; opts.Add(new FloatMenuOption(label, action, MenuOptionPriority.Medium, null, victim2, 0f, null)); } } } foreach (TargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true)) { TargetInfo stripTarg = current4; FloatMenuOption item2; if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { item2 = new FloatMenuOption("CannotStrip".Translate(new object[] { stripTarg.Thing.LabelCap }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(stripTarg, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { item2 = new FloatMenuOption("Strip".Translate(new object[] { stripTarg.Thing.LabelCap }), delegate { stripTarg.Thing.SetForbidden(false, false); Job job = new Job(JobDefOf.Strip, stripTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }, MenuOptionPriority.Medium, null, null, 0f, null); } opts.Add(item2); } CompInventory compInventory = pawn.TryGetComp <CompInventory>(); // Need compInventory here for equip and wear options if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c2.GetThingList(); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null) { string label2 = equipment.Label; FloatMenuOption item3; if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserve(equipment, 1)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(equipment, pawn.Faction, true).LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item3 = new FloatMenuOption("CannotEquip".Translate(new object[] { label2 }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { string text = "Equip".Translate(new object[] { label2 }); if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) { text = text + " " + "EquipWarningBrawler".Translate(); } item3 = new FloatMenuOption(text, delegate { equipment.SetForbidden(false, true); Job job = new Job(JobDefOf.Equip, equipment); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); MoteThrower.ThrowStatic(equipment.DrawPos, ThingDefOf.Mote_FeedbackEquip, 1f); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.Medium, null, null, 0f, null); } opts.Add(item3); } } if (pawn.apparel != null) { Apparel apparel = Find.ThingGrid.ThingAt <Apparel>(c2); if (apparel != null) { FloatMenuOption item4; if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!pawn.CanReserve(apparel, 1)) { Pawn pawn2 = Find.Reservations.FirstReserverOf(apparel, pawn.Faction, true); item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "ReservedBy".Translate(new object[] { pawn2.LabelShort }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null); } else { // Added check for inventory capacity int count; if (compInventory != null && !compInventory.CanFitInInventory(apparel, out count, false, true)) { item4 = new FloatMenuOption("CannotWear".Translate(new object[] { apparel.Label }) + " (" + "CR_InventoryFull".Translate() + ")", null); } else { item4 = new FloatMenuOption("ForceWear".Translate(new object[] { apparel.LabelShort }), new Action(delegate { apparel.SetForbidden(false, true); Job job = new Job(JobDefOf.Wear, apparel); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); }), MenuOptionPriority.Medium, null, null); } } opts.Add(item4); } } // *** NEW: Pick up option *** if (compInventory != null) { List <Thing> thingList = c2.GetThingList(); if (!thingList.NullOrEmpty <Thing>()) { Thing item = thingList.FirstOrDefault(thing => thing.def.alwaysHaulable && !(thing is Corpse)); if (item != null) { FloatMenuOption pickUpOption; int count = 0; if (!pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelShort + " (" + "NoPath".Translate() + ")", null); } else if (!pawn.CanReserve(item)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelShort + " (" + "ReservedBy".Translate(new object[] { Find.Reservations.FirstReserverOf(item, pawn.Faction) }), null); } else if (!compInventory.CanFitInInventory(item, out count)) { pickUpOption = new FloatMenuOption("CR_CannotPickUp".Translate() + " " + item.LabelShort + " (" + "CR_InventoryFull".Translate() + ")", null); } else { pickUpOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelShort, new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = 1 }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); } opts.Add(pickUpOption); if (count > 1 && item.stackCount > 1) { int numToCarry = Math.Min(count, item.stackCount); FloatMenuOption pickUpStackOption = new FloatMenuOption("CR_PickUp".Translate() + " " + item.LabelShort + " x" + numToCarry.ToString(), new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = numToCarry }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); opts.Add(pickUpStackOption); FloatMenuOption pickUpHalfStackOption = new FloatMenuOption("CE_PickUpHalf" + " " + item.LabelShort + " x" + (numToCarry / 2).ToString(), new Action(delegate { item.SetForbidden(false); Job job = new Job(JobDefOf.TakeInventory, item) { maxNumToCarry = numToCarry / 2 }; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); })); opts.Add(pickUpHalfStackOption); } } } } if (pawn.equipment != null && pawn.equipment.Primary != null) { Thing thing = Find.ThingGrid.ThingAt(c2, ThingDefOf.EquipmentRack); if (thing != null) { if (!pawn.CanReach(thing, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotDeposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing.def.label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null)); } else { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(thing)) { if (c.GetStorable() == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1)) { Action action2 = delegate { ThingWithComps t; if (pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true)) { t.SetForbidden(false, true); Job job = new Job(JobDefOf.HaulToCell, t, c); job.haulMode = HaulMode.ToCellStorage; job.maxNumToCarry = 1; job.playerForced = true; pawn.drafter.TakeOrderedJob(job); } }; opts.Add(new FloatMenuOption("Deposit".Translate(new object[] { pawn.equipment.Primary.LabelCap, thing.def.label }), action2, MenuOptionPriority.Medium, null, null, 0f, null)); break; } } } } if (pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <TargetInfo>()) { Action action3 = delegate { ThingWithComps thingWithComps; pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true); pawn.drafter.TakeOrderedJob(new Job(JobDefOf.Wait, 20, false)); }; opts.Add(new FloatMenuOption("Drop".Translate(new object[] { pawn.equipment.Primary.Label }), action3, MenuOptionPriority.Medium, null, null, 0f, null)); } } foreach (TargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true)) { TargetInfo dest = current5; if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null)); } else if (!pawn.CanReserve(dest.Thing, 1)) { opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action4 = delegate { Job job = new Job(JobDefOf.TradeWithPawn, pTarg); job.playerForced = true; pawn.drafter.TakeOrderedJob(job); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total); }; string str = string.Empty; if (pTarg.Faction != null) { str = " (" + pTarg.Faction.Name + ")"; } Thing thing2 = dest.Thing; opts.Add(new FloatMenuOption("TradeWith".Translate(new object[] { pTarg.LabelShort }) + str, action4, MenuOptionPriority.Medium, null, thing2, 0f, null)); } } foreach (Thing current6 in Find.ThingGrid.ThingsAt(c2)) { foreach (FloatMenuOption current7 in current6.GetFloatMenuOptions(pawn)) { opts.Add(current7); } } }
public override void DoWindowContents(Rect inRect) { if (this.Anchor == MainTabWindowAnchor.Left) { this.currentWindowRect.x = 0f; } else { this.currentWindowRect.x = (float)Screen.width - this.currentWindowRect.width; } this.currentWindowRect.y = (float)(Screen.height - 35) - this.currentWindowRect.height; if (this.def.concept != null) { ConceptDatabase.KnowledgeDemonstrated(this.def.concept, KnowledgeAmount.GuiFrame); } this.RecentHeight = RimWorld.MainTabWindow_Inspect.PaneSize.y; if (this.NumSelected > 0) { try { Rect rect = inRect.ContractedBy(12f); rect.yMin -= 4f; GUI.BeginGroup(rect); bool flag = true; if (this.NumSelected > 1) { flag = !(from t in this.Selected where !InspectPaneUtility.CanInspectTogether(this.Selected.First <object>(), t) select t).Any <object>(); } else { Rect rect2 = new Rect(rect.width - 30f, 0f, 30f, 30f); if (Find.Selector.SelectedZone == null || Find.Selector.SelectedZone.ContainsCell(MainTabWindow_Inspect.lastSelectCell)) { if (Widgets.ImageButton(rect2, TexButton.SelectOverlappingNext)) { this.SelectNextInCell(); } TooltipHandler.TipRegion(rect2, "SelectNextInSquareTip".Translate(new object[] { KeyBindingDefOf.SelectNextInCell.MainKeyLabel })); } if (Find.Selector.SingleSelectedThing != null) { Widgets.InfoCardButton(rect.width - 60f, 0f, Find.Selector.SingleSelectedThing); } } Rect rect3 = new Rect(0f, 0f, rect.width - 60f, 50f); string label = InspectPaneUtility.AdjustedLabelFor(this.Selected, rect3); rect3.width += 300f; Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(rect3, label); if (flag && this.NumSelected == 1) { Rect rect4 = rect.AtZero(); rect4.yMin += 26f; InspectPaneFiller.DoPaneContentsFor((ISelectable)Find.Selector.FirstSelectedObject, rect4); } } catch (Exception ex) { Log.Error("Exception doing inspect pane: " + ex.ToString()); } finally { GUI.EndGroup(); } } }
public static void RoomStatsOnGUI() { RoomStatsDrawer.Anonymous temp = new RoomStatsDrawer.Anonymous(); if (!RoomStatsDrawer.ShouldShowRoomStats) { return; } temp.room = Gen.MouseCell().GetRoom(); Text.Font = GameFont.Small; RoomStatsDrawer.CalculateColumnsSizes(temp.room); temp.windowRect = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 108f + RoomStatsDrawer.statLabelColumnWidth + RoomStatsDrawer.scoreColumnWidth + RoomStatsDrawer.scoreStageLabelColumnWidth, (float)(65 + RoomStatsDrawer.DisplayedRoomStatsCount * 25)); RoomStatsDrawer.Anonymous temp5 = temp; temp5.windowRect.x = temp5.windowRect.x + 5f; RoomStatsDrawer.Anonymous temp2 = temp; temp2.windowRect.y = temp2.windowRect.y + 5f; if (temp.windowRect.xMax > (float)Screen.width) { RoomStatsDrawer.Anonymous temp3 = temp; temp3.windowRect.x = temp3.windowRect.x - (temp.windowRect.width + 10f); } if (temp.windowRect.yMax > (float)Screen.height) { RoomStatsDrawer.Anonymous temp4 = temp; temp4.windowRect.y = temp4.windowRect.y - (temp.windowRect.height + 10f); } Find.WindowStack.ImmediateWindow(74975, temp.windowRect, WindowLayer.Super, delegate { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; float num = 19f; Rect rect = new Rect(19f, num, temp.windowRect.width - 38f, 100f); GUI.color = Color.white; Widgets.Label(rect, RoomStatsDrawer.GetRoomRoleLabel(temp.room)); num += 25f; for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++) { RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i]; if (!roomStatDef.isHidden) { float stat = temp.room.GetStat(roomStatDef); RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat); if (temp.room.Role.IsStatRelated(roomStatDef)) { GUI.color = RoomStatsDrawer.RelatedStatColor; } else { GUI.color = Color.gray; } Rect rect2 = new Rect(rect.x, num, RoomStatsDrawer.statLabelColumnWidth, 23f); Widgets.Label(rect2, roomStatDef.LabelCap); Rect rect3 = new Rect(rect2.xMax + 35f, num, RoomStatsDrawer.scoreColumnWidth, 23f); string label; if (roomStatDef.displayRounded) { label = Mathf.RoundToInt(stat).ToString(); } else { label = stat.ToString("0.##"); } Widgets.Label(rect3, label); Rect rect4 = new Rect(rect3.xMax + 35f, num, RoomStatsDrawer.scoreStageLabelColumnWidth, 23f); Widgets.Label(rect4, scoreStage.label); num += 25f; } } GUI.color = Color.white; }, true, false, 1f); }
protected override void FillTab() { Pawn pawn = null; if (base.SelPawn != null) { pawn = base.SelPawn; } else { Corpse corpse = base.SelThing as Corpse; if (corpse != null) { pawn = corpse.innerPawn; } } if (pawn == null) { Log.Error("Health tab found no selected pawn to display."); return; } Corpse corpse2 = base.SelThing as Corpse; bool showBloodLoss = corpse2 == null || corpse2.Age < 60000; bool flag = !pawn.RaceProps.Humanlike && pawn.Downed; bool flag2 = base.SelThing.def.AllRecipes.Any <RecipeDef>(); bool flag3 = flag2 && !pawn.Dead && (pawn.IsColonist || pawn.IsPrisonerOfColony || flag); TextAnchor anchor = Text.Anchor; Rect rect = new Rect(20f, 51f, ITab_Pawn_Health_Alternate.PanelSize.x - 40f, 345f); float height = this.size.y - rect.height - 109f; Rect position = new Rect(rect.x, rect.y + rect.height + 16f, rect.width, height); if (!flag3) { this.operationsTabSelected = false; } List <TabRecord> list = new List <TabRecord>(); list.Add(new TabRecord("HealthOverview".Translate(), delegate { this.operationsTabSelected = false; }, !this.operationsTabSelected)); if (flag3) { string label; if (pawn.RaceProps.mechanoid) { label = "MedicalOperationsMechanoidsShort".Translate(new object[] { pawn.BillStack.Count }); } else { label = "MedicalOperationsShort".Translate(new object[] { pawn.BillStack.Count }); } list.Add(new TabRecord(label, delegate { this.operationsTabSelected = true; }, this.operationsTabSelected)); } GUI.color = TabDrawer.BoxColor; GUI.DrawTexture(rect, TabDrawer.WhiteTexture); GUI.color = TabDrawer.BoxBorderColor; Widgets.DrawBox(rect, 1); GUI.color = Color.white; TabDrawer.DrawTabs(new Rect(rect.x, rect.y, rect.width - 90f, rect.height), list, ITab_Pawn_Health_Alternate.TabAtlasTex); float num = 0f; GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; if (!this.operationsTabSelected) { Rect position2 = rect.ContractedBy(12f); if (pawn.playerSettings != null && !pawn.Dead) { Rect rect2 = new Rect(position2.x + 4f, position2.y + 8f, position2.width, 32f); MedicalCareUtility.MedicalCareSetter(rect2, ref pawn.playerSettings.medCare); position2.y += 50f; position2.height -= 50f; } try { GUI.BeginGroup(position2); Rect leftRect = new Rect(0f, num, position2.width, position2.height - num); num = this.healthCardUtility.DrawStatus(leftRect, pawn, num, showBloodLoss); } finally { GUI.EndGroup(); } } else { Rect position3 = rect.ContractedBy(12f); try { GUI.BeginGroup(position3); Rect rect3 = new Rect(0f, 0f, position3.width, position3.height); this.operationsScrollView.Begin(rect3); ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.MedicalOperations, KnowledgeAmount.GuiFrame); num = this.healthCardUtility.DrawMedOperationsTab(rect3, pawn, base.SelThing, num); this.operationsScrollView.End(num); } finally { GUI.EndGroup(); } } Text.Font = GameFont.Small; GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; GUI.BeginGroup(position); Rect leftRect2 = new Rect(0f, 0f, position.width, position.height); this.healthCardUtility.DrawInjuries(leftRect2, pawn, showBloodLoss); GUI.EndGroup(); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; if (this.PreferenceTabBrowseButtons != null && this.PreferenceTabBrowseButtons.Value) { Pawn pawn2 = null; if (base.SelPawn != null) { pawn2 = base.SelPawn; } else { Corpse corpse3 = base.SelThing as Corpse; if (corpse3 != null) { pawn2 = corpse3.innerPawn; } } if (pawn2 != null) { BrowseButtonDrawer.DrawBrowseButtons(this.size, pawn2); } } GUI.color = Color.white; Text.Anchor = anchor; Rect rect4 = new Rect(0f, 0f, this.size.x, this.size.y); if (Event.current.type == EventType.ScrollWheel && Mouse.IsOver(rect4)) { Event.current.Use(); } }
protected override void FillTab() { float fieldHeight = 30.0f; Vehicle_Cart cart = this.SelThing as Vehicle_Cart; ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; Rect innerRect1 = GenUI.ContractedBy(new Rect(0.0f, 0.0f, this.size.x, this.size.y), 10f); GUI.BeginGroup(innerRect1); Rect mountedRect = new Rect(0.0f, 30.0f, innerRect1.width, fieldHeight); float mountedRectY = mountedRect.y; Widgets.ListSeparator(ref mountedRectY, innerRect1.width, txtDriver.Translate()); mountedRect.y += fieldHeight; Rect thingIconRect = new Rect(mountedRect.x, mountedRect.y, 30f, fieldHeight); Rect thingLabelRect = new Rect(mountedRect.x + 35f, mountedRect.y + 5.0f, innerRect1.width - 35f, fieldHeight); Rect thingButtonRect = new Rect(mountedRect.x, mountedRect.y, innerRect1.width, fieldHeight); if (cart.mountableComp.IsMounted) { Pawn driver = cart.mountableComp.Driver; Widgets.ThingIcon(thingIconRect, driver); Widgets.Label(thingLabelRect, driver.Label); if (Event.current.button == 1 && Widgets.InvisibleButton(thingButtonRect)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); FloatMenuOption dismount = new FloatMenuOption(txtDismount.Translate(driver.LabelBase), () => { cart.mountableComp.Dismount(); }); options.Add(dismount); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; } Rect storageRect = new Rect(0.0f, thingIconRect.y, innerRect1.width, fieldHeight); float storageRectY = storageRect.y; Widgets.ListSeparator(ref storageRectY, innerRect1.width, txtStorage.Translate()); storageRect.y += fieldHeight; thingIconRect.y = storageRect.y; thingLabelRect.y = storageRect.y; thingButtonRect.y = storageRect.y; foreach (var thing in cart.storage) { if ((thing.ThingID.IndexOf("Human_Corpse") <= -1) ? false : true) { Widgets.DrawTextureFitted(thingIconRect, ContentFinder <Texture2D> .Get("Things/Pawn/IconHuman_Corpse"), 1.0f); } else if ((thing.ThingID.IndexOf("Corpse") <= -1) ? false : true) { Corpse corpse = thing as Corpse; Widgets.ThingIcon(thingIconRect, corpse.innerPawn.def); } else { Widgets.ThingIcon(thingIconRect, thing); } Widgets.Label(thingLabelRect, thing.Label.Translate()); if (Event.current.button == 1 && Widgets.InvisibleButton(thingButtonRect)) { List <FloatMenuOption> options = new List <FloatMenuOption>(); options.Add(new FloatMenuOption(Translator.Translate("ThingInfo"), () => { Find.WindowStack.Add((Window) new Dialog_InfoCard(thing)); })); options.Add(new FloatMenuOption(Translator.Translate("DropThing"), () => { Thing dummy; cart.storage.TryDrop(thing, cart.Position, ThingPlaceMode.Near, out dummy); })); Find.WindowStack.Add((Window) new FloatMenu(options, thing.LabelCap, false, false)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; } if (Widgets.TextButton(new Rect(180f, 400f, 100f, 30f), "Drop All")) { cart.storage.TryDropAll(cart.Position, ThingPlaceMode.Near); } GUI.EndGroup(); }