More of reusing objects in SexStatusViewModel

This commit is contained in:
amevarashi 2023-07-24 20:47:00 +05:00
parent bed83e1eca
commit ffe6a9b7f7
6 changed files with 212 additions and 209 deletions

View File

@ -47,25 +47,5 @@ namespace RJWSexperience.SexHistory.UI
_labelRight = ""; _labelRight = "";
Border = null; Border = null;
} }
public BarInfo(string label, float fillPercent, Texture2D fillTexture, TipSignal tooltip, string labelRight = "", Texture2D border = null)
{
_label = label.CapitalizeFirst();
_fillPercent = Mathf.Clamp01(fillPercent);
FillTexture = fillTexture;
Tooltip = tooltip;
_labelRight = labelRight.CapitalizeFirst();
Border = border;
}
public BarInfo(string label, float fillPercent, Texture2D fillTexture, string labelRight = "")
{
_label = label.CapitalizeFirst();
_fillPercent = Mathf.Clamp01(fillPercent);
FillTexture = fillTexture;
Tooltip = default;
_labelRight = labelRight.CapitalizeFirst();
Border = null;
}
} }
} }

View File

@ -1,86 +1,93 @@
using RimWorld; using RimWorld;
using rjw; using rjw;
using System;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
namespace RJWSexperience.SexHistory.UI namespace RJWSexperience.SexHistory.UI
{ {
public readonly struct InfoCard public class InfoCard
{ {
public readonly SexPartnerHistoryRecord partnerRecord; private readonly Pawn _pawn;
public readonly string label; private readonly string _tooltipLabel;
public readonly string lastSexTime;
public readonly string name;
public readonly string sexCount;
public readonly string orgasms;
public readonly string relations;
public readonly BarInfo bestSextype;
public readonly PartnerPortraitInfo portraitInfo;
public readonly TipSignal tooltip;
public InfoCard(Pawn pawn, SexPartnerHistoryRecord partnerRecord, string label, string tooltipLabel, int lastSexTimeTicks) public string Label { get; }
public string LastSexTime { get; set; }
public string Name { get; private set; }
public string SexCount { get; private set; }
public string Orgasms { get; private set; }
public string Relations { get; private set; }
public BarInfo BestSextype { get; }
public SexPartnerHistoryRecord PartnerRecord { get; private set; }
public PartnerPortraitInfo PortraitInfo { get; }
public TipSignal Tooltip { get; private set; }
public InfoCard(Pawn pawn, string label, string tooltipLabel)
{ {
this.partnerRecord = partnerRecord; Label = label;
this.label = label; _pawn = pawn;
_tooltipLabel = tooltipLabel;
BestSextype = new BarInfo();
PortraitInfo = new PartnerPortraitInfo(_pawn);
}
lastSexTime = UIUtility.GetSexDays(lastSexTimeTicks); public void UpdatePartnerRecord(SexPartnerHistoryRecord partnerRecord)
portraitInfo = new PartnerPortraitInfo(pawn, partnerRecord); {
PartnerRecord = partnerRecord;
PortraitInfo.UpdatePartnerRecord(partnerRecord);
if (partnerRecord != null) if (partnerRecord == null)
{ {
name = partnerRecord.Partner?.Name?.ToStringFull ?? partnerRecord.Label.CapitalizeFirst(); Name = Keyed.Unknown;
sexCount = Keyed.RS_Sex_Count + partnerRecord.TotalSexCount; SexCount = Keyed.RS_Sex_Count + "?";
Orgasms = Keyed.RS_Orgasms + "?";
Relations = string.Empty;
Tooltip = default;
if (partnerRecord.Raped > 0) BestSextype.Label = Keyed.RS_Best_Sextype + ": " + Keyed.Sextype[(int)xxx.rjwSextype.None];
{ BestSextype.FillPercent = 0f;
sexCount += " " + Keyed.RS_Raped + partnerRecord.Raped; BestSextype.FillTexture = Texture2D.linearGrayTexture;
} BestSextype.LabelRight = "";
if (partnerRecord.RapedMe > 0) return;
{
sexCount += " " + Keyed.RS_RapedMe + partnerRecord.RapedMe;
}
orgasms = Keyed.RS_Orgasms + partnerRecord.OrgasmCount;
relations = pawn.GetRelationsString(partnerRecord.Partner);
tooltip = new TipSignal(() =>
{
string completeTip = tooltipLabel;
if (partnerRecord.Incest)
{
completeTip += " - " + Keyed.Incest;
}
if (partnerRecord.IamFirst)
{
completeTip += "\n" + Keyed.RS_LostVirgin(partnerRecord.Label, pawn.LabelShort);
}
if (partnerRecord.BestSexTickAbs != 0)
{
completeTip += "\n" + Keyed.RS_HadBestSexDaysAgo(partnerRecord.BestSexElapsedTicks.ToStringTicksToDays() + " " + Keyed.RS_Ago);
}
return completeTip;
}, tooltipLabel.GetHashCode());
float relativeBestSatisfaction = partnerRecord.BestSatisfaction / UIUtility.BASESAT;
bestSextype = new BarInfo(
label: Keyed.RS_Best_Sextype + ": " + Keyed.Sextype[(int)partnerRecord.BestSextype],
fillPercent: relativeBestSatisfaction / 2,
fillTexture: HistoryUtility.SextypeColor[(int)partnerRecord.BestSextype],
labelRight: relativeBestSatisfaction.ToStringPercent());
} }
else
Name = partnerRecord.Partner?.Name?.ToStringFull ?? partnerRecord.Label.CapitalizeFirst();
SexCount = Keyed.RS_Sex_Count + partnerRecord.TotalSexCount;
if (partnerRecord.Raped > 0)
{ {
name = Keyed.Unknown; SexCount += " " + Keyed.RS_Raped + partnerRecord.Raped;
sexCount = Keyed.RS_Sex_Count + "?";
orgasms = Keyed.RS_Orgasms + "?";
relations = string.Empty;
tooltip = default;
bestSextype = new BarInfo(
label: String.Format(Keyed.RS_Best_Sextype + ": {0}", Keyed.Sextype[(int)xxx.rjwSextype.None]),
fillPercent: 0f,
fillTexture: Texture2D.linearGrayTexture);
} }
if (partnerRecord.RapedMe > 0)
{
SexCount += " " + Keyed.RS_RapedMe + partnerRecord.RapedMe;
}
Orgasms = Keyed.RS_Orgasms + partnerRecord.OrgasmCount;
Relations = _pawn.GetRelationsString(partnerRecord.Partner);
Tooltip = new TipSignal(() =>
{
string completeTip = _tooltipLabel;
if (partnerRecord.Incest)
{
completeTip += " - " + Keyed.Incest;
}
if (partnerRecord.IamFirst)
{
completeTip += "\n" + Keyed.RS_LostVirgin(partnerRecord.Label, _pawn.LabelShort);
}
if (partnerRecord.BestSexTickAbs != 0)
{
completeTip += "\n" + Keyed.RS_HadBestSexDaysAgo(partnerRecord.BestSexElapsedTicks.ToStringTicksToDays() + " " + Keyed.RS_Ago);
}
return completeTip;
}, _tooltipLabel.GetHashCode());
float relativeBestSatisfaction = partnerRecord.BestSatisfaction / UIUtility.BASESAT;
BestSextype.Label = Keyed.RS_Best_Sextype + ": " + Keyed.Sextype[(int)partnerRecord.BestSextype];
BestSextype.FillPercent = relativeBestSatisfaction / 2;
BestSextype.FillTexture = HistoryUtility.SextypeColor[(int)partnerRecord.BestSextype];
BestSextype.LabelRight = relativeBestSatisfaction.ToStringPercent();
} }
} }
} }

