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); }
static bool Prefix(ref bool __result, Pawn pawn, StyleItemDef styleItemDef) { if (styleItemDef is GradientHairMaskDef) { __result = false; return(false); } return(true); }
static bool Prefix(ref float __result, StyleItemDef styleItem) { if (!(styleItem is GradientHairMaskDef)) { return(true); } __result = -styleItem.index; return(false); }
public static bool Prefix(Pawn pawn, TattooType tattooType, ref StyleItemDef __result) { IEnumerable <StyleItemDef> source = from item in DefDatabase <StyleItemDef> .AllDefs where PawnStyleItemChooser.WantsToUseStyle(pawn, item, tattooType) select item; if (!source.Any <StyleItemDef>()) { Log.Error("Error finding style item for " + pawn.LabelShort + " of " + pawn.Faction); __result = default(StyleItemDef); return(false); } __result = source.RandomElementByWeight((StyleItemDef s) => PawnStyleItemChooser.TotalStyleItemLikelihood(s, pawn)); return(false); }