RJW-Sexperience/Source/RJWSexperience/Configurations.cs

107 lines
4.3 KiB
C#
Raw Permalink Normal View History

2022-05-09 03:16:51 +00:00
using UnityEngine;
2021-07-30 17:25:46 +00:00
using Verse;
2022-05-09 03:16:51 +00:00
using RJWSexperience.Settings;
2021-07-30 17:25:46 +00:00
namespace RJWSexperience
{
2022-05-09 03:16:51 +00:00
public class Configurations : ModSettings, ITab
{
2022-05-06 14:30:26 +00:00
public string Label => Keyed.TabLabelMain;
2022-05-09 03:16:51 +00:00
public const int CurrentSettingsVersion = 1;
2022-05-06 14:30:26 +00:00
// Defaults
public const float LustEffectPowerDefault = 0.5f;
2022-04-19 18:13:22 +00:00
public const bool EnableBastardRelationDefault = true;
2022-05-09 03:16:51 +00:00
public const float LustLimitDefault = SettingsTabHistory.MaxLustDeviationDefault / 3f;
public const float MaxSingleLustChangeDefault = 0.5f;
2022-05-07 16:05:27 +00:00
public const bool SexCanFillBucketsDefault = false;
2022-05-06 14:30:26 +00:00
public const bool selectionLockedDefault = false;
2022-05-06 14:30:26 +00:00
// Private attributes
private float lustEffectPower = LustEffectPowerDefault;
2022-04-19 18:13:22 +00:00
private bool enableBastardRelation = EnableBastardRelationDefault;
private float lustLimit = LustLimitDefault;
private float maxSingleLustChange = MaxSingleLustChangeDefault;
2022-05-07 16:05:27 +00:00
private bool sexCanFillBuckets = SexCanFillBucketsDefault;
2022-05-06 14:30:26 +00:00
private bool selectionLocked = selectionLockedDefault;
2022-05-10 06:27:20 +00:00
private SettingsTabHistory history = SettingsTabHistory.CreateDefault();
private SettingsTabDebug debug = new SettingsTabDebug();
2022-05-06 14:30:26 +00:00
//Public read-only properties
public float LustEffectPower => lustEffectPower;
public bool EnableBastardRelation => enableBastardRelation;
public float LustLimit => lustLimit;
public float MaxSingleLustChange => maxSingleLustChange;
2022-05-07 16:05:27 +00:00
public bool SexCanFillBuckets => sexCanFillBuckets;
2022-05-09 03:16:51 +00:00
public SettingsTabHistory History => history;
public SettingsTabDebug Debug => debug;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S2292:Trivial properties should be auto-implemented", Justification = "Can't scribe property")]
public bool SelectionLocked { get => selectionLocked; set => selectionLocked = value; }
public void ResetToDefault()
{
lustEffectPower = LustEffectPowerDefault;
2022-04-19 18:13:22 +00:00
enableBastardRelation = EnableBastardRelationDefault;
lustLimit = LustLimitDefault;
maxSingleLustChange = MaxSingleLustChangeDefault;
2022-05-09 03:16:51 +00:00
sexCanFillBuckets = SexCanFillBucketsDefault;
}
public override void ExposeData()
{
2022-05-09 03:16:51 +00:00
int version = CurrentSettingsVersion;
Scribe_Values.Look(ref version, "SettingsVersion", 0);
2022-05-06 14:30:26 +00:00
Scribe_Values.Look(ref lustEffectPower, "LustEffectPower", LustEffectPowerDefault);
Scribe_Values.Look(ref enableBastardRelation, "EnableBastardRelation", EnableBastardRelationDefault);
Scribe_Values.Look(ref lustLimit, "LustLimit", LustLimitDefault);
Scribe_Values.Look(ref maxSingleLustChange, "maxSingleLustChange", MaxSingleLustChangeDefault);
Scribe_Values.Look(ref selectionLocked, "SelectionLocked", selectionLockedDefault);
Scribe_Values.Look(ref sexCanFillBuckets, "SexCanFillBuckets", SexCanFillBucketsDefault);
2022-05-09 03:16:51 +00:00
Scribe_Deep.Look(ref history, "History");
2022-05-06 14:30:26 +00:00
Scribe_Deep.Look(ref debug, "Debug");
base.ExposeData();
2022-05-06 14:30:26 +00:00
if (Scribe.mode != LoadSaveMode.LoadingVars)
return;
2022-05-09 03:16:51 +00:00
if (history == null)
{
history = new SettingsTabHistory();
// Previously history settings were in Configurations. Direct call to try read old data
history.ExposeData();
}
2022-05-06 14:30:26 +00:00
if (debug == null)
{
2022-05-09 03:16:51 +00:00
debug = new SettingsTabDebug();
2022-05-06 14:30:26 +00:00
debug.Reset();
}
}
2022-05-06 14:30:26 +00:00
public void DoTabContents(Rect inRect)
{
2022-05-09 03:16:51 +00:00
const float lineHeight = SettingsWidgets.lineHeight;
Listing_Standard listmain = new Listing_Standard();
listmain.maxOneColumn = true;
listmain.Begin(inRect);
2022-05-09 03:16:51 +00:00
SettingsWidgets.SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_2_Label + " x" + lustEffectPower, Keyed.Option_2_Desc, ref lustEffectPower, 0f, 2f, 0.01f);
SettingsWidgets.SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_8_Label + " " + lustLimit, Keyed.Option_8_Desc, ref lustLimit, 0f, 5000f, 1f);
SettingsWidgets.SliderOption(listmain.GetRect(lineHeight * 2f), Keyed.Option_MaxSingleLustChange_Label + " " + maxSingleLustChange, Keyed.Option_MaxSingleLustChange_Desc, ref maxSingleLustChange, 0f, 10f, 0.05f);
2022-04-19 18:13:22 +00:00
listmain.CheckboxLabeled(Keyed.Option_EnableBastardRelation_Label, ref enableBastardRelation, Keyed.Option_EnableBastardRelation_Desc);
2022-05-07 16:05:27 +00:00
listmain.CheckboxLabeled(Keyed.Option_SexCanFillBuckets_Label, ref sexCanFillBuckets, Keyed.Option_SexCanFillBuckets_Desc);
if (SexperienceMod.Settings.Debug.DevMode)
LustUtility.DrawGraph(listmain.GetRect(300f));
if (listmain.ButtonText(Keyed.Button_ResetToDefault))
{
ResetToDefault();
}
listmain.End();
}
}
2021-07-30 17:25:46 +00:00
}