View File

@ -5,29 +5,43 @@ using Verse;
namespace RJWSexperience.SexHistory.UI namespace RJWSexperience.SexHistory.UI
{ {
public readonly struct PartnerPortraitInfo public class PartnerPortraitInfo
{ {
public readonly SexPartnerHistoryRecord partnerRecord; private readonly Pawn _pawn;
public readonly bool lover;
public readonly Func<Vector2, Texture> portraitGetter; public SexPartnerHistoryRecord PartnerRecord { get; private set; }
public bool Lover { get; private set; }
public Func<Vector2, Texture> PortraitGetter { get; private set; }
public PartnerPortraitInfo(Pawn pawn)
{
_pawn = pawn;
}
public PartnerPortraitInfo(Pawn pawn, SexPartnerHistoryRecord partnerRecord) public PartnerPortraitInfo(Pawn pawn, SexPartnerHistoryRecord partnerRecord)
{ {
this.partnerRecord = partnerRecord; _pawn = pawn;
lover = false; UpdatePartnerRecord(partnerRecord);
}
public void UpdatePartnerRecord(SexPartnerHistoryRecord partnerRecord)
{
PartnerRecord = partnerRecord;
if (partnerRecord?.Partner != null) if (partnerRecord?.Partner != null)
{ {
portraitGetter = (size) => PortraitsCache.Get(partnerRecord.Partner, size, Rot4.South, default, 1, true, true, false, false); PortraitGetter = (size) => PortraitsCache.Get(partnerRecord.Partner, size, Rot4.South, default, 1, true, true, false, false);
lover = LovePartnerRelationUtility.LovePartnerRelationExists(pawn, partnerRecord.Partner); Lover = LovePartnerRelationUtility.LovePartnerRelationExists(_pawn, partnerRecord.Partner);
} }
else if (partnerRecord?.Race?.uiIcon != null) else if (partnerRecord?.Race?.uiIcon != null)
{ {
portraitGetter = (_) => partnerRecord.Race.uiIcon; PortraitGetter = (_) => partnerRecord.Race.uiIcon;
Lover = false;
} }
else else
{ {
portraitGetter = (_) => HistoryUtility.UnknownPawn; PortraitGetter = (_) => HistoryUtility.UnknownPawn;
Lover = false;
} }
} }
} }

View File

@ -3,53 +3,58 @@ using UnityEngine;
namespace RJWSexperience.SexHistory.UI namespace RJWSexperience.SexHistory.UI
{ {
public readonly struct PreferedRaceCard public class PreferedRaceCard
{ {
public readonly string preferRaceLabel; private readonly SexHistoryComp _sexHistory;
public readonly string preferRaceTypeLabel;
public readonly string sexCount; public string PreferRaceLabel { get; private set; }
public readonly BarInfo barInfo; public string PreferRaceTypeLabel { get; private set; }
public readonly Func<Vector2, Texture> portraitGetter; public string SexCount { get; private set; }
public BarInfo BarInfo { get; } = new BarInfo(Texture2D.linearGrayTexture);
public Func<Vector2, Texture> PortraitGetter { get; private set; }
public PreferedRaceCard(SexHistoryComp sexHistory) public PreferedRaceCard(SexHistoryComp sexHistory)
{ {
if (sexHistory.PreferRace == null) _sexHistory = sexHistory;
}
public void Update()
{
if (_sexHistory.PreferRace == null)
{ {
preferRaceLabel = Keyed.None; PreferRaceLabel = Keyed.None;
preferRaceTypeLabel = null; PreferRaceTypeLabel = null;
sexCount = null; SexCount = null;
barInfo = null; BarInfo.Label = null;
portraitGetter = (_) => HistoryUtility.UnknownPawn; BarInfo.FillPercent = 0f;
PortraitGetter = (_) => HistoryUtility.UnknownPawn;
return; return;
} }
preferRaceLabel = sexHistory.PreferRace.LabelCap; PreferRaceLabel = _sexHistory.PreferRace.LabelCap;
sexCount = Keyed.RS_Sex_Count + sexHistory.PreferRaceSexCount; SexCount = Keyed.RS_Sex_Count + _sexHistory.PreferRaceSexCount;
portraitGetter = (size) => UIUtility.GetRaceIcon(sexHistory.PreferRacePawn, size); PortraitGetter = (size) => UIUtility.GetRaceIcon(_sexHistory.PreferRacePawn, size);
if (sexHistory.PreferRace != sexHistory.ParentPawn.def) if (_sexHistory.PreferRace != _sexHistory.ParentPawn.def)
{ {
if (sexHistory.PreferRace.race.Animal != sexHistory.ParentPawn.def.race.Animal) if (_sexHistory.PreferRace.race.Animal != _sexHistory.ParentPawn.def.race.Animal)
{ {
preferRaceTypeLabel = Keyed.RS_Bestiality; PreferRaceTypeLabel = Keyed.RS_Bestiality;
barInfo = new BarInfo( BarInfo.Label = Keyed.RS_SexInfo(Keyed.RS_Bestiality, _sexHistory.BestialityCount);
label: Keyed.RS_SexInfo(Keyed.RS_Bestiality, sexHistory.BestialityCount), BarInfo.FillPercent = _sexHistory.BestialityCount / 100f;
fillPercent: sexHistory.BestialityCount / 100f,
fillTexture: Texture2D.linearGrayTexture);
} }
else else
{ {
preferRaceTypeLabel = Keyed.RS_Interspecies; PreferRaceTypeLabel = Keyed.RS_Interspecies;
barInfo = new BarInfo( BarInfo.Label = Keyed.RS_SexInfo(Keyed.RS_Interspecies, _sexHistory.InterspeciesCount);
label: Keyed.RS_SexInfo(Keyed.RS_Interspecies, sexHistory.InterspeciesCount), BarInfo.FillPercent = _sexHistory.InterspeciesCount / 100f;
fillPercent: sexHistory.InterspeciesCount / 100f,
fillTexture: Texture2D.linearGrayTexture);
} }
} }
else else
{ {
preferRaceTypeLabel = null; PreferRaceTypeLabel = null;
barInfo = null; BarInfo.Label = null;
BarInfo.FillPercent = 0f;
} }
} }
} }

View File

@ -48,15 +48,31 @@ namespace RJWSexperience.SexHistory.UI
{ {
AgeAndTitle = Pawn.ageTracker.AgeBiologicalYears + ", " + Pawn.def.label; AgeAndTitle = Pawn.ageTracker.AgeBiologicalYears + ", " + Pawn.def.label;
} }
for (int i = 0; i < Sextype.Length; i++)
{
int sexIndex = Sextype[i];
SexTypes.Add(new BarInfo(HistoryUtility.SextypeColor[sexIndex]));
}
InfoCards.Add(new InfoCard(Pawn, Keyed.RS_Recent_Sex_Partner, Keyed.RS_Recent_Sex_Partner_ToolTip));
InfoCards.Add(new InfoCard(Pawn, Keyed.RS_First_Sex_Partner, Keyed.RS_First_Sex_Partner_ToolTip));
InfoCards.Add(new InfoCard(Pawn, Keyed.RS_Most_Sex_Partner, Keyed.RS_Most_Sex_Partner_ToolTip));
InfoCards.Add(new InfoCard(Pawn, Keyed.RS_Best_Sex_Partner, Keyed.RS_Best_Sex_Partner_ToolTip));
SelectedPartnerCard = new InfoCard(Pawn, Keyed.RS_Selected_Partner, Keyed.RS_Selected_Partner);
PreferedRaceCard = new PreferedRaceCard(_history);
} }
public Pawn Pawn => _history.ParentPawn; public Pawn Pawn => _history.ParentPawn;
public string Name { get; } public string Name { get; }
public string AgeAndTitle { get; } public string AgeAndTitle { get; }
public List<InfoCard> InfoCards { get; } = new List<InfoCard>(); public List<InfoCard> InfoCards { get; } = new List<InfoCard>();
public InfoCard SelectedPartnerCard { get; private set; } public InfoCard SelectedPartnerCard { get; }
public PreferedRaceCard PreferedRaceCard { get; private set; } public PreferedRaceCard PreferedRaceCard { get; }
public List<BarInfo> SexTypes { get; } = new List<BarInfo>(); public List<BarInfo> SexTypes { get; } = new List<BarInfo>();
public BarInfo PartnerCount { get; } = new BarInfo(HistoryUtility.Partners);
public BarInfo VirginsTaken { get; } = new BarInfo(HistoryUtility.Partners);
public BarInfo TotalSex { get; } = new BarInfo(HistoryUtility.TotalSex); public BarInfo TotalSex { get; } = new BarInfo(HistoryUtility.TotalSex);
public BarInfo Lust { get; } = new BarInfo(HistoryUtility.Slaanesh); public BarInfo Lust { get; } = new BarInfo(HistoryUtility.Slaanesh);
public BarInfo BestSextype { get; } = new BarInfo(); public BarInfo BestSextype { get; } = new BarInfo();
@ -87,7 +103,7 @@ namespace RJWSexperience.SexHistory.UI
UpdateBars(); UpdateBars();
UpdateQuirks(); UpdateQuirks();
UpdateVirginAndSexuality(); UpdateVirginAndSexuality();
PreferedRaceCard = new PreferedRaceCard(_history); PreferedRaceCard.Update();
int tickRateMultiplier = (int)Find.TickManager.TickRateMultiplier; int tickRateMultiplier = (int)Find.TickManager.TickRateMultiplier;
if (tickRateMultiplier == 0) // Paused if (tickRateMultiplier == 0) // Paused
@ -101,35 +117,21 @@ namespace RJWSexperience.SexHistory.UI
private void UpdateInfoCards() private void UpdateInfoCards()
{ {
InfoCards.Clear(); InfoCard recentSexPartner = InfoCards[0];
recentSexPartner.LastSexTime = UIUtility.GetSexDays(_history.RecentSexTickAbs);
recentSexPartner.UpdatePartnerRecord(_history.RecentPartnerRecord);
InfoCards.Add(new InfoCard( InfoCard firstSexPartner = InfoCards[1];
pawn: Pawn, firstSexPartner.LastSexTime = UIUtility.GetSexDays(_history.FirstSexTickAbs);
partnerRecord: _history.RecentPartnerRecord, firstSexPartner.UpdatePartnerRecord(_history.FirstPartnerRecord);
label: Keyed.RS_Recent_Sex_Partner,
tooltipLabel: Keyed.RS_Recent_Sex_Partner_ToolTip,
lastSexTimeTicks: _history.RecentSexTickAbs));
InfoCards.Add(new InfoCard( InfoCard mostSexPartner = InfoCards[2];
pawn: Pawn, mostSexPartner.LastSexTime = UIUtility.GetSexDays(_history.MostSexTickAbs);
partnerRecord: _history.FirstPartnerRecord, mostSexPartner.UpdatePartnerRecord(_history.MostPartnerRecord);
label: Keyed.RS_First_Sex_Partner,
tooltipLabel: Keyed.RS_First_Sex_Partner_ToolTip,
lastSexTimeTicks: _history.FirstSexTickAbs));
InfoCards.Add(new InfoCard( InfoCard bestSexPartner = InfoCards[3];
pawn: Pawn, bestSexPartner.LastSexTime = UIUtility.GetSexDays(_history.BestSexTickAbs);
partnerRecord: _history.MostPartnerRecord, bestSexPartner.UpdatePartnerRecord(_history.BestSexPartnerRecord);
label: Keyed.RS_Most_Sex_Partner,
tooltipLabel: Keyed.RS_Most_Sex_Partner_ToolTip,
lastSexTimeTicks: _history.MostSexTickAbs));
InfoCards.Add(new InfoCard(
pawn: Pawn,
partnerRecord: _history.BestSexPartnerRecord,
label: Keyed.RS_Best_Sex_Partner,
tooltipLabel: Keyed.RS_Best_Sex_Partner_ToolTip,
lastSexTimeTicks: _history.BestSexTickAbs));
if (SelectedPartner != null) if (SelectedPartner != null)
{ {
@ -145,34 +147,28 @@ namespace RJWSexperience.SexHistory.UI
maxSatisfaction = UIUtility.BASESAT; maxSatisfaction = UIUtility.BASESAT;
} }
SexTypes.Clear();
for (int i = 0; i < Sextype.Length; i++) for (int i = 0; i < Sextype.Length; i++)
{ {
int sexIndex = Sextype[i]; int sexIndex = Sextype[i];
float AverageSatisfaction = _history.GetAVGSat(sexIndex); float AverageSatisfaction = _history.GetAVGSat(sexIndex);
float relativeSat = AverageSatisfaction / maxSatisfaction; float relativeSat = AverageSatisfaction / maxSatisfaction;
float satisfactionRelativeToBase = AverageSatisfaction / UIUtility.BASESAT; float satisfactionRelativeToBase = AverageSatisfaction / UIUtility.BASESAT;
SexTypes.Add(new BarInfo(
label: Keyed.RS_SexInfo(Keyed.Sextype[sexIndex], _history.GetSexCount(sexIndex)), BarInfo sexTypeBar = SexTypes[i];
fillPercent: relativeSat, sexTypeBar.Label = Keyed.RS_SexInfo(Keyed.Sextype[sexIndex], _history.GetSexCount(sexIndex));
fillTexture: HistoryUtility.SextypeColor[sexIndex], sexTypeBar.FillPercent = relativeSat;
tooltip: Keyed.RS_LastSex + ": " + UIUtility.GetSexDays(_history.GetSextypeRecentTickAbs(sexIndex), true), sexTypeBar.Tooltip = Keyed.RS_LastSex + ": " + UIUtility.GetSexDays(_history.GetSextypeRecentTickAbs(sexIndex), true);
labelRight: Keyed.RS_SatAVG(satisfactionRelativeToBase))); sexTypeBar.LabelRight = Keyed.RS_SatAVG(satisfactionRelativeToBase);
} }
SexTypes.Add(new BarInfo( PartnerCount.Label = string.Format(Keyed.RS_Sex_Partners + ": {0} ({1})", _history.PartnerCount, Pawn.records.GetValue(RsDefOf.Record.SexPartnerCount));
label: string.Format(Keyed.RS_Sex_Partners + ": {0} ({1})", _history.PartnerCount, Pawn.records.GetValue(RsDefOf.Record.SexPartnerCount)), PartnerCount.FillPercent = _history.PartnerCount / 50f;
fillPercent: _history.PartnerCount / 50,
fillTexture: HistoryUtility.Partners));
SexTypes.Add(new BarInfo( VirginsTaken.Label = string.Format(Keyed.RS_VirginsTaken + ": {0:0}", _history.VirginsTaken);
label: string.Format(Keyed.RS_VirginsTaken + ": {0:0}", _history.VirginsTaken), VirginsTaken.FillPercent = _history.VirginsTaken / 100f;
fillPercent: _history.VirginsTaken / 100,
fillTexture: HistoryUtility.Partners));
TotalSex.Label = string.Format(Keyed.RS_TotalSexHad + ": {0:0} ({1:0})", _history.TotalSexHad, Pawn.records.GetValue(xxx.CountOfSex)); TotalSex.Label = string.Format(Keyed.RS_TotalSexHad + ": {0:0} ({1:0})", _history.TotalSexHad, Pawn.records.GetValue(xxx.CountOfSex));
TotalSex.FillPercent = _history.TotalSexHad / 100; TotalSex.FillPercent = _history.TotalSexHad / 100f;
TotalSex.LabelRight = Keyed.RS_SatAVG(_history.AVGSat); TotalSex.LabelRight = Keyed.RS_SatAVG(_history.AVGSat);
float lust = Pawn.records.GetValue(RsDefOf.Record.Lust); float lust = Pawn.records.GetValue(RsDefOf.Record.Lust);
@ -308,13 +304,13 @@ namespace RJWSexperience.SexHistory.UI
Partners = partners; Partners = partners;
break; break;
case PartnerOrderMode.Recent: case PartnerOrderMode.Recent:
Partners = partners.OrderBy(x => x.partnerRecord.RecentSexTickAbs); Partners = partners.OrderBy(x => x.PartnerRecord.RecentSexTickAbs);
break; break;
case PartnerOrderMode.Most: case PartnerOrderMode.Most:
Partners = partners.OrderBy(x => x.partnerRecord.TotalSexCount); Partners = partners.OrderBy(x => x.PartnerRecord.TotalSexCount);
break; break;
case PartnerOrderMode.Name: case PartnerOrderMode.Name:
Partners = partners.OrderBy(x => x.partnerRecord.Label); Partners = partners.OrderBy(x => x.PartnerRecord.Label);
break; break;
} }
} }
@ -327,18 +323,16 @@ namespace RJWSexperience.SexHistory.UI
private void UpdateSelectedPartnerCard() private void UpdateSelectedPartnerCard()
{ {
SelectedPartnerCard.UpdatePartnerRecord(SelectedPartner);
if (SelectedPartner == null) if (SelectedPartner == null)
{ {
SelectedPartnerCard = default; SelectedPartnerCard.LastSexTime = null;
return; }
else
{
SelectedPartnerCard.LastSexTime = UIUtility.GetSexDays(SelectedPartner.RecentSexTickAbs);
} }
SelectedPartnerCard = new InfoCard(
pawn: Pawn,
partnerRecord: SelectedPartner,
label: Keyed.RS_Selected_Partner,
tooltipLabel: Keyed.RS_Selected_Partner,
lastSexTimeTicks: SelectedPartner.RecentSexTickAbs);
} }
private float GetStatValue(StatDef statDef) => Pawn.Dead ? 0f : Pawn.GetStatValue(statDef); private float GetStatValue(StatDef statDef) => Pawn.Dead ? 0f : Pawn.GetStatValue(statDef);

