private void DrawThingRow(ref float y, float width, Thing thing, bool canRetrieve = false) { Rect rect = new Rect(0f, y, width, 28f); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl) { Rect rect2 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect2, "DropThing".Translate()); if (canRetrieve && Widgets.ButtonImage(rect2, ITabButton.Drop)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceDrop(thing); } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = ITab_Inventory.HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_Inventory.ThingLabelColor; Rect rect5 = new Rect(36f, y, rect.width - 36f, rect.height); string text = thing.LabelCap; Text.WordWrap = false; Widgets.Label(rect5, text.Truncate(rect5.width, null)); Text.WordWrap = true; string text2 = thing.LabelCap; if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(rect, text2); y += 28f; }
private void DrawThingRow(ref float y, float width, Thing thing, bool inventory = false) { Rect rect = new Rect(0f, y, width, ThingIconSize); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (inventory && this.SelPawnForCargo.Spawned) { Rect rectDrop = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rectDrop, "DropThing".Translate()); if (Widgets.ButtonImage(rectDrop, TexCommandShips.Drop)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceDrop(thing); } rect.width -= 24f; } Rect rect2 = rect; rect2.xMin = rect2.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect2); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = ITab_Ship_Cargo.HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (!(thing.def.DrawMatSingle is null) && !(thing.def.DrawMatSingle.mainTexture is null)) { Widgets.ThingIcon(new Rect(4f, y, ThingIconSize, ThingRowheight), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_Ship_Cargo.ThingLabelColor; Rect rect3 = new Rect(ThingLeftX, y, rect.width - ThingLeftX, rect.height); string text = thing.LabelCap; Text.WordWrap = false; Widgets.Label(rect3, text.Truncate(rect3.width, null)); Text.WordWrap = true; string text2 = thing.DescriptionDetailed; if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(rect, text2); y += ThingRowheight; }
private void DrawThingRow(ref float y, float width, Thing thing, bool inventory = false) { Rect rect = new Rect(0f, y, width, ThingIconSize); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; Rect rect2 = rect; rect2.xMin = rect2.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect2); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = ITab_Ship_Cargo.HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (!(thing.def.DrawMatSingle is null) && !(thing.def.DrawMatSingle.mainTexture is null)) { Widgets.ThingIcon(new Rect(4f, y, ThingIconSize, ThingRowheight), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_Ship_Cargo.ThingLabelColor; Rect rect3 = new Rect(ThingLeftX, y, rect.width - ThingLeftX, rect.height); string text = thing.LabelCap; Text.WordWrap = false; Widgets.Label(rect3, text.Truncate(rect3.width, null)); Text.WordWrap = true; string text2 = thing.DescriptionDetailed; if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(rect, text2); y += ThingRowheight; }
private void DrawThingRow(ref float y, float width, Thing thing, int?transferStackCount = null, bool inventory = false, bool missingFromInventory = false) { var color = GUI.color; if (missingFromInventory) { GUI.color = MissingItemColor; } Rect rect = new Rect(0f, y, width, ThingIconSize); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (inventory && SelPawnForCargo.Spawned) { Rect rectDrop = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rectDrop, "DropThing".Translate()); if (Widgets.ButtonImage(rectDrop, VehicleTex.Drop)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceDrop(thing); } rect.width -= 24f; } Rect rect2 = rect; rect2.xMin = rect2.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect2); rect.width -= 60f; GUI.color = color; if (Mouse.IsOver(rect)) { GUI.color = HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (!(thing.def.DrawMatSingle is null) && !(thing.def.DrawMatSingle.mainTexture is null)) { Widgets.ThingIcon(new Rect(4f, y, ThingIconSize, ThingRowHeight), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; if (!missingFromInventory) { GUI.color = ThingLabelColor; } else { GUI.color = MissingItemColor; } Rect rect3 = new Rect(ThingLeftX, y, rect.width - ThingLeftX, rect.height); string text = string.Empty; if (transferStackCount != null) { text = thing.LabelCapNoCount + " x" + transferStackCount.Value.ToStringCached(); } else { text = thing.LabelCap; } Text.WordWrap = false; Widgets.Label(rect3, text.Truncate(rect3.width, null)); Text.WordWrap = true; string text2 = thing.DescriptionDetailed; if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(rect, text2); y += ThingRowHeight; GUI.color = color; }
private void DrawThingRow(ref float y, float width, Thing thing, bool inventory = false) { Rect rect = new Rect(0f, y, width, 28f); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; bool flag = false; if (CanControl && (inventory || CanControlColonist || (SelPawnForGear.Spawned && !SelPawnForGear.Map.IsPlayerHome))) { Rect rect2 = new Rect(rect.width - 24f, y, 24f, 24f); bool flag2 = false; if (SelPawnForGear.IsQuestLodger()) { flag2 = inventory || !EquipmentUtility.QuestLodgerCanUnequip(thing, SelPawnForGear); } Apparel apparel; bool flag3 = (apparel = thing as Apparel) != null && SelPawnForGear.apparel != null && SelPawnForGear.apparel.IsLocked(apparel); flag = flag2 || flag3; if (Mouse.IsOver(rect2)) { if (flag3) { TooltipHandler.TipRegion(rect2, "DropThingLocked".Translate()); } else if (flag2) { TooltipHandler.TipRegion(rect2, "DropThingLodger".Translate()); } else { TooltipHandler.TipRegion(rect2, "DropThing".Translate()); } } Color color = (flag ? Color.grey : Color.white); Color mouseoverColor = (flag ? color : GenUI.MouseoverColor); if (Widgets.ButtonImage(rect2, TexButton.Drop, color, mouseoverColor, !flag) && !flag) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (CanControlColonist) { if (FoodUtility.WillIngestFromInventoryNow(SelPawnForGear, thing)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegionByKey(rect3, "ConsumeThing", thing.LabelNoCount, thing); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); FoodUtility.IngestFromInventoryNow(SelPawnForGear, thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect rect5 = new Rect(36f, y, rect.width - 36f, rect.height); string text = thing.LabelCap; Apparel apparel2 = thing as Apparel; if (apparel2 != null && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced(apparel2)) { text += ", " + "ApparelForcedLower".Translate(); } if (flag) { text += " (" + "ApparelLockedLower".Translate() + ")"; } Text.WordWrap = false; Widgets.Label(rect5, text.Truncate(rect5.width)); Text.WordWrap = true; if (Mouse.IsOver(rect)) { string text2 = thing.DescriptionDetailed; if (thing.def.useHitPoints) { text2 = text2 + "\n" + thing.HitPoints + " / " + thing.MaxHitPoints; } TooltipHandler.TipRegion(rect, text2); } y += 28f; }
private void DrawThingRow(ref float y, float width, Thing thing, bool inventory = false) { Rect rect = new Rect(0f, y, width, 28f); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (this.CanControl && (inventory || this.CanControlColonist || (this.SelPawnForGear.Spawned && !this.SelPawnForGear.Map.IsPlayerHome))) { Rect rect2 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect2, "DropThing".Translate()); if (Widgets.ButtonImage(rect2, TexButton.Drop)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); this.InterfaceDrop(thing); } rect.width -= 24f; } if (this.CanControlColonist) { if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing)); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); this.InterfaceIngest(thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = ITab_Pawn_Gear.HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_Pawn_Gear.ThingLabelColor; Rect rect5 = new Rect(36f, y, rect.width - 36f, rect.height); string text = thing.LabelCap; Apparel apparel = thing as Apparel; if (apparel != null && this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced(apparel)) { text = text + ", " + "ApparelForcedLower".Translate(); } Text.WordWrap = false; Widgets.Label(rect5, text.Truncate(rect5.width, null)); Text.WordWrap = true; string text2 = thing.DescriptionDetailed; if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(rect, text2); y += 28f; }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { var dropForbidden = IsItemDropForbidden(thing); Color color = dropForbidden ? Color.grey : Color.white; Color mouseoverColor = dropForbidden ? Color.grey : GenUI.MouseoverColor; Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, dropForbidden ? "DropThingLocked".Translate() : "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop, color, mouseoverColor) && !dropForbidden) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (CanControlColonist) { if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing)); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceIngest(thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Text.WordWrap = false; Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null)); Text.WordWrap = true; string text2 = string.Concat(new object[] { thing.LabelCap, "\n", thing.DescriptionDetailed, "\n", thing.GetWeightAndBulkTip() }); if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", "HitPointsBasic".Translate().CapitalizeFirst(), ": ", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(thingLabelRect, text2); y += 28f; // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); CompBiocodable compBiocoded = eq.TryGetComp <CompBiocodable>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null); } else if (SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear)) { var forbiddenEquipOrPutAway = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(eqLabel) : "CannotEquip".Translate(eqLabel); equipOption = new FloatMenuOption(forbiddenEquipOrPutAway + ": " + "CE_CannotChangeEquipment".Translate(), null); } else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null); } else { string equipOptionLabel = "Equip".Translate(eqLabel); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption( equipOptionLabel, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } //Reload apparel option IEnumerable <Apparel> worn_apparel = SelPawnForGear?.apparel?.WornApparel ?? Enumerable.Empty <Apparel>(); foreach (var apparel in worn_apparel) { var compReloadable = apparel.TryGetComp <CompReloadable>(); if (compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true)) { if (!SelPawnForGear.Drafted) //TODO-1.2 This should be doable for drafted pawns as well, but the job does nothing. Figure out what's wrong and remove this condition. { FloatMenuOption reloadApparelOption = new FloatMenuOption( "CE_ReloadApparel".Translate(apparel.Label, thing.Label), new Action(delegate { //var reloadJob = JobMaker.MakeJob(JobDefOf.Reload, apparel, thing); //SelPawnForGear.jobs.StartJob(reloadJob, JobCondition.InterruptForced, null, SelPawnForGear.CurJob?.def != reloadJob.def, true); SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing)); }) ); floatOptionList.Add(reloadApparelOption); } } } // Consume option if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceIngest(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug) { floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null)); } else { floatOptionList.Add(new FloatMenuOption(label, eatFood)); } } // Drop, and drop&haul options if (IsItemDropForbidden(eq)) { floatOptionList.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null)); floatOptionList.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null)); } else { floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), new Action(delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); }))); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), new Action(delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }))); } // Stop holding in inventory option if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
private void DrawThingRow(ref float y, float width, Thing thing, bool showDropButtonIfPrisoner = false) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl || (SelPawnForGear.Faction == Faction.OfPlayer && SelPawnForGear.RaceProps.packAnimal) || (showDropButtonIfPrisoner && SelPawnForGear.IsPrisonerOfColony)) { Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (CanControlColonist) { if ((thing.def.IsNutritionGivingIngestible || thing.def.IsNonMedicalDrug) && thing.IngestibleNow && base.SelPawn.WillEat(thing, null) && (!SelPawnForGear.IsTeetotaler() || !thing.def.IsNonMedicalDrug)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(thing.LabelNoCount, thing)); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); InterfaceIngest(thing); } } rect.width -= 24f; } Rect rect4 = rect; rect4.xMin = rect4.xMax - 60f; CaravanThingsTabUtility.DrawMass(thing, rect4); rect.width -= 60f; if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing, 1f); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ThingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if ((thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) || (SelPawnForGear.inventory != null && SelPawnForGear.HoldTrackerIsHeld(thing))) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Text.WordWrap = false; Widgets.Label(thingLabelRect, thingLabel.Truncate(thingLabelRect.width, null)); Text.WordWrap = true; string text2 = string.Concat(new object[] { thing.LabelCap, "\n", thing.DescriptionDetailed, "\n", thing.GetWeightAndBulkTip() }); if (thing.def.useHitPoints) { string text3 = text2; text2 = string.Concat(new object[] { text3, "\n", "HitPointsBasic".Translate().CapitalizeFirst(), ": ", thing.HitPoints, " / ", thing.MaxHitPoints }); } TooltipHandler.TipRegion(thingLabelRect, text2); y += 28f; // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); CompBiocodable compBiocoded = eq.TryGetComp <CompBiocodable>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (compBiocoded != null && compBiocoded.Biocoded && compBiocoded.CodedPawn != SelPawnForGear) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null); } else if (SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CE_PutAway".Translate(eqLabel), new Action(delegate { SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(eqLabel), null); } else { string equipOptionLabel = "Equip".Translate(eqLabel); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption( equipOptionLabel, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action dropApparel = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDrop(thing); }; Action dropApparelHaul = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }; if (CanControl && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Action eatFood = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); InterfaceIngest(thing); }; string label = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort); if (SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug) { floatOptionList.Add(new FloatMenuOption(label + ": " + TraitDefOf.DrugDesire.degreeDatas.Where(x => x.degree == -1).First()?.label, null)); } else { floatOptionList.Add(new FloatMenuOption(label, eatFood)); } } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel)); floatOptionList.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), dropApparelHaul)); if (CanControl && SelPawnForGear.HoldTrackerIsHeld(thing)) { Action forgetHoldTracker = delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); SelPawnForGear.HoldTrackerForget(thing); }; floatOptionList.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), forgetHoldTracker)); } } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu }
private void DrawThingRow(ref float y, float width, Thing thing) { // Sumghai started from the right, as several things in vanilla do, and that's fine with me: /************************* InfoCardButton *************************/ // (it's the little "i" that pulls up full info on the item.) // It's 24f by 24f in size width -= 24f; Widgets.InfoCardButton(width, y, thing); /************************* Allow/Forbid toggle *************************/ // We make this 24 by 24 too: width -= 24f; var forbidRect = new Rect(width, y, 24f, 24f); // is creating this rect actually necessary? var allowFlag = !thing.IsForbidden(Faction.OfPlayer); var tmpFlag = allowFlag; if (allowFlag) { TooltipHandler.TipRegion(forbidRect, "CommandNotForbiddenDesc".Translate()); } else { TooltipHandler.TipRegion(forbidRect, "CommandForbiddenDesc".Translate()); } // TooltipHandler.TipRegion(forbidRect, "Allow/Forbid"); // TODO: Replace "Allow/Forbid" with a translated entry in a Keyed Language XML file Widgets.Checkbox(forbidRect.x, forbidRect.y, ref allowFlag, 24f, false, true); if (allowFlag != tmpFlag) // spamming SetForbidden is bad when playing multi-player - it spams Sync requests { thing.SetForbidden(!allowFlag, false); } /************************* Mass *************************/ width -= 60f; // Caravans use 100f var massRect = new Rect(width, y, 60f, 28f); CaravanThingsTabUtility.DrawMass(thing, massRect); /************************* How soon does it rot? *************************/ // Some mods add non-food items that rot, so we track those too: var cr = thing.TryGetComp <CompRottable>(); if (cr != null) { var rotTicks = Math.Min(int.MaxValue, cr.TicksUntilRotAtCurrentTemp); if (rotTicks < 36000000) { width -= 60f; // Caravans use 75f? TransferableOneWayWidget.cs var rotRect = new Rect(width, y, 60f, 28f); GUI.color = Color.yellow; Widgets.Label(rotRect, (rotTicks / 60000f).ToString("0.#")); GUI.color = Color.white; TooltipHandler.TipRegion(rotRect, "DaysUntilRotTip".Translate()); } } // finish how long food will last /************************* Text area *************************/ // TODO: use a ButtonInvisible over the entire area with a label and the icon. var itemRect = new Rect(0f, y, width, 28f); if (Mouse.IsOver(itemRect)) { GUI.color = ITab_Pawn_Gear.HighlightColor; GUI.DrawTexture(itemRect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing); } //TODO: set all this once: Text.Anchor = TextAnchor.MiddleLeft; GUI.color = ITab_Pawn_Gear.ThingLabelColor; // TODO: Aaaaah, sure? var textRect = new Rect(36f, y, itemRect.width - 36f, itemRect.height); var text = thing.LabelCap; Text.WordWrap = false; Widgets.Label(textRect, text.Truncate(textRect.width)); // if (Widgets.ButtonText(rect4, text.Truncate(rect4.width, null),false)) { if (Widgets.ButtonInvisible(itemRect)) { Find.Selector.ClearSelection(); Find.Selector.Select(thing); } //TODO: etc Text.WordWrap = true; /************************* mouse-over description *************************/ var text2 = thing.DescriptionDetailed; if (thing.def.useHitPoints) { var text3 = text2; text2 = string.Concat(text3, "\n", thing.HitPoints, " / ", thing.MaxHitPoints); } TooltipHandler.TipRegion(itemRect, text2); y += 28f; } // end draw thing row