mirror of
https://github.com/amevarashi/RJW-Sexperience.git
synced 2024-08-14 23:54:08 +00:00
New settings handling
This commit is contained in:
parent
fed4b54915
commit
8d49addd63
24 changed files with 309 additions and 233 deletions
35
Source/RJWSexperience/Settings/SettingHandle.cs
Normal file
35
Source/RJWSexperience/Settings/SettingHandle.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using Verse;
|
||||
|
||||
namespace RJWSexperience.Settings
|
||||
{
|
||||
public class SettingHandle<T> : ISettingHandle
|
||||
{
|
||||
public T Value { get; set; }
|
||||
public readonly string XmlLabel;
|
||||
public readonly T DefaultValue;
|
||||
|
||||
public SettingHandle(string xmlLabel, T defaultValue)
|
||||
{
|
||||
XmlLabel = xmlLabel;
|
||||
DefaultValue = defaultValue;
|
||||
Value = defaultValue;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Value = DefaultValue;
|
||||
}
|
||||
|
||||
public void Scribe()
|
||||
{
|
||||
T value = Value;
|
||||
Scribe_Values.Look(ref value, XmlLabel, DefaultValue);
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public static implicit operator T(SettingHandle<T> settingHandle)
|
||||
{
|
||||
return settingHandle.Value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue