mirror of
				https://github.com/amevarashi/RJW-Sexperience.git
				synced 2024-08-14 23:54:08 +00:00 
			
		
		
		
	Fix history window crashing from a modded passion
This commit is contained in:
		
							parent
							
								
									1b5da7bde8
								
							
						
					
					
						commit
						85dcfd538c
					
				
					 2 changed files with 31 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
using UnityEngine;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
using System;
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJWSexperience.SexHistory
 | 
			
		||||
| 
						 | 
				
			
			@ -47,11 +49,31 @@ namespace RJWSexperience.SexHistory
 | 
			
		|||
			Texture2D.linearGrayTexture    //? = 20
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		public static readonly Texture2D[] PassionBG = new Texture2D[]
 | 
			
		||||
		private static readonly Texture2D[] PassionBG = new Texture2D[]
 | 
			
		||||
		{
 | 
			
		||||
			Texture2D.blackTexture,    //None = 0,
 | 
			
		||||
			SolidColorMaterials.NewSolidColorTexture(0.800f, 0.800f, 0.800f, 1.0f),    //Minor = 1,
 | 
			
		||||
			SolidColorMaterials.NewSolidColorTexture(1.000f, 0.875f, 0.000f, 1.0f)     //Major = 2,
 | 
			
		||||
			SolidColorMaterials.NewSolidColorTexture(0.800f, 0.800f, 0.800f, 1.0f),    //Minor = 1, Gray
 | 
			
		||||
			SolidColorMaterials.NewSolidColorTexture(1.000f, 0.875f, 0.000f, 1.0f),    //Major = 2, Golden
 | 
			
		||||
			Texture2D.blackTexture,    // VSE Apathy = 3
 | 
			
		||||
			SolidColorMaterials.NewSolidColorTexture(0.500f, 0.875f, 0.000f, 1.0f),    //VSE Natural = 4, Light Green
 | 
			
		||||
			SolidColorMaterials.NewSolidColorTexture(1.000f, 0.375f, 0.000f, 1.0f),    //VSE Critical = 5, Reddish
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		public static Texture2D GetPassionBG(Passion? passion)
 | 
			
		||||
		{
 | 
			
		||||
			int passionIndex = (int)(passion ?? 0);
 | 
			
		||||
 | 
			
		||||
			// Vanilla Skills Expanded adds new passion levels
 | 
			
		||||
			if (passionIndex < 0)
 | 
			
		||||
			{
 | 
			
		||||
				passionIndex = 0;
 | 
			
		||||
			}
 | 
			
		||||
			else if (passionIndex >= PassionBG.Length)
 | 
			
		||||
			{
 | 
			
		||||
				passionIndex = 0;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return PassionBG[passionIndex];
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -408,7 +408,7 @@ namespace RJWSexperience.SexHistory.UI
 | 
			
		|||
 | 
			
		||||
			tmp = listmain.GetRect(FONTHEIGHT);
 | 
			
		||||
			p = pawn.records.GetValue(VariousDefOf.Lust);
 | 
			
		||||
			FillableBarLabeled(tmp, String.Format(Keyed.Lust + ": {0:0.00}", p), Mathf.Clamp01(p.Normalization(-SexperienceMod.Settings.LustLimit * 3, SexperienceMod.Settings.LustLimit * 3)), HistoryUtility.Slaanesh, Texture2D.blackTexture, null, String.Format(xxx.sex_drive_stat.LabelCap.CapitalizeFirst() + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_drive_stat)));
 | 
			
		||||
			FillableBarLabeled(tmp, String.Format(Keyed.Lust + ": {0:0.00}", p), Mathf.Clamp01(p.Normalization(-SexperienceMod.Settings.LustLimit * 3, SexperienceMod.Settings.LustLimit * 3)), HistoryUtility.Slaanesh, Texture2D.blackTexture, null, String.Format(xxx.sex_drive_stat.LabelCap + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_drive_stat)));
 | 
			
		||||
			listmain.Gap(1f);
 | 
			
		||||
			if (Mouse.IsOver(tmp))
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			@ -458,12 +458,12 @@ namespace RJWSexperience.SexHistory.UI
 | 
			
		|||
			if (p < history.BeenRapedCount)
 | 
			
		||||
			{
 | 
			
		||||
				p = history.BeenRapedCount;
 | 
			
		||||
				FillableBarLabeled(tmp, String.Format(Keyed.RS_BeenRaped + ": {0}", p), p / 50, Texture2D.grayTexture, Texture2D.blackTexture, null, String.Format(xxx.vulnerability_stat.LabelCap.CapitalizeFirst() + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
 | 
			
		||||
				FillableBarLabeled(tmp, String.Format(Keyed.RS_BeenRaped + ": {0}", p), p / 50, Texture2D.grayTexture, Texture2D.blackTexture, null, String.Format(xxx.vulnerability_stat.LabelCap + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
 | 
			
		||||
				listmain.Gap(1f);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				FillableBarLabeled(tmp, String.Format(Keyed.RS_RapedSomeone + ": {0}", p), p / 50, HistoryUtility.Khorne, Texture2D.blackTexture, null, String.Format(xxx.vulnerability_stat.LabelCap.CapitalizeFirst() + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
 | 
			
		||||
				FillableBarLabeled(tmp, String.Format(Keyed.RS_RapedSomeone + ": {0}", p), p / 50, HistoryUtility.Khorne, Texture2D.blackTexture, null, String.Format(xxx.vulnerability_stat.LabelCap + ": {0:P2}", pawn.Dead ? 0 : pawn.GetStatValue(xxx.vulnerability_stat)));
 | 
			
		||||
				listmain.Gap(1f);
 | 
			
		||||
			}
 | 
			
		||||
			if (Mouse.IsOver(tmp))
 | 
			
		||||
| 
						 | 
				
			
			@ -473,7 +473,7 @@ namespace RJWSexperience.SexHistory.UI
 | 
			
		|||
 | 
			
		||||
			p = pawn.Dead ? 0 : pawn.GetStatValue(xxx.sex_satisfaction);
 | 
			
		||||
			tmp = listmain.GetRect(FONTHEIGHT);
 | 
			
		||||
			FillableBarLabeled(tmp, String.Format(xxx.sex_satisfaction.LabelCap.CapitalizeFirst() + ": {0:P2}", p), p / 2, HistoryUtility.Satisfaction, Texture2D.blackTexture);
 | 
			
		||||
			FillableBarLabeled(tmp, String.Format(xxx.sex_satisfaction.LabelCap + ": {0:P2}", p), p / 2, HistoryUtility.Satisfaction, Texture2D.blackTexture);
 | 
			
		||||
			listmain.Gap(1f);
 | 
			
		||||
			if (Mouse.IsOver(tmp))
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			@ -483,7 +483,7 @@ namespace RJWSexperience.SexHistory.UI
 | 
			
		|||
			SkillRecord skill = pawn.skills?.GetSkill(VariousDefOf.Sex);
 | 
			
		||||
			p = skill?.Level ?? 0;
 | 
			
		||||
			tmp = listmain.GetRect(FONTHEIGHT);
 | 
			
		||||
			FillableBarLabeled(tmp, $"{Keyed.RS_SexSkill}: {p}, {skill?.xpSinceLastLevel / skill?.XpRequiredForLevelUp:P2}", p / 20, HistoryUtility.Tzeentch, Texture2D.blackTexture, null, $"{VariousDefOf.SexAbility.LabelCap.CapitalizeFirst()}: {pawn.GetSexStat():P2}", HistoryUtility.PassionBG[(int)(skill?.passion ?? 0)]);
 | 
			
		||||
			FillableBarLabeled(tmp, $"{Keyed.RS_SexSkill}: {p}, {skill?.xpSinceLastLevel / skill?.XpRequiredForLevelUp:P2}", p / 20, HistoryUtility.Tzeentch, Texture2D.blackTexture, null, $"{VariousDefOf.SexAbility.LabelCap}: {pawn.GetSexStat():P2}", HistoryUtility.GetPassionBG(skill?.passion));
 | 
			
		||||
			if (Mouse.IsOver(tmp))
 | 
			
		||||
			{
 | 
			
		||||
				TooltipHandler.TipRegion(tmp, RJWUIUtility.GetStatExplanation(pawn, VariousDefOf.SexAbility, pawn.GetSexStat()));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue