protected override void DrawConfigInterface(Rect baseRect, Color baseColor) { Rect rect = new Rect(28f, 32f, 100f, 30f); GUI.color = new Color(1f, 1f, 1f, 0.65f); Widgets.Label(rect, this.RepeatInfoText); GUI.color = baseColor; WidgetRow widgetRow = new WidgetRow(baseRect.xMax, baseRect.y + 29f, UIDirection.LeftThenUp, 99999f, 4f); if (widgetRow.ButtonText("Details".Translate() + "...", null, true, false)) { Find.WindowStack.Add(new Dialog_BillConfig_Hysteresis(this, ((Thing)this.billStack.billGiver).Position)); } if (widgetRow.ButtonText(this.repeatMode.GetLabel().PadRight(20), null, true, false)) { BillRepeatModeUtility.MakeConfigFloatMenu(this); } if (widgetRow.ButtonIcon((Texture2D)DetourInjector.ButtonPlus.GetValue(null), null)) { if (this.repeatMode == BillRepeatMode.Forever) { this.repeatMode = BillRepeatMode.RepeatCount; this.repeatCount = 1; } else if (this.repeatMode == BillRepeatMode.TargetCount) { this.targetCount += this.recipe.targetCountAdjustment; } else if (this.repeatMode == BillRepeatMode.RepeatCount) { this.repeatCount++; } SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); } if (widgetRow.ButtonIcon((Texture2D)DetourInjector.ButtonMinus.GetValue(null), null)) { if (this.repeatMode == BillRepeatMode.Forever) { this.repeatMode = BillRepeatMode.RepeatCount; this.repeatCount = 1; } else if (this.repeatMode == BillRepeatMode.TargetCount) { this.targetCount = Mathf.Max(0, this.targetCount - this.recipe.targetCountAdjustment); } else if (this.repeatMode == BillRepeatMode.RepeatCount) { this.repeatCount = Mathf.Max(0, this.repeatCount - 1); } SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); } }
private static void CreateRepeatButton(Bill_Production _this, WidgetRow widgetRow) { Texture2D tex = null; if (_this.repeatMode == BillRepeatModeDefOf.RepeatCount) { tex = TexButton.RepeatCount; } else if (_this.repeatMode == BillRepeatModeDefOf.TargetCount) { tex = TexButton.TargetCount; } else if (_this.repeatMode == BillRepeatModeDefOf.Forever) { tex = TexButton.Forever; } if (widgetRow.ButtonIcon(tex, _this.repeatMode.GetLabel())) { BillRepeatModeUtility.MakeConfigFloatMenu(_this); } }
private static void CreateRepeatButton(Bill_Production _this, WidgetRow widgetRow) { Texture2D tex = null; switch (_this.repeatMode) { case BillRepeatMode.RepeatCount: tex = TexButton.RepeatCount; break; case BillRepeatMode.TargetCount: tex = TexButton.TargetCount; break; case BillRepeatMode.Forever: tex = TexButton.Forever; break; } if (widgetRow.ButtonIcon(tex, _this.repeatMode.GetLabel())) { BillRepeatModeUtility.MakeConfigFloatMenu(_this); } }
// // Rest of the original class which is not changed // // /* * public BillRepeatMode repeatMode; * * public int repeatCount = 1; * * public int targetCount = 10; * * public BillStoreMode storeMode = BillStoreMode.BestStockpile; * * public string RepeatInfoText * { * get * { * if (this.repeatMode == BillRepeatMode.Forever) * { * return "Forever".Translate(); * } * if (this.repeatMode == BillRepeatMode.RepeatCount) * { * return this.repeatCount.ToString() + "x"; * } * if (this.repeatMode == BillRepeatMode.TargetCount) * { * return this.recipe.WorkerCounter.CountProducts(this).ToString() + "/" + this.targetCount.ToString(); * } * throw new InvalidOperationException(); * } * } * * public Bill_Production() * { * } * * public Bill_Production(RecipeDef recipe) : base(recipe) * { * } * * public override void ExposeData() * { * base.ExposeData(); * Scribe_Values.LookValue<int>(ref this.repeatCount, "repeatCount", 0, false); * Scribe_Values.LookValue<int>(ref this.targetCount, "targetCount", 0, false); * Scribe_Values.LookValue<BillRepeatMode>(ref this.repeatMode, "repeatMode", BillRepeatMode.RepeatCount, false); * Scribe_Values.LookValue<BillStoreMode>(ref this.storeMode, "storeMode", BillStoreMode.DropOnFloor, false); * } * * public override BillStoreMode GetStoreMode() * { * return this.storeMode; * } * * public override bool ShouldDoNow() * { * if (this.suspended) * { * return false; * } * if (this.repeatMode == BillRepeatMode.Forever) * { * return true; * } * if (this.repeatMode == BillRepeatMode.RepeatCount) * { * return this.repeatCount > 0; * } * if (this.repeatMode == BillRepeatMode.TargetCount) * { * return this.recipe.WorkerCounter.CountProducts(this) < this.targetCount; * } * throw new InvalidOperationException(); * } * * public override void Notify_IterationCompleted(Pawn billDoer, List<Thing> ingredients) * { * if (this.repeatMode == BillRepeatMode.RepeatCount) * { * this.repeatCount--; * if (this.repeatCount == 0) * { * Messages.Message("MessageBillComplete".Translate(new object[] * { * this.LabelCap * }), (Thing)this.billStack.billGiver, MessageSound.Benefit); * } * } * } */ protected override void DoConfigInterface(Rect baseRect, Color baseColor) { Rect rect = new Rect(28f, 32f, 100f, 30f); GUI.color = new Color(1f, 1f, 1f, 0.65f); Widgets.Label(rect, this.RepeatInfoText); GUI.color = baseColor; WidgetRow widgetRow = new WidgetRow(baseRect.xMax, baseRect.y + 29f, UIDirection.LeftThenUp, 99999f, 4f); if (widgetRow.ButtonText("Details".Translate() + "...", null, true, false)) { Find.WindowStack.Add(new Dialog_BillConfig(this, ((Thing)this.billStack.billGiver).Position)); } if (widgetRow.ButtonText(this.repeatMode.GetLabel().PadRight(20), null, true, false)) { BillRepeatModeUtility.MakeConfigFloatMenu(this); } Event e = Event.current; int modifier = 1; if (e.shift) { modifier = 5; } else if (e.control) { modifier = 25; } if (widgetRow.ButtonIcon(TexButton.Plus, null)) { if (this.repeatMode == BillRepeatMode.Forever) { this.repeatMode = BillRepeatMode.RepeatCount; this.repeatCount = modifier; } else if (this.repeatMode == BillRepeatMode.TargetCount) { this.targetCount += modifier; } else if (this.repeatMode == BillRepeatMode.RepeatCount) { this.repeatCount += modifier; } SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); if (TutorSystem.TutorialMode && this.repeatMode == BillRepeatMode.RepeatCount) { TutorSystem.Notify_Event(this.recipe.defName + "-RepeatCountSetTo-" + this.repeatCount); } } if (widgetRow.ButtonIcon(TexButton.Minus, null)) { if (this.repeatMode == BillRepeatMode.Forever) { this.repeatMode = BillRepeatMode.RepeatCount; this.repeatCount = modifier; } else if (this.repeatMode == BillRepeatMode.TargetCount) { this.targetCount = Mathf.Max(0, this.targetCount - modifier); } else if (this.repeatMode == BillRepeatMode.RepeatCount) { this.repeatCount = Mathf.Max(0, this.repeatCount - modifier); } SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); if (TutorSystem.TutorialMode && this.repeatMode == BillRepeatMode.RepeatCount) { TutorSystem.Notify_Event(this.recipe.defName + "-RepeatCountSetTo-" + this.repeatCount); } } }
public override void DoWindowContents(Rect inRect) { AddRenameButton(inRect); AddRenamedLabel(); #region Origianl Text.Font = GameFont.Small; Rect rect2 = new Rect(0f, 50f, 180f, inRect.height - 50f); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(rect2); if (bill.suspended) { if (listing_Standard.ButtonText("Suspended".Translate(), null)) { bill.suspended = false; } } else if (listing_Standard.ButtonText("NotSuspended".Translate(), null)) { bill.suspended = true; } #endregion AddAssignWorkerButton(listing_Standard); if (listing_Standard.ButtonText(bill.repeatMode.GetLabel(), null)) { BillRepeatModeUtility.MakeConfigFloatMenu(bill); } var label = ("BillStoreMode_" + bill.storeMode).Translate(); if (listing_Standard.ButtonText(label, null)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (BillStoreModeDef current in from bsm in DefDatabase <BillStoreModeDef> .AllDefs orderby bsm.listOrder select bsm) { BillStoreModeDef smLocal = current; list.Add(new FloatMenuOption(("BillStoreMode_" + current).Translate(), delegate { this.bill.storeMode = smLocal; }, MenuOptionPriority.Default, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(list)); } listing_Standard.Gap(12f); if (bill.repeatMode == BillRepeatModeDefOf.RepeatCount) { listing_Standard.Label("RepeatCount".Translate(bill.RepeatInfoText)); listing_Standard.IntSetter(ref bill.repeatCount, 1, "1", 42f); listing_Standard.IntAdjuster(ref bill.repeatCount, 1, 25, 1); // changed listing_Standard.IntAdjuster(ref bill.repeatCount, 10, 250, 1); } else if (bill.repeatMode == BillRepeatModeDefOf.TargetCount) { var text = "CurrentlyHave".Translate() + ": "; text += bill.recipe.WorkerCounter.CountProducts(bill); text += " / "; text += bill.targetCount >= 999999 ? "Infinite".Translate().ToLower() : bill.targetCount.ToString(); var text2 = bill.recipe.WorkerCounter.ProductsDescription(bill); if (!text2.NullOrEmpty()) { var text3 = text; text = string.Concat(text3, "\n", "CountingProducts".Translate(), ": ", text2); } listing_Standard.Label(text); // changed // todo : extract method listing_Standard.IntSetter(ref bill.targetCount, 1, "1", 42f); listing_Standard.IntAdjuster(ref bill.targetCount, 1, 25, 1); listing_Standard.IntAdjuster(ref bill.targetCount, 10, 250, 1); } listing_Standard.Gap(12f); listing_Standard.Label("IngredientSearchRadius".Translate() + ": " + bill.ingredientSearchRadius.ToString("F0")); bill.ingredientSearchRadius = listing_Standard.Slider(bill.ingredientSearchRadius, 3f, 100f, null); // changed if (bill.ingredientSearchRadius >= 100f) { bill.ingredientSearchRadius = 999f; } //listing_Standard.Gap(-4f); // °¸ ��»ף if (bill.recipe.workSkill != null) { listing_Standard.Label("AllowedSkillRange".Translate(bill.recipe.workSkill.label.ToLower())); listing_Standard.IntRange(ref bill.allowedSkillRange, 0, 20); } AddMinBarButton(listing_Standard); #region original listing_Standard.End(); Rect rect3 = new Rect(rect2.xMax + 6f, 50f, 280f, -1f); rect3.yMax = inRect.height - this.CloseButSize.y - 6f; ThingFilterUI.DoThingFilterConfigWindow(rect3, ref this.scrollPosition, this.bill.ingredientFilter, this.bill.recipe.fixedIngredientFilter, 4, null, null); Rect rect4 = new Rect(rect3.xMax + 6f, rect3.y + 30f, 0f, 0f); rect4.xMax = inRect.xMax; rect4.yMax = inRect.height - this.CloseButSize.y - 6f; StringBuilder stringBuilder = new StringBuilder(); if (this.bill.recipe.description != null) { stringBuilder.AppendLine(this.bill.recipe.description); stringBuilder.AppendLine(); } stringBuilder.AppendLine(Translator.Translate("WorkAmount") + ": " + GenText.ToStringWorkAmount(this.bill.recipe.WorkAmountTotal(null))); stringBuilder.AppendLine(); for (int i = 0; i < this.bill.recipe.ingredients.Count; i++) { IngredientCount ingredientCount = this.bill.recipe.ingredients[i]; if (!GenText.NullOrEmpty(ingredientCount.filter.Summary)) { stringBuilder.AppendLine(this.bill.recipe.IngredientValueGetter.BillRequirementsDescription(this.bill.recipe, ingredientCount)); } } stringBuilder.AppendLine(); string text5 = this.bill.recipe.IngredientValueGetter.ExtraDescriptionLine(this.bill.recipe); if (text5 != null) { stringBuilder.AppendLine(text5); stringBuilder.AppendLine(); } stringBuilder.AppendLine(Translator.Translate("MinimumSkills")); stringBuilder.AppendLine(this.bill.recipe.MinSkillString); Text.Font = GameFont.Small; string text6 = stringBuilder.ToString(); if (Text.CalcHeight(text6, rect4.width) > rect4.height) { Text.Font = GameFont.Tiny; } Widgets.Label(rect4, text6); Text.Font = GameFont.Small; if (this.bill.recipe.products.Count == 1) { Widgets.InfoCardButton(rect4.x, rect3.y, this.bill.recipe.products[0].thingDef); } #endregion }