mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
101 lines
3 KiB
C#
101 lines
3 KiB
C#
using RimWorld;
|
|
using rjw;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace RJWSexperience.SexHistory.UI
|
|
{
|
|
public static class RJWUIUtility
|
|
{
|
|
public const float FONTHEIGHT = 22f;
|
|
public const float CARDHEIGHT = 110f;
|
|
public const float LISTPAWNSIZE = 100f;
|
|
public const float BASESAT = 0.40f;
|
|
public const float ICONSIZE = 30f;
|
|
|
|
public static void DrawQuirk(this Rect rect, Pawn pawn)
|
|
{
|
|
List<Quirk> quirks = Quirk.All.FindAll(x => pawn.Has(x));
|
|
string quirkstr = quirks.Select(x => x.Key).ToCommaList();
|
|
string tooltip = "";
|
|
|
|
Widgets.Label(rect, "Quirks".Translate() + quirkstr);
|
|
|
|
if (Mouse.IsOver(rect))
|
|
{
|
|
if (quirks.NullOrEmpty())
|
|
{
|
|
tooltip = "NoQuirks".Translate();
|
|
}
|
|
else
|
|
{
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
foreach (var q in quirks)
|
|
{
|
|
stringBuilder.AppendLine(q.Key.Colorize(Color.yellow));
|
|
stringBuilder.AppendLine(q.LocaliztionKey.Translate(pawn.Named("pawn")).AdjustedFor(pawn).Resolve());
|
|
stringBuilder.AppendLine("");
|
|
}
|
|
tooltip = stringBuilder.ToString().TrimEndNewlines();
|
|
}
|
|
Widgets.DrawHighlight(rect);
|
|
}
|
|
|
|
TooltipHandler.TipRegion(rect, tooltip);
|
|
}
|
|
|
|
public static void DrawSexuality(this Rect rect, CompRJW comp)
|
|
{
|
|
if (comp != null)
|
|
{
|
|
string sexuality = Keyed.Sexuality[(int)comp.orientation];
|
|
Widgets.Label(rect, Keyed.RS_Sexuality + ": " + sexuality);
|
|
Widgets.DrawHighlightIfMouseover(rect);
|
|
}
|
|
}
|
|
|
|
public static string GetRelationsString(this Pawn pawn, Pawn otherpawn)
|
|
{
|
|
if (otherpawn != null)
|
|
{
|
|
IEnumerable<PawnRelationDef> relations = pawn.GetRelations(otherpawn);
|
|
if (!relations.EnumerableNullOrEmpty()) return relations.Select(x => x.GetGenderSpecificLabel(otherpawn)).ToCommaList().CapitalizeFirst();
|
|
}
|
|
return "";
|
|
}
|
|
|
|
public static void DrawBorder(this Rect rect, Texture border, float thickness = 1f)
|
|
{
|
|
GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, thickness), border);
|
|
GUI.DrawTexture(new Rect(rect.x + rect.width - thickness, rect.y, thickness, rect.height), border);
|
|
GUI.DrawTexture(new Rect(rect.x, rect.y + rect.height - thickness, rect.width, thickness), border);
|
|
GUI.DrawTexture(new Rect(rect.x, rect.y, thickness, rect.height), border);
|
|
}
|
|
|
|
public static string GetStatExplanation(Pawn pawn, StatDef stat, float val)
|
|
{
|
|
if (!pawn.Dead)
|
|
return stat.description + "\n" + stat.Worker.GetExplanationFull(StatRequest.For(pawn), ToStringNumberSense.Undefined, val);
|
|
return "Dead".Translate();
|
|
}
|
|
|
|
public static string GetSexDays(int absticks, bool printUnknown = false)
|
|
{
|
|
if (absticks != 0)
|
|
return GenDate.ToStringTicksToDays(GenTicks.TicksAbs - absticks) + " " + Keyed.RS_Ago;
|
|
else if (printUnknown)
|
|
return Keyed.Unknown;
|
|
return "";
|
|
}
|
|
|
|
public static Texture GetRaceIcon(Pawn pawn, Vector2 size)
|
|
{
|
|
if (pawn != null)
|
|
return PortraitsCache.Get(pawn, size, Rot4.South, default, 1, true, true, false, false);
|
|
return HistoryUtility.UnknownPawn;
|
|
}
|
|
}
|
|
}
|