forked from RimWorldMod/Tech-Advancing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModSettings.cs
71 lines (56 loc) · 2 KB
/
ModSettings.cs
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
using System.Reflection;
using Harmony;
using RimWorld;
using UnityEngine;
using Verse;
namespace TechAdvancing
{
public class Settings : ModSettings
{
private static void DrawText(Rect canvas, string Text, ref float drawpos, bool increaseDrawpos = true)
{
var descHeight = Verse.Text.CalcSize(Text).y; //Verse.Text.CalcHeight(descTR, Listing.ColumnSpacing);
Rect drawCanvas = new Rect(canvas.x+200, canvas.y + drawpos, canvas.width, descHeight);
GUI.Label(drawCanvas, Text);
if (increaseDrawpos)
{
drawpos += drawCanvas.height;
}
}
public override void ExposeData()
{
base.ExposeData();
}
public static void DoSettingsWindowContents(Rect rect)
{
Rect TA_Cfgrect = new Rect(0f, 0f, 180f, 20f);
TA_Cfgrect.x = (rect.width - TA_Cfgrect.width) / 4f;
TA_Cfgrect.y = 40f;
float drawpos = 30f;
Color defaultGuiColor = GUI.contentColor;
if (Current.ProgramState == ProgramState.Playing)
{
if (Widgets.ButtonText(TA_Cfgrect, "TAcfgmenulabel".Translate(), true, false, true))
{
Find.WindowStack.Add((Window)new TechAdvancing_Config_Tab());
}
}
else
{
GUI.contentColor = Color.red;
DrawText(rect,"TAcfgunavailable".Translate(),ref drawpos,true);
GUI.contentColor = defaultGuiColor;
}
}
}
public class SettingController : Mod
{
public SettingController(ModContentPack content)
: base(content)
{
GetSettings<Settings>();
}
public override string SettingsCategory() { return "TAcfgmenulabel".Translate(); }
public override void DoSettingsWindowContents(Rect inRect) { Settings.DoSettingsWindowContents(inRect); }
}
}