-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSettings.cs
More file actions
82 lines (66 loc) · 2.42 KB
/
Settings.cs
File metadata and controls
82 lines (66 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Verse;
namespace No_Forced_Slowdown
{
public class Settings : ModSettings
{
public enum SlowdownDegree
{
RegularGameplay,
DisableGamespeedLock,
DisableGamespeedSlowdown
}
private static string minSecondsTextBuffer = "60"; // Unsaved
public static SlowdownDegree CurrentModFunction = SlowdownDegree.DisableGamespeedSlowdown;
public static int MinSecondsToNextSlowdown = 60;
public static float LastRealTimeSlowdown; // Unsaved
public static void DoSettingsWindowContents(Rect rect)
{
IEnumerable<SlowdownDegree> allDegrees = Enum.GetValues(typeof(SlowdownDegree)).Cast<SlowdownDegree>();
Listing_Standard modOptions = new Listing_Standard();
modOptions.Begin(rect);
modOptions.Gap(20f);
modOptions.Label("NFS.ModFunctions".Translate());
// Toggle how much the mod interferes with vanilla TimeSlower
foreach (SlowdownDegree degree in allDegrees)
{
string name = "NFS." + degree.ToString();
string label = name.Translate();
bool active = CurrentModFunction == degree;
string tooltip = (name + ".Tooltip").Translate();
if (modOptions.RadioButton(label, active, default, tooltip))
{
CurrentModFunction = degree;
}
}
if (CurrentModFunction == SlowdownDegree.DisableGamespeedLock)
{
modOptions.Gap(60f);
// Determine real time seconds timer for Settings.MinSecondsToNextSlowdown
Rect TextFieldRect = modOptions.GetRect(Text.LineHeight);
Rect labelRect = TextFieldRect.LeftPart(0.75f);
Rect inputRect = TextFieldRect.RightPart(0.20f);
Widgets.Label(labelRect, "NFS.MinSecondsToNextSlowdown".Translate());
Widgets.DrawHighlightIfMouseover(labelRect);
TooltipHandler.TipRegion(labelRect, "NFS.MinSecondsToNextSlowdown.Tooltip".Translate());
Widgets.TextFieldNumeric(inputRect, ref MinSecondsToNextSlowdown, ref minSecondsTextBuffer);
}
modOptions.End();
}
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look(ref CurrentModFunction, "NFS_CurrentModFunction", SlowdownDegree.DisableGamespeedSlowdown);
Scribe_Values.Look(ref MinSecondsToNextSlowdown, "NFS_MinSecondsToNextSlowdown", 60);
if (Scribe.mode == LoadSaveMode.LoadingVars)
{
// Set unsaved values
LastRealTimeSlowdown = -1 * MinSecondsToNextSlowdown;
minSecondsTextBuffer = MinSecondsToNextSlowdown.ToString();
}
}
}
}