public static void FittedDefIconCount(Rect rect, ThingDef def, ThingDef stuff, int quantity) { Widgets.DefIcon(rect, def, stuff); Text.Anchor = TextAnchor.LowerCenter; Text.Font = GameFont.Tiny; Widgets.Label(rect, quantity.ToString()); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; }
// The icons are highlighted red if they are not fulfilled i.e. the pawn is // not wearing / does not have the item equipped. // [ TagName ] [icon_0] [icon_2] public static void DrawTag(Rect r, Tag tag) { var rect = r.TopPartPixels(SPACED_HEIGHT); var tagNameWidth = tag.name.GetWidthCached(); Widgets.Label(rect.LeftPartPixels(tagNameWidth), tag.name); rect.AdjHorzBy(tagNameWidth + SPACED_HEIGHT); foreach (var td in tag.requiredItems) { Widgets.DefIcon(rect.PopLeftPartPixels(SPACED_HEIGHT), td.Def, td.RandomStuff); } }
private void DrawThing(Thing thing, Rect rect) { var hexWidth = Hexagon.width * hexagonScale; var hexHeight = Hexagon.height * hexagonScale; var hexRect = new Rect(rect.center.x - (hexWidth / 2), rect.center.y - (hexHeight / 2), hexWidth, hexHeight); GUI.DrawTexture(hexRect, Hexagon); if (thing != null) { Widgets.DefIcon(rect, thing.def); var label = thing.def.label.CapitalizeFirst(); var size = Text.CalcSize(label); var labelRect = new Rect((rect.x + (rect.width / 2)) - (size.x / 2), rect.yMax + 10, size.x, 24); Widgets.Label(labelRect, label); } }
public bool DrawPawnStats(Rect rect) { // header [ Prev ] [ Current Pawn Name ] [ Next ] // Render of Pawn with Clothes var topPartRect = rect.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT); var lhs = topPartRect.PopLeftPartPixels(ModGUIUtility.SPACED_HEIGHT); var rhs = topPartRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT); Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(topPartRect, $"{selectedUnit.name}"); Text.Anchor = TextAnchor.UpperLeft; rect.PopRightPartPixels(GenUI.GapTiny); rect.PopTopPartPixels(GenUI.GapTiny); ModGUIUtility.ListSeperator(ref rect, "ApparelWhichCanBeWorn".Translate()); var wornApparel = selectedUnit.loadout.HypotheticalWornApparel(pawn.RaceProps.body).ToList(); var apparels = ApparelUtility.ApparelCanFitOnBody(pawn.RaceProps.body, wornApparel.Select(td => td.Def).ToList()).ToList(); var allocatedHeight = apparels.Count * ModGUIUtility.DEFAULT_HEIGHT; var viewRect = new Rect(rect.x, rect.y, rect.width - 16f, allocatedHeight); Widgets.BeginScrollView(rect, ref wearableApparelScroll, viewRect); int aIdx = 0; foreach (var apparel in apparels) { var apparelRect = viewRect.PopTopPartPixels(ModGUIUtility.DEFAULT_HEIGHT); if (aIdx++ % 2 == 0) { Widgets.DrawLightHighlight(apparelRect); } Widgets.DefIcon(apparelRect.LeftPart(.15f), apparel); Widgets.Label(apparelRect.RightPart(.85f), apparel.LabelCap); } Widgets.EndScrollView(); return(false); }
//public static void DefLabelWithIcon(Rect rect, Def def, float iconMargin = 2f, float textOffsetX = 6f) //copypaste public static void DefLabelWithIconButNoTooltipCmonReally(Rect rect, Def def, float iconMargin = 2f, float textOffsetX = 6f) { //DrawHighlightIfMouseover(rect); //TooltipHandler.TipRegion(rect, def.description); GUI.BeginGroup(rect); Rect rect2 = new Rect(0f, 0f, rect.height, rect.height); if (iconMargin != 0f) { rect2 = rect2.ContractedBy(iconMargin); } Widgets.DefIcon(rect2, def, null, 1f, null, drawPlaceholder: true); Rect rect3 = new Rect(rect2.xMax + textOffsetX, 0f, rect.width, rect.height); Text.Anchor = TextAnchor.MiddleLeft; Text.WordWrap = false; Widgets.Label(rect3, def.LabelCap); Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; GUI.EndGroup(); }
public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu) { Rect rect2 = rect; rect2.height--; bool flag = !Disabled && Mouse.IsOver(rect2); bool flag2 = false; Text.Font = CurrentFont; Rect rect3 = rect; rect3.xMin += 4f; rect3.xMax = rect.x + 27f; rect3.yMin += 4f; rect3.yMax = rect.y + 27f; if (flag) { rect3.x += 4f; } Rect rect4 = rect; rect4.xMin += HorizontalMargin; rect4.xMax -= HorizontalMargin; rect4.xMax -= 4f; rect4.xMax -= extraPartWidth + IconOffset; rect4.x += IconOffset; if (flag) { rect4.x += 4f; } Rect rect5 = default(Rect); if (extraPartWidth != 0f) { float num = Mathf.Min(Text.CalcSize(Label).x, rect4.width - 4f); rect5 = new Rect(rect4.xMin + num, rect4.yMin, extraPartWidth, 30f); flag2 = Mouse.IsOver(rect5); } if (!Disabled) { MouseoverSounds.DoRegion(rect2); } Color color = GUI.color; if (Disabled) { GUI.color = ColorBGDisabled * color; } else if (flag && !flag2) { GUI.color = ColorBGActiveMouseover * color; } else { GUI.color = ColorBGActive * color; } GUI.DrawTexture(rect, BaseContent.WhiteTex); GUI.color = ((!Disabled) ? ColorTextActive : ColorTextDisabled) * color; if (sizeMode == FloatMenuSizeMode.Tiny) { rect4.y += 1f; } Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG); Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect4, Label); Text.Anchor = TextAnchor.UpperLeft; GUI.color = iconColor; if (shownItem != null || drawPlaceHolderIcon) { Widgets.DefIcon(rect3, shownItem, null, 1f, drawPlaceHolderIcon); } else if ((bool)itemIcon) { GUI.DrawTexture(rect3, itemIcon); } GUI.color = color; if (extraPartOnGUI != null) { bool num2 = extraPartOnGUI(rect5); GUI.color = color; if (num2) { return(true); } } if (flag && mouseoverGuiAction != null) { mouseoverGuiAction(); } if (tutorTag != null) { UIHighlighter.HighlightOpportunity(rect, tutorTag); } if (Widgets.ButtonInvisible(rect2)) { if (tutorTag != null && !TutorSystem.AllowAction(tutorTag)) { return(false); } Chosen(colonistOrdering, floatMenu); if (tutorTag != null) { TutorSystem.Notify_Event(tutorTag); } return(true); } return(false); }
protected override void DrawIcon(Rect rect, Material buttonMat = null) { Widgets.DefIcon(rect, PlacingDef, stuffDef, 0.85f); }
public virtual bool DoGUI(Rect rect, TieredFloatMenu floatMenu) { if (maxFloatMenuWidth != -1f) { rect.width = maxFloatMenuWidth; } Rect rect2 = rect; rect2.height--; bool flag = !Disabled && Mouse.IsOver(rect2); bool flag2 = false; Text.Font = CurrentFont; Rect rect3 = rect; rect3.xMin += 4f; rect3.xMax = rect.x + 27f; rect3.yMin += 4f; rect3.yMax = rect.y + 27f; if (flag) { rect3.x += 4f; } Rect rect4 = rect; rect4.xMin += HorizontalMargin; rect4.xMax -= HorizontalMargin; rect4.xMax -= 4f; rect4.xMax -= extraPartWidth + IconOffset; rect4.x += IconOffset; if (flag) { rect4.x += 4f; } Rect rect5 = default(Rect); if (extraPartWidth != 0f) { float num = Mathf.Min(Text.CalcSize(Label).x, rect4.width - 4f); rect5 = new Rect(rect4.xMin + num, rect4.yMin, extraPartWidth, 30f); flag2 = Mouse.IsOver(rect5); } Color color = GUI.color; //if (Disabled) //{ // GUI.color = ColorBGDisabled * color; //} //else if (flag && !flag2) //{ // GUI.color = ColorBGActiveMouseover * color; //} //else //{ // GUI.color = ColorBGActive * color; //} //GUI.DrawTexture(rect, BaseContent.WhiteTex); if (this.selected && iconSelected != null) { GUI.DrawTexture(rect, iconSelected); } else if (Mouse.IsOver(rect) && iconHover != null) { GUI.DrawTexture(rect, iconHover); } else if (curIcon != null) { GUI.DrawTexture(rect, curIcon); } if (toolTip.Length > 0) { TooltipHandler.TipRegion(rect, toolTip); } if (labelInt != null) { Text.Anchor = this.textAnchor; var textRect = new Rect(rect); textRect.x += this.leftTextIndent; Widgets.Label(textRect, Label); Text.Anchor = TextAnchor.UpperLeft; } GUI.color = ((!Disabled) ? ColorTextActive : ColorTextDisabled) * color; if (sizeMode == FloatMenuSizeMode.Tiny) { rect4.y += 1f; } Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG); GUI.color = iconColor; if (shownItem != null || drawPlaceHolderIcon) { Widgets.DefIcon(rect3, shownItem, null, 1f, drawPlaceholder: drawPlaceHolderIcon); } else if ((bool)itemIcon) { GUI.DrawTexture(rect3, itemIcon); } GUI.color = color; if (extraPartOnGUI != null) { bool num2 = extraPartOnGUI(rect); GUI.color = color; if (num2) { return(true); } } if (flag && mouseoverGuiAction != null) { mouseoverGuiAction(); } if (tutorTag != null) { UIHighlighter.HighlightOpportunity(rect, tutorTag); } if (Widgets.ButtonInvisible(rect2)) { if (tutorTag != null && !TutorSystem.AllowAction(tutorTag)) { return(false); } Chosen(floatMenu); if (tutorTag != null) { TutorSystem.Notify_Event(tutorTag); } //return true; } return(false); }
protected override void DrawIcon(Rect rect, Material buttonMat = null) { Widgets.DefIcon(rect, buildableDef, thingDef, 0.85f, false); }
public void DrawBodyPartGroup(BodyDef bodyDef, BodyPartGroup group, List <ApparelLayerDef> layers, ref float curY, List <Rect> columns, List <Tuple <Item, Tag> > wornApparel) { var groupRect = new Rect(columns[0].x, curY, columns[0].width, ModGUIUtility.SPACED_HEIGHT); var def = group.def; GUI.color = Color.gray; Widgets.Label(groupRect, def.LabelCap); GUI.color = Color.white; Text.Font = GameFont.Tiny; foreach (var column in group.layers.OrderByDescending(d => d.drawOrder)) { var idx = layers.FirstIndexOf(c => c == column) + 1; var columnRect = new Rect(columns[idx].x, curY, columns[idx].width, ModGUIUtility.SPACED_HEIGHT); var loadoutTags = selectedUnit.loadout.tags; var(overlappingApparel, overlappingTag) = wornApparel .FirstOrDefault(item => ApparelSlotMaker.Create(bodyDef, item.Item1.Def) .Intersects(def, column)) ?? new Tuple <Item, Tag>(null, null); var possibleDefs = loadoutTags .SelectMany(t => t.ItemsWithTagMatching(item => item.Def.IsApparel && ApparelSlotMaker.Create(bodyDef, (ThingDef)item.Def).Intersects(def, column))) .ToList(); if (overlappingApparel != null) { possibleDefs.RemoveAll(tup => tup.Item1 == overlappingTag); } if (overlappingApparel == null && possibleDefs.EnumerableNullOrEmpty()) { Widgets.DrawBoxSolidWithOutline(columnRect, Widgets.WindowBGFillColor, Color.gray); } else { if (overlappingApparel != null) { var col = GetColorForTagAtIndex(loadoutTags.IndexOf(overlappingTag)); Widgets.DrawBoxSolidWithOutline(columnRect, Widgets.WindowBGFillColor, col); Widgets.DefIcon(columnRect.ContractedBy(3f), overlappingApparel.Def, overlappingApparel.RandomStuff); if (possibleDefs.Any()) { var str = ""; foreach (var(pTag, pApparel) in possibleDefs) { str += $"\n - {pApparel.Def.LabelCap} from {pTag.name}"; } TooltipHandler.TipRegion(columnRect, $"{overlappingApparel.Def.LabelCap} from {overlappingTag.name} blocks:{str}"); } } else { var nextHighestPrio = possibleDefs.OrderBy(tup => loadoutTags.IndexOf(tup.Item1)).First().Item2; Widgets.DrawBoxSolidWithOutline(columnRect, Widgets.WindowBGFillColor, Color.red); Widgets.DefIcon(columnRect.ContractedBy(3f), nextHighestPrio.Def, color: new Color(0.5f, 0.5f, 0.5f, 0.3f)); var str = "Blocked Tags:"; foreach (var(pTag, pApparel) in possibleDefs) { str += $"\n - {pApparel.Def.LabelCap} from {pTag.name}"; } TooltipHandler.TipRegion(columnRect, str); } } } Text.Font = GameFont.Small; curY += ModGUIUtility.SPACED_HEIGHT; foreach (var child in group.children) { DrawBodyPartGroup(bodyDef, child, layers, ref curY, columns, wornApparel); } }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Medium; Rect rect = new Rect(40f, 0f, 400f, 34f); Widgets.Label(rect, bill.LabelCap); Widgets.DefIcon(new Rect(0f, rect.y, 34f, 34f), bill.recipe, null, 1f, drawPlaceholder: true); float width = (int)((inRect.width - 34f) / 3f); Rect rect2 = new Rect(0f, 80f, width, inRect.height - 80f); Rect rect3 = new Rect(rect2.xMax + 17f, 50f, width, inRect.height - 50f - CloseButSize.y); Rect rect4 = new Rect(rect3.xMax + 17f, 50f, 0f, inRect.height - 50f - CloseButSize.y); rect4.xMax = inRect.xMax; Text.Font = GameFont.Small; Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(rect3); Listing_Standard listing_Standard2 = listing_Standard.BeginSection(RepeatModeSubdialogHeight); if (listing_Standard2.ButtonText(bill.repeatMode.LabelCap)) { BillRepeatModeUtility.MakeConfigFloatMenu(bill); } listing_Standard2.Gap(); if (bill.repeatMode == BillRepeatModeDefOf.RepeatCount) { listing_Standard2.Label("RepeatCount".Translate(bill.repeatCount)); listing_Standard2.IntEntry(ref bill.repeatCount, ref repeatCountEditBuffer); } else if (bill.repeatMode == BillRepeatModeDefOf.TargetCount) { string arg = "CurrentlyHave".Translate() + ": "; arg += bill.recipe.WorkerCounter.CountProducts(bill); arg += " / "; arg += ((bill.targetCount < 999999) ? bill.targetCount.ToString() : "Infinite".Translate().ToLower().ToString()); string str = bill.recipe.WorkerCounter.ProductsDescription(bill); if (!str.NullOrEmpty()) { arg += "\n" + "CountingProducts".Translate() + ": " + str.CapitalizeFirst(); } listing_Standard2.Label(arg); int targetCount = bill.targetCount; listing_Standard2.IntEntry(ref bill.targetCount, ref targetCountEditBuffer, bill.recipe.targetCountAdjustment); bill.unpauseWhenYouHave = Mathf.Max(0, bill.unpauseWhenYouHave + (bill.targetCount - targetCount)); ThingDef producedThingDef = bill.recipe.ProducedThingDef; if (producedThingDef != null) { if (producedThingDef.IsWeapon || producedThingDef.IsApparel) { listing_Standard2.CheckboxLabeled("IncludeEquipped".Translate(), ref bill.includeEquipped); } if (producedThingDef.IsApparel && producedThingDef.apparel.careIfWornByCorpse) { listing_Standard2.CheckboxLabeled("IncludeTainted".Translate(), ref bill.includeTainted); } Widgets.Dropdown(listing_Standard2.GetRect(30f), bill, (Bill_Production b) => b.includeFromZone, (Bill_Production b) => GenerateStockpileInclusion(), (bill.includeFromZone == null) ? "IncludeFromAll".Translate() : "IncludeSpecific".Translate(bill.includeFromZone.label)); if (bill.recipe.products.Any((ThingDefCountClass prod) => prod.thingDef.useHitPoints)) { Widgets.FloatRange(listing_Standard2.GetRect(28f), 975643279, ref bill.hpRange, 0f, 1f, "HitPoints", ToStringStyle.PercentZero); bill.hpRange.min = Mathf.Round(bill.hpRange.min * 100f) / 100f; bill.hpRange.max = Mathf.Round(bill.hpRange.max * 100f) / 100f; } if (producedThingDef.HasComp(typeof(CompQuality))) { Widgets.QualityRange(listing_Standard2.GetRect(28f), 1098906561, ref bill.qualityRange); } if (producedThingDef.MadeFromStuff) { listing_Standard2.CheckboxLabeled("LimitToAllowedStuff".Translate(), ref bill.limitToAllowedStuff); } } } if (bill.repeatMode == BillRepeatModeDefOf.TargetCount) { listing_Standard2.CheckboxLabeled("PauseWhenSatisfied".Translate(), ref bill.pauseWhenSatisfied); if (bill.pauseWhenSatisfied) { listing_Standard2.Label("UnpauseWhenYouHave".Translate() + ": " + bill.unpauseWhenYouHave.ToString("F0")); listing_Standard2.IntEntry(ref bill.unpauseWhenYouHave, ref unpauseCountEditBuffer, bill.recipe.targetCountAdjustment); if (bill.unpauseWhenYouHave >= bill.targetCount) { bill.unpauseWhenYouHave = bill.targetCount - 1; unpauseCountEditBuffer = bill.unpauseWhenYouHave.ToStringCached(); } } } listing_Standard.EndSection(listing_Standard2); listing_Standard.Gap(); Listing_Standard listing_Standard3 = listing_Standard.BeginSection(StoreModeSubdialogHeight); string text = string.Format(bill.GetStoreMode().LabelCap, (bill.GetStoreZone() != null) ? bill.GetStoreZone().SlotYielderLabel() : ""); if (bill.GetStoreZone() != null && !bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone())) { text += string.Format(" ({0})", "IncompatibleLower".Translate()); Text.Font = GameFont.Tiny; } if (listing_Standard3.ButtonText(text)) { Text.Font = GameFont.Small; List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (BillStoreModeDef item in DefDatabase <BillStoreModeDef> .AllDefs.OrderBy((BillStoreModeDef bsm) => bsm.listOrder)) { if (item == BillStoreModeDefOf.SpecificStockpile) { List <SlotGroup> allGroupsListInPriorityOrder = bill.billStack.billGiver.Map.haulDestinationManager.AllGroupsListInPriorityOrder; int count = allGroupsListInPriorityOrder.Count; for (int i = 0; i < count; i++) { SlotGroup group = allGroupsListInPriorityOrder[i]; Zone_Stockpile zone_Stockpile = group.parent as Zone_Stockpile; if (zone_Stockpile == null) { continue; } if (!bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, zone_Stockpile)) { list.Add(new FloatMenuOption(string.Format("{0} ({1})", string.Format(item.LabelCap, group.parent.SlotYielderLabel()), "IncompatibleLower".Translate()), null)); continue; } list.Add(new FloatMenuOption(string.Format(item.LabelCap, group.parent.SlotYielderLabel()), delegate { bill.SetStoreMode(BillStoreModeDefOf.SpecificStockpile, (Zone_Stockpile)group.parent); })); } } else { BillStoreModeDef smLocal = item; list.Add(new FloatMenuOption(smLocal.LabelCap, delegate { bill.SetStoreMode(smLocal); })); } } Find.WindowStack.Add(new FloatMenu(list)); } Text.Font = GameFont.Small; listing_Standard.EndSection(listing_Standard3); listing_Standard.Gap(); Listing_Standard listing_Standard4 = listing_Standard.BeginSection(WorkerSelectionSubdialogHeight); Widgets.Dropdown(listing_Standard4.GetRect(30f), bill, (Bill_Production b) => b.pawnRestriction, (Bill_Production b) => GeneratePawnRestrictionOptions(), (bill.pawnRestriction == null) ? "AnyWorker".TranslateSimple() : bill.pawnRestriction.LabelShortCap); if (bill.pawnRestriction == null && bill.recipe.workSkill != null) { listing_Standard4.Label("AllowedSkillRange".Translate(bill.recipe.workSkill.label)); listing_Standard4.IntRange(ref bill.allowedSkillRange, 0, 20); } listing_Standard.EndSection(listing_Standard4); listing_Standard.End(); Rect rect5 = rect4; bool flag = true; for (int j = 0; j < bill.recipe.ingredients.Count; j++) { if (!bill.recipe.ingredients[j].IsFixedIngredient) { flag = false; break; } } if (!flag) { rect5.yMin = rect5.yMax - (float)IngredientRadiusSubdialogHeight; rect4.yMax = rect5.yMin - 17f; bool num = bill.GetStoreZone() == null || bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone()); ThingFilterUI.DoThingFilterConfigWindow(rect4, ref thingFilterScrollPosition, bill.ingredientFilter, bill.recipe.fixedIngredientFilter, 4, null, bill.recipe.forceHiddenSpecialFilters, forceHideHitPointsConfig: false, bill.recipe.GetPremultipliedSmallIngredients(), bill.Map); bool flag2 = bill.GetStoreZone() == null || bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, bill.GetStoreZone()); if (num && !flag2) { Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(bill.LabelCap, bill.billStack.billGiver.LabelShort.CapitalizeFirst(), bill.GetStoreZone().label), bill.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, historical: false); } } else { rect5.yMin = 50f; } Listing_Standard listing_Standard5 = new Listing_Standard(); listing_Standard5.Begin(rect5); string str2 = "IngredientSearchRadius".Translate().Truncate(rect5.width * 0.6f); string str3 = ((bill.ingredientSearchRadius == 999f) ? "Unlimited".TranslateSimple().Truncate(rect5.width * 0.3f) : bill.ingredientSearchRadius.ToString("F0")); listing_Standard5.Label(str2 + ": " + str3); bill.ingredientSearchRadius = listing_Standard5.Slider((bill.ingredientSearchRadius > 100f) ? 100f : bill.ingredientSearchRadius, 3f, 100f); if (bill.ingredientSearchRadius >= 100f) { bill.ingredientSearchRadius = 999f; } listing_Standard5.End(); Listing_Standard listing_Standard6 = new Listing_Standard(); listing_Standard6.Begin(rect2); if (bill.suspended) { if (listing_Standard6.ButtonText("Suspended".Translate())) { bill.suspended = false; SoundDefOf.Click.PlayOneShotOnCamera(); } } else if (listing_Standard6.ButtonText("NotSuspended".Translate())) { bill.suspended = true; SoundDefOf.Click.PlayOneShotOnCamera(); } StringBuilder stringBuilder = new StringBuilder(); if (bill.recipe.description != null) { stringBuilder.AppendLine(bill.recipe.description); stringBuilder.AppendLine(); } stringBuilder.AppendLine("WorkAmount".Translate() + ": " + bill.recipe.WorkAmountTotal(null).ToStringWorkAmount()); for (int k = 0; k < bill.recipe.ingredients.Count; k++) { IngredientCount ingredientCount = bill.recipe.ingredients[k]; if (!ingredientCount.filter.Summary.NullOrEmpty()) { stringBuilder.AppendLine(bill.recipe.IngredientValueGetter.BillRequirementsDescription(bill.recipe, ingredientCount)); } } stringBuilder.AppendLine(); string text2 = bill.recipe.IngredientValueGetter.ExtraDescriptionLine(bill.recipe); if (text2 != null) { stringBuilder.AppendLine(text2); stringBuilder.AppendLine(); } if (!bill.recipe.skillRequirements.NullOrEmpty()) { stringBuilder.AppendLine("MinimumSkills".Translate()); stringBuilder.AppendLine(bill.recipe.MinSkillString); } Text.Font = GameFont.Small; string text3 = stringBuilder.ToString(); if (Text.CalcHeight(text3, rect2.width) > rect2.height) { Text.Font = GameFont.Tiny; } listing_Standard6.Label(text3); Text.Font = GameFont.Small; listing_Standard6.End(); if (bill.recipe.products.Count == 1) { ThingDef thingDef = bill.recipe.products[0].thingDef; Widgets.InfoCardButton(rect2.x, rect4.y, thingDef, GenStuff.DefaultStuffFor(thingDef)); } }
public void DrawTagEditor(Rect r) { _ = r.PopRightPartPixels(Margin); var topRect = r.TopPartPixels(22f); if (Widgets.ButtonText(topRect.LeftPart(0.33f), "SelectTag")) { var floatOpts = LoadoutManager.OptionPerTag(tag => $"{tag.name}", tag => curTag = tag); if (floatOpts.Count == 0) { Messages.Message(new Message("NoTagsYetWarning", MessageTypeDefOf.RejectInput)); } else { Find.WindowStack.Add(new FloatMenu(floatOpts)); } } topRect.AdjHorzBy(topRect.width * 0.33f); if (Widgets.ButtonText(topRect.LeftHalf(), "CreateNewTag")) { curTag = new Tag(string.Empty); LoadoutManager.AddTag(curTag); } if (Widgets.ButtonText(topRect.RightHalf(), "DeleteTag")) { var floatOpts = LoadoutManager.OptionPerTag(tag => $"{tag.name}", LoadoutManager.RemoveTag); if (floatOpts.Count == 0) { Messages.Message(new Message("NoTagsYetWarning", MessageTypeDefOf.RejectInput)); } else { Find.WindowStack.Add(new FloatMenu(floatOpts)); } } r.AdjVertBy(ModGUIUtility.DEFAULT_HEIGHT); if (curTag == null) { return; } Widgets.ListSeparator(ref r.m_YMin, r.width, "Modify".Translate() + " " + curTag.name); // [ Tag Name ] [ Edit Name ] var rect = r.PopTopPartPixels(ModGUIUtility.DEFAULT_HEIGHT); ModGUIUtility.InputField(rect, "ChangeTagName".Translate(), ref curTag.name); curTag.name ??= " "; var viewRect = new Rect(r.x, r.y, rect.width - 16f, (curTag.requiredItems.Count * ModGUIUtility.SPACED_HEIGHT * 2)); Widgets.BeginScrollView(r, ref curItemScroll, viewRect); var visibilityRect = r; visibilityRect.y += curItemScroll.y; var baseRect = viewRect; List <Item> toRemove = new List <Item>(); // List each item in the currently required items // [ Info ] [ Icon ] [ Name ] [ Edit Filter ] [ Edit Quantity ] [ Remove ] foreach (var item in curTag.requiredItems) { var def = item.Def; var itemRect = baseRect.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT * 2); if (!itemRect.Overlaps(visibilityRect)) { continue; } // Info Rect infoRect = itemRect.PopLeftPartPixels(GenUI.SmallIconSize); if (Widgets.ButtonImageFitted(infoRect.ContractedBy(1f), TexButton.Info)) { Thing thing = Utility.MakeThingWithoutID(def, item.RandomStuff, item.RandomQuality); Find.WindowStack.Add(new Dialog_InfoCard(thing)); } // Icon var iconRect = itemRect.PopLeftPartPixels(ModGUIUtility.SPACED_HEIGHT * 2); if (item.Quantity > 1) { ModGUIUtility.FittedDefIconCount(iconRect, def, item.RandomStuff, item.Quantity); } else { Widgets.DefIcon(iconRect, def, item.RandomStuff); } TooltipHandler.TipRegion(iconRect, item.Def.DescriptionDetailed); // Remove var removeButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 1.5f); if (Widgets.ButtonImageFitted(removeButton.ContractedBy(1f), TexButton.DeleteX)) { toRemove.Add(item); } TooltipHandler.TipRegion(removeButton, "RemoveItemFromTag".Translate()); // Copy, Paste var copyPasteButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 3); ModGUIUtility.DraggableCopyPaste(copyPasteButton, ref item.filter, Filter.CopyFrom); TooltipHandler.TipRegion(copyPasteButton, "CopyPasteExplain".Translate()); // Edit var constrainButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 1.5f); if (Widgets.ButtonImageFitted(constrainButton.ContractedBy(1f), Textures.EditTex)) { Find.WindowStack.Add(new Dialog_ItemSpecifier(item.Filter)); } TooltipHandler.TipRegion(constrainButton, Strings.SpecifyElementsToolTip); var quantityFieldRect = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 2f); item.quantityStr ??= item.Quantity.ToString(); ModGUIUtility.InputField(quantityFieldRect.ContractedBy(0, quantityFieldRect.height / 4.0f), "QuantityField" + item.Def.defName, ref item.quantityStr); if (item.quantityStr == "") { item.SetQuantity(0); } else { try { item.SetQuantity(int.Parse(item.quantityStr)); } catch (Exception e) { Log.ErrorOnce($"Invalid numeric string {item.quantityStr}: " + e.Message, item.quantityStr.GetHashCode()); } } TooltipHandler.TipRegion(quantityFieldRect, Strings.EditQuantity); // Name Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(itemRect, item.Label); Text.Anchor = TextAnchor.UpperLeft; } Widgets.EndScrollView(); foreach (var item in toRemove) { curTag.requiredItems.Remove(item); } }
private void DrawDefList(Rect r, IReadOnlyList <ThingDef> defList) { var itms = curTag.requiredItems.Select(it => it.Def).ToHashSet(); List <ThingDef> defs = defList.Where(t => !itms.Contains(t)).ToList(); if (defFilter != string.Empty) { var filter = defFilter.ToLower(); var acceptedLayers = DefDatabase <ApparelLayerDef> .AllDefsListForReading .Where(l => l.LabelCap.ToString().ToLower().Contains(filter)); defs.RemoveAll(td => { if (td.IsApparel) { if (td.apparel.layers.Intersect(acceptedLayers).Any()) { return(false); } } return(!td.LabelCap.ToString().ToLowerInvariant().Contains(filter)); }); } ModGUIUtility.InputField(r.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT).ContractedBy(2f), "Def List Filter", ref defFilter); var viewRect = new Rect(r.x, r.y, r.width - 16f, (defs.Count * ModGUIUtility.DEFAULT_HEIGHT)); Widgets.BeginScrollView(r, ref curScroll, viewRect); GUI.BeginGroup(viewRect); var rect = new Rect(0, 0, viewRect.width, ModGUIUtility.DEFAULT_HEIGHT); var viewFrustum = r.AtZero(); viewFrustum.y += curScroll.y; for (int i = 0; i < defs.Count; i++) { if (!rect.Overlaps(viewFrustum)) { rect.y += ModGUIUtility.DEFAULT_HEIGHT; continue; } var descRect = rect.LeftPart(0.85f); var def = defs[i]; Widgets.DefIcon(descRect.LeftPart(.15f), def); Widgets.Label(descRect.RightPart(.85f), def.LabelCap); TooltipHandler.TipRegion(rect, def.DescriptionDetailed); if (Widgets.ButtonInvisible(descRect)) { AddDefToTag(def); } if (Widgets.ButtonImageFitted(rect.RightPart(0.15f).ContractedBy(2f), TexButton.Info)) { var stuff = def.MadeFromStuff ? GenStuff.AllowedStuffsFor(def).First() : null; Thing thing = Utility.MakeThingWithoutID(def, stuff, QualityCategory.Normal); Find.WindowStack.Add(new Dialog_InfoCard(thing)); } if (i % 2 == 0) { Widgets.DrawLightHighlight(rect); } Widgets.DrawHighlightIfMouseover(rect); rect.y += ModGUIUtility.DEFAULT_HEIGHT; } GUI.EndGroup(); Widgets.EndScrollView(); }
protected override void DrawIcon(Rect rect, Material buttonMat, GizmoRenderParms parms) { Widgets.DefIcon(rect, buildableDef, thingDef, 0.85f); }
private void DrawRecipeRow(RecipeDef recipe, ref float currY, float viewRect_width) { Rect rect2; Rect rect; rect = new Rect(0, currY, viewRect_width, 30); currY += ROW_HIGHT; //Display Image of Product if (recipe.products.Count > 0) { rect2 = rect; rect2.width = 30; rect2.height = 30; Widgets.DefIcon(rect2, recipe.products[0].thingDef); } rect.x = 60; Widgets.Label(rect, "" + recipe.label); rect.width = 100; rect.x = 350; if (Recipes[recipe] == enum_RecipeStatus.Learnable) { if (Widgets.ButtonText(rect, "PRF_RecipeTab_Button_Learn".Translate())) { parrentDB.Quered_Recipes.Add(recipe); } } else if (Recipes[recipe] == enum_RecipeStatus.Quered) { if (Widgets.ButtonText(rect, "PRF_RecipeTab_Button_Cancel".Translate())) { if (parrentDB.Quered_Recipes.Contains(recipe)) { parrentDB.Quered_Recipes.Remove(recipe); } } } /*Temporaly Disabled Forget Recipe Functionality*/ /*else if (Recipes[recipe] == enum_RecipeStatus.Saved) * { * //TODO add a Are you sure? popup * if (Widgets.ButtonText(rect, "PRF_RecipeTab_Button_Forget".Translate())) * { * parrentDB.Saved_Recipes.Remove(recipe); * } * }*/ else if (Recipes[recipe] == enum_RecipeStatus.InPorogress) { //TODO add a Are you sure? popup if (Widgets.ButtonText(rect, "PRF_RecipeTab_Button_Abort".Translate(parrentDB.Progress_Learning.ToStringWorkAmount()))) { parrentDB.Recipe_Learning = null; } } }
public override void DoWindowContents(Rect inRect) { Rect rect = new Rect(inRect); rect = rect.ContractedBy(18f); rect.height = 34f; rect.x += 34f; Text.Font = GameFont.Medium; Widgets.Label(rect, GetTitle()); Rect rect2 = new Rect(inRect.x + 9f, rect.y, 34f, 34f); if (thing != null) { Widgets.ThingIcon(rect2, thing); } else { Widgets.DefIcon(rect2, def, stuff, 1f, drawPlaceholder: true); } Rect rect3 = new Rect(inRect); rect3.yMin = rect.yMax; rect3.yMax -= 38f; Rect rect4 = rect3; List <TabRecord> list = new List <TabRecord>(); TabRecord item = new TabRecord("TabStats".Translate(), delegate { tab = InfoCardTab.Stats; }, tab == InfoCardTab.Stats); list.Add(item); if (ThingPawn != null) { if (ThingPawn.RaceProps.Humanlike) { TabRecord item2 = new TabRecord("TabCharacter".Translate(), delegate { tab = InfoCardTab.Character; }, tab == InfoCardTab.Character); list.Add(item2); } TabRecord item3 = new TabRecord("TabHealth".Translate(), delegate { tab = InfoCardTab.Health; }, tab == InfoCardTab.Health); list.Add(item3); if (ModsConfig.RoyaltyActive && ThingPawn.RaceProps.Humanlike && ThingPawn.Faction == Faction.OfPlayer && !ThingPawn.IsQuestLodger() && ThingPawn.royalty != null && PermitsCardUtility.selectedFaction != null) { TabRecord item4 = new TabRecord("TabPermits".Translate(), delegate { tab = InfoCardTab.Permits; }, tab == InfoCardTab.Permits); list.Add(item4); } TabRecord item5 = new TabRecord("TabRecords".Translate(), delegate { tab = InfoCardTab.Records; }, tab == InfoCardTab.Records); list.Add(item5); } if (list.Count > 1) { rect4.yMin += 45f; TabDrawer.DrawTabs(rect4, list); } FillCard(rect4.ContractedBy(18f)); if (def != null && def is BuildableDef) { IEnumerable <ThingDef> enumerable = GenStuff.AllowedStuffsFor((BuildableDef)def); if (enumerable.Count() > 0 && ShowMaterialsButton(inRect, history.Count > 0)) { List <FloatMenuOption> list2 = new List <FloatMenuOption>(); foreach (ThingDef item6 in enumerable) { ThingDef localStuff = item6; list2.Add(new FloatMenuOption(item6.LabelCap, delegate { stuff = localStuff; Setup(); }, item6)); } Find.WindowStack.Add(new FloatMenu(list2)); } } if (history.Count > 0 && Widgets.BackButtonFor(inRect)) { Hyperlink hyperlink = history[history.Count - 1]; history.RemoveAt(history.Count - 1); Find.WindowStack.TryRemove(typeof(Dialog_InfoCard), doCloseSound: false); hyperlink.OpenDialog(); } }
public void DrawTags(Rect rect) { var tags = selectedUnit.loadout.tags.ToList(); DrawHeaderButtons(ref rect, tags); rect.AdjVertBy(GenUI.GapTiny); ModGUIUtility.ListSeperator(ref rect, "AppliedTags".Translate()); tagsHeight = tags.Sum(tag => GenUI.ListSpacing * Mathf.Max(1, (Mathf.CeilToInt(tag.requiredItems.Count / 4.0f)))); var viewRect = new Rect(rect.x, rect.y, rect.width - 16f, tagsHeight); Widgets.BeginScrollView(rect, ref tagScroll, viewRect); foreach (var tag in tags) { var tagIdx = tags.FindIndex(t => t == tag); var tagHeight = GenUI.ListSpacing * Mathf.Max(1, (Mathf.CeilToInt(tag.requiredItems.Count / 4.0f))); var tagRect = viewRect.PopTopPartPixels(tagHeight); var editButtonRect = tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing); if (Widgets.ButtonImageFitted(editButtonRect, Textures.EditTex)) { Find.WindowStack.Add(new Dialog_TagEditor(tag)); } TooltipHandler.TipRegion(editButtonRect, $"Edit {tag.name}"); /*if (Widgets.ButtonImageFitted(tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing), TexButton.DeleteX)) { * selectedUnit.loadout.tags.Remove(tag); * * if ( LoadoutManager.PawnsWithTags.TryGetValue(tag, out var pList)) * { * pList.pawns.Remove(pawn); * } * * var loadoutItems = tag.ThingsAcceptedInList(pawn.InventoryAndEquipment().ToList()).ToList(); * selectedUnit.loadout.itemsToRemove.AddRange(loadoutItems.ToList()); * }*/ if (tagIdx != 0) { if (Widgets.ButtonImageFitted(tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing), TexButton.ReorderUp)) { var tmp = selectedUnit.loadout.tags[tagIdx - 1]; selectedUnit.loadout.tags[tagIdx - 1] = tag; selectedUnit.loadout.tags[tagIdx] = tmp; } } else { tagRect.PopRightPartPixels(GenUI.ListSpacing); } if (tagIdx != tags.Count - 1) { if (Widgets.ButtonImageFitted(tagRect.PopRightPartPixels(GenUI.ListSpacing).TopPartPixels(GenUI.ListSpacing), TexButton.ReorderDown)) { var tmp = selectedUnit.loadout.tags[tagIdx + 1]; selectedUnit.loadout.tags[tagIdx + 1] = tag; selectedUnit.loadout.tags[tagIdx] = tmp; } } else { tagRect.PopRightPartPixels(GenUI.ListSpacing); } Widgets.DrawBoxSolid(tagRect.PopLeftPartPixels(10.0f), Panel_ShowCoverage.GetColorForTagAtIndex(tagIdx)); tagRect.AdjHorzBy(3f); Widgets.Label(tagRect.PopLeftPartPixels(tag.name.GetWidthCached() + 10f), tag.name); var y = tagRect.y; // draw required items in blocks of 4 for (int i = 0; i < tag.requiredItems.Count; i += 4) { for (int j = 0; j < 4; j++) { var drawRect = new Rect(tagRect.x + GenUI.ListSpacing * j, y + (i / 4.0f) * GenUI.ListSpacing, GenUI.ListSpacing, GenUI.ListSpacing); var idx = i + j; if (idx >= tag.requiredItems.Count) { break; } var item = tag.requiredItems[idx]; if (item.Quantity > 1) { ModGUIUtility.FittedDefIconCount(drawRect, item.Def, item.RandomStuff, item.Quantity); } else { Widgets.DefIcon(drawRect, item.Def, item.RandomStuff); } TooltipHandler.TipRegion(drawRect, item.Def.LabelCap); } } } Widgets.EndScrollView(); }