View File

@ -161,13 +161,13 @@ namespace RJWSexperience.SexHistory.UI
Rect sexinfoRect2 = new Rect(rect.x + portraitRect.width, rect.y + (FONTHEIGHT * 2), rect.width - portraitRect.width, FONTHEIGHT); Rect sexinfoRect2 = new Rect(rect.x + portraitRect.width, rect.y + (FONTHEIGHT * 2), rect.width - portraitRect.width, FONTHEIGHT);
Rect bestsexRect = new Rect(rect.x + 2f, rect.y + (FONTHEIGHT * 3), rect.width - 4f, FONTHEIGHT - 2f); Rect bestsexRect = new Rect(rect.x + 2f, rect.y + (FONTHEIGHT * 3), rect.width - 4f, FONTHEIGHT - 2f);
if (context.partnerRecord != null) if (context.PartnerRecord != null)
{ {
DrawPartnerPortrait(portraitRect, context.portraitInfo); DrawPartnerPortrait(portraitRect, context.PortraitInfo);
Widgets.DrawHighlightIfMouseover(portraitRect); Widgets.DrawHighlightIfMouseover(portraitRect);
if (Widgets.ButtonInvisible(portraitRect)) if (Widgets.ButtonInvisible(portraitRect))
{ {
SexHistoryComp partnerHistory = context.partnerRecord.Partner?.TryGetComp<SexHistoryComp>(); SexHistoryComp partnerHistory = context.PartnerRecord.Partner?.TryGetComp<SexHistoryComp>();
if (partnerHistory != null) if (partnerHistory != null)
{ {
ChangePawn(partnerHistory); ChangePawn(partnerHistory);
@ -179,24 +179,24 @@ namespace RJWSexperience.SexHistory.UI
} }
} }
GUI.Label(sexinfoRect2, context.relations + " ", fontStyleRight); GUI.Label(sexinfoRect2, context.Relations + " ", fontStyleRight);
TooltipHandler.TipRegion(rect, context.tooltip); TooltipHandler.TipRegion(rect, context.Tooltip);
} }
else else
{ {
Widgets.DrawTextureFitted(portraitRect, HistoryUtility.UnknownPawn, 1.0f); Widgets.DrawTextureFitted(portraitRect, HistoryUtility.UnknownPawn, 1.0f);
} }
Widgets.Label(nameRect, context.name); Widgets.Label(nameRect, context.Name);
Widgets.Label(sexinfoRect, context.sexCount); Widgets.Label(sexinfoRect, context.SexCount);
Widgets.Label(sexinfoRect2, context.orgasms); Widgets.Label(sexinfoRect2, context.Orgasms);
UIUtility.FillableBarLabeled(bestsexRect, context.bestSextype); UIUtility.FillableBarLabeled(bestsexRect, context.BestSextype);
} }
protected void DrawSexInfoCard(Rect rect, InfoCard context) protected void DrawSexInfoCard(Rect rect, InfoCard context)
{ {
rect.SplitHorizontally(FONTHEIGHT, out Rect labelRect, out Rect infoRect); rect.SplitHorizontally(FONTHEIGHT, out Rect labelRect, out Rect infoRect);
GUI.Label(labelRect, context.label, fontStyleLeft); GUI.Label(labelRect, context.Label, fontStyleLeft);
GUI.Label(labelRect, context.lastSexTime, fontStyleRight); GUI.Label(labelRect, context.LastSexTime, fontStyleRight);
DrawInfoWithPortrait(infoRect, context); DrawInfoWithPortrait(infoRect, context);
} }
@ -225,22 +225,22 @@ namespace RJWSexperience.SexHistory.UI
Rect infoRect2 = new Rect(infoRect.x, infoRect.y + FONTHEIGHT, infoRect.width, FONTHEIGHT); Rect infoRect2 = new Rect(infoRect.x, infoRect.y + FONTHEIGHT, infoRect.width, FONTHEIGHT);
Rect infoRect3 = new Rect(infoRect.x, infoRect.y + (FONTHEIGHT * 2), infoRect.width - 2f, FONTHEIGHT); Rect infoRect3 = new Rect(infoRect.x, infoRect.y + (FONTHEIGHT * 2), infoRect.width - 2f, FONTHEIGHT);
Widgets.DrawTextureFitted(portraitRect, preferedRaceCard.portraitGetter(portraitRect.size), 1.0f); Widgets.DrawTextureFitted(portraitRect, preferedRaceCard.PortraitGetter(portraitRect.size), 1.0f);
GUI.Label(infoRect1, preferedRaceCard.preferRaceLabel, fontStyleLeft); GUI.Label(infoRect1, preferedRaceCard.PreferRaceLabel, fontStyleLeft);
if (preferedRaceCard.preferRaceTypeLabel != null) if (preferedRaceCard.PreferRaceTypeLabel != null)
{ {
GUI.Label(infoRect1, preferedRaceCard.preferRaceTypeLabel + " ", fontStyleRight); GUI.Label(infoRect1, preferedRaceCard.PreferRaceTypeLabel + " ", fontStyleRight);
} }
if (preferedRaceCard.sexCount != null) if (preferedRaceCard.SexCount != null)
{ {
GUI.Label(infoRect2, preferedRaceCard.sexCount, fontStyleLeft); GUI.Label(infoRect2, preferedRaceCard.SexCount, fontStyleLeft);
} }
if (preferedRaceCard.barInfo != null) if (preferedRaceCard.BarInfo.Label != null)
{ {
UIUtility.FillableBarLabeled(infoRect3, preferedRaceCard.barInfo); UIUtility.FillableBarLabeled(infoRect3, preferedRaceCard.BarInfo);
} }
} }
@ -390,6 +390,9 @@ namespace RJWSexperience.SexHistory.UI
listmain.FillableBarLabeled(_context.SexTypes[i]); listmain.FillableBarLabeled(_context.SexTypes[i]);
} }
listmain.FillableBarLabeled(_context.PartnerCount);
listmain.FillableBarLabeled(_context.VirginsTaken);
//Partner list //Partner list
Rect listLabelRect = listmain.GetRect(FONTHEIGHT); Rect listLabelRect = listmain.GetRect(FONTHEIGHT);
Rect sortbtnRect = new Rect(listLabelRect.xMax - 80f, listLabelRect.y, 80f, listLabelRect.height); Rect sortbtnRect = new Rect(listLabelRect.xMax - 80f, listLabelRect.y, 80f, listLabelRect.height);
@ -429,13 +432,13 @@ namespace RJWSexperience.SexHistory.UI
DrawPartnerPortrait(pawnRect, partner); DrawPartnerPortrait(pawnRect, partner);
Widgets.DrawHighlightIfMouseover(pawnRect); Widgets.DrawHighlightIfMouseover(pawnRect);
GUI.Label(labelRect, partner.partnerRecord.Label, fontStyleCenter); GUI.Label(labelRect, partner.PartnerRecord.Label, fontStyleCenter);
if (Widgets.ButtonInvisible(pawnRect)) if (Widgets.ButtonInvisible(pawnRect))
{ {
_context.SetSelectedPartner(partner.partnerRecord); _context.SetSelectedPartner(partner.PartnerRecord);
SoundDefOf.Click.PlayOneShotOnCamera(); SoundDefOf.Click.PlayOneShotOnCamera();
} }
if (partner.partnerRecord == _context.SelectedPartner) if (partner.PartnerRecord == _context.SelectedPartner)
{ {
Widgets.DrawHighlightSelected(pawnRect); Widgets.DrawHighlightSelected(pawnRect);
} }
@ -447,22 +450,22 @@ namespace RJWSexperience.SexHistory.UI
protected void DrawPartnerPortrait(Rect rect, PartnerPortraitInfo context) protected void DrawPartnerPortrait(Rect rect, PartnerPortraitInfo context)
{ {
Rect iconRect = new Rect(rect.x + (rect.width * 3 / 4), rect.y, rect.width / 4, rect.height / 4); Rect iconRect = new Rect(rect.x + (rect.width * 3 / 4), rect.y, rect.width / 4, rect.height / 4);
Texture img = context.portraitGetter(rect.size); Texture img = context.PortraitGetter(rect.size);
if (context.partnerRecord.IamFirst) if (context.PartnerRecord.IamFirst)
{ {
GUI.color = HistoryUtility.HistoryColor; GUI.color = HistoryUtility.HistoryColor;
Widgets.DrawTextureFitted(rect, HistoryUtility.FirstOverlay, 1.0f); Widgets.DrawTextureFitted(rect, HistoryUtility.FirstOverlay, 1.0f);
GUI.color = Color.white; GUI.color = Color.white;
} }
if (context.partnerRecord.Incest) if (context.PartnerRecord.Incest)
{ {
Widgets.DrawTextureFitted(iconRect, HistoryUtility.Incest, 1.0f); Widgets.DrawTextureFitted(iconRect, HistoryUtility.Incest, 1.0f);
iconRect.x -= iconRect.width; iconRect.x -= iconRect.width;
} }
Widgets.DrawTextureFitted(rect, img, 1.0f); Widgets.DrawTextureFitted(rect, img, 1.0f);
if (context.lover) if (context.Lover)
{ {
Widgets.DrawTextureFitted(iconRect, HistoryUtility.Heart, 1.0f); Widgets.DrawTextureFitted(iconRect, HistoryUtility.Heart, 1.0f);
} }