public static string GetDropLabel(Dialog_BillConfig dialog) { Bill_Production bill = Traverse.Create(dialog).Field("bill").GetValue <Bill_Production>(); GroupMode groupMode = BillAssignationUtility.IsFor(bill); switch (groupMode) { case GroupMode.ColonyOnly: return("PrisonLabor_ColonyOnly".Translate()); case GroupMode.PrisonersOnly: return("PrisonLabor_PrisonersOnly".Translate()); case GroupMode.ColonistsOnly: return("AnyWorker".Translate()); case GroupMode.SlavesOnly: return("AnySlave".Translate()); case GroupMode.CaptiveOnly: return("PrisonLabor_PrisonersAndSlaveOnly".Translate()); default: return((!ModsConfig.IdeologyActive || !bill.SlavesOnly) ? ("AnyWorker".Translate()) : ("AnySlave".Translate())); } }
public static string GetLabel(Dialog_BillConfig dialog) { Bill_Production bill = Traverse.Create(dialog).Field("bill").GetValue <Bill_Production>(); if (bill.PawnRestriction != null) { return(bill.PawnRestriction.LabelShortCap); } return(GetDropLabel(dialog)); }
static void DrawRadiusDefaultButton(Dialog_BillConfig instance, Listing_Standard listing) { var rect = listing.GetRect(0); rect = new Rect(180f, rect.y - 2f, 65f, 24f); if (Widgets.ButtonText(rect, "Default")) { SoundDefOf.Click.PlayOneShotOnCamera(); var bill = (Bill_Production)Bill.GetValue(instance); defaultSearchIngredientRadius.Value = bill.ingredientSearchRadius; } }
public static bool Prefix(Dialog_BillConfig __instance, Rect inRect) { if (!(BillGetter.GetValue(__instance) is Bill_Production billRaw)) { return(true); } ShowCustomTakeToStockpileMenu(billRaw, inRect); Main.Instance.OnProductionDialogBeingShown(); return(true); }
static void DialogBillConfig(Dialog_BillConfig __instance) { Bill_Production bill = __instance.bill; SyncBillSuspended.Watch(bill); SyncBillSkillRange.Watch(bill); SyncIngredientSearchRadius.Watch(bill); SyncBillProduction.Watch(bill); if (bill.recipe.ProducedThingDef != null) { SyncBillIncludeCriteria.Watch(bill); SyncBillIncludeHpRange.Watch(bill); SyncBillIncludeQualityRange.Watch(bill); } }
private static void DrawWorkTableNavigation(Dialog_BillConfig dialog, Bill_Production bill, Rect inRect) { var workTable = Find.Selector.SingleSelectedThing as Building_WorkTable; var billStack = workTable?.BillStack; if (billStack == null || billStack.Count < 2) { return; } const float buttonWidth = 14f; const float xOffset = 10f + 2 * buttonWidth; var leftRect = new Rect(inRect.xMax - xOffset, inRect.yMin + 4f, buttonWidth, 24f); var thisBillIndexInWorkTable = billStack.Bills.FirstIndexOf(b => b == bill); void Move(int direction) { var otherBill = (Bill_Production)billStack.Bills[thisBillIndexInWorkTable + direction]; dialog.Close(); Find.WindowStack.Add(new Dialog_BillConfig(otherBill, workTable.Position)); } if (thisBillIndexInWorkTable > 0) { if (Widgets.ButtonImage(leftRect, Resources.LeftArrow)) { Move(-1); } TooltipHandler.TipRegion(leftRect, "IW.OpenPreviousBillTip".Translate()); } if (thisBillIndexInWorkTable < billStack.Count - 1) { var rightRect = new Rect(leftRect); rightRect.xMin += 4f + buttonWidth; rightRect.xMax += 4f + buttonWidth; if (Widgets.ButtonImage(rightRect, Resources.RightArrow)) { Move(1); } TooltipHandler.TipRegion(rightRect, "IW.OpenNextBillTip".Translate()); } }
public static void Prefix(Dialog_BillConfig __instance) { Bill_Production bill = billInfo.GetValue(__instance) as Bill_Production; if (bill.UsesKnowledge()) { if (bill.IsResearch()) { HarmonyPatches.FutureTech = true; } else { HarmonyPatches.CurrentTech = true; } } if (bill.IsWeaponsTraining()) { HarmonyPatches.WeaponTrainingSelection = true; } }
public static void Prefix(Dialog_BillConfig __instance) { Bill_Production bill = billInfo.GetValue(__instance) as Bill_Production; if (bill.UsesKnowledge()) { if (bill.recipe == TechDefOf.ResearchTech || bill.recipe == TechDefOf.DocumentTech) { HarmonyPatches.FutureTech = true; } else { HarmonyPatches.CurrentTech = true; } } if (bill.recipe == TechDefOf.TrainWeaponMelee || bill.recipe == TechDefOf.TrainWeaponShooting) { HarmonyPatches.WeaponTrainingSelection = true; } }
public static void DrawFilters(Dialog_BillConfig __instance, Rect inRect) { var billRaw = (Bill_Production)BillGetter.GetValue(__instance); if (billRaw == null) { return; } Main.Instance.IsRootBillFilterBeingDrawn = false; var extendedBillDataStorage = Main.Instance.GetExtendedBillDataStorage(); extendedBillDataStorage.MirrorBillToLinkedBills(billRaw); var extendedBillData = extendedBillDataStorage.GetExtendedDataFor(billRaw); if (extendedBillData == null) { return; } // Bill navigation buttons DrawWorkTableNavigation(__instance, billRaw, inRect); // Linked bill handling if (extendedBillDataStorage.IsLinkedBill(billRaw)) { var unlinkRect = new Rect(inRect.xMin + 28f, inRect.yMin + 50f, 24f, 24f); if (Widgets.ButtonImage(unlinkRect, Resources.BreakLink)) { extendedBillDataStorage.RemoveBillFromLinkSets(billRaw); } TooltipHandler.TipRegion(unlinkRect, "IW.BreakLinkToOtherBillsTip".Translate()); } // Bill renaming { var renameRect = new Rect(inRect.xMax - 75f, inRect.yMin + 4f, 24f, 24f); if (Widgets.ButtonImage(renameRect, Resources.Rename)) { Find.WindowStack.Add(new Dialog_RenameBill(extendedBillData, billRaw.LabelCap)); } TooltipHandler.TipRegion(renameRect, "IW.RenameBillTip".Translate()); } const float columnWidth = 180f; const float middleColumn = columnWidth + 34f; // Allowed worker filter var potentialWorkers = GetAllowedWorkersWithSkillLevel(billRaw); if (potentialWorkers != null) { var anyoneText = "IW.NoColRestrictionLabel".Translate(); var workerButtonRect = new Rect(middleColumn + 3f, inRect.yMin + 18f, columnWidth, 30f); var currentWorkerLabel = extendedBillData.Worker != null ? "IW.RestrictToLabel".Translate() + " " + extendedBillData.Worker.NameStringShort.CapitalizeFirst() : anyoneText; if (Widgets.ButtonText(workerButtonRect, currentWorkerLabel)) { var potentialWorkerList = new List <FloatMenuOption> { new FloatMenuOption( anyoneText, delegate { extendedBillData.Worker = null; }) }; foreach (var allowedWorkerAndTheirSkill in potentialWorkers) { var allowedWorker = allowedWorkerAndTheirSkill.First; var skillRecord = allowedWorkerAndTheirSkill.Second; var skillPrefix = ""; if (skillRecord != null) { var level = skillRecord.Level; string passion; switch (skillRecord.passion) { case Passion.Minor: passion = "+"; break; case Passion.Major: passion = "++"; break; default: passion = ""; break; } skillPrefix = $"[{level}{passion}] "; } var nameWithSkill = $"{skillPrefix}" + "IW.RestrictToLabel".Translate() + " " + $"{allowedWorker}"; var workerMenuItem = new FloatMenuOption(nameWithSkill, delegate { extendedBillData.Worker = allowedWorker; }); potentialWorkerList.Add(workerMenuItem); } Find.WindowStack.Add(new FloatMenu(potentialWorkerList)); } TooltipHandler.TipRegion(workerButtonRect, "IW.RestrictJobToSpecificColonistTip".Translate()); } // Custom take to stockpile, overlay dummy button { var storeRect = new Rect(middleColumn + 3f, inRect.yMin + 114f, columnWidth, 30f); var label = extendedBillData.UsesTakeToStockpile() ? extendedBillData.CurrentTakeToStockpileLabel() : ("BillStoreMode_" + billRaw.storeMode).Translate(); Widgets.ButtonText(storeRect, label); TooltipHandler.TipRegion(storeRect, "IW.CrafterWillToSpecificStockpileTip".Translate()); } // Filter copy/paste buttons if (billRaw.ingredientFilter != null) { const float filterButtonWidth = 96f; const float filterButtonHeight = 24f; var oldFont = Text.Font; Text.Font = GameFont.Tiny; var copyPasteHandler = Main.Instance.BillCopyPasteHandler; var copyButtonRect = new Rect(inRect.xMax - filterButtonWidth * 2 + 4f, inRect.yMax - 35f, filterButtonWidth, filterButtonHeight); var parentFilter = billRaw.recipe?.fixedIngredientFilter; if (Widgets.ButtonText(copyButtonRect, "IW.CopyFilterButton".Translate())) { copyPasteHandler.CopyFilter(billRaw.ingredientFilter, parentFilter); } TooltipHandler.TipRegion(copyButtonRect, "IW.CopyFilterTip".Translate()); if (copyPasteHandler.IsMatchingFilterCopied(parentFilter)) { var pasteButtonRect = new Rect(copyButtonRect); pasteButtonRect.xMin += filterButtonWidth + 4f; pasteButtonRect.xMax += filterButtonWidth + 4f; if (Widgets.ButtonText(pasteButtonRect, "IW.PasteFilterButton".Translate())) { copyPasteHandler.PasteCopiedFilterInto(billRaw.ingredientFilter); } } Text.Font = oldFont; } if (!ExtendedBillDataStorage.CanOutputBeFiltered(billRaw)) { return; } if (billRaw.repeatMode != BillRepeatModeDefOf.TargetCount) { return; } { var keyboardRect = new Rect(middleColumn + 90f, inRect.yMin + 208f, 24f, 24f); void TargetCountSetter(int i) { billRaw.targetCount = i; if (billRaw.unpauseWhenYouHave >= billRaw.targetCount) { billRaw.unpauseWhenYouHave = billRaw.targetCount - 1; } } if (Widgets.ButtonImage(keyboardRect, Resources.Rename)) { Find.WindowStack.Add(new Dialog_NumericEntry( billRaw.targetCount, i => i > 0, TargetCountSetter)); } TooltipHandler.TipRegion(keyboardRect, "IW.RenameTip".Translate()); } const float buttonHeight = 26f; const float smallButtonHeight = 24f; var y = inRect.height - 248f + Text.LineHeight; // "Unpause when" level adjustment buttons if (billRaw.pauseWhenSatisfied) { var buttonWidth = 42f; var minusOneRect = new Rect(middleColumn, inRect.height - 70, buttonWidth, smallButtonHeight); if (Widgets.ButtonText(minusOneRect, "-1")) { if (billRaw.unpauseWhenYouHave > 0) { billRaw.unpauseWhenYouHave--; } } var plusOneRect = new Rect(minusOneRect); plusOneRect.xMin += buttonWidth + 2f; plusOneRect.xMax += buttonWidth + 2f; if (Widgets.ButtonText(plusOneRect, "+1")) { if (billRaw.unpauseWhenYouHave < billRaw.targetCount - 1) { billRaw.unpauseWhenYouHave++; } } var keyboardRect = new Rect(plusOneRect.xMax + 2f, plusOneRect.yMin, 24f, 24f); if (Widgets.ButtonImage(keyboardRect, Resources.Rename)) { Find.WindowStack.Add(new Dialog_NumericEntry( billRaw.unpauseWhenYouHave, i => i < billRaw.targetCount, i => billRaw.unpauseWhenYouHave = i)); } TooltipHandler.TipRegion(keyboardRect, "IW.RenameTip".Translate()); } // Restrict counting to specific stockpile { y += 33; var subRect = new Rect(0f, y, columnWidth, buttonHeight); var anyStockpileText = "IW.CountOnStockpilesText".Translate(); var currentCountingStockpileLabel = extendedBillData.UsesCountingStockpile() ? "Count in " + extendedBillData.GetCountingStockpile().label : anyStockpileText; var map = Find.VisibleMap; var allStockpiles = map.zoneManager.AllZones.OfType <Zone_Stockpile>().ToList(); if (Widgets.ButtonText(subRect, currentCountingStockpileLabel)) { var potentialStockpileList = new List <FloatMenuOption> { new FloatMenuOption( anyStockpileText, delegate { extendedBillData.RemoveCountingStockpile(); }) }; foreach (var stockpile in allStockpiles) { var stockpileName = "IW.CountInText".Translate() + " " + stockpile.label; var menuOption = new FloatMenuOption( stockpileName, delegate { extendedBillData.SetCountingStockpile(stockpile); }); potentialStockpileList.Add(menuOption); } Find.WindowStack.Add(new FloatMenu(potentialStockpileList)); } TooltipHandler.TipRegion(subRect, "IW.WillCountTowardsTargetTip".Translate()); } var thingDef = billRaw.recipe.products.First().thingDef; if (!thingDef.CountAsResource) { // Counted items filter y += 33; var countedLabelRect = new Rect(0f, y, columnWidth, buttonHeight); Widgets.Label(countedLabelRect, "IW.CountedItemsFilter".Translate()); y += Text.LineHeight; var filter = extendedBillData.OutputFilter; if (filter.allowedHitPointsConfigurable) { var allowedHitPointsPercents = filter.AllowedHitPointsPercents; var rect1 = new Rect(0f, y, columnWidth, buttonHeight); Widgets.FloatRange(rect1, 10, ref allowedHitPointsPercents, 0f, 1f, "HitPoints", ToStringStyle.PercentZero); TooltipHandler.TipRegion(rect1, "IW.HitPointsTip".Translate()); filter.AllowedHitPointsPercents = allowedHitPointsPercents; } if (filter.allowedQualitiesConfigurable) { y += 33; var rect2 = new Rect(0f, y, columnWidth, buttonHeight); var allowedQualityLevels = filter.AllowedQualityLevels; Widgets.QualityRange(rect2, 11, ref allowedQualityLevels); TooltipHandler.TipRegion(rect2, "IW.QualityTip".Translate()); filter.AllowedQualityLevels = allowedQualityLevels; } } // Use input ingredients for counted items filter if (billRaw.ingredientFilter != null && thingDef.MadeFromStuff) { y += 33; var subRect = new Rect(0f, y, columnWidth, buttonHeight); Widgets.CheckboxLabeled(subRect, "IW.MatchInputIngredientsText".Translate(), ref extendedBillData.UseInputFilter); TooltipHandler.TipRegion(subRect, "IW.IngredientsTip".Translate()); } // Deadmans clothing count filter if (thingDef.IsApparel) { var nonDeadmansApparelFilter = new SpecialThingFilterWorker_NonDeadmansApparel(); if (!nonDeadmansApparelFilter.CanEverMatch(thingDef)) { // Thing can't be worn. return; } y += 26; var rect3 = new Rect(0f, y, columnWidth, buttonHeight); Widgets.CheckboxLabeled(rect3, "IW.CountCorpseClothesLabel".Translate(), ref extendedBillData.AllowDeadmansApparel); TooltipHandler.TipRegion(rect3, "IW.CountCorpseClothesDesc".Translate()); y += 26; var rect4 = new Rect(0f, y, columnWidth, buttonHeight); Widgets.CheckboxLabeled(rect4, "IW.CountEquippedClothesLabel".Translate(), ref extendedBillData.CountWornApparel); TooltipHandler.TipRegion(rect4, "IW.CountEquippedClothesDesc".Translate()); } }
public static void DrawFilters(Dialog_BillConfig __instance, Rect inRect) { var billRaw = (Bill_Production)BillGetter.GetValue(__instance); if (billRaw == null) { return; } var extendedBillDataStorage = Main.Instance.GetExtendedBillDataStorage(); extendedBillDataStorage.MirrorBillToLinkedBills(billRaw); var extendedBillData = extendedBillDataStorage.GetOrCreateExtendedDataFor(billRaw); if (extendedBillData == null) { return; } // Bill navigation buttons DrawWorkTableNavigation(__instance, billRaw, inRect); var nextConfigButtonX = inRect.xMin + 28f; // Copy bill button { var copyBillRect = new Rect(nextConfigButtonX, inRect.yMin + 50f, 24f, 24f); if (Widgets.ButtonImage(copyBillRect, Resources.CopyButton)) { Main.Instance.BillCopyPasteHandler.DoCopy(billRaw); } TooltipHandler.TipRegion(copyBillRect, "IW.CopyJustBillsTip".Translate()); nextConfigButtonX += 28f; } // Paste into bill button { var pasteRect = new Rect(nextConfigButtonX, inRect.yMin + 50f, 24f, 24f); var copyPasteHandler = Main.Instance.BillCopyPasteHandler; if (copyPasteHandler.CanPasteInto(billRaw)) { if (Widgets.ButtonImage(pasteRect, Resources.PasteButton)) { copyPasteHandler.DoPasteInto(billRaw); } TooltipHandler.TipRegion(pasteRect, "IW.PasteBillSettings".Translate()); nextConfigButtonX += 28f; } } // Linked bill handling if (extendedBillDataStorage.IsLinkedBill(billRaw)) { var unlinkRect = new Rect(nextConfigButtonX, inRect.yMin + 50f, 24f, 24f); if (Widgets.ButtonImage(unlinkRect, Resources.BreakLink)) { extendedBillDataStorage.RemoveBillFromLinkSets(billRaw); } TooltipHandler.TipRegion(unlinkRect, "IW.BreakLinkToOtherBillsTip".Translate()); } // Bill renaming { var renameRect = new Rect(inRect.xMax - 75f, inRect.yMin + 4f, 24f, 24f); if (Widgets.ButtonImage(renameRect, Resources.Rename)) { Find.WindowStack.Add(new Dialog_RenameBill(extendedBillData, billRaw.LabelCap)); } TooltipHandler.TipRegion(renameRect, "IW.RenameBillTip".Translate()); } const float columnWidth = 180f; if (!ExtendedBillDataStorage.CanOutputBeFiltered(billRaw)) { return; } if (billRaw.repeatMode != BillRepeatModeDefOf.TargetCount) { return; } Listing_Standard optionsList = new Listing_Standard(); float optionsHeight = 120; optionsList.Begin(new Rect(0, inRect.height - optionsHeight, columnWidth, optionsHeight)); // Inventory Filter if (billRaw.includeEquipped) { optionsList.CheckboxLabeled("IW.CountAwayLabel".Translate(), ref extendedBillData.CountAway, "IW.CountAwayDesc".Translate()); } else { optionsList.Gap(Text.LineHeight + optionsList.verticalSpacing); } // Output Filter if (optionsList.ButtonText("IW.OutputFilterLabel".Translate())) { Window temp = Find.WindowStack.currentlyDrawnWindow; temp.Close(); Find.WindowStack.Add(new Dialog_ThingFilter(extendedBillData, temp)); } optionsList.End(); }
public static void Postfix(Dialog_BillConfig __instance) { ThingFilterPatch.thingFilterCallerStack.Pop(); }
static void BillIngredientSearchRadius(Dialog_BillConfig __instance) { SyncIngredientSearchRadius.Watch(__instance.bill); }
static void Postfix(Dialog_BillConfig __instance) { __instance.absorbInputAroundWindow = false; }
private static void Prefix(Dialog_BillConfig __instance, Rect inRect) { BillRequirementsMod.CurrentBill = (Bill_Production)BillFld.GetValue(__instance); }
static IEnumerable <Widgets.DropdownMenuElement <Pawn> > Postfix_GenerateFields(IEnumerable <Widgets.DropdownMenuElement <Pawn> > values, Dialog_BillConfig __instance) { int check = ModsConfig.IdeologyActive ? 1 : 0; int i = 0; Bill_Production bill = Traverse.Create(__instance).Field("bill").GetValue <Bill_Production>(); Widgets.DropdownMenuElement <Pawn> anyone = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption("PrisonLabor_ColonyOnly".Translate(), delegate { Traverse.Create(bill).Field("slavesOnly").SetValue(true); Traverse.Create(bill).Field("pawnRestriction").SetValue(null); BillAssignationUtility.SetFor(bill, GroupMode.ColonyOnly); }), payload = null }; yield return(anyone); foreach (Widgets.DropdownMenuElement <Pawn> value in values) { yield return(value); if (check == i) { Widgets.DropdownMenuElement <Pawn> prisonerMenu = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption("PrisonLabor_PrisonersOnly".Translate(), delegate { bill.SetAnyPawnRestriction(); BillAssignationUtility.SetFor(bill, GroupMode.PrisonersOnly); }), payload = null }; yield return(prisonerMenu); Widgets.DropdownMenuElement <Pawn> anyCaptive = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption("PrisonLabor_PrisonersAndSlaveOnly".Translate(), delegate { bill.SetAnySlaveRestriction(); BillAssignationUtility.SetFor(bill, GroupMode.CaptiveOnly); }), payload = null }; yield return(anyCaptive); } i++; } WorkGiverDef workGiver = bill.billStack.billGiver.GetWorkgiver(); SkillDef workSkill = bill.recipe.workSkill; IEnumerable <Pawn> allPrisonersOfColony = PawnsFinder.AllMaps_PrisonersOfColony; allPrisonersOfColony = allPrisonersOfColony.OrderBy((Pawn pawn) => pawn.LabelShortCap); if (workSkill != null) { allPrisonersOfColony = allPrisonersOfColony.OrderByDescending((Pawn pawn) => pawn.skills.GetSkill(bill.recipe.workSkill).Level); } if (workGiver == null) { Log.ErrorOnce("Generating pawn restrictions for a BillGiver without a Workgiver", 96455148); yield break; } allPrisonersOfColony = allPrisonersOfColony.OrderByDescending((Pawn pawn) => pawn.workSettings.WorkIsActive(workGiver.workType)); allPrisonersOfColony = allPrisonersOfColony.OrderBy((Pawn pawn) => pawn.WorkTypeIsDisabled(workGiver.workType)); Widgets.DropdownMenuElement <Pawn> dropdownMenuElement; foreach (Pawn pawn in allPrisonersOfColony) { if (PrisonLaborUtility.LaborEnabled(pawn)) { if (pawn.WorkTypeIsDisabled(workGiver.workType)) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(string.Format("P: {0} ({1})", pawn.LabelShortCap, "WillNever".Translate(workGiver.verb)), null), payload = pawn }; yield return(dropdownMenuElement); } else if (bill.recipe.workSkill != null && !pawn.workSettings.WorkIsActive(workGiver.workType)) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(string.Format("P: {0} ({1} {2}, {3})", pawn.LabelShortCap, pawn.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate { bill.SetPawnRestriction(pawn); }), payload = pawn }; yield return(dropdownMenuElement); } else if (!pawn.workSettings.WorkIsActive(workGiver.workType)) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(string.Format("P: {0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate { bill.SetPawnRestriction(pawn); }), payload = pawn }; yield return(dropdownMenuElement); } else if (bill.recipe.workSkill != null) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption($"P: {pawn.LabelShortCap} ({pawn.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate { bill.SetPawnRestriction(pawn); }), payload = pawn }; yield return(dropdownMenuElement); } else { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption($"P: {pawn.LabelShortCap}", delegate { bill.SetPawnRestriction(pawn); }), payload = pawn }; yield return(dropdownMenuElement); } } } }
static IEnumerable <Widgets.DropdownMenuElement <Pawn> > Postfix(IEnumerable <Widgets.DropdownMenuElement <Pawn> > values, Dialog_BillConfig __instance) { foreach (Widgets.DropdownMenuElement <Pawn> value in values) { yield return(value); } Bill_Production bill = Traverse.Create(__instance).Field("bill").GetValue <Bill_Production>(); WorkGiverDef workGiver = bill.billStack.billGiver.GetWorkgiver(); List <Pawn> allPrisonersOfColony = PawnsFinder.AllMaps_PrisonersOfColony; Widgets.DropdownMenuElement <Pawn> dropdownMenuElement; foreach (Pawn pawn in allPrisonersOfColony) { if (PrisonLaborUtility.LaborEnabled(pawn)) { if (pawn.WorkTypeIsDisabled(workGiver.workType)) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "WillNever".Translate(workGiver.verb)), null), payload = pawn }; yield return(dropdownMenuElement); } else if (bill.recipe.workSkill != null && !pawn.workSettings.WorkIsActive(workGiver.workType)) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(string.Format("{0} ({1} {2}, {3})", pawn.LabelShortCap, pawn.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate { bill.pawnRestriction = pawn; }), payload = pawn }; yield return(dropdownMenuElement); } else if (!pawn.workSettings.WorkIsActive(workGiver.workType)) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate { bill.pawnRestriction = pawn; }), payload = pawn }; yield return(dropdownMenuElement); } else if (bill.recipe.workSkill != null) { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption($"{pawn.LabelShortCap} ({pawn.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate { bill.pawnRestriction = pawn; }), payload = pawn }; yield return(dropdownMenuElement); } else { dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn> { option = new FloatMenuOption($"{pawn.LabelShortCap}", delegate { bill.pawnRestriction = pawn; }), payload = pawn }; yield return(dropdownMenuElement); } } } }
public static void DrawFilters(Dialog_BillConfig __instance, Rect inRect) { var billRaw = (Bill_Production)BillGetter.GetValue(__instance); if (billRaw == null) { return; } var extendedBillDataStorage = Main.Instance.GetExtendedBillDataStorage(); extendedBillDataStorage.MirrorBillToLinkedBills(billRaw); var extendedBillData = extendedBillDataStorage.GetOrCreateExtendedDataFor(billRaw); if (extendedBillData == null) { return; } // Bill navigation buttons DrawWorkTableNavigation(__instance, billRaw, inRect); var nextConfigButtonX = inRect.xMin + 28f; // Copy bill button { var copyBillRect = new Rect(nextConfigButtonX, inRect.yMin + 50f, 24f, 24f); if (Widgets.ButtonImage(copyBillRect, Resources.CopyButton)) { Main.Instance.BillCopyPasteHandler.DoCopy(billRaw); } TooltipHandler.TipRegion(copyBillRect, "IW.CopyJustBillsTip".Translate()); nextConfigButtonX += 28f; } // Paste into bill button { var pasteRect = new Rect(nextConfigButtonX, inRect.yMin + 50f, 24f, 24f); var copyPasteHandler = Main.Instance.BillCopyPasteHandler; if (copyPasteHandler.CanPasteInto(billRaw)) { if (Widgets.ButtonImage(pasteRect, Resources.PasteButton)) { copyPasteHandler.DoPasteInto(billRaw); } TooltipHandler.TipRegion(pasteRect, "IW.PasteBillSettings".Translate()); nextConfigButtonX += 28f; } } // Linked bill handling if (extendedBillDataStorage.IsLinkedBill(billRaw)) { var unlinkRect = new Rect(nextConfigButtonX, inRect.yMin + 50f, 24f, 24f); if (Widgets.ButtonImage(unlinkRect, Resources.BreakLink)) { extendedBillDataStorage.RemoveBillFromLinkSets(billRaw); } TooltipHandler.TipRegion(unlinkRect, "IW.BreakLinkToOtherBillsTip".Translate()); } // Bill renaming { var renameRect = new Rect(inRect.xMax - 75f, inRect.yMin + 4f, 24f, 24f); if (Widgets.ButtonImage(renameRect, Resources.Rename)) { Find.WindowStack.Add(new Dialog_RenameBill(extendedBillData, billRaw.LabelCap)); } TooltipHandler.TipRegion(renameRect, "IW.RenameBillTip".Translate()); } const float columnWidth = 180f; if (!ExtendedBillDataStorage.CanOutputBeFiltered(billRaw)) { return; } if (billRaw.repeatMode != BillRepeatModeDefOf.TargetCount) { return; } const float buttonHeight = 26f; var y = inRect.height - 84f; // Helper method for checkboxes void SimpleCheckBoxWithToolTip(string label, ref bool setting, string tip) { var subRect = new Rect(0f, y, columnWidth, buttonHeight); Widgets.CheckboxLabeled(subRect, label.Translate(), ref setting); TooltipHandler.TipRegion(subRect, tip.Translate()); y += 26; }; // Checkbox helper method with consistent language tokens void SimpleCheckBox(string label, ref bool setting) { SimpleCheckBoxWithToolTip($"IW.{label}Label", ref setting, $"IW.{label}Desc"); } // Inventory Filter if (billRaw.includeEquipped) { SimpleCheckBox("CountAway", ref extendedBillData.CountAway); } }
public static void Prefix(Dialog_BillConfig __instance) { ThingFilterPatch.thingFilterCallerStack.Push(__instance.GetType().GetField("bill", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(__instance)); }