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
{
2023-03-24 15:22:54 +00:00
public static Configurations Settings { get; private set; }
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)
{
2023-03-24 15:22:54 +00:00
Settings = GetSettings<Configurations>();
2022-05-06 14:30:26 +00:00
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>
{
2023-03-24 15:22:54 +00:00
new SettingsTabMain(Settings),
new SettingsTabHistory(Settings),
new SettingsTabDebug(Settings),
2022-05-06 14:30:26 +00:00
};
foreach (ITab tab in tabs)
tabRecords.Add(new TabRecord(tab.Label, delegate { this.CurrentTab = tab; }, delegate { return this?.CurrentTab == tab; }));
2023-03-24 15:22:54 +00:00
CurrentTab = tabs[0];
2022-05-06 14:30:26 +00:00
}
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);
}
}
}