public override void DoWindowContents(Rect inRect) { // Title GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Text.Font = GameFont.Medium; var titleRect = new Rect(0f, 0f, inRect.width, 40f); Widgets.Label(titleRect, "Dialog_EditNames_Title".Translate()); Text.Font = GameFont.Tiny; GenUI.ResetLabelAlign(); //Name list var scrollViewVisible = new Rect(0f, titleRect.height + 10, inRect.width, inRect.height - titleRect.height - 60f); var scrollBarVisible = SettingsHandler.STATE_LIMIT * 42f > scrollViewVisible.height; var scrollViewTotal = new Rect(0f, 0f - 10f, scrollViewVisible.width - (scrollBarVisible ? ScrollBarWidthMargin : 0) - 20f, SettingsHandler.STATE_LIMIT * 42f); Widgets.BeginScrollView(scrollViewVisible, ref scrollPosition, scrollViewTotal); if (SettingsHandler.DoStateNamesDrawerContents(scrollViewTotal)) { settingsHaveChanged = true; } Widgets.EndScrollView(); }
public override void DoWindowContents(Rect inRect) { var contentRect = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f); bool scrollBarVisible = totalContentHeight > contentRect.height; var scrollViewTotal = new Rect(0f, 0f, contentRect.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.DrawHighlight(contentRect); Widgets.BeginScrollView(contentRect, ref scrollPosition, scrollViewTotal); float curY = 0f; Rect r = new Rect(0, curY, scrollViewTotal.width, LabelHeight); Widgets.CheckboxLabeled(r, "LWMDSperDSUturnOn".Translate(), ref Settings.allowPerDSUSettings);//TODO TooltipHandler.TipRegion(r, "LWMDSperDSUturnOnDesc".Translate()); curY += LabelHeight + 1f; if (!Settings.allowPerDSUSettings) { r = new Rect(5f, curY, scrollViewTotal.width - 10f, LabelHeight); Widgets.Label(r, "LWMDSperDSUWarning".Translate()); curY += LabelHeight; } Widgets.DrawLineHorizontal(0f, curY, scrollViewTotal.width); curY += 10f; // todo: make this static? //List<ThingDef> l=DefDatabase<ThingDef>.AllDefsListForReading.Where(ThingDef d => d.Has // Roll my own buttons, because dammit, I want left-justified buttons: // (mirroring Widgets.ButtonTextWorker) GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var bg = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBG", true); var bgmouseover = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGMouseover", true); var bgclick = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGClick", true); // note: make own list b/c this can modify what's in the DefDatabase. foreach (ThingDef u in Settings.AllDeepStorageUnits.ToList()) { //////////////// Disble button: ////////////////// // disabled if it's already been disabled previously // or if it's slated to be disabled on window close bool isEnabled = !tracker.HasDefaultValueFor(u.defName, "def") && (this.unitsToBeDisabled == null || !unitsToBeDisabled.Contains(u)); bool wasEnabled = isEnabled; Rect disableRect = new Rect(5f, curY, LabelHeight, LabelHeight); TooltipHandler.TipRegion(disableRect, "TODO: Add description. But basically, you can disable some units and they won't show up in game.\n\nVERY likely to cause unimportant errors in saved games."); Widgets.Checkbox(disableRect.x, disableRect.y, ref isEnabled, LabelHeight, false, true, null, null); if (!isEnabled && wasEnabled) // newly disabled { Utils.Warn(Utils.DBF.Settings, "Marking unit for disabling: " + u.defName); if (unitsToBeDisabled == null) { unitsToBeDisabled = new HashSet <ThingDef>(); } unitsToBeDisabled.Add(u); // hash sets don't care if it's already there! } if (isEnabled && !wasEnabled) // add back: { Utils.Warn(Utils.DBF.Settings, "Restoring disabled unit: " + u.defName); if (unitsToBeDisabled != null && unitsToBeDisabled.Contains(u)) { unitsToBeDisabled.Remove(u); } if (tracker.HasDefaultValueFor(u.defName, "def")) { tracker.Remove(u.defName, "def"); } if (!DefDatabase <ThingDef> .AllDefsListForReading.Contains(u)) { ReturnDefToUse(u); } } //////////////// Select def: ////////////////// r = new Rect(10f + LabelHeight, curY, (scrollViewTotal.width) * 2 / 3 - 12f - LabelHeight, LabelHeight); // Draw button-ish background: Texture2D atlas = bg; if (Mouse.IsOver(r)) { atlas = bgmouseover; if (Input.GetMouseButton(0)) { atlas = bgclick; } } Widgets.DrawAtlas(r, atlas); // button text: Widgets.Label(r, u.label + " (defName: " + u.defName + ")"); // button clickiness: if (Widgets.ButtonInvisible(r)) { Find.WindowStack.Add(new Dialog_DSU_Settings(u)); } //////////////// Reset button: ////////////////// r = new Rect((scrollViewTotal.width) * 2 / 3 + 2f, curY, (scrollViewTotal.width) / 3 - 7f, LabelHeight); if (tracker.IsChanged(u.defName) && Widgets.ButtonText(r, "ResetBinding".Translate())) { ResetDSUToDefaults(u.defName); } curY += LabelHeight + 2f; } GenUI.ResetLabelAlign(); // end buttons Widgets.EndScrollView(); // close button: r = new Rect(inRect.width / 2 - (CloseButSize.x / 2), inRect.height - CloseButSize.y - 5f, CloseButSize.x, CloseButSize.y); if (Widgets.ButtonText(r, "CloseButton".Translate())) { if (unitsToBeDisabled != null && unitsToBeDisabled.Count > 0) { //TODO: add out-of-order flag. foreach (ThingDef d in unitsToBeDisabled) { Utils.Warn(Utils.DBF.Settings, "Closing Window: Removing def: " + d.defName); RemoveDefFromUse(d); tracker.AddDefaultValue(d.defName, "def", d); } unitsToBeDisabled = null; } Close(); } r = new Rect(10f, inRect.height - CloseButSize.y - 5f, 2 * CloseButSize.x, CloseButSize.y); if (tracker.HasAnyDefaultValues && Widgets.ButtonText(r, "LWM.ResetAllToDefault".Translate())) { Utils.Mess(Utils.DBF.Settings, "Resetting all per-building storage settings to default:"); ResetAllToDefaults(); } totalContentHeight = curY; }
public static void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index % 2 == 1) { GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0) { Rect rect2 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegion(rect2, "TraderCount".Translate()); Rect rect4 = new Rect((float)(rect2.x - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleRight; TradeUI.DrawPrice(rect4, trad, TradeAction.PlayerBuys); } width = (float)(width - 175.0); Rect rect5 = new Rect((float)(width - 240.0), 0f, 240f, rect.height); if (trad.TraderWillTrade) { bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1.0 && trad.IsCurrency; TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash, null); } else { TradeUI.DrawWillNotTradeIndication(rect, trad); } width = (float)(width - 240.0); int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect6 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; TradeUI.DrawPrice(rect6, trad, TradeAction.PlayerSells); Rect rect7 = new Rect((float)(rect6.x - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, num2.ToStringCached()); TooltipHandler.TipRegion(rect7, "ColonyCount".Translate()); } width = (float)(width - 175.0); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, (!trad.TraderWillTrade) ? TradeUI.NoTradeColor : Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect(num - 240f, 0f, 240f, rect.height); TransferableOneWayWidget.stoppingPoints.Clear(); if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage)) { float num2 = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = (num2 > 0f) ? Mathf.FloorToInt(num2 / this.GetMass(trad.AnyThing)) : 0; TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Pawn pawn = trad.AnyThing as Pawn; bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony); Rect rect3 = rect2; int min = 0; int max = maxCount; List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints; TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints, this.playerPawnsReadOnly && flag); num -= 240f; if (this.drawMarketValue) { Rect rect4 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMarketValue(rect4, trad); num -= 100f; } if (this.drawMass) { Rect rect5 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMass(rect5, trad, availableMass); num -= 100f; } if (this.drawDaysUntilRot) { Rect rect6 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawDaysUntilRot(rect6, trad); num -= 75f; } if (this.drawItemNutrition) { Rect rect7 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawItemNutrition(rect7, trad); num -= 75f; } if (this.drawForagedFoodPerDay) { Rect rect8 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; if (!this.DrawGrazeability(rect8, trad)) { this.DrawForagedFoodPerDay(rect8, trad); } num -= 75f; } if (this.drawNutritionEatenPerDay) { Rect rect9 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawNutritionEatenPerDay(rect9, trad); num -= 75f; } if (this.ShouldShowCount(trad)) { Rect rect10 = new Rect(num - 75f, 0f, 75f, rect.height); Widgets.DrawHighlightIfMouseover(rect10); Text.Anchor = TextAnchor.MiddleLeft; Rect rect11 = rect10; rect11.xMin += 5f; rect11.xMax -= 5f; Widgets.Label(rect11, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect10, this.sourceCountDesc); } num -= 75f; if (this.drawEquippedWeapon) { Rect rect12 = new Rect(num - 30f, 0f, 30f, rect.height); Rect iconRect = new Rect(num - 30f, (rect.height - 30f) / 2f, 30f, 30f); this.DrawEquippedWeapon(rect12, iconRect, trad); num -= 30f; } Pawn pawn2 = trad.AnyThing as Pawn; if (pawn2 != null && pawn2.def.race.Animal) { Rect rect13 = new Rect(num - TransferableOneWayWidget.BondIconWidth, (rect.height - TransferableOneWayWidget.BondIconWidth) / 2f, TransferableOneWayWidget.BondIconWidth, TransferableOneWayWidget.BondIconWidth); num -= TransferableOneWayWidget.BondIconWidth; Rect rect14 = new Rect(num - TransferableOneWayWidget.PregnancyIconWidth, (rect.height - TransferableOneWayWidget.PregnancyIconWidth) / 2f, TransferableOneWayWidget.PregnancyIconWidth, TransferableOneWayWidget.PregnancyIconWidth); num -= TransferableOneWayWidget.PregnancyIconWidth; string iconTooltipText = TrainableUtility.GetIconTooltipText(pawn2); if (!iconTooltipText.NullOrEmpty()) { TooltipHandler.TipRegion(rect13, iconTooltipText); } if (pawn2.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, null) != null) { GUI.DrawTexture(rect13, TransferableOneWayWidget.BondIcon); } if (pawn2.health.hediffSet.HasHediff(HediffDefOf.Pregnant, true)) { TooltipHandler.TipRegion(rect14, PawnColumnWorker_Pregnant.GetTooltipText(pawn2)); GUI.DrawTexture(rect14, TransferableOneWayWidget.PregnantIcon); } } Rect idRect = new Rect(0f, 0f, num, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DrawItemRow(Rect rect, ThingDef thing, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Color white = GUI.color; if (tradeablesPrices[index] < 1) { GUI.color = ColorLibrary.Grey; } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; Rect rect1 = new Rect(num - 100f, 0f, 100f, rect.height); rect1 = rect1.Rounded(); int newPrice = tradeablesPrices[index]; string label = newPrice.ToString(); rect1.xMax -= 5f; rect1.xMin += 5f; if (Text.Anchor == TextAnchor.MiddleLeft) { rect1.xMax += 300f; } if (Text.Anchor == TextAnchor.MiddleRight) { rect1.xMin -= 300f; } Rect rect2 = new Rect(num - 560f, 0f, 240f, rect.height); if (newPrice > 0) { if (Widgets.ButtonText(rect1, "Disable")) { newPrice = -10; } tradeablesPrices[index] = newPrice; } if (newPrice > 0) { Widgets.IntEntry(rect2, ref newPrice, ref label, 50); tradeablesPrices[index] = newPrice; } else { if (Widgets.ButtonText(rect2, "Reset")) { tradeablesPrices[index] = Convert.ToInt32(thing.BaseMarketValue * 10 / 6); } } Rect categoryLabel = new Rect(num - 300, 0f, 200f, rect.height); Widgets.Label(categoryLabel, thing.FirstThingCategory.LabelCap); Rect rect3 = new Rect(0f, 0f, 27f, 27f); Widgets.ThingIcon(rect3, thing); Widgets.InfoCardButton(40f, 0f, thing); Text.Anchor = TextAnchor.MiddleLeft; Rect rect4 = new Rect(80f, 0f, rect.width - 80f, rect.height); Text.WordWrap = false; GUI.color = Color.white; Widgets.Label(rect4, thing.LabelCap); Text.WordWrap = true; GenUI.ResetLabelAlign(); GUI.EndGroup(); GUI.color = white; }
private static float DrawOverviewTab(Rect leftRect, Pawn pawn, float curY) { curY += 4f; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperLeft; GUI.color = new Color(0.9f, 0.9f, 0.9f); string str = ((pawn.gender == Gender.None) ? ((string)"PawnSummary".Translate(pawn.Named("PAWN"))) : ((string)"PawnSummaryWithGender".Translate(pawn.Named("PAWN")))); Rect rect = new Rect(0f, curY, leftRect.width, 34f); Widgets.Label(rect, str.CapitalizeFirst()); if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, () => pawn.ageTracker.AgeTooltipString, 73412); Widgets.DrawHighlight(rect); } GUI.color = Color.white; curY += 34f; bool flag = pawn.RaceProps.IsFlesh && (pawn.Faction == Faction.OfPlayer || pawn.HostFaction == Faction.OfPlayer || (pawn.NonHumanlikeOrWildMan() && pawn.InBed() && pawn.CurrentBed().Faction == Faction.OfPlayer)); if (pawn.foodRestriction != null && pawn.foodRestriction.Configurable) { Rect rect2 = new Rect(0f, curY, leftRect.width * 0.42f, 23f); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect2, "FoodRestriction".Translate()); GenUI.ResetLabelAlign(); if (Widgets.ButtonText(new Rect(rect2.width, curY, leftRect.width - rect2.width, 23f), pawn.foodRestriction.CurrentFoodRestriction.label)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); List <FoodRestriction> allFoodRestrictions = Current.Game.foodRestrictionDatabase.AllFoodRestrictions; for (int i = 0; i < allFoodRestrictions.Count; i++) { FoodRestriction localRestriction = allFoodRestrictions[i]; list.Add(new FloatMenuOption(localRestriction.label, delegate { pawn.foodRestriction.CurrentFoodRestriction = localRestriction; })); } list.Add(new FloatMenuOption("ManageFoodRestrictions".Translate(), delegate { Find.WindowStack.Add(new Dialog_ManageFoodRestrictions(null)); })); Find.WindowStack.Add(new FloatMenu(list)); } curY += 23f; } if (pawn.IsColonist && !pawn.Dead) { bool selfTend = pawn.playerSettings.selfTend; Rect rect3 = new Rect(0f, curY, leftRect.width, 24f); Widgets.CheckboxLabeled(rect3, "SelfTend".Translate(), ref pawn.playerSettings.selfTend); if (pawn.playerSettings.selfTend && !selfTend) { if (pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor)) { pawn.playerSettings.selfTend = false; Messages.Message("MessageCannotSelfTendEver".Translate(pawn.LabelShort, pawn), MessageTypeDefOf.RejectInput, historical: false); } else if (pawn.workSettings.GetPriority(WorkTypeDefOf.Doctor) == 0) { Messages.Message("MessageSelfTendUnsatisfied".Translate(pawn.LabelShort, pawn), MessageTypeDefOf.CautionInput, historical: false); } } if (Mouse.IsOver(rect3)) { TooltipHandler.TipRegion(rect3, "SelfTendTip".Translate(Faction.OfPlayer.def.pawnsPlural, 0.7f.ToStringPercent()).CapitalizeFirst()); } curY += 28f; } if (flag && pawn.playerSettings != null && !pawn.Dead && Current.ProgramState == ProgramState.Playing) { MedicalCareUtility.MedicalCareSetter(new Rect(0f, curY, 140f, 28f), ref pawn.playerSettings.medCare); if (Widgets.ButtonText(new Rect(leftRect.width - 70f, curY, 70f, 28f), "MedGroupDefaults".Translate())) { Find.WindowStack.Add(new Dialog_MedicalDefaults()); } curY += 32f; } Text.Font = GameFont.Small; if (pawn.def.race.IsFlesh) { Pair <string, Color> painLabel = GetPainLabel(pawn); string painTip = GetPainTip(pawn); curY = DrawLeftRow(leftRect, curY, "PainLevel".Translate(), painLabel.First, painLabel.Second, painTip); } if (!pawn.Dead) { IEnumerable <PawnCapacityDef> source = (pawn.def.race.Humanlike ? DefDatabase <PawnCapacityDef> .AllDefs.Where((PawnCapacityDef x) => x.showOnHumanlikes) : ((!pawn.def.race.Animal) ? DefDatabase <PawnCapacityDef> .AllDefs.Where((PawnCapacityDef x) => x.showOnMechanoids) : DefDatabase <PawnCapacityDef> .AllDefs.Where((PawnCapacityDef x) => x.showOnAnimals))); { foreach (PawnCapacityDef item in source.OrderBy((PawnCapacityDef act) => act.listOrder)) { if (PawnCapacityUtility.BodyCanEverDoCapacity(pawn.RaceProps.body, item)) { PawnCapacityDef activityLocal = item; Pair <string, Color> efficiencyLabel = GetEfficiencyLabel(pawn, item); Func <string> textGetter = () => (!pawn.Dead) ? GetPawnCapacityTip(pawn, activityLocal) : ""; curY = DrawLeftRow(leftRect, curY, item.GetLabelFor(pawn.RaceProps.IsFlesh, pawn.RaceProps.Humanlike).CapitalizeFirst(), efficiencyLabel.First, efficiencyLabel.Second, new TipSignal(textGetter, pawn.thingIDNumber ^ item.index)); } } return(curY); } } return(curY); }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { GUI.DrawTexture(rect, TradeUI.TradeAlternativeBGTex); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect((float)(width - 240.0), 0f, 240f, rect.height); TransferableOneWayWidget.stoppingPoints.Clear(); if (this.availableMassGetter != null && (!(trad.AnyThing is Pawn) || this.includePawnsMassInMassUsage)) { float num = availableMass + this.GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = (!(num <= 0.0)) ? Mathf.FloorToInt(num / this.GetMass(trad.AnyThing)) : 0; TransferableOneWayWidget.stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Rect rect3 = rect2; int min = 0; int max = maxCount; List <TransferableCountToTransferStoppingPoint> extraStoppingPoints = TransferableOneWayWidget.stoppingPoints; TransferableUIUtility.DoCountAdjustInterface(rect3, trad, index, min, max, false, extraStoppingPoints); width = (float)(width - 240.0); if (this.drawMarketValue) { Rect rect4 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMarketValue(rect4, trad); width = (float)(width - 100.0); } if (this.drawMass) { Rect rect5 = new Rect((float)(width - 100.0), 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawMass(rect5, trad, availableMass); width = (float)(width - 100.0); } if (this.drawDaysUntilRotForTile >= 0) { Rect rect6 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; this.DrawDaysUntilRot(rect6, trad); width = (float)(width - 75.0); } Rect rect7 = new Rect((float)(width - 75.0), 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect7, this.sourceCountDesc); width = (float)(width - 75.0); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DoArchivableRow(Rect rect, IArchivable archivable, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Widgets.DrawHighlightIfMouseover(rect); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Text.WordWrap = false; Rect rect2 = rect; Rect rect3 = rect2; rect3.width = 30f; rect2.xMin += 35f; float num = Find.Archive.IsPinned(archivable) ? 1f : ((!Mouse.IsOver(rect3)) ? 0f : 0.25f); Rect position = new Rect(rect3.x + (rect3.width - 22f) / 2f, rect3.y + (rect3.height - 22f) / 2f, 22f, 22f).Rounded(); if (num > 0f) { GUI.color = new Color(1f, 1f, 1f, num); GUI.DrawTexture(position, PinTex); } else { GUI.color = PinOutlineColor; GUI.DrawTexture(position, PinOutlineTex); } GUI.color = Color.white; Rect rect4 = rect2; Rect outerRect = rect2; outerRect.width = 30f; rect2.xMin += 35f; Texture archivedIcon = archivable.ArchivedIcon; if (archivedIcon != null) { GUI.color = archivable.ArchivedIconColor; Widgets.DrawTextureFitted(outerRect, archivedIcon, 0.8f); GUI.color = Color.white; } Rect rect5 = rect2; rect5.width = 80f; rect2.xMin += 85f; Vector2 location = (Find.CurrentMap != null) ? Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile) : default(Vector2); GUI.color = new Color(0.75f, 0.75f, 0.75f); Widgets.Label(label: GenDate.DateShortStringAt(GenDate.TickGameToAbs(archivable.CreatedTicksGame), location).Truncate(rect5.width), rect: rect5); GUI.color = Color.white; Rect rect6 = rect2; Widgets.Label(rect6, archivable.ArchivedLabel.Truncate(rect6.width)); GenUI.ResetLabelAlign(); Text.WordWrap = true; TooltipHandler.TipRegionByKey(rect3, "PinArchivableTip", 200); if (Mouse.IsOver(rect4)) { displayedMessageIndex = index; } if (Widgets.ButtonInvisible(rect3)) { if (Find.Archive.IsPinned(archivable)) { Find.Archive.Unpin(archivable); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(); } else { Find.Archive.Pin(archivable); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(); } } if (!Widgets.ButtonInvisible(rect4)) { return; } if (Event.current.button == 1) { LookTargets lookTargets = archivable.LookTargets; if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget())) { CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget()); Find.MainTabsRoot.EscapeCurrentTab(); } } else { archivable.OpenArchived(); } }
private void DrawTradeableRow(Rect rowRect, ThingEntry entry, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rowRect); } var trade = entry.tradeable; // Begin Row group GUI.BeginGroup(rowRect); float x = 0; // starting from left // Draw item icon and info icon Text.Anchor = TextAnchor.MiddleLeft; var idRect = new Rect(x, 0, iconNameAreaWidth, rowRect.height); TransferableUIUtility.DoExtraAnimalIcons(trade, rowRect, ref x); DrawTradeableLabels(idRect, entry); x += iconNameAreaWidth; // Draw the price for requesting the item var priceTextArea = new Rect(x, 0, priceTextAreaWidth, rowRect.height); var price = DrawPrice(priceTextArea, trade); x += priceTextAreaWidth; // Draw the number the colony currently has, if any var countHeldBy = trade.CountHeldBy(Transactor.Colony); if (countHeldBy != 0) { var colonyItemCountArea = new Rect(x, 0, colonyItemCountAreaWidth, rowRect.height); if (Mouse.IsOver(colonyItemCountArea)) { Widgets.DrawHighlight(colonyItemCountArea); } var paddedRect = colonyItemCountArea; paddedRect.xMin += 5f; paddedRect.xMax -= 5f; Widgets.Label(paddedRect, countHeldBy.ToStringCached()); TooltipHandler.TipRegion(colonyItemCountArea, colonyCountTooltipText); } // Draw the input box to select number of requests var countAdjustInterfaceRect = new Rect(rightAlignOffset, 0, rightContentSize, rowRect.height); var interactiveNumericFieldArea = new Rect(countAdjustInterfaceRect.center.x - 45f, countAdjustInterfaceRect.center.y - 12.5f, 90f, 25f).Rounded(); var paddedNumericFieldArea = interactiveNumericFieldArea.ContractedBy(2f); paddedNumericFieldArea.xMax -= 15f; paddedNumericFieldArea.xMin += 16f; if (requestSession?.deal != null) { var amountRequested = requestSession.deal.GetCountForItem(thingTypeFilter, trade); var amountAsString = amountRequested.ToString(); Widgets.TextFieldNumeric(paddedNumericFieldArea, ref amountRequested, ref amountAsString, 0, float.MaxValue); requestSession.deal.AdjustItemRequest(thingTypeFilter, entry, amountRequested, price); // Draw the reset to zero button by input field if (amountRequested > 0) { var resetToZeroButton = interactiveNumericFieldArea; resetToZeroButton.x -= resetItemCountAreaWidth - 5; resetToZeroButton.width = resetItemCountAreaWidth; if (Widgets.ButtonText(resetToZeroButton, "0")) { requestSession.deal.AdjustItemRequest(thingTypeFilter, entry, 0, price); } } } // End Row group GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect(num - 240f, 0f, 240f, rect.height); stoppingPoints.Clear(); if (availableMassGetter != null && (!(trad.AnyThing is Pawn) || includePawnsMassInMassUsage)) { float num2 = availableMass + GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = (num2 <= 0f) ? 0 : Mathf.FloorToInt(num2 / GetMass(trad.AnyThing)); stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } VehiclePawn pawn = trad.AnyThing as VehiclePawn; bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony); UIHelper.DoCountAdjustInterface(rect2, trad, AvailablePawns, index, 0, maxCount, false, stoppingPoints, playerPawnsReadOnly && flag); num -= 240f; if (drawMarketValue) { Rect rect3 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawMarketValue(rect3, trad); num -= 100f; } if (drawMass) { Rect rect4 = new Rect(num - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawMass(rect4, trad, availableMass); num -= 100f; } if (drawFishPerDay) { Rect rect7 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; if (!DrawGrazeability(rect7, trad)) { DrawForagedFoodPerDay(rect7, trad); } num -= 75f; } if (drawNutritionEatenPerDay) { Rect rect8 = new Rect(num - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawNutritionEatenPerDay(rect8, trad); num -= 75f; } num -= 150f; //... num -= 75f; Rect idRect = new Rect(0f, 0f, num, rect.height); UIHelper.DrawVehicleTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
// draws the label and appropriate input for a single setting private void DrawHandleEntry(SettingHandle handle, Rect parentRect, ref float curY, float scrollViewHeight) { var entryHeight = HandleEntryHeight; if (handle.CustomDrawer != null && handle.CustomDrawerHeight > entryHeight) { entryHeight = handle.CustomDrawerHeight + HandleEntryPadding * 2; } var skipDrawing = curY - scrollPosition.y + entryHeight <0f || curY - scrollPosition.y> scrollViewHeight; if (!skipDrawing) { var entryRect = new Rect(parentRect.x, parentRect.y + curY, parentRect.width, entryHeight).ContractedBy(HandleEntryPadding); var mouseOver = Mouse.IsOver(entryRect); if (mouseOver) { Widgets.DrawHighlight(entryRect); } var controlRect = new Rect(entryRect.x + entryRect.width / 2f, entryRect.y, entryRect.width / 2f, entryRect.height); GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var leftHalfRect = new Rect(entryRect.x, entryRect.y, entryRect.width / 2f - HandleEntryPadding, entryRect.height); var labelRect = handle.CustomDrawer == null ? leftHalfRect : entryRect; // give full width to the label just in case Widgets.Label(labelRect, handle.Title); GenUI.ResetLabelAlign(); bool valueChanged = false; if (handle.CustomDrawer == null) { SettingsHandleDrawer drawer; var handleType = handle.ValueType; if (handleType.IsEnum) { handleType = typeof(Enum); } handleDrawers.TryGetValue(handleType, out drawer); if (drawer == null) { drawer = defaultHandleDrawer; } valueChanged = drawer(handle, controlRect, handleControlInfo[handle]); } else { try { valueChanged = handle.CustomDrawer(controlRect); } catch (Exception e) { HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, "SettingsHandle.CustomDrawer"); } } if (valueChanged) { settingsHaveChanged = true; } if (mouseOver) { if (!handle.Description.NullOrEmpty()) { TooltipHandler.TipRegion(entryRect, handle.Description); } if (Input.GetMouseButtonUp(1)) { var options = new List <FloatMenuOption>(1); options.Add(new FloatMenuOption("HugsLib_settings_resetValue".Translate(), () => { ResetSetting(handle); })); Find.WindowStack.Add(new FloatMenu(options)); } } } curY += entryHeight; }
protected void DrawLoadPresetList(Rect inRect) { DrawEntryHeader("Preset Files: Load mode", backgroundColor: Color.green); var presetFiles = _userData.PresetManager.AllPresetFiles; if (presetFiles == null) { Log.ErrorOnce("[PrepareLanding] PresetManager.AllPresetFiles is null.", 0x1238cafe); return; } var presetFilesCount = presetFiles.Count; if (presetFiles.Count == 0) { ListingStandard.Label("No existing presets."); return; } // add a gap before the scroll view ListingStandard.Gap(DefaultGapLineHeight); /* * Buttons */ var buttonsRectSpace = ListingStandard.GetRect(30f); var splittedRect = buttonsRectSpace.SplitRectWidthEvenly(_buttonList.Count); for (var i = 0; i < _buttonList.Count; i++) { // get button descriptor var buttonDescriptor = _buttonList[i]; // display button; if clicked: call the related action if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label)) { buttonDescriptor.Action(); } // display tool-tip (if any) if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip)) { TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip); } } /* * Label */ // number of elements (tiles) to display var itemsToDisplay = Math.Min(presetFilesCount - _listDisplayStartIndex, MaxItemsToDisplay); // label to display where we actually are in the tile list GenUI.SetLabelAlign(TextAnchor.MiddleCenter); var heightBefore = ListingStandard.StartCaptureHeight(); ListingStandard.Label( $"{_listDisplayStartIndex}: {_listDisplayStartIndex + itemsToDisplay - 1} / {presetFilesCount - 1}", DefaultElementHeight); GenUI.ResetLabelAlign(); var counterLabelRect = ListingStandard.EndCaptureHeight(heightBefore); Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f); // add a gap before the scroll view ListingStandard.Gap(DefaultGapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - 30f; // height of the 'virtual' portion of the scroll view var scrollableViewHeight = itemsToDisplay * DefaultElementHeight + DefaultGapLineHeight * MaxItemsToDisplay; /* * Scroll view */ var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosPresetFiles, 16f); var endIndex = _listDisplayStartIndex + itemsToDisplay; for (var i = _listDisplayStartIndex; i < endIndex; i++) { var selectedPresetFile = presetFiles[i]; var labelText = Path.GetFileNameWithoutExtension(selectedPresetFile.Name); // display the label var labelRect = innerLs.GetRect(DefaultElementHeight); var selected = i == _selectedItemIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter)) { // save item index _selectedItemIndex = i; _selectedFileName = labelText; } // add a thin line between each label innerLs.GapLine(DefaultGapLineHeight); } ListingStandard.EndScrollView(innerLs); }
protected void AddMinimizedWindowContent(Listing_Standard listingStandard, Rect inRect) { /* constants used for GUI elements */ // default line height const float gapLineHeight = 4f; // default visual element height const float elementHeight = 30f; //check if we have something to display (tiles) var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles; var matchingTilesCount = matchingTiles.Count; if (matchingTilesCount == 0) { // revert to initial window size if needed MinimizedWindow.windowRect.height = MinimizedWindow.InitialSize.y; return; } /* * Buttons */ if (listingStandard.ButtonText("Clear Filtered Tiles")) { // clear everything PrepareLanding.Instance.TileFilter.ClearMatchingTiles(); // reset starting display index _tileDisplayIndexStart = 0; // reset selected index _selectedTileIndex = -1; // don't go further as there are no tile content to draw return; } var buttonsRectSpace = listingStandard.GetRect(30f); var splittedRect = buttonsRectSpace.SplitRectWidthEvenly(_minimizedWindowButtonsDescriptorList.Count); for (var i = 0; i < _minimizedWindowButtonsDescriptorList.Count; i++) { // get button descriptor var buttonDescriptor = _minimizedWindowButtonsDescriptorList[i]; // display button; if clicked: call the related action if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label)) { buttonDescriptor.Action(); } // display tool-tip (if any) if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip)) { TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip); } } /* * Display label (where we actually are in the tile list) */ // number of elements (tiles) to display var itemsToDisplay = Math.Min(matchingTilesCount - _tileDisplayIndexStart, MaxDisplayedTileWhenMinimized); // label to display where we actually are in the tile list GenUI.SetLabelAlign(TextAnchor.MiddleCenter); var heightBefore = listingStandard.StartCaptureHeight(); listingStandard.Label( $"{_tileDisplayIndexStart}: {_tileDisplayIndexStart + itemsToDisplay - 1} / {matchingTilesCount - 1}", elementHeight); GenUI.ResetLabelAlign(); var counterLabelRect = listingStandard.EndCaptureHeight(heightBefore); Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f); // add a gap before the scroll view listingStandard.Gap(gapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = inRect.height - listingStandard.CurHeight; // recalculate window height: initial size + visible scroll view height + current height of the listing standard (hence accounting for all buttons above) var newWindowHeight = MinimizedWindow.InitialSize.y + maxScrollViewOuterHeight + listingStandard.CurHeight; // minimized window height can't be more than 70% of the screen height MinimizedWindow.windowRect.height = Mathf.Min(newWindowHeight, UI.screenHeight * 0.70f); // height of the 'virtual' portion of the scroll view var scrollableViewHeight = itemsToDisplay * elementHeight + gapLineHeight * MaxDisplayedTileWhenMinimized; /* * Scroll view */ var innerLs = listingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosMatchingTiles, 16f); var endIndex = _tileDisplayIndexStart + itemsToDisplay; for (var i = _tileDisplayIndexStart; i < endIndex; i++) { var selectedTileId = matchingTiles[i]; // get latitude & longitude for the tile var vector = Find.WorldGrid.LongLatOf(selectedTileId); var labelText = $"{i}: {vector.y.ToStringLatitude()} {vector.x.ToStringLongitude()}"; // display the label var labelRect = innerLs.GetRect(elementHeight); var selected = i == _selectedTileIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter)) { // go to the location of the selected tile _selectedTileIndex = i; Find.WorldInterface.SelectedTile = selectedTileId; Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } // add a thin line between each label innerLs.GapLine(gapLineHeight); } listingStandard.EndScrollView(innerLs); }
private static bool Prefix(ref Dialog_AdvancedGameConfig __instance, Rect inRect) { var listingStandard = new Listing_Standard { ColumnWidth = 200f }; listingStandard.Begin(inRect.AtZero()); listingStandard.Label("MapSize".Translate()); var mapSizes = Traverse.Create(__instance).Field("MapSizes").GetValue <int[]>(); foreach (var mapSize in mapSizes) { switch (mapSize) { case 200: listingStandard.Label("MapSizeSmall".Translate()); break; case 250: listingStandard.Label("MapSizeMedium".Translate()); break; case 300: listingStandard.Label("MapSizeLarge".Translate()); break; case 350: listingStandard.Label("MapSizeExtreme".Translate()); break; } var label = "MapSizeDesc".Translate(mapSize, mapSize * mapSize); if (listingStandard.RadioButton(label, Find.GameInitData.mapSize == mapSize)) { Find.GameInitData.mapSize = mapSize; } } listingStandard.Label("Custom Map Size"); var lab = "MapSizeDesc".Translate(_customSize, _customSize * _customSize); if (listingStandard.RadioButton(lab, Find.GameInitData.mapSize == _customSize)) { Find.GameInitData.mapSize = _customSize; } listingStandard.Label("New Size:"); _settingsString = Widgets.TextField(new Rect(90f, 362f, 60f, 20f), _settingsString); if (Widgets.ButtonText(new Rect(160f, 362f, 40f, 22f), "Apply")) { if (int.TryParse(_settingsString, out var result) && result > 0) { if (mapSizes.Contains(result)) { Messages.Message("Built in maps already has these dimensions", MessageTypeDefOf.NegativeEvent); _settingsString = _customSize.ToStringSafe(); } else { _customSize = result; } } else { Messages.Message("Must be an positive integer", MessageTypeDefOf.NegativeEvent); _settingsString = _customSize.ToStringSafe(); } } listingStandard.NewColumn(); GenUI.SetLabelAlign(TextAnchor.MiddleCenter); listingStandard.Label("MapStartSeason".Translate()); var label1 = Find.GameInitData.startingSeason != Season.Undefined ? Find.GameInitData.startingSeason.LabelCap() : "MapStartSeasonDefault".Translate(); var gridLayout = new GridLayout(listingStandard.GetRect(32f), 5, 1, 0.0f); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(0), "-")) { var startingSeason = Find.GameInitData.startingSeason; Find.GameInitData.startingSeason = startingSeason != Season.Undefined ? startingSeason - 1 : Season.Winter; } Widgets.Label(gridLayout.GetCellRectByIndex(1, 3), label1); if (Widgets.ButtonText(gridLayout.GetCellRectByIndex(4), "+")) { var startingSeason = Find.GameInitData.startingSeason; Find.GameInitData.startingSeason = startingSeason != Season.Winter ? startingSeason + 1 : Season.Undefined; } GenUI.ResetLabelAlign(); var selTile = Traverse.Create(__instance).Field("selTile").GetValue <int>(); if (selTile >= 0 && Find.GameInitData.startingSeason != Season.Undefined && GenTemperature.AverageTemperatureAtTileForTwelfth(selTile, Find.GameInitData.startingSeason.GetFirstTwelfth(Find.WorldGrid.LongLatOf(selTile).y)) < 3.0) { listingStandard.Label("MapTemperatureDangerWarning".Translate()); } if (Find.GameInitData.mapSize > 250) { listingStandard.Label("MapSizePerformanceWarning".Translate()); } listingStandard.End(); return(false); }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 500f); Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref leftScrollPosition, viewRect); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width, 50f); Widgets.LabelCacheHeight(ref rect, selectedProject.LabelCap); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, selectedProject.description); num += rect2.height + 10f; string text = "ProjectTechLevel".Translate().CapitalizeFirst() + ": " + selectedProject.techLevel.ToStringHuman().CapitalizeFirst() + "\n" + "YourTechLevel".Translate().CapitalizeFirst() + ": " + Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst(); float num2 = selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); if (num2 != 1f) { string text2 = text; text = text2 + "\n\n" + "ResearchCostMultiplier".Translate().CapitalizeFirst() + ": " + num2.ToStringPercent() + "\n" + "ResearchCostComparison".Translate(selectedProject.baseCost.ToString("F0"), selectedProject.CostApparent.ToString("F0")); } Rect rect3 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect3, text); num = rect3.yMax + 10f; float num3 = DrawResearchPrereqs(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); if (num3 > 0f) { num += num3 + 15f; } num += DrawResearchBenchRequirements(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); num = (leftScrollViewHeight = num + 3f); Widgets.EndScrollView(); bool flag = Prefs.DevMode && selectedProject != Find.ResearchManager.currentProj && !selectedProject.IsFinished; Rect rect6 = new Rect(0f, 0f, 90f, 50f); if (flag) { rect6.x = (outRect.width - (rect6.width * 2f + 20f)) / 2f; } else { rect6.x = (outRect.width - rect6.width) / 2f; } rect6.y = outRect.y + outRect.height + 20f; if (selectedProject.IsFinished) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Finished".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (selectedProject == Find.ResearchManager.currentProj) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "InProgress".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (!selectedProject.CanStartNow) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Locked".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (Widgets.ButtonText(rect6, "Research".Translate())) { SoundDefOf.ResearchStart.PlayOneShotOnCamera(); Find.ResearchManager.currentProj = selectedProject; TutorSystem.Notify_Event("StartResearchProject"); } if (flag) { Rect rect7 = rect6; rect7.x += rect7.width + 20f; if (Widgets.ButtonText(rect7, "Debug Insta-finish")) { Find.ResearchManager.currentProj = selectedProject; Find.ResearchManager.FinishProject(selectedProject); } } Rect rect8 = new Rect(15f, rect6.y + rect6.height + 20f, position.width - 30f, 35f); Widgets.FillableBar(rect8, selectedProject.ProgressPercent, ResearchBarFillTex, ResearchBarBGTex, doBorder: true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect8, selectedProject.ProgressApparent.ToString("F0") + " / " + selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; } GUI.EndGroup(); }
// MAYBE TODO: request quality of items as well? // MAYBE TODO: request prisoners (may not always be available) private void DrawWindowHeader(Rect headerRowRect, float headerRowHeight) { // Begin Header group GUI.BeginGroup(headerRowRect); Text.Font = GameFont.Medium; // Draw player priceFaction name var playerFactionNameArea = new Rect(0, 0, headerRowRect.width / 2, headerRowRect.height); Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(playerFactionNameArea, Faction.OfPlayer.Name.Truncate(playerFactionNameArea.width)); // Draw trader name var tradingFactionNameArea = new Rect(headerRowRect.width / 2, 0, headerRowRect.width / 2, headerRowRect.height); Text.Anchor = TextAnchor.UpperRight; var tradingFactionName = faction.Name; if (Text.CalcSize(tradingFactionName).x > tradingFactionNameArea.width) { tradingFactionName = tradingFactionName.Truncate(tradingFactionNameArea.width); } Widgets.Label(tradingFactionNameArea, tradingFactionName); // Draw just below player priceFaction name float amountRequestedTextHeight = 20; var secondRowY = (headerRowHeight - amountRequestedTextHeight) / 2; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; var negotiatorNameArea = new Rect(0, secondRowY - 2, headerRowRect.width / 2, secondRowY); Widgets.Label(negotiatorNameArea, "IR.ItemRequestWindow.NegotiatorLabel".Translate(negotiator.LabelShort)); // Draw just below trader name Text.Anchor = TextAnchor.UpperRight; var factionTechLevelArea = new Rect(headerRowRect.width / 2, secondRowY - 2, headerRowRect.width / 2, secondRowY); Widgets.Label(factionTechLevelArea, "IR.ItemRequestWindow.TechLevelLabel".Translate(faction.def.techLevel.ToString())); // Draw the filter dropdowns Text.Anchor = TextAnchor.MiddleLeft; var filterDropdownArea = new Rect(0, headerRowHeight - amountRequestedTextHeight, headerRowRect.width - rightContentSize, amountRequestedTextHeight); DrawFilterDropdowns(filterDropdownArea); // Draw the amount requested text GUI.color = new Color(1f, 1f, 1f, 0.6f); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; var clarificationTextArea = new Rect(rightAlignOffset, headerRowHeight - amountRequestedTextHeight, rightContentSize, amountRequestedTextHeight); Widgets.Label(clarificationTextArea, "IR.ItemRequestWindow.AmountRequested".Translate()); // End Header group GUI.color = Color.white; GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DrawFilteredTiles() { DrawEntryHeader("PLMWFTIL_FilteredTiles".Translate(), backgroundColor: Color.yellow); // default line height const float gapLineHeight = 4f; //check if we have something to display (tiles) var matchingTiles = PrepareLanding.Instance.TileFilter.AllMatchingTiles; var matchingTilesCount = matchingTiles.Count; if (matchingTilesCount == 0) { return; } /* * Buttons */ if (ListingStandard.ButtonText("PLMWFTIL_ClearFilteredTiles".Translate())) { // clear everything PrepareLanding.Instance.TileFilter.ClearMatchingTiles(); // reset starting display index _tileDisplayIndexStart = 0; // reset selected index _selectedTileIndex = -1; // don't go further as there are no tile content to draw return; } var buttonsRectSpace = ListingStandard.GetRect(30f); var splittedRect = buttonsRectSpace.SplitRectWidthEvenly(_minimizedWindowButtonsDescriptorList.Count); for (var i = 0; i < _minimizedWindowButtonsDescriptorList.Count; i++) { // get button descriptor var buttonDescriptor = _minimizedWindowButtonsDescriptorList[i]; // display button; if clicked: call the related action if (Widgets.ButtonText(splittedRect[i], buttonDescriptor.Label)) { buttonDescriptor.Action(); } // display tool-tip (if any) if (!string.IsNullOrEmpty(buttonDescriptor.ToolTip)) { TooltipHandler.TipRegion(splittedRect[i], buttonDescriptor.ToolTip); } } /* * Label */ // number of elements (tiles) to display var itemsToDisplay = Math.Min(matchingTilesCount - _tileDisplayIndexStart, MaxDisplayedTileWhenMinimized); // label to display where we actually are in the tile list GenUI.SetLabelAlign(TextAnchor.MiddleCenter); var heightBefore = ListingStandard.StartCaptureHeight(); ListingStandard.Label( $"{_tileDisplayIndexStart}: {_tileDisplayIndexStart + itemsToDisplay - 1} / {matchingTilesCount - 1}", DefaultElementHeight); GenUI.ResetLabelAlign(); var counterLabelRect = ListingStandard.EndCaptureHeight(heightBefore); Core.Gui.Widgets.DrawHighlightColor(counterLabelRect, Color.cyan, 0.50f); // add a gap before the scroll view ListingStandard.Gap(gapLineHeight); /* * Calculate heights */ // height of the scrollable outer Rect (visible portion of the scroll view, not the 'virtual' one) var maxScrollViewOuterHeight = InRect.height - ListingStandard.CurHeight - 30f; // height of the 'virtual' portion of the scroll view var scrollableViewHeight = itemsToDisplay * DefaultElementHeight + gapLineHeight * MaxDisplayedTileWhenMinimized; /* * Scroll view */ var innerLs = ListingStandard.BeginScrollView(maxScrollViewOuterHeight, scrollableViewHeight, ref _scrollPosMatchingTiles, 16f); var endIndex = _tileDisplayIndexStart + itemsToDisplay; for (var i = _tileDisplayIndexStart; i < endIndex; i++) { var selectedTileId = matchingTiles[i]; var selectedTile = Find.World.grid[selectedTileId]; // get latitude & longitude for the tile var vector = Find.WorldGrid.LongLatOf(selectedTileId); var labelText = $"{i}: {vector.y.ToStringLatitude()} {vector.x.ToStringLongitude()} - {selectedTile.biome.LabelCap} ; {selectedTileId}"; // display the label var labelRect = innerLs.GetRect(DefaultElementHeight); var selected = i == _selectedTileIndex; if (Core.Gui.Widgets.LabelSelectable(labelRect, labelText, ref selected, TextAnchor.MiddleCenter)) { // go to the location of the selected tile _selectedTileIndex = i; Find.WorldInterface.SelectedTile = selectedTileId; Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } // add a thin line between each label innerLs.GapLine(gapLineHeight); } ListingStandard.EndScrollView(innerLs); }
public override void DoWindowContents(Rect inRect) { var contentMargin = new Vector2(12, 18); string title = "IR.FulfillItemRequestWindow.ReviewItems".Translate(); string closeString = "IR.FulfillItemRequestWindow.Trade".Translate(); string cancelString = "IR.FulfillItemRequestWindow.Postpone".Translate(); var totalValue = deal.TotalRequestedValue; // Begin Window group GUI.BeginGroup(inRect); // Draw the names of negotiator and factions inRect = inRect.AtZero(); var x = contentMargin.x; var headerRowHeight = 35f; var headerRowRect = new Rect(x, contentMargin.y, inRect.width - x, headerRowHeight); var titleArea = new Rect(x, 0, headerRowRect.width, headerRowRect.height); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Medium; Widgets.Label(titleArea, title); Text.Font = GameFont.Small; float constScrollbarSize = 16; float rowHeight = 30; var cumulativeContentHeight = 6f + (requestedItems.Count * rowHeight); var mainRect = new Rect(x, headerRowRect.y + headerRowRect.height + 10, inRect.width - (x * 2), inRect.height - offsetFromBottom - headerRowRect.y - headerRowRect.height); var scrollRect = new Rect(mainRect.x, 0, mainRect.width - constScrollbarSize, cumulativeContentHeight); var bottom = scrollPosition.y - 30f; var top = scrollPosition.y + mainRect.height; var y = 6f; Widgets.BeginScrollView(mainRect, ref scrollPosition, scrollRect); for (var i = 0; i < requestedItems.Count; i++) { var counter = i; if (y > bottom && y < top) { var rect = new Rect(mainRect.x, y, scrollRect.width, 30f); DrawRequestedItem(rect, requestedItems[i], counter); } y += 30f; } Widgets.EndScrollView(); var horizontalLineY = mainRect.y + mainRect.height; Widgets.DrawLineHorizontal(x, horizontalLineY, inRect.width - (contentMargin.x * 2)); // Draw total Text.Anchor = TextAnchor.MiddleRight; var totalStringRect = new Rect(mainRect.width - offsetFromRight - 155, horizontalLineY, 140, rowHeight); Widgets.Label(totalStringRect, "IR.FulfillItemRequestWindow.Total".Translate()); Widgets.DrawLineVertical(mainRect.width - offsetFromRight, horizontalLineY, rowHeight); var totalPriceRect = new Rect(mainRect.width - offsetFromRight, horizontalLineY, offsetFromRight, rowHeight); GUI.color = totalValue > colonySilver ? Color.red : Color.white; Widgets.Label(totalPriceRect, totalValue.ToStringMoney("F2")); if (totalValue > colonySilver) { TooltipHandler.TipRegion(totalPriceRect, "IR.FulfillItemRequestWindow.NotEnoughSilverStored".Translate()); } GUI.color = Color.white; Text.Anchor = TextAnchor.MiddleLeft; var closeButtonArea = new Rect(x, inRect.height - (contentMargin.y * 2), 100, 50); if (Widgets.ButtonText(closeButtonArea, closeString, false)) { TradeButtonPressed(); } Text.Anchor = TextAnchor.MiddleRight; var cancelButtonArea = new Rect(totalPriceRect.x, closeButtonArea.y, totalPriceRect.width + 10, closeButtonArea.height); if (Widgets.ButtonText(cancelButtonArea, cancelString, false)) { Close(); } GenUI.ResetLabelAlign(); GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { var windowButtonSize = CloseButSize; var contentRect = new Rect(0, 0, inRect.width, inRect.height - (windowButtonSize.y + 10f)).ContractedBy(10f); GUI.BeginGroup(contentRect); var titleRect = new Rect(0f, 0f, contentRect.width, TitleLabelHeight); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(titleRect, "HugsLib_settings_windowTitle".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; if (listedMods.Count > 0) { var scrollViewVisible = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height); var scrollBarVisible = totalContentHeight > scrollViewVisible.height; var scrollViewTotal = new Rect(0f, 0f, scrollViewVisible.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.BeginScrollView(scrollViewVisible, ref scrollPosition, scrollViewTotal); var curY = 0f; for (int i = 0; i < listedMods.Count; i++) { var entry = listedMods[i]; if (!entry.Visible) { continue; } currentlyDrawnEntry = entry.ModName; DrawModEntryHeader(entry, scrollViewTotal.width, ref curY); if ((entry.SettingsPack != null && entry.SettingsPack.AlwaysExpandEntry) || expandedModEntries.Contains(entry)) { for (int j = 0; j < entry.Handles.Count; j++) { var handle = entry.Handles[j]; if (handle.VisibilityPredicate != null) { try { if (!handle.VisibilityPredicate()) { continue; } } catch (Exception e) { HugsLibController.Logger.ReportException(e, currentlyDrawnEntry, true, "SettingsHandle.VisibilityPredicate"); } } DrawHandleEntry(handle, scrollViewTotal, ref curY, scrollViewVisible.height); } } currentlyDrawnEntry = null; } Widgets.EndScrollView(); totalContentHeight = curY; } else { Widgets.Label(new Rect(0, titleRect.height, contentRect.width, titleRect.height), "HugsLib_settings_noSettings".Translate()); } GUI.EndGroup(); Text.Font = GameFont.Small; var resetButtonRect = new Rect(0, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y); if (Widgets.ButtonText(resetButtonRect, "HugsLib_settings_resetAll".Translate())) { ShowResetPrompt("HugsLib_settings_resetAll_prompt".Translate(), HugsLibController.SettingsManager.ModSettingsPacks.SelectMany(p => p.Handles)); } var closeButtonRect = new Rect(inRect.width - windowButtonSize.x, inRect.height - windowButtonSize.y, windowButtonSize.x, windowButtonSize.y); if (closingScheduled) { closingScheduled = false; Close(); } if (Widgets.ButtonText(closeButtonRect, "CloseButton".Translate())) { GUI.FocusControl(null); // unfocus, so that a focused text field may commit its value closingScheduled = true; } }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 520f); Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref leftScrollPosition, viewRect); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width - 0f, 50f); Widgets.LabelCacheHeight(ref rect, selectedProject.LabelCap); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, selectedProject.description); num += rect2.height; Rect rect3 = new Rect(0f, num, viewRect.width, 500f); num += DrawTechprintInfo(rect3, selectedProject); if ((int)selectedProject.techLevel > (int)Faction.OfPlayer.def.techLevel) { float num2 = selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); Rect rect4 = new Rect(0f, num, viewRect.width, 0f); string text = "TechLevelTooLow".Translate(Faction.OfPlayer.def.techLevel.ToStringHuman(), selectedProject.techLevel.ToStringHuman(), num2.ToStringPercent()); if (num2 != 1f) { text += " " + "ResearchCostComparison".Translate(selectedProject.baseCost.ToString("F0"), selectedProject.CostApparent.ToString("F0")); } Widgets.LabelCacheHeight(ref rect4, text); num += rect4.height; } if (!ColonistsHaveResearchBench) { GUI.color = ColoredText.RedReadable; Rect rect5 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect5, "CannotResearchNoBench".Translate()); num += rect5.height; GUI.color = Color.white; } num += DrawResearchPrereqs(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); num += DrawResearchBenchRequirements(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject); Rect rect8 = new Rect(0f, num, viewRect.width, 500f); num += DrawUnlockableHyperlinks(rect8, selectedProject); num = (leftScrollViewHeight = num + 3f); Widgets.EndScrollView(); Rect rect9 = new Rect(0f, outRect.yMax + 10f, position.width, 68f); if (selectedProject.CanStartNow && selectedProject != Find.ResearchManager.currentProj) { if (Widgets.ButtonText(rect9, "Research".Translate())) { SoundDefOf.ResearchStart.PlayOneShotOnCamera(); Find.ResearchManager.currentProj = selectedProject; TutorSystem.Notify_Event("StartResearchProject"); if (!ColonistsHaveResearchBench) { Messages.Message("MessageResearchMenuWithoutBench".Translate(), MessageTypeDefOf.CautionInput); } } } else { string text2 = ""; if (selectedProject.IsFinished) { text2 = "Finished".Translate(); Text.Anchor = TextAnchor.MiddleCenter; } else if (selectedProject == Find.ResearchManager.currentProj) { text2 = "InProgress".Translate(); Text.Anchor = TextAnchor.MiddleCenter; } else { text2 = "Locked".Translate() + ":"; if (!selectedProject.PrerequisitesCompleted) { text2 += "\n " + "PrerequisitesNotCompleted".Translate(); } if (!selectedProject.TechprintRequirementMet) { text2 += "\n " + "InsufficientTechprintsApplied".Translate(selectedProject.TechprintsApplied, selectedProject.techprintCount); } } Widgets.DrawHighlight(rect9); Widgets.Label(rect9.ContractedBy(5f), text2); Text.Anchor = TextAnchor.UpperLeft; } Rect rect10 = new Rect(0f, rect9.yMax + 10f, position.width, 35f); Widgets.FillableBar(rect10, selectedProject.ProgressPercent, ResearchBarFillTex, ResearchBarBGTex, doBorder: true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect10, selectedProject.ProgressApparent.ToString("F0") + " / " + selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; if (Prefs.DevMode && selectedProject != Find.ResearchManager.currentProj && !selectedProject.IsFinished && Widgets.ButtonText(new Rect(rect9.x, rect9.y - 30f, 120f, 30f), "Debug: Finish now")) { Find.ResearchManager.currentProj = selectedProject; Find.ResearchManager.FinishProject(selectedProject); } if (Prefs.DevMode && !selectedProject.TechprintRequirementMet && Widgets.ButtonText(new Rect(rect9.x + 120f, rect9.y - 30f, 120f, 30f), "Debug: Apply techprint")) { Find.ResearchManager.ApplyTechprint(selectedProject, null); SoundDefOf.TechprintApplied.PlayOneShotOnCamera(); } } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { Vector2 vector = new Vector2(120f, 40f); float y = vector.y; float num = 600f; float num2 = (float)((inRect.width - num) / 2.0); Rect position = new Rect(num2 + inRect.x, inRect.y, num, (float)(inRect.height - (y + 10.0))).ContractedBy(10f); Rect position2 = new Rect(position.x, (float)(position.y + position.height + 10.0), position.width, y); GUI.BeginGroup(position); Rect rect = new Rect(0f, 0f, position.width, 40f); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(rect, "KeyboardConfig".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height); Rect rect2 = new Rect(0f, 0f, (float)(outRect.width - 16.0), this.contentHeight); Widgets.BeginScrollView(outRect, ref this.scrollPosition, rect2, true); float num3 = 0f; KeyBindingCategoryDef keyBindingCategoryDef = null; Dialog_KeyBindings.keyBindingsWorkingList.Clear(); Dialog_KeyBindings.keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs); Dialog_KeyBindings.keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index); for (int i = 0; i < Dialog_KeyBindings.keyBindingsWorkingList.Count; i++) { KeyBindingDef keyBindingDef = Dialog_KeyBindings.keyBindingsWorkingList[i]; if (keyBindingCategoryDef != keyBindingDef.category) { bool skipDrawing = num3 - this.scrollPosition.y + 40.0 < 0.0 || num3 - this.scrollPosition.y > outRect.height; keyBindingCategoryDef = keyBindingDef.category; this.DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref num3, skipDrawing); } bool skipDrawing2 = num3 - this.scrollPosition.y + 34.0 < 0.0 || num3 - this.scrollPosition.y > outRect.height; this.DrawKeyEntry(keyBindingDef, rect2, ref num3, skipDrawing2); } Widgets.EndScrollView(); GUI.EndGroup(); GUI.BeginGroup(position2); int num4 = 3; float num5 = (float)(vector.x * (float)num4 + 10.0 * (float)(num4 - 1)); float num6 = (float)((position2.width - num5) / 2.0); float num7 = (float)(vector.x + 10.0); Rect rect3 = new Rect(num6, 0f, vector.x, vector.y); Rect rect4 = new Rect(num6 + num7, 0f, vector.x, vector.y); Rect rect5 = new Rect((float)(num6 + num7 * 2.0), 0f, vector.x, vector.y); if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true)) { this.keyPrefsData.ResetToDefaults(); this.keyPrefsData.ErrorCheck(); SoundDefOf.TickLow.PlayOneShotOnCamera(null); Event.current.Use(); } if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true)) { this.Close(true); Event.current.Use(); } if (Widgets.ButtonText(rect5, "OK".Translate(), true, false, true)) { KeyPrefs.KeyPrefsData = this.keyPrefsData; KeyPrefs.Save(); this.Close(true); this.keyPrefsData.ErrorCheck(); Event.current.Use(); } GUI.EndGroup(); }
public static void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0 && trad.IsThing) { Rect rect2 = new Rect(width - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegionByKey(rect2, "TraderCount"); Rect rect4 = new Rect(rect2.x - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleRight; DrawPrice(rect4, trad, TradeAction.PlayerBuys); } width -= 175f; Rect rect5 = new Rect(width - 240f, 0f, 240f, rect.height); if (trad.TraderWillTrade) { bool flash = Time.time - Dialog_Trade.lastCurrencyFlashTime < 1f && trad.IsCurrency; TransferableUIUtility.DoCountAdjustInterface(rect5, trad, index, trad.GetMinimumToTransfer(), trad.GetMaximumToTransfer(), flash); } else { DrawWillNotTradeIndication(rect5, trad); } width -= 240f; int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect6 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawPrice(rect6, trad, TradeAction.PlayerSells); Rect rect7 = new Rect(rect6.x - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect7)) { Widgets.DrawHighlight(rect7); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect8 = rect7; rect8.xMin += 5f; rect8.xMax -= 5f; Widgets.Label(rect8, num2.ToStringCached()); TooltipHandler.TipRegionByKey(rect7, "ColonyCount"); } width -= 175f; TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, trad.TraderWillTrade ? Color.white : NoTradeColor); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
public void DrawTradeableRow(Rect rect, Tradeable trad, int index) { if (index == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int num = trad.CountHeldBy(Transactor.Trader); if (num != 0) { Rect rect2 = new Rect(width - 75f, 0f, 75f, rect.height); if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Text.Anchor = TextAnchor.MiddleRight; Rect rect3 = rect2; rect3.xMin += 5f; rect3.xMax -= 5f; Widgets.Label(rect3, num.ToStringCached()); TooltipHandler.TipRegion(rect2, "TraderCount".Translate()); } width -= 85f; Rect rect4 = new Rect(width - 240f, 0f, 240f, rect.height); if (index == 2 && notesTradeable.CountHeldBy(Transactor.Colony) == 0 && notesTradeable.CountHeldBy(Transactor.Trader) == 0) { Text.Anchor = TextAnchor.MiddleCenter; Color color = GUI.color; GUI.color = Color.gray; Widgets.Label(rect4, "NoNotes".Translate()); GUI.color = color; } else if (index == 1 && isVirtual && VirtualTrader.SilverAlsoAdjustable) { ExtUtil.DoCountAdjustInterfaceForSilver(rect4, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader), flash: false); } else { TransferableUIUtility.DoCountAdjustInterface(rect4, trad, index, -trad.CountHeldBy(Transactor.Colony), trad.CountHeldBy(Transactor.Trader)); } width -= 240f; int num2 = trad.CountHeldBy(Transactor.Colony); if (num2 != 0) { Rect rect5 = new Rect(width - 75f - 10f, 0f, 75f, rect.height); if (Mouse.IsOver(rect5)) { Widgets.DrawHighlight(rect5); } Text.Anchor = TextAnchor.MiddleLeft; Rect rect6 = rect5; rect6.xMin += 5f; rect6.xMax -= 5f; Widgets.Label(rect6, num2.ToStringCached()); TooltipHandler.TipRegion(rect5, "ColonyCount".Translate()); } GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DrawLeftRect(Rect leftOutRect) { Rect position = leftOutRect; GUI.BeginGroup(position); if (this.selectedProject != null) { Rect outRect = new Rect(0f, 0f, position.width, 500f); Rect viewRect = new Rect(0f, 0f, (float)(outRect.width - 16.0), this.leftScrollViewHeight); Widgets.BeginScrollView(outRect, ref this.leftScrollPosition, viewRect, true); float num = 0f; Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleLeft); Rect rect = new Rect(0f, num, viewRect.width, 50f); Widgets.LabelCacheHeight(ref rect, this.selectedProject.LabelCap, true, false); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; num += rect.height; Rect rect2 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect2, this.selectedProject.description, true, false); num = (float)(num + (rect2.height + 10.0)); string text = "ProjectTechLevel".Translate().CapitalizeFirst() + ": " + this.selectedProject.techLevel.ToStringHuman().CapitalizeFirst() + "\n" + "YourTechLevel".Translate().CapitalizeFirst() + ": " + Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst(); float num2 = this.selectedProject.CostFactor(Faction.OfPlayer.def.techLevel); if (num2 != 1.0) { string text2 = text; text = text2 + "\n\n" + "ResearchCostMultiplier".Translate().CapitalizeFirst() + ": " + num2.ToStringPercent() + "\n" + "ResearchCostComparison".Translate(this.selectedProject.baseCost.ToString("F0"), this.selectedProject.CostApparent.ToString("F0")); } Rect rect3 = new Rect(0f, num, viewRect.width, 0f); Widgets.LabelCacheHeight(ref rect3, text, true, false); num = (float)(rect3.yMax + 10.0); Rect rect4 = new Rect(0f, num, viewRect.width, 500f); float num3 = this.DrawResearchPrereqs(this.selectedProject, rect4); if (num3 > 0.0) { num = (float)(num + (num3 + 15.0)); } Rect rect5 = new Rect(0f, num, viewRect.width, 500f); num += this.DrawResearchBenchRequirements(this.selectedProject, rect5); num = (this.leftScrollViewHeight = (float)(num + 3.0)); Widgets.EndScrollView(); bool flag = Prefs.DevMode && this.selectedProject.PrerequisitesCompleted && this.selectedProject != Find.ResearchManager.currentProj && !this.selectedProject.IsFinished; Rect rect6 = new Rect(0f, 0f, 90f, 50f); if (flag) { rect6.x = (float)((outRect.width - (rect6.width * 2.0 + 20.0)) / 2.0); } else { rect6.x = (float)((outRect.width - rect6.width) / 2.0); } rect6.y = (float)(outRect.y + outRect.height + 20.0); if (this.selectedProject.IsFinished) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Finished".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (this.selectedProject == Find.ResearchManager.currentProj) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "InProgress".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (!this.selectedProject.CanStartNow) { Widgets.DrawMenuSection(rect6); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect6, "Locked".Translate()); Text.Anchor = TextAnchor.UpperLeft; } else if (Widgets.ButtonText(rect6, "Research".Translate(), true, false, true)) { SoundDef.Named("ResearchStart").PlayOneShotOnCamera(null); Find.ResearchManager.currentProj = this.selectedProject; TutorSystem.Notify_Event("StartResearchProject"); } if (flag) { Rect rect7 = rect6; rect7.x += (float)(rect7.width + 20.0); if (Widgets.ButtonText(rect7, "Debug Insta-finish", true, false, true)) { Find.ResearchManager.currentProj = this.selectedProject; Find.ResearchManager.InstantFinish(this.selectedProject, false); } } Rect rect8 = new Rect(15f, (float)(rect6.y + rect6.height + 20.0), (float)(position.width - 30.0), 35f); Widgets.FillableBar(rect8, this.selectedProject.ProgressPercent, MainTabWindow_Research.ResearchBarFillTex, MainTabWindow_Research.ResearchBarBGTex, true); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect8, this.selectedProject.ProgressApparent.ToString("F0") + " / " + this.selectedProject.CostApparent.ToString("F0")); Text.Anchor = TextAnchor.UpperLeft; } GUI.EndGroup(); }
private void DoRow(Rect rect, TransferableOneWay trad, int index, float availableMass) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float width = rect.width; int maxCount = trad.MaxCount; Rect rect2 = new Rect(width - 240f, 0f, 240f, rect.height); stoppingPoints.Clear(); if (availableMassGetter != null && (!(trad.AnyThing is Pawn) || includePawnsMassInMassUsage)) { float num = availableMass + GetMass(trad.AnyThing) * (float)trad.CountToTransfer; int threshold = ((!(num <= 0f)) ? Mathf.FloorToInt(num / GetMass(trad.AnyThing)) : 0); stoppingPoints.Add(new TransferableCountToTransferStoppingPoint(threshold, "M<", ">M")); } Pawn pawn = trad.AnyThing as Pawn; bool flag = pawn != null && (pawn.IsColonist || pawn.IsPrisonerOfColony); TransferableUIUtility.DoCountAdjustInterface(rect2, trad, index, 0, maxCount, flash: false, stoppingPoints, (playerPawnsReadOnly && flag) || readOnly); width -= 240f; if (drawMarketValue) { Rect rect3 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawMarketValue(rect3, trad); width -= 100f; } if (drawMass) { Rect rect4 = new Rect(width - 100f, 0f, 100f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawMass(rect4, trad, availableMass); width -= 100f; } if (drawDaysUntilRot) { Rect rect5 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawDaysUntilRot(rect5, trad); width -= 75f; } if (drawItemNutrition) { Rect rect6 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawItemNutrition(rect6, trad); width -= 75f; } if (drawForagedFoodPerDay) { Rect rect7 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; if (!DrawGrazeability(rect7, trad)) { DrawForagedFoodPerDay(rect7, trad); } width -= 75f; } if (drawNutritionEatenPerDay) { Rect rect8 = new Rect(width - 75f, 0f, 75f, rect.height); Text.Anchor = TextAnchor.MiddleLeft; DrawNutritionEatenPerDay(rect8, trad); width -= 75f; } if (ShouldShowCount(trad)) { Rect rect9 = new Rect(width - 75f, 0f, 75f, rect.height); Widgets.DrawHighlightIfMouseover(rect9); Text.Anchor = TextAnchor.MiddleLeft; Rect rect10 = rect9; rect10.xMin += 5f; rect10.xMax -= 5f; Widgets.Label(rect10, maxCount.ToStringCached()); TooltipHandler.TipRegion(rect9, sourceCountDesc); } width -= 75f; if (drawEquippedWeapon) { Rect rect11 = new Rect(width - 30f, 0f, 30f, rect.height); Rect iconRect = new Rect(width - 30f, (rect.height - 30f) / 2f, 30f, 30f); DrawEquippedWeapon(rect11, iconRect, trad); width -= 30f; } TransferableUIUtility.DoExtraAnimalIcons(trad, rect, ref width); Rect idRect = new Rect(0f, 0f, width, rect.height); TransferableUIUtility.DrawTransferableInfo(trad, idRect, Color.white); GenUI.ResetLabelAlign(); GUI.EndGroup(); }
private void DrawItemRow(Rect rect, CommandOption commandOption, int index) { // Highlight every other row if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Text.Font = GameFont.Small; GUI.BeginGroup(rect); float num = rect.width; Rect rect1 = new Rect(num - 100f, 0f, 100f, rect.height); rect1 = rect1.Rounded(); // TextAnchor Fix rect1.xMax -= 5f; rect1.xMin += 5f; if (Text.Anchor == TextAnchor.MiddleLeft) { rect1.xMax += 300f; } if (Text.Anchor == TextAnchor.MiddleRight) { rect1.xMin -= 300f; } Rect rect2 = new Rect(num - 560f, 0f, 75f, rect.height); // Store value for reference int newPrice = commandOption.costSilverStore; string priceLabel = newPrice.ToString(); int newLocalCooldown = commandOption.localCooldownMs / 1000; string localCooldownLabel = newLocalCooldown.ToString(); int newGlobalCooldown = commandOption.globalCooldownMs / 1000; string globalCooldownLabel = newGlobalCooldown.ToString(); // Silver Cost Widgets.TextFieldNumeric(rect2, ref newPrice, ref priceLabel, -1f); filteredRows[index].costSilverStore = newPrice; // Local Cooldown rect2.x += rect2.width + 75f; Widgets.TextFieldNumeric(rect2, ref newLocalCooldown, ref localCooldownLabel, 0f); filteredRows[index].localCooldownMs = newLocalCooldown * 1000; // Global Cooldown rect2.x += rect2.width + 100f; Widgets.TextFieldNumeric(rect2, ref newGlobalCooldown, ref globalCooldownLabel, 0f); filteredRows[index].globalCooldownMs = newGlobalCooldown * 1000; // Icons for ItemDefs Rect rect3 = new Rect(0f, 0f, 27f, 27f); if (commandOption.Action() is ItemAction) { ItemAction itemAction = (ItemAction)commandOption.Action(); ThingDef thingDef = itemAction.thingDef; Widgets.ThingIcon(rect3, thingDef); Widgets.InfoCardButton(40f, 0f, thingDef); } // Label for item/event Text.Anchor = TextAnchor.MiddleLeft; Rect rect4 = new Rect(80f, 0f, rect.width - 80f, rect.height); Text.WordWrap = false; GUI.color = Color.white; Widgets.Label(rect4, commandOption.Action().Name.CapitalizeFirst()); Text.WordWrap = true; GenUI.ResetLabelAlign(); GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { Vector2 vector = new Vector2(120f, 40f); float y = vector.y; float num = 600f; float num2 = (inRect.width - num) / 2f; Rect position = new Rect(num2 + inRect.x, inRect.y, num, inRect.height - (y + 10f)).ContractedBy(10f); Rect position2 = new Rect(position.x, position.y + position.height + 10f, position.width, y); GUI.BeginGroup(position); Rect rect = new Rect(0f, 0f, position.width, 40f); Text.Font = GameFont.Medium; GenUI.SetLabelAlign(TextAnchor.MiddleCenter); Widgets.Label(rect, "KeyboardConfig".Translate()); GenUI.ResetLabelAlign(); Text.Font = GameFont.Small; Rect outRect = new Rect(0f, rect.height, position.width, position.height - rect.height); Rect rect2 = new Rect(0f, 0f, outRect.width - 16f, contentHeight); Widgets.BeginScrollView(outRect, ref scrollPosition, rect2); float curY = 0f; KeyBindingCategoryDef keyBindingCategoryDef = null; keyBindingsWorkingList.Clear(); keyBindingsWorkingList.AddRange(DefDatabase <KeyBindingDef> .AllDefs); keyBindingsWorkingList.SortBy((KeyBindingDef x) => x.category.index, (KeyBindingDef x) => x.index); for (int i = 0; i < keyBindingsWorkingList.Count; i++) { KeyBindingDef keyBindingDef = keyBindingsWorkingList[i]; if (keyBindingCategoryDef != keyBindingDef.category) { bool skipDrawing = curY - scrollPosition.y + 40f < 0f || curY - scrollPosition.y > outRect.height; keyBindingCategoryDef = keyBindingDef.category; DrawCategoryEntry(keyBindingCategoryDef, rect2.width, ref curY, skipDrawing); } bool skipDrawing2 = curY - scrollPosition.y + 34f < 0f || curY - scrollPosition.y > outRect.height; DrawKeyEntry(keyBindingDef, rect2, ref curY, skipDrawing2); } Widgets.EndScrollView(); GUI.EndGroup(); GUI.BeginGroup(position2); int num3 = 3; float num4 = vector.x * (float)num3 + 10f * (float)(num3 - 1); float num5 = (position2.width - num4) / 2f; float num6 = vector.x + 10f; Rect rect3 = new Rect(num5, 0f, vector.x, vector.y); Rect rect4 = new Rect(num5 + num6, 0f, vector.x, vector.y); Rect rect5 = new Rect(num5 + num6 * 2f, 0f, vector.x, vector.y); if (Widgets.ButtonText(rect3, "ResetButton".Translate())) { keyPrefsData.ResetToDefaults(); keyPrefsData.ErrorCheck(); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); Event.current.Use(); } if (Widgets.ButtonText(rect4, "CancelButton".Translate())) { Close(); Event.current.Use(); } if (Widgets.ButtonText(rect5, "OK".Translate())) { KeyPrefs.KeyPrefsData = keyPrefsData; KeyPrefs.Save(); Close(); keyPrefsData.ErrorCheck(); Event.current.Use(); } GUI.EndGroup(); }
public override void DoWindowContents(Rect inRect) { var contentRect = new Rect(0, 0, inRect.width, inRect.height - (CloseButSize.y + 10f)).ContractedBy(10f); // var scrollViewVisible = new Rect(0f, titleRect.height, contentRect.width, contentRect.height - titleRect.height); var scrollBarVisible = totalContentHeight > contentRect.height; var scrollViewTotal = new Rect(0f, 0f, contentRect.width - (scrollBarVisible ? ScrollBarWidthMargin : 0), totalContentHeight); Widgets.DrawHighlight(contentRect); Widgets.BeginScrollView(contentRect, ref scrollPosition, scrollViewTotal); var curY = 0f; var r = new Rect(0, curY, scrollViewTotal.width, LabelHeight); // r=new Rect(0,curY,scrollViewTotal.width, LabelHeight); Widgets.CheckboxLabeled(r, "LWMDSperDSUturnOn".Translate(), ref Settings.allowPerDSUSettings); //TODO TooltipHandler.TipRegion(r, "LWMDSperDSUturnOnDesc".Translate()); curY += LabelHeight + 1f; if (!Settings.allowPerDSUSettings) { r = new Rect(5f, curY, scrollViewTotal.width - 10f, LabelHeight); Widgets.Label(r, "LWMDSperDSUWarning".Translate()); curY += LabelHeight; } Widgets.DrawLineHorizontal(0f, curY, scrollViewTotal.width); curY += 10f; // todo: make this static? //List<ThingDef> l=DefDatabase<ThingDef>.AllDefsListForReading.Where(ThingDef d => d.Has // Roll my own buttons, because dammit, I want left-justified buttons: // (mirroring Widgets.ButtonTextWorker) GenUI.SetLabelAlign(TextAnchor.MiddleLeft); var bg = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBG"); var bgmouseover = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGMouseover"); var bgclick = ContentFinder <Texture2D> .Get("UI/Widgets/ButtonBGClick"); foreach (var u in Settings.allDeepStorageUnits) { r = new Rect(5f, curY, scrollViewTotal.width * 2 / 3 - 7f, LabelHeight); // Draw button-ish background: var atlas = bg; if (Mouse.IsOver(r)) { atlas = bgmouseover; if (Input.GetMouseButton(0)) { atlas = bgclick; } } Widgets.DrawAtlas(r, atlas); // button text: Widgets.Label(r, u.label + " (defName: " + u.defName + ")"); // button clickiness: if (Widgets.ButtonInvisible(r)) { Find.WindowStack.Add(new Dialog_DSU_Settings(u)); } // Reset button: r = new Rect(scrollViewTotal.width * 2 / 3 + 2f, curY, scrollViewTotal.width / 3 - 7f, LabelHeight); if (IsDSUChanged(u) && Widgets.ButtonText(r, "ResetBinding".Translate())) { ResetDSUToDefaults(u.defName); } curY += LabelHeight + 2f; } GenUI.ResetLabelAlign(); // end buttons Widgets.EndScrollView(); r = new Rect(10f, inRect.height - CloseButSize.y - 5f, inRect.width / 3, CloseButSize.y); if (defaultDSUValues.Count > 0 && Widgets.ButtonText(r, "LWM.ResetAllToDefault".Translate())) { Utils.Mess(Utils.DBF.Settings, "Resetting all per-building storage settings to default:"); ResetAllToDefaults(); } totalContentHeight = curY; }
private void DoArchivableRow(Rect rect, IArchivable archivable, int index) { if (index % 2 == 1) { Widgets.DrawLightHighlight(rect); } Widgets.DrawHighlightIfMouseover(rect); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Text.WordWrap = false; Rect rect2 = rect; Rect rect3 = rect2; rect3.width = 30f; rect2.xMin += 40f; float num; if (Find.Archive.IsPinned(archivable)) { num = 1f; } else if (Mouse.IsOver(rect3)) { num = 0.25f; } else { num = 0f; } if (num > 0f) { GUI.color = new Color(1f, 1f, 1f, num); GUI.DrawTexture(new Rect(rect3.x + (rect3.width - 22f) / 2f, rect3.y + (rect3.height - 22f) / 2f, 22f, 22f).Rounded(), MainTabWindow_History.PinTex); GUI.color = Color.white; } Rect rect4 = rect2; Rect outerRect = rect2; outerRect.width = 30f; rect2.xMin += 40f; Texture archivedIcon = archivable.ArchivedIcon; if (archivedIcon != null) { GUI.color = archivable.ArchivedIconColor; Widgets.DrawTextureFitted(outerRect, archivedIcon, 0.8f); GUI.color = Color.white; } Rect rect5 = rect2; rect5.width = 200f; rect2.xMin += 210f; Vector2 location = (Find.CurrentMap == null) ? default(Vector2) : Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile); GUI.color = new Color(0.75f, 0.75f, 0.75f); int num2 = GenDate.TickGameToAbs(archivable.CreatedTicksGame); string str = string.Concat(new object[] { GenDate.DateFullStringAt((long)num2, location), ", ", GenDate.HourInteger((long)num2, location.x), "LetterHour".Translate() }); Widgets.Label(rect5, str.Truncate(rect5.width, null)); GUI.color = Color.white; Rect rect6 = rect2; Widgets.Label(rect6, archivable.ArchivedLabel.Truncate(rect6.width, null)); GenUI.ResetLabelAlign(); Text.WordWrap = true; TooltipHandler.TipRegion(rect3, "PinArchivableTip".Translate(200)); if (Mouse.IsOver(rect4)) { TooltipHandler.TipRegion(rect4, archivable.ArchivedTooltip); } if (Widgets.ButtonInvisible(rect3, false)) { if (Find.Archive.IsPinned(archivable)) { Find.Archive.Unpin(archivable); SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null); } else { Find.Archive.Pin(archivable); SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null); } } if (Widgets.ButtonInvisible(rect4, false)) { if (Event.current.button == 1) { LookTargets lookTargets = archivable.LookTargets; if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget())) { CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget()); Find.MainTabsRoot.EscapeCurrentTab(true); } } else { archivable.OpenArchived(); } } }
public override void DoSettingsWindowContents(Rect rect) { Listing_Standard list = new Listing_Standard() { ColumnWidth = rect.width }; list.Begin(rect); list.Gap(10); { Rect fullRect = list.GetRect(Text.LineHeight); Rect leftRect = fullRect.LeftHalf().Rounded(); Rect rightRect = fullRect.RightHalf().Rounded(); GenUI.SetLabelAlign(TextAnchor.MiddleRight); Widgets.Label(leftRect, Static.LabelStoneTypesAvailable); GenUI.ResetLabelAlign(); Widgets.IntRange(rightRect, 316192000, ref Settings.StoneTypesAvailable, 1, 8); } list.Gap(25); { Rect fullRect = list.GetRect(30f); Rect leftLabelRect = fullRect.LeftHalf().Rounded(); Rect rightLabelRect = fullRect.RightHalf().Rounded(); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(leftLabelRect, Static.LabelStoneTypesToSpawn); PatchDescription GraphicsPatch = patches.Find(x => x.file == "Patches_Core_Stone_CustomGraphics.xml"); var status = settings.PatchDisabled[GraphicsPatch]; Widgets.CheckboxLabeled(rightLabelRect, "Enable Cupro'ss Stone Textures", ref status); settings.PatchDisabled[GraphicsPatch] = status; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } list.Gap(10); { Rect fullRect = list.GetRect(30f); Rect rightLabelRect = fullRect.RightHalf().Rounded(); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkLimestone, Static.ChunkSandstone, Static.Limestone?.LabelCap, Static.Sandstone?.LabelCap, ref Settings.SpawnLimestone, ref Settings.SpawnSandstone ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkClaystone, Static.ChunkAndesite, Static.Claystone?.LabelCap, Static.Andesite?.LabelCap, ref Settings.SpawnClaystone, ref Settings.SpawnAndesite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkSyenite, Static.ChunkGneiss, Static.Syenite?.LabelCap, Static.Gneiss?.LabelCap, ref Settings.SpawnSyenite, ref Settings.SpawnGneiss ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkMarble, Static.ChunkQuartzite, Static.Marble?.LabelCap, Static.Quartzite?.LabelCap, ref Settings.SpawnMarble, ref Settings.SpawnQuartzite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkSlate, Static.ChunkSchist, Static.Slate?.LabelCap, Static.Schist?.LabelCap, ref Settings.SpawnSlate, ref Settings.SpawnSchist ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkGabbro, Static.ChunkGranite, Static.Gabbro?.LabelCap, Static.Granite?.LabelCap, ref Settings.SpawnGabbro, ref Settings.SpawnGranite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); DualCheckboxesWithIcons_ThingDef( fullRect.LeftHalf(), Static.ChunkDiorite, Static.ChunkDunite, Static.Diorite?.LabelCap, Static.Dunite?.LabelCap, ref Settings.SpawnDiorite, ref Settings.SpawnDunite ); } list.Gap(10); { Rect fullRect = list.GetRect(30f); Rect leftRect = fullRect.LeftHalf().LeftHalf().RightPartPixels(150).Rounded(); Rect leftIconRect = fullRect.LeftHalf().LeftHalf().LeftHalf().LeftHalf().RightPartPixels(30).Rounded(); Widgets.ThingIcon(leftIconRect, Static.ChunkPegmatite); Widgets.CheckboxLabeled(leftRect, Static.Pegmatite?.LabelCap, ref Settings.SpawnPegmatite); Widgets.DrawHighlightIfMouseover(leftRect); } GenUI.ResetLabelAlign(); list.End(); }