RJW-Sexperience/Source/RJWSexperience/SexperienceMod.cs

59 lines
1.4 KiB
C#
Raw Normal View History

using UnityEngine;
2022-05-06 14:30:26 +00:00
using System.Collections.Generic;
using Verse;
2022-05-06 14:30:26 +00:00
using RJWSexperience.Settings;
namespace RJWSexperience
{
public class SexperienceMod : Mod
{
private static Configurations settings;
public static Configurations Settings { get => settings; }
2022-05-06 14:30:26 +00:00
public ITab CurrentTab { get; private set; }
private readonly List<TabRecord> tabRecords;
public SexperienceMod(ModContentPack content) : base(content)
{
settings = GetSettings<Configurations>();
2022-05-06 14:30:26 +00:00
CurrentTab = settings;
tabRecords = new List<TabRecord>();
}
public override string SettingsCategory()
{
return Keyed.Mod_Title;
}
2022-05-06 14:30:26 +00:00
/// <summary>
/// Fills tabRecords list.
/// This method cannot be called in constructor because at that stage language file is not loaded
/// </summary>
private void InitTabRecords()
{
List<ITab> tabs = new List<ITab>
{
settings,
2022-05-09 03:16:51 +00:00
settings.History,
2022-05-06 14:30:26 +00:00
settings.Debug
};
foreach (ITab tab in tabs)
tabRecords.Add(new TabRecord(tab.Label, delegate { this.CurrentTab = tab; }, delegate { return this?.CurrentTab == tab; }));
}
public override void DoSettingsWindowContents(Rect inRect)
{
if (tabRecords.NullOrEmpty())
InitTabRecords();
2022-05-11 13:18:16 +00:00
Rect contentRect = inRect.BottomPartPixels(inRect.height - TabDrawer.TabHeight);
2022-05-06 14:30:26 +00:00
_ = TabDrawer.DrawTabs(contentRect, tabRecords);
CurrentTab.DoTabContents(contentRect);
}
}
}