public static bool Prefix(HairDef hair, ref bool __result) { var extension = HairDefExtension.Get(hair); // Don't include non-random or beards in the list of possible hairstyles if (!extension.randomlySelectable) { __result = false; return(false); } return(true); }
private void DrawRow(Listing_Standard usedListing, StyleItemDef listedStyleItem, Color colour, ref StyleItemDef hairToChange) { const int rowHeight = 72; var originalColour = GUI.color; var rect = usedListing.GetRect(rowHeight); // Full-rect stuff if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } else if (listedStyleItem == hairToChange) { GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, GUI.color.a * 0.5f); GUI.DrawTexture(rect, TexUI.HighlightTex); GUI.color = originalColour; } if (Widgets.ButtonInvisible(rect, true)) { hairToChange = listedStyleItem; RimWorld.SoundDefOf.Click.PlayOneShotOnCamera(); } // Preview image (consider poorly-configured defs) if (!StaticConstructorClass.badHairDefs.Contains(listedStyleItem)) { var previewImageRect = rect.LeftPartPixels(rowHeight); var hairGraphic = GraphicDatabase.Get <Graphic_Multi>(listedStyleItem.texPath, ShaderDatabase.Cutout, Vector2.one, colour); GUI.color = colour; GUI.DrawTexture(previewImageRect, hairGraphic.MatSouth.mainTexture); GUI.color = originalColour; } // Text var textRect = rect.RightPartPixels(rect.width - rowHeight - usedListing.verticalSpacing); var originalFont = Text.Font; var originalAnchor = Text.Anchor; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.LowerLeft; string hairLabelCap = listedStyleItem.LabelCap; if (Text.CalcSize(hairLabelCap).x > textRect.width) { string hairLabelCapOriginal = hairLabelCap; hairLabelCap = hairLabelCap.Truncate(textRect.width, truncatedLabelCache); TooltipHandler.TipRegion(textRect, () => hairLabelCapOriginal, listedStyleItem.GetHashCode()); } Widgets.Label(textRect.TopHalf(), hairLabelCap); Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(textRect.BottomHalf(), $"{"WorkAmount".Translate()}: {((float)HairDefExtension.Get(listedStyleItem).workToStyle).ToStringWorkAmount()}"); Text.Font = originalFont; Text.Anchor = originalAnchor; usedListing.Gap(usedListing.verticalSpacing); }