public override void DoWindowContents(Rect inRect) { if (Widgets.ButtonText(new Rect(0, 5, 30f, 30), "-1")) { MainMod.SelectedPriority -= (short)GenUI.CurrentAdjustmentMultiplier(); editBuffer = ((int)MainMod.SelectedPriority).ToStringCached(); } if (Widgets.ButtonText(new Rect(210, 5, 30f, 30), "+1")) { MainMod.SelectedPriority += (short)GenUI.CurrentAdjustmentMultiplier(); editBuffer = ((int)MainMod.SelectedPriority).ToStringCached(); } int pri = MainMod.SelectedPriority; Widgets.TextFieldNumeric <int>(new Rect(45, 5, 150, 30), ref pri, ref editBuffer, -32766, 32768); MainMod.SelectedPriority = (short)pri; Rect offset = new Rect(0f, 50f, 20f, 20f); float spacing = 3f + offset.width; for (int i = -5; i <= 5; i++) { if (Widgets.ButtonText(offset, i.ToString())) { MainMod.SelectedPriority = (short)i; editBuffer = i.ToStringCached(); } offset.x += spacing; } }
private void LabeledIntEntry(Rect rect, string label, ref int value, ref string editBuffer, int multiplier, int largeMultiplier, int min, int max) { float num = rect.width / 15f; Widgets.Label(rect, label); if (multiplier != largeMultiplier) { if (Widgets.ButtonText(new Rect(rect.xMax - num * 5f, rect.yMin, (float)num, rect.height), (-1 * largeMultiplier).ToString(), true, true, true)) { value -= largeMultiplier * GenUI.CurrentAdjustmentMultiplier(); editBuffer = value.ToString(); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); } if (Widgets.ButtonText(new Rect(rect.xMax - num, rect.yMin, num, rect.height), "+" + largeMultiplier.ToString(), true, true, true)) { value += largeMultiplier * GenUI.CurrentAdjustmentMultiplier(); editBuffer = value.ToString(); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } } if (Widgets.ButtonText(new Rect(rect.xMax - num * 4f, rect.yMin, num, rect.height), (-1 * multiplier).ToString(), true, true, true)) { value -= multiplier * GenUI.CurrentAdjustmentMultiplier(); editBuffer = value.ToString(); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); } if (Widgets.ButtonText(new Rect(rect.xMax - (num * 2f), rect.yMin, num, rect.height), "+" + multiplier.ToString(), true, true, true)) { value += multiplier * GenUI.CurrentAdjustmentMultiplier(); editBuffer = value.ToString(); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } Widgets.TextFieldNumeric <int>(new Rect(rect.xMax - (num * 3f), rect.yMin, num, rect.height), ref value, ref editBuffer, min, max); }
void DoInterface_Column1(Rect _RectTotal, IntVec3 dropLocation = new IntVec3(), Map dropMap = null) { Rect _RectTopHalf = _RectTotal.TopHalf(); Rect _RectBottomHalf = _RectTotal.BottomHalf(); Rect _RectQuarter1 = _RectTopHalf.TopHalf(); if (this.ConstructionInProgress) { Widgets.TextArea(_RectQuarter1, this.label + " - In Progress", true); } else { Widgets.TextArea(_RectQuarter1, this.label, true); } Rect _RectQuarter2 = _RectTopHalf.BottomHalf(); Widgets.TextArea(_RectQuarter2, "Work: " + this.WorkRemaining.ToString() + " / " + this.TotalNeededWork.ToString(), true); Rect _RectQuarter3 = _RectBottomHalf.TopHalf(); Widgets.TextArea(_RectQuarter3, "RU:" + this.TotalNeededResources + " Power: " + this.TotalNeededPower, true); Rect _RectQuarter4 = _RectBottomHalf.BottomHalf(); Widgets.TextArea(_RectQuarter4.LeftHalf(), "Avalable: " + this.UnitsAvalable.ToString() + " Requested: " + this.UnitsRequestedAditional.ToString(), true); if (dropMap != null && this.UnitsAvalable >= 1) { if (Widgets.ButtonText(_RectQuarter4.RightHalf().RightHalf(), "Deploy", true, false, true)) { //Log.Message("Drop"); this.InitiateDrop(dropLocation, dropMap); } } if (Widgets.ButtonText(_RectQuarter4.RightHalf().LeftHalf().LeftHalf(), "-")) { if (this.UnitsRequestedAditional > 0) { this.UnitsRequestedAditional -= 1 * GenUI.CurrentAdjustmentMultiplier(); } if (this.UnitsRequestedAditional < 0) { this.UnitsRequestedAditional = 0; } } ; if (!this.PreventConstruction) { if (Widgets.ButtonText(_RectQuarter4.RightHalf().LeftHalf().RightHalf(), "+")) { this.UnitsRequestedAditional += 1 * GenUI.CurrentAdjustmentMultiplier(); } ; } }
private void DrawPriceAdjuster(Rect rect, ref int val, int countChange = 50, int min = 0) { rect.width = 42f; if (Widgets.ButtonText(rect, "-" + countChange, true, false, true)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(null); val -= countChange * GenUI.CurrentAdjustmentMultiplier(); if (val < min) { val = min; } } rect.x += rect.width + 2f; if (Widgets.ButtonText(rect, "+" + countChange, true, false, true)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(null); val += countChange * GenUI.CurrentAdjustmentMultiplier(); if (val < min) { val = min; } } }
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, RepeatInfoText); GUI.color = baseColor; WidgetRow widgetRow = new WidgetRow(baseRect.xMax, baseRect.y + 29f, UIDirection.LeftThenUp); if (widgetRow.ButtonText("Details".Translate() + "...")) { Find.WindowStack.Add(new Dialog_BillConfig(this, ((Thing)billStack.billGiver).Position)); } if (widgetRow.ButtonText(repeatMode.LabelCap.PadRight(20))) { BillRepeatModeUtility.MakeConfigFloatMenu(this); } if (widgetRow.ButtonIcon(TexButton.Plus)) { if (repeatMode == BillRepeatModeDefOf.Forever) { repeatMode = BillRepeatModeDefOf.RepeatCount; repeatCount = 1; } else if (repeatMode == BillRepeatModeDefOf.TargetCount) { int num = recipe.targetCountAdjustment * GenUI.CurrentAdjustmentMultiplier(); targetCount += num; unpauseWhenYouHave += num; } else if (repeatMode == BillRepeatModeDefOf.RepeatCount) { repeatCount += GenUI.CurrentAdjustmentMultiplier(); } SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); if (TutorSystem.TutorialMode && repeatMode == BillRepeatModeDefOf.RepeatCount) { TutorSystem.Notify_Event(recipe.defName + "-RepeatCountSetTo-" + repeatCount); } } if (widgetRow.ButtonIcon(TexButton.Minus)) { if (repeatMode == BillRepeatModeDefOf.Forever) { repeatMode = BillRepeatModeDefOf.RepeatCount; repeatCount = 1; } else if (repeatMode == BillRepeatModeDefOf.TargetCount) { int num2 = recipe.targetCountAdjustment * GenUI.CurrentAdjustmentMultiplier(); targetCount = Mathf.Max(0, targetCount - num2); unpauseWhenYouHave = Mathf.Max(0, unpauseWhenYouHave - num2); } else if (repeatMode == BillRepeatModeDefOf.RepeatCount) { repeatCount = Mathf.Max(0, repeatCount - GenUI.CurrentAdjustmentMultiplier()); } SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); if (TutorSystem.TutorialMode && repeatMode == BillRepeatModeDefOf.RepeatCount) { TutorSystem.Notify_Event(recipe.defName + "-RepeatCountSetTo-" + repeatCount); } } }
/// <summary> /// область снизу слева - добавляемые в ордер вещи /// </summary> /// <param name="inRect"></param> public void DoWindowAddThingList(Rect inRect) { if (!ShowAddThingList) { return; } if (AddThingGrid == null) { //инициализация AddThingGrid = new GridBox <TransferableOneWay>(); Transferables = GameUtils.DistinctThings(AllThings); var dicMaxCount = Transferables.ToDictionary(t => t, t => t.MaxCount); AddThingGrid.DataSource = Transferables; AddThingGrid.LineHeight = 24f; AddThingGrid.Tooltip = null; AddThingGrid.OnDrawLine = (int line, TransferableOneWay item, Rect rectLine) => { try { if (!item.HasAnyThing) { return; } float currentWidth = rectLine.width; //ввод кол-во и кнопки < > currentWidth -= 60f + rectLine.height * 2f; Rect rect3 = new Rect(rectLine.width - 60f - rectLine.height, 0f, 60f, rectLine.height); int num2 = GenUI.CurrentAdjustmentMultiplier(); //зажали кнопку для прибавления по 10/100 if (item.CanAdjustBy(-1 * num2).Accepted) { Rect rect4 = new Rect(rect3.x - rectLine.height, 0f, rectLine.height, rectLine.height).ContractedBy(1f); if (Widgets.ButtonText(rect4, "<", true, false, true)) { item.AdjustBy(-1 * num2); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } } int countToTransfer = item.CountToTransfer; string editBuffer = item.EditBuffer; Widgets.TextFieldNumeric <int>(rect3.ContractedBy(2f), ref countToTransfer, ref editBuffer, 0f, (float)dicMaxCount[item]); item.AdjustTo(countToTransfer); item.EditBuffer = editBuffer; if (item.CanAdjustBy(1 * num2).Accepted) { Rect rect4 = new Rect(rect3.xMax, 0f, rectLine.height, rectLine.height).ContractedBy(1f); if (Widgets.ButtonText(rect4, ">", true, false, true)) { item.AdjustBy(1 * num2); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } } //кол-во rect3 = new Rect(currentWidth - 60f, 0f, 60f, rectLine.height); Text.WordWrap = false; Text.Anchor = TextAnchor.MiddleRight; Widgets.Label(rect3, dicMaxCount[item].ToString()); currentWidth -= 60f; //цена rect3 = new Rect(currentWidth - 60f, 0f, 80f, rectLine.height); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect3, item.AnyThing.MarketValue.ToStringMoney()); Text.WordWrap = true; currentWidth -= 60f; //Иконка i и описание GameUtils.DravLineThing(new Rect(0f, 0f, currentWidth, rectLine.height), item.AnyThing, Color.white); } catch (Exception e) { Log.Error(e.ToString()); } }; } //заголовок Rect rect = new Rect(0f, 0f, inRect.width, 24); inRect.yMin += rect.height; Text.Font = GameFont.Tiny; // высота Tiny 18 Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect, "OCity_Dialog_Exchenge_Select_For_Sale".Translate(PlaceCurrent.Name)); //кнопка "Выбрать" rect.xMin += inRect.width - 150f; Text.Anchor = TextAnchor.MiddleCenter; if (Widgets.ButtonText(rect.ContractedBy(1f), "OCity_Dialog_Exchenge_Choose".Translate(), true, false, true)) { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); AddThingListApply(); return; } Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleLeft; AddThingGrid.Area = inRect; AddThingGrid.Drow(); }
public static void DoCountAdjustInterfaceForSilver(Rect rect, Transferable trad, int _, int min, int max, bool flash) { rect = rect.Rounded(); Rect rect2 = new Rect(rect.center.x - 45f, rect.center.y - 12.5f, 90f, 25f).Rounded(); if (flash) { GUI.DrawTexture(rect2, TransferableUIUtility.FlashTex); } bool num = trad is TransferableOneWay transferableOneWay && transferableOneWay.HasAnyThing && transferableOneWay.AnyThing is Pawn && transferableOneWay.MaxCount == 1; if (num) { bool flag = trad.CountToTransfer != 0; bool checkOn = flag; Widgets.Checkbox(rect2.position, ref checkOn); if (checkOn != flag) { if (checkOn) { trad.AdjustTo(trad.GetMaximumToTransfer()); } else { trad.AdjustTo(trad.GetMinimumToTransfer()); } } } else { Rect rect3 = rect2.ContractedBy(2f); rect3.xMax -= 15f; rect3.xMin += 16f; int val = trad.CountToTransfer; string buffer = trad.EditBuffer; Widgets.TextFieldNumeric(rect3, ref val, ref buffer, min, max); trad.AdjustTo(val); trad.EditBuffer = buffer; } Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; if (!num) { int num2 = (trad.PositiveCountDirection == TransferablePositiveCountDirection.Source) ? 1 : (-1); int num3 = GenUI.CurrentAdjustmentMultiplier(); bool flag2 = trad.GetRange() == 1; if (trad.CanAdjustBy(num2 * num3).Accepted) { Rect rect4 = new Rect(rect2.x - 30f, rect.y, 30f, rect.height); if (flag2) { rect4.x -= rect4.width; rect4.width += rect4.width; } if (Widgets.ButtonText(rect4, "<")) { trad.AdjustBy(num2 * num3); SoundDefOf.Tick_High.PlayOneShotOnCamera(); } if (!flag2) { string label = "<<"; int? num4 = null; rect4.x -= rect4.width; if (Widgets.ButtonText(rect4, label)) { if (num4.HasValue) { trad.AdjustTo(num4.Value); } else if (num2 == 1) { trad.AdjustTo(trad.GetMaximumToTransfer()); } else { trad.AdjustTo(trad.GetMinimumToTransfer()); } SoundDefOf.Tick_High.PlayOneShotOnCamera(); } } } if (trad.CanAdjustBy(-num2 * num3).Accepted) { Rect rect5 = new Rect(rect2.xMax, rect.y, 30f, rect.height); if (flag2) { rect5.width += rect5.width; } if (Widgets.ButtonText(rect5, ">")) { trad.AdjustBy(-num2 * num3); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } if (!flag2) { string label2 = ">>"; int? num5 = null; rect5.x += rect5.width; if (Widgets.ButtonText(rect5, label2)) { if (num5.HasValue) { trad.AdjustTo(num5.Value); } else if (num2 == 1) { trad.AdjustTo(trad.GetMinimumToTransfer()); } else { trad.AdjustTo(trad.GetMaximumToTransfer()); } SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } } } } if (trad.CountToTransfer != 0) { Rect position = new Rect(rect2.x + rect2.width / 2f - (float)(TradeArrow.width / 2), rect2.y + rect2.height / 2f - (float)(TradeArrow.height / 2), TradeArrow.width, TradeArrow.height); TransferablePositiveCountDirection positiveCountDirection = trad.PositiveCountDirection; if ((positiveCountDirection == TransferablePositiveCountDirection.Source && trad.CountToTransfer > 0) || (positiveCountDirection == TransferablePositiveCountDirection.Destination && trad.CountToTransfer < 0)) { position.x += position.width; position.width *= -1f; } GUI.DrawTexture(position, TradeArrow); } }
private static void DoCountAdjustInterfaceInternal(Rect rect, Transferable trad, int index, int min, int max, bool flash, bool readOnly) { rect = rect.Rounded(); Rect rect2 = new Rect(rect.center.x - 45f, rect.center.y - 12.5f, 90f, 25f).Rounded(); if (flash) { GUI.DrawTexture(rect2, TransferableUIUtility.FlashTex); } TransferableOneWay transferableOneWay = trad as TransferableOneWay; bool flag = transferableOneWay != null && transferableOneWay.HasAnyThing && transferableOneWay.AnyThing is Pawn && transferableOneWay.MaxCount == 1; if (!trad.Interactive || readOnly) { if (flag) { bool flag2 = trad.CountToTransfer != 0; Widgets.Checkbox(rect2.position, ref flag2, 24f, true, false, null, null); } else { GUI.color = ((trad.CountToTransfer != 0) ? Color.white : TransferableUIUtility.ZeroCountColor); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect2, trad.CountToTransfer.ToStringCached()); } } else if (flag) { bool flag3 = trad.CountToTransfer != 0; bool flag4 = flag3; Widgets.Checkbox(rect2.position, ref flag4, 24f, false, true, null, null); if (flag4 != flag3) { if (flag4) { trad.AdjustTo(trad.GetMaximumToTransfer()); } else { trad.AdjustTo(trad.GetMinimumToTransfer()); } } } else { Rect rect3 = rect2.ContractedBy(2f); rect3.xMax -= 15f; rect3.xMin += 16f; int countToTransfer = trad.CountToTransfer; string editBuffer = trad.EditBuffer; Widgets.TextFieldNumeric <int>(rect3, ref countToTransfer, ref editBuffer, (float)min, (float)max); trad.AdjustTo(countToTransfer); trad.EditBuffer = editBuffer; } Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; if (trad.Interactive && !flag) { TransferablePositiveCountDirection positiveCountDirection = trad.PositiveCountDirection; int num = (positiveCountDirection != TransferablePositiveCountDirection.Source) ? -1 : 1; int num2 = GenUI.CurrentAdjustmentMultiplier(); bool flag5 = trad.GetRange() == 1; if (trad.CanAdjustBy(num * num2).Accepted) { Rect rect4 = new Rect(rect2.x - 30f, rect.y, 30f, rect.height); if (flag5) { rect4.x -= rect4.width; rect4.width += rect4.width; } if (Widgets.ButtonText(rect4, "<", true, false, true)) { trad.AdjustBy(num * num2); SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } if (!flag5) { string label = "<<"; int? num3 = null; int num4 = 0; for (int i = 0; i < TransferableUIUtility.stoppingPoints.Count; i++) { TransferableCountToTransferStoppingPoint transferableCountToTransferStoppingPoint = TransferableUIUtility.stoppingPoints[i]; if (positiveCountDirection == TransferablePositiveCountDirection.Source) { if (trad.CountToTransfer < transferableCountToTransferStoppingPoint.threshold && (transferableCountToTransferStoppingPoint.threshold < num4 || !num3.HasValue)) { label = transferableCountToTransferStoppingPoint.leftLabel; num3 = new int?(transferableCountToTransferStoppingPoint.threshold); } } else if (trad.CountToTransfer > transferableCountToTransferStoppingPoint.threshold && (transferableCountToTransferStoppingPoint.threshold > num4 || !num3.HasValue)) { label = transferableCountToTransferStoppingPoint.leftLabel; num3 = new int?(transferableCountToTransferStoppingPoint.threshold); } } rect4.x -= rect4.width; if (Widgets.ButtonText(rect4, label, true, false, true)) { if (num3.HasValue) { trad.AdjustTo(num3.Value); } else if (num == 1) { trad.AdjustTo(trad.GetMaximumToTransfer()); } else { trad.AdjustTo(trad.GetMinimumToTransfer()); } SoundDefOf.Tick_High.PlayOneShotOnCamera(null); } } } if (trad.CanAdjustBy(-num * num2).Accepted) { Rect rect5 = new Rect(rect2.xMax, rect.y, 30f, rect.height); if (flag5) { rect5.width += rect5.width; } if (Widgets.ButtonText(rect5, ">", true, false, true)) { trad.AdjustBy(-num * num2); SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } if (!flag5) { string label2 = ">>"; int? num5 = null; int num6 = 0; for (int j = 0; j < TransferableUIUtility.stoppingPoints.Count; j++) { TransferableCountToTransferStoppingPoint transferableCountToTransferStoppingPoint2 = TransferableUIUtility.stoppingPoints[j]; if (positiveCountDirection == TransferablePositiveCountDirection.Destination) { if (trad.CountToTransfer < transferableCountToTransferStoppingPoint2.threshold && (transferableCountToTransferStoppingPoint2.threshold < num6 || !num5.HasValue)) { label2 = transferableCountToTransferStoppingPoint2.rightLabel; num5 = new int?(transferableCountToTransferStoppingPoint2.threshold); } } else if (trad.CountToTransfer > transferableCountToTransferStoppingPoint2.threshold && (transferableCountToTransferStoppingPoint2.threshold > num6 || !num5.HasValue)) { label2 = transferableCountToTransferStoppingPoint2.rightLabel; num5 = new int?(transferableCountToTransferStoppingPoint2.threshold); } } rect5.x += rect5.width; if (Widgets.ButtonText(rect5, label2, true, false, true)) { if (num5.HasValue) { trad.AdjustTo(num5.Value); } else if (num == 1) { trad.AdjustTo(trad.GetMinimumToTransfer()); } else { trad.AdjustTo(trad.GetMaximumToTransfer()); } SoundDefOf.Tick_Low.PlayOneShotOnCamera(null); } } } } if (trad.CountToTransfer != 0) { Rect position = new Rect(rect2.x + rect2.width / 2f - (float)(TransferableUIUtility.TradeArrow.width / 2), rect2.y + rect2.height / 2f - (float)(TransferableUIUtility.TradeArrow.height / 2), (float)TransferableUIUtility.TradeArrow.width, (float)TransferableUIUtility.TradeArrow.height); TransferablePositiveCountDirection positiveCountDirection2 = trad.PositiveCountDirection; if ((positiveCountDirection2 == TransferablePositiveCountDirection.Source && trad.CountToTransfer > 0) || (positiveCountDirection2 == TransferablePositiveCountDirection.Destination && trad.CountToTransfer < 0)) { position.x += position.width; position.width *= -1f; } GUI.DrawTexture(position, TransferableUIUtility.TradeArrow); } }
public static void IntEntry(Rect rect, ref int value, ref string editBuffer, int multiplier = 1, int min = 1, int max = 100) { int num = (int)rect.width / 8; int change; if (Widgets.ButtonText(new Rect(rect.xMin, rect.yMin, num, rect.height), "min".Translate().CapitalizeFirst())) { if (value != min) { value = min; editBuffer = value.ToStringCached(); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } if (Widgets.ButtonText(new Rect(rect.xMin + (float)num, rect.yMin, num, rect.height), (-10 * multiplier).ToStringCached())) { change = 10 * multiplier * GenUI.CurrentAdjustmentMultiplier(); if (value - change >= min) { value -= change; editBuffer = value.ToStringCached(); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } if (Widgets.ButtonText(new Rect(rect.xMin + (float)(num * 2), rect.yMin, num, rect.height), (-1 * multiplier).ToStringCached())) { change = multiplier * GenUI.CurrentAdjustmentMultiplier(); if (value - change >= min) { value -= change; editBuffer = value.ToStringCached(); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } if (Widgets.ButtonText(new Rect(rect.xMax - (float)(num * 3), rect.yMin, num, rect.height), "+" + multiplier.ToStringCached())) { change = multiplier * GenUI.CurrentAdjustmentMultiplier(); if (value + change <= max) { value += change; editBuffer = value.ToStringCached(); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } if (Widgets.ButtonText(new Rect(rect.xMax - (float)(num * 2), rect.yMin, num, rect.height), "+" + (10 * multiplier).ToStringCached())) { change = 10 * multiplier * GenUI.CurrentAdjustmentMultiplier(); if (value + change <= max) { value += change; editBuffer = value.ToStringCached(); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } if (Widgets.ButtonText(new Rect(rect.xMax - (float)num, rect.yMin, num, rect.height), "max".Translate().CapitalizeFirst())) { if (value != max) { value = max; editBuffer = value.ToStringCached(); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); } else { SoundDefOf.ClickReject.PlayOneShotOnCamera(); } } Widgets.TextFieldNumeric(new Rect(rect.xMin + (float)(num * 3), rect.yMin, rect.width - (float)(num * 6), rect.height), ref value, ref editBuffer, min, max); }
private static void Postfix(Zone_Growing __instance, ref IEnumerable <Gizmo> __result) { if (Find.Selector.NumSelected != 1) { return; } var data = __instance.GetFarmingHysteresisData(); var harvestedThingDef = __instance.GetPlantDefToGrow().plant.harvestedThingDef; var harvestHysteresisCommand = new Command_Toggle { defaultLabel = "FarmingHysteresis.EnableFarmingHysteresis".Translate(), defaultDesc = "FarmingHysteresis.EnableFarmingHysteresisisDesc".Translate(), icon = TexCommand.ForbidOff, isActive = () => data.Enabled, toggleAction = () => { if (data.Enabled) { data.Disable(__instance); } else { data.Enable(__instance); } } }; var result = new List <Gizmo>(__result); if (harvestedThingDef != null) { result.Add(harvestHysteresisCommand); } if (data.Enabled) { if (harvestedThingDef == null) { data.DisableDueToMissingHarvestedThingDef(__instance); return; } // If hysteresis is enabled, disable the manual sowing enabled button var sowingGizmo = result.Find(g => g is Command_Toggle t && t.defaultLabel == "CommandAllowSow".Translate()); result.Remove(sowingGizmo); var useGlobalValuesCommand = new Command_Toggle { defaultLabel = "FarmingHysteresis.UseGlobalValues".Translate(), defaultDesc = "FarmingHysteresis.UseGlobalValuesDesc".Translate(), icon = TexCommand.ForbidOff, isActive = () => data.useGlobalValues, toggleAction = () => { if (data.useGlobalValues || FarmingHysteresisMapComponent.For(Find.CurrentMap).HasBoundsFor(harvestedThingDef)) { // We were already using global values OR such global values already exist for this harvest type. // So just flip the value. data.useGlobalValues = !data.useGlobalValues; } else { // This is the first time this harvest type is switching to global values. // Copy the initial global values over from the local values for a better user experience. var currentLowerBound = data.LowerBound; var currentUpperBound = data.UpperBound; data.useGlobalValues = true; data.LowerBound = currentLowerBound; data.UpperBound = currentUpperBound; } } }; result.Add(useGlobalValuesCommand); Texture2D uiIcon = harvestedThingDef.uiIcon; var decrementLowerHysteresisCommand = new Command_Decrement { defaultLabel = "FarmingHysteresis.DecrementLowerHysteresis".Translate(GenUI.CurrentAdjustmentMultiplier()), defaultDesc = "FarmingHysteresis.DecrementLowerHysteresisDesc".Translate( GenUI.CurrentAdjustmentMultiplier(), KeyBindingDefOf.ModifierIncrement_10x.MainKeyLabel, KeyBindingDefOf.ModifierIncrement_100x.MainKeyLabel ), icon = uiIcon, action = () => data.LowerBound -= GenUI.CurrentAdjustmentMultiplier() }; result.Add(decrementLowerHysteresisCommand); var incrementLowerHysteresisCommand = new Command_Increment { defaultLabel = "FarmingHysteresis.IncrementLowerHysteresis".Translate(GenUI.CurrentAdjustmentMultiplier()), defaultDesc = "FarmingHysteresis.IncrementLowerHysteresisDesc".Translate( GenUI.CurrentAdjustmentMultiplier(), KeyBindingDefOf.ModifierIncrement_10x.MainKeyLabel, KeyBindingDefOf.ModifierIncrement_100x.MainKeyLabel ), icon = uiIcon, action = () => data.LowerBound += GenUI.CurrentAdjustmentMultiplier() }; result.Add(incrementLowerHysteresisCommand); var decrementUpperHysteresisCommand = new Command_Decrement { defaultLabel = "FarmingHysteresis.DecrementUpperHysteresis".Translate(GenUI.CurrentAdjustmentMultiplier()), defaultDesc = "FarmingHysteresis.DecrementUpperHysteresisDesc".Translate( GenUI.CurrentAdjustmentMultiplier(), KeyBindingDefOf.ModifierIncrement_10x.MainKeyLabel, KeyBindingDefOf.ModifierIncrement_100x.MainKeyLabel ), icon = uiIcon, action = () => data.UpperBound -= GenUI.CurrentAdjustmentMultiplier() }; result.Add(decrementUpperHysteresisCommand); var incrementUpperHysteresisCommand = new Command_Increment { defaultLabel = "FarmingHysteresis.IncrementUpperHysteresis".Translate(GenUI.CurrentAdjustmentMultiplier()), defaultDesc = "FarmingHysteresis.IncrementUpperHysteresisDesc".Translate( GenUI.CurrentAdjustmentMultiplier(), KeyBindingDefOf.ModifierIncrement_10x.MainKeyLabel, KeyBindingDefOf.ModifierIncrement_100x.MainKeyLabel ), icon = uiIcon, action = () => data.UpperBound += GenUI.CurrentAdjustmentMultiplier() }; result.Add(incrementUpperHysteresisCommand); } __result = result; }
public static void ItemMenu(Rect rect) { var mod = LoadedModManager.GetMod <TwitchToolkit>(); var scrollRect = new Rect(_padding + 300f, _padding + _height, 60f, 20f); var searchRect = new Rect(_padding, _padding + _height, 300f, 20f); searchquery = Widgets.TextField(searchRect, searchquery, 999, new Regex("^[a-z0-9_]*$", RegexOptions.IgnoreCase)); if (searchquery != "") { if (Widgets.ButtonText(scrollRect, "search")) { ItemScroll = 0; } } scrollRect.width = 40f; scrollRect.x += 60f; if (ItemScroll > 0) { if (Widgets.ButtonText(scrollRect, "up")) { ItemScroll = Math.Max(0, ItemScroll - 1); } } int count = 0; int scroll = 0; if (ItemScroll < (items.Count - count) - 8) { scrollRect.x += 40f; if (Widgets.ButtonText(scrollRect, "down")) { ItemScroll++; } } scrollRect.x = _padding + (rect.width - (_padding * 2)) / 2 + (rect.width - (_padding * 2)) / 4; scrollRect.width = (rect.width - (_padding * 2)) / 4; if (ResetItemStage == 0) { ResetAdminWarning = "Reset to Default"; } else if (ResetItemStage == 1) { ResetAdminWarning = "Are you sure?"; } else if (ResetItemStage == 2) { ResetAdminWarning = "One more time"; } else if (ResetItemStage == 3) { ResetItemStage = 0; ResetItemData(); mod.WriteSettings(); ItemMenu(rect); } if (Widgets.ButtonText(scrollRect, ResetAdminWarning)) { ResetItemStage += 1; } scrollRect.y += _height; Rect itemline = new Rect(_padding, _padding + _height, 600f, 30f); List <Item> query = items.Where(a => (a.abr.Contains(searchquery.ToLower()))).ToList(); foreach (Item item in query) { if (++scroll <= ItemScroll) { continue; } itemline.y += 30f; if (itemline.y > rect.height - 50f) { continue; } Rect smallButton = new Rect(300f, itemline.y, 40f, 30f); string pricelabel = (item.price) < 0 ? "Disabled" : item.price.ToString(); Widgets.Label(itemline, $"{ItemScroll + count + 1} - {item.abr}: {pricelabel}"); int newprice = item.price; if (Widgets.ButtonText(smallButton, "-" + 100)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); newprice -= 100 * GenUI.CurrentAdjustmentMultiplier(); if (newprice < 1) { newprice = 1; } } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "-" + 10)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); newprice -= 10 * GenUI.CurrentAdjustmentMultiplier(); if (newprice < 1) { newprice = 1; } } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "-" + 1)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); newprice -= 1 * GenUI.CurrentAdjustmentMultiplier(); if (newprice < 1) { newprice = 1; } } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "+" + 1)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice += 1 * GenUI.CurrentAdjustmentMultiplier(); } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "+" + 10)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice += 10 * GenUI.CurrentAdjustmentMultiplier(); } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "+" + 100)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice += 100 * GenUI.CurrentAdjustmentMultiplier(); } smallButton.x += 40f; smallButton.width = 60f; if (Widgets.ButtonText(smallButton, "Disable")) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice = -10; } ItemPrices[item.id] = newprice; item.price = newprice; count++; } }
public static void EventMenu(Rect rect) { var mod = LoadedModManager.GetMod <TwitchToolkit>(); var scrollRect = new Rect(_padding + 300f, _padding + _height, 60f, 20f); var searchRect = new Rect(_padding, _padding + _height, 300f, 20f); searchquery = Widgets.TextField(searchRect, searchquery, 999, new Regex("^[a-z0-9_]*$", RegexOptions.IgnoreCase)); if (searchquery != "") { if (Widgets.ButtonText(scrollRect, "search")) { ProductScroll = 0; } } scrollRect.width = 40f; scrollRect.x += 60f; if (ProductScroll > 0) { if (Widgets.ButtonText(scrollRect, "up")) { ProductScroll = Math.Max(0, ProductScroll - 1); } } int count = 0; int scroll = 0; scrollRect.x += 40f; if (ProductScroll < (products.Count - count) - 8) { if (Widgets.ButtonText(scrollRect, "down")) { ProductScroll++; } } scrollRect.x += 40f; if (Widgets.ButtonText(scrollRect, "x0.5")) { Products.MultiplyProductPrices(0.5); } scrollRect.x += 40f; if (Widgets.ButtonText(scrollRect, "x2")) { Products.MultiplyProductPrices(2); } scrollRect.x += 40f; if (Widgets.ButtonText(scrollRect, "x5")) { Products.MultiplyProductPrices(5); } scrollRect.x += 40f; if (Widgets.ButtonText(scrollRect, "x10")) { Products.MultiplyProductPrices(10); } scrollRect.x += 40f; scrollRect.width = (150f); if (ResetProductStage == 0) { ResetAdminWarning = "Reset to Default"; } else if (ResetProductStage == 1) { ResetAdminWarning = "Are you sure?"; } else if (ResetProductStage == 2) { ResetAdminWarning = "One more time"; } else if (ResetProductStage == 3) { ResetProductStage = 0; ResetProductData(); EventMenu(rect); } if (Widgets.ButtonText(scrollRect, ResetAdminWarning)) { ResetProductStage += 1; } scrollRect.y += _height; Rect productline = new Rect(_padding, _padding + _height, 600f, 30f); List <Product> query = products.Where(a => (a.abr.Contains(searchquery))).ToList(); foreach (Product product in query) { if (++scroll <= ProductScroll) { continue; } productline.y += 30f; if (productline.y > rect.height - 50f) { continue; } Rect smallButton = new Rect(300f, productline.y, 40f, 30f); string pricelabel = (product.amount) < 0 ? "Disabled" : product.amount.ToString(); Widgets.Label(productline, $"{ProductScroll + count + 1} - {product.name}: {pricelabel}"); int newprice = product.amount; if (Widgets.ButtonText(smallButton, "-" + 500)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); newprice -= 500 * GenUI.CurrentAdjustmentMultiplier(); if (newprice < 50) { newprice = 50; } } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "-" + 50)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); newprice -= 50 * GenUI.CurrentAdjustmentMultiplier(); if (newprice < 50) { newprice = 50; } } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "-" + 10)) { SoundDefOf.AmountDecrement.PlayOneShotOnCamera(); newprice -= 10 * GenUI.CurrentAdjustmentMultiplier(); if (newprice < 50) { newprice = 50; } } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "+" + 10)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice += 10 * GenUI.CurrentAdjustmentMultiplier(); } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "+" + 50)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice += 50 * GenUI.CurrentAdjustmentMultiplier(); } smallButton.x += 40f; if (Widgets.ButtonText(smallButton, "+" + 500)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice += 500 * GenUI.CurrentAdjustmentMultiplier(); } string karmabutton = product.karmatype.ToString(); smallButton.x += 60f; smallButton.width = 60f; if (Widgets.ButtonText(smallButton, karmabutton)) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); if (product.karmatype == KarmaType.Doom) { product.karmatype = 0; ProductKarmaTypes[product.id] = 0; } else { product.karmatype = product.karmatype + 1; ProductKarmaTypes[product.id] = ProductKarmaTypes[product.id] + 1; } } smallButton.x += 60f; if (Widgets.ButtonText(smallButton, "Disable")) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); newprice = -10; } smallButton.x += 60f; if (Widgets.ButtonText(smallButton, "Max: " + ProductMaxEvents[product.id])) { SoundDefOf.AmountIncrement.PlayOneShotOnCamera(); if (ProductMaxEvents[product.id] < 10) { ProductMaxEvents[product.id]++; } else { ProductMaxEvents[product.id] = 1; } } ProductAmounts[product.id] = newprice; product.amount = newprice; count++; } }