Skip to content

Commit e36f785

Browse files
committed
v1.0.4 excludes Finalizers per default (changable)
1 parent 460637b commit e36f785

File tree

7 files changed

+53
-21
lines changed

7 files changed

+53
-21
lines changed

About/Manifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<Manifest>
33
<identifier>net.pardeike.rimworld.mod.visualexceptions</identifier>
4-
<version>1.0.3.0</version>
4+
<version>1.0.4.0</version>
55
<targetVersions>
66
<li>1.2.0</li>
77
<li>1.3.0</li>
1 KB
Binary file not shown.

Source/ExceptionInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ List<ModInfo> GetAllMethods(Exception ex, int level)
121121
var method = Harmony.GetMethodFromStackframe(frame);
122122
var patches = Mods.FindPatches(method);
123123

124-
modInfos.AddRange(Mods.GetFinalizers(patches));
124+
if (ExceptionState.configuration.IncludeFinalizers)
125+
modInfos.AddRange(Mods.GetFinalizers(patches));
125126
modInfos.AddRange(Mods.GetPostfixes(patches));
126127
modInfos.AddRange(Mods.GetPrefixes(patches));
127128
modInfos.AddRange(Mods.GetTranspilers(patches));

Source/ExceptionState.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ internal static void Load()
3939
configuration = (Configuration)serializer.ReadObject(stream);
4040
}
4141
else
42-
configuration = new Configuration { Debugging = true, TabToTheRight = false, UseSound = true };
42+
configuration = new Configuration
43+
{
44+
Debugging = true,
45+
TabToTheRight = false,
46+
UseSound = true,
47+
IncludeFinalizers = false
48+
};
4349
}
4450
catch
4551
{

Source/Main.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using UnityEngine;
1+
using HarmonyLib;
2+
using System.Linq;
3+
using UnityEngine;
24
using Verse;
35

46
namespace VisualExceptions
@@ -22,21 +24,21 @@ public override void DoSettingsWindowContents(Rect inRect)
2224
list.Gap(12f);
2325

2426
var conf = ExceptionState.configuration;
25-
var debugging = conf.Debugging;
26-
var tabToTheRight = conf.TabToTheRight;
27-
var useSound = conf.UseSound;
28-
29-
list.CheckboxLabeled("Enabled", ref debugging);
30-
list.CheckboxLabeled("Show exceptions to the right", ref tabToTheRight);
31-
list.CheckboxLabeled("Use sound", ref useSound);
32-
33-
if (debugging != conf.Debugging || tabToTheRight != conf.TabToTheRight || useSound != conf.UseSound)
27+
var props = AccessTools.GetDeclaredProperties(typeof(Configuration));
28+
var values = props.Select(prop => (prop, prop.TryGetAttribute<SettingsAttribute>(), (bool)prop.GetValue(conf))).ToArray();
29+
var needsSave = false;
30+
foreach (var value in values)
3431
{
35-
conf.Debugging = debugging;
36-
conf.TabToTheRight = tabToTheRight;
37-
conf.UseSound = useSound;
38-
ExceptionState.Save();
32+
var temp = value.Item3;
33+
list.CheckboxLabeled(value.Item2.label, ref temp);
34+
if (temp != value.Item3)
35+
{
36+
needsSave = true;
37+
value.prop.SetValue(conf, temp);
38+
}
3939
}
40+
if (needsSave)
41+
ExceptionState.Save();
4042

4143
list.End();
4244
}

Source/Models.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,35 @@
88

99
namespace VisualExceptions
1010
{
11+
[AttributeUsage(AttributeTargets.Property)]
12+
internal class SettingsAttribute : Attribute
13+
{
14+
internal readonly string label;
15+
16+
internal SettingsAttribute(string label)
17+
{
18+
this.label = label;
19+
}
20+
}
21+
1122
[DataContract]
1223
internal class Configuration
1324
{
14-
[DataMember] internal bool Debugging { get; set; }
15-
[DataMember] internal bool TabToTheRight { get; set; }
16-
[DataMember] internal bool UseSound { get; set; }
25+
[DataMember]
26+
[Settings("Enabled")]
27+
internal bool Debugging { get; set; }
28+
29+
[DataMember]
30+
[Settings("Show exceptions to the right")]
31+
internal bool TabToTheRight { get; set; }
32+
33+
[DataMember]
34+
[Settings("Use sound")]
35+
internal bool UseSound { get; set; }
36+
37+
[DataMember]
38+
[Settings("Include Finalizers")]
39+
internal bool IncludeFinalizers { get; set; }
1740
}
1841

1942
[DataContract]

Source/VisualExceptions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<OutputPath>..\Current\Assemblies\</OutputPath>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1212
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
13-
<Version>1.0.3.0</Version>
13+
<Version>1.0.4.0</Version>
1414
<Copyright>Copyright Andreas Pardeike</Copyright>
1515
</PropertyGroup>
1616

0 commit comments

Comments
 (0)