diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..f35ff892
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,34 @@
+[*.{cs,vb}]
+
+# IDE0060: Remove unused parameter
+dotnet_code_quality_unused_parameters = all:none
+
+# CA1303: Do not pass literals as localized parameters
+dotnet_diagnostic.CA1303.severity = none
+
+# CA1031: Do not catch general exception types
+dotnet_diagnostic.CA1031.severity = none
+
+# CA2227: Collection properties should be read only
+dotnet_diagnostic.CA2227.severity = none
+
+# CA1305: Specify IFormatProvider
+dotnet_diagnostic.CA1305.severity = none
+
+# CA1304: Specify CultureInfo
+dotnet_diagnostic.CA1304.severity = none
+
+#CA1801:
+dotnet_diagnostic.CA1801.severity = none
+
+#CA1822:
+dotnet_diagnostic.CA1822.severity = none
+
+# CA1307: Specify StringComparison
+dotnet_diagnostic.CA1307.severity = none
+
+# CA3075: Insecure DTD processing in XML
+dotnet_diagnostic.CA3075.severity = none
+
+# CA1720: Identifier contains type name
+dotnet_diagnostic.CA1720.severity = none
diff --git a/Debugging/DebugVars.cs b/Debugging/DebugVars.cs
index dcc79a58..d6274f50 100644
--- a/Debugging/DebugVars.cs
+++ b/Debugging/DebugVars.cs
@@ -2,6 +2,6 @@
{
public static class DebugVars
{
- public static bool ShowDebug = false;
+ public static bool ShowDebug { get; } = false;
}
}
diff --git a/Debugging/ModDebug.cs b/Debugging/ModDebug.cs
index 9741976d..62e9a5a4 100644
--- a/Debugging/ModDebug.cs
+++ b/Debugging/ModDebug.cs
@@ -6,7 +6,7 @@ namespace ModLib.Debugging
{
public static class ModDebug
{
- public static void ShowError(string message, string title="", Exception exception = null)
+ public static void ShowError(string message, string title = "", Exception exception = null)
{
if (string.IsNullOrWhiteSpace(title))
title = "";
diff --git a/ExtensionMethods/ExceptionExtensionMethods.cs b/ExtensionMethods/ExceptionExtensionMethods.cs
index 2765b8a0..0c37318a 100644
--- a/ExtensionMethods/ExceptionExtensionMethods.cs
+++ b/ExtensionMethods/ExceptionExtensionMethods.cs
@@ -10,7 +10,10 @@ public static class ExceptionExtensionMethods
{
public static string ToStringFull(this Exception ex)
{
- return GetString(ex);
+ if (ex != null)
+ return GetString(ex);
+ else
+ return "";
}
private static string GetString(Exception ex)
diff --git a/ExtensionMethods/IEnumerableExtensions.cs b/ExtensionMethods/IEnumerableExtensions.cs
index 61ca06c4..4964fb03 100644
--- a/ExtensionMethods/IEnumerableExtensions.cs
+++ b/ExtensionMethods/IEnumerableExtensions.cs
@@ -13,9 +13,14 @@ public static class IEnumerableExtensions
///
public static IEnumerable Do(this IEnumerable enumerable, Action action)
{
- foreach (var item in enumerable)
- action?.Invoke(item);
- return enumerable;
+ if (enumerable != null)
+ {
+ foreach (var item in enumerable)
+ action?.Invoke(item);
+ return enumerable;
+ }
+ else
+ return null;
}
}
}
diff --git a/ExtensionMethods/MBBindingListExtensions.cs b/ExtensionMethods/MBBindingListExtensions.cs
index 10b83e93..2859b1b4 100644
--- a/ExtensionMethods/MBBindingListExtensions.cs
+++ b/ExtensionMethods/MBBindingListExtensions.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using TaleWorlds.Library;
namespace ModLib
@@ -7,6 +8,8 @@ public static class MBBindingListExtensions
{
public static void AddRange(this MBBindingList bindingList, List listToAdd)
{
+ if (listToAdd == null) throw new ArgumentNullException(nameof(listToAdd));
+ if (bindingList == null) throw new ArgumentNullException(nameof(bindingList));
if (listToAdd.Count == 1)
bindingList.Add(listToAdd[0]);
else if (listToAdd.Count > 0)
diff --git a/ExtensionMethods/StackExtension.cs b/ExtensionMethods/StackExtension.cs
index 5b6fb46c..29bb9466 100644
--- a/ExtensionMethods/StackExtension.cs
+++ b/ExtensionMethods/StackExtension.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
namespace ModLib
@@ -7,11 +8,13 @@ public static class StackExtension
{
public static void AppendToTop(this Stack baseStack, Stack toAppend)
{
+ if (toAppend == null) throw new ArgumentNullException(nameof(toAppend));
+ if (baseStack == null) throw new ArgumentNullException(nameof(baseStack));
if (toAppend.Count == 0)
return;
T[] array = toAppend.ToArray();
- for (int i = array.Count() - 1; i >= 0; i--)
+ for (int i = array.Length - 1; i >= 0; i--)
{
baseStack.Push(array[i]);
}
diff --git a/ExtensionMethods/StringExtensions.cs b/ExtensionMethods/StringExtensions.cs
index ed79273c..70b3974f 100644
--- a/ExtensionMethods/StringExtensions.cs
+++ b/ExtensionMethods/StringExtensions.cs
@@ -5,22 +5,28 @@ public static class StringExtensions
public static int Count(this string str, char c)
{
int count = 0;
- foreach (var ch in str)
+ if (!string.IsNullOrEmpty(str))
{
- if (ch == c) count++;
+ foreach (var ch in str)
+ {
+ if (ch == c) count++;
+ }
}
return count;
}
public static string Last(this string str)
{
- if (str.Length > 0)
+ if (!string.IsNullOrEmpty(str))
{
- int index = str.Length - 1;
- return str[index].ToString();
+ if (str.Length > 0)
+ {
+ int index = str.Length - 1;
+ return str[index].ToString();
+ }
}
- else
- return string.Empty;
+
+ return string.Empty;
}
}
}
diff --git a/FileDatabase/FileDatabase.cs b/FileDatabase/FileDatabase.cs
index 9d45e4fa..aeee0bac 100644
--- a/FileDatabase/FileDatabase.cs
+++ b/FileDatabase/FileDatabase.cs
@@ -11,7 +11,7 @@ namespace ModLib
{
public static class FileDatabase
{
- private static readonly string LoadablesFolderName = "Loadables";
+ private const string LoadablesFolderName = "Loadables";
public static Dictionary> Data { get; } = new Dictionary>();
///
@@ -61,6 +61,7 @@ public static bool SaveToFile(string moduleFolderName, ISerialisableFile sf, Loc
{
try
{
+ if (sf == null) throw new ArgumentNullException(nameof(sf));
if (string.IsNullOrWhiteSpace(sf.ID))
throw new Exception($"FileDatabase tried to save an object of type {sf.GetType().FullName} but the ID value was null.");
if (string.IsNullOrWhiteSpace(moduleFolderName))
@@ -104,7 +105,7 @@ public static bool SaveToFile(string moduleFolderName, ISerialisableFile sf, Loc
}
catch (Exception ex)
{
- ModDebug.ShowError($"Cannot create the file for type {sf.GetType().FullName} with ID {sf.ID} for module {moduleFolderName}:", "Error saving to file", ex);
+ ModDebug.ShowError($"Cannot create the file for type {sf?.GetType().FullName} with ID {sf?.ID} for module {moduleFolderName}:", "Error saving to file", ex);
return false;
}
}
@@ -151,7 +152,7 @@ public static bool DeleteFile(string moduleFolderName, ISerialisableFile sf, Loc
private static void Add(ISerialisableFile loadable)
{
if (loadable == null)
- throw new ArgumentNullException("Tried to add something to the FileDatabase Data dictionary that was null");
+ throw new ArgumentNullException(nameof(loadable), "Tried to add something to the FileDatabase Data dictionary that was null");
if (string.IsNullOrWhiteSpace(loadable.ID))
throw new ArgumentNullException($"Loadable of type {loadable.GetType().ToString()} has missing ID field");
@@ -233,7 +234,7 @@ private static void LoadAllFiles(string moduleName)
//Loop through any subfolders and load the files in them
string[] subDirs = Directory.GetDirectories(moduleLoadablesPath);
- if (subDirs.Count() > 0)
+ if (subDirs.Any())
{
foreach (var subDir in subDirs)
{
@@ -275,7 +276,7 @@ private static void LoadAllFiles(string moduleName)
}
}
string[] subfolders = Directory.GetDirectories(modConfigsPath);
- if (subfolders.Count() > 0)
+ if (subfolders.Any())
{
foreach (var subFolder in subfolders)
{
@@ -305,6 +306,7 @@ private static void LoadAllFiles(string moduleName)
/// Returns the file name of the given ISerialisableFile, including the file extension.
public static string GetFileNameFor(ISerialisableFile sf)
{
+ if (sf == null) throw new ArgumentNullException(nameof(sf));
return $"{sf.GetType().Name}.{sf.ID}.xml";
}
diff --git a/FileDatabase/SettingsBase.cs b/FileDatabase/SettingsBase.cs
index c31ec078..43b1b3d1 100644
--- a/FileDatabase/SettingsBase.cs
+++ b/FileDatabase/SettingsBase.cs
@@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using TaleWorlds.Library;
namespace ModLib
{
@@ -43,7 +42,7 @@ internal List GetSettingPropertyGroups()
let propAttr = p.GetCustomAttribute(true)
let groupAttr = p.GetCustomAttribute(true)
where propAttr != null
- let groupAttrToAdd = groupAttr == null ? SettingPropertyGroupAttribute.Default : groupAttr
+ let groupAttrToAdd = groupAttr ?? SettingPropertyGroupAttribute.Default
select new SettingProperty(propAttr, groupAttrToAdd, p, this)).ToList();
//Loop through each property
@@ -85,8 +84,7 @@ private SettingPropertyGroup GetGroupFor(SettingProperty sp, ICollection groupsList)
+ private static SettingPropertyGroup GetGroupFor(string groupName, ICollection groupsList)
{
return groupsList.GetGroup(groupName);
}
@@ -119,8 +117,7 @@ private SettingPropertyGroup GetGroupForRecursive(string groupName, ICollection<
if (groupName.Contains(SubGroupDelimiter))
{
//Need to go deeper
- string truncatedGroupName;
- string topGroupName = GetTopGroupName(groupName, out truncatedGroupName);
+ string topGroupName = GetTopGroupName(groupName, out string truncatedGroupName);
SettingPropertyGroup topGroup = GetGroupFor(topGroupName, groupsList);
if (topGroup == null)
{
@@ -142,7 +139,7 @@ private SettingPropertyGroup GetGroupForRecursive(string groupName, ICollection<
}
}
- private string GetTopGroupName(string groupName, out string truncatedGroupName)
+ private static string GetTopGroupName(string groupName, out string truncatedGroupName)
{
int index = groupName.IndexOf(SubGroupDelimiter);
string topGroupName = groupName.Substring(0, index);
@@ -151,7 +148,7 @@ private string GetTopGroupName(string groupName, out string truncatedGroupName)
return topGroupName;
}
- private void CheckIsValid(SettingProperty prop)
+ private static void CheckIsValid(SettingProperty prop)
{
if (!prop.Property.CanRead)
throw new Exception($"Property {prop.Property.Name} in {prop.SettingsInstance.GetType().FullName} must have a getter.");
diff --git a/FileDatabase/SettingsDatabase.cs b/FileDatabase/SettingsDatabase.cs
index af967391..8a88f3d9 100644
--- a/FileDatabase/SettingsDatabase.cs
+++ b/FileDatabase/SettingsDatabase.cs
@@ -33,6 +33,7 @@ public static List ModSettingsVMs
/// Returns true if successful. Returns false if the object's ID key is already present in the SettingsDatabase.
public static bool RegisterSettings(SettingsBase settings)
{
+ if (settings == null) throw new ArgumentNullException(nameof(settings));
if (!AllSettingsDict.ContainsKey(settings.ID))
{
AllSettingsDict.Add(settings.ID, settings);
@@ -68,6 +69,7 @@ public static ISerialisableFile GetSettings(string uniqueID)
/// Return true if the settings object was saved successfully. Returns false if it failed to save.
public static bool SaveSettings(SettingsBase settingsInstance)
{
+ if (settingsInstance == null) throw new ArgumentNullException(nameof(settingsInstance));
return FileDatabase.SaveToFile(settingsInstance.ModuleFolderName, settingsInstance, FileDatabase.Location.Configs);
}
@@ -78,6 +80,7 @@ public static bool SaveSettings(SettingsBase settingsInstance)
/// Returns the instance of the new object with default values.
public static SettingsBase ResetSettingsInstance(SettingsBase settingsInstance)
{
+ if (settingsInstance == null) throw new ArgumentNullException(nameof(settingsInstance));
string id = settingsInstance.ID;
SettingsBase newObj = (SettingsBase)Activator.CreateInstance(settingsInstance.GetType());
newObj.ID = id;
diff --git a/GUI/ViewModels/SettingProperty.cs b/GUI/ViewModels/SettingProperty.cs
index 2743e6b3..c9aefcd6 100644
--- a/GUI/ViewModels/SettingProperty.cs
+++ b/GUI/ViewModels/SettingProperty.cs
@@ -27,7 +27,7 @@ public bool SatisfiesSearch
{
get
{
- if (ScreenVM == null || ScreenVM.SearchText == "")
+ if (ScreenVM == null || string.IsNullOrWhiteSpace(ScreenVM.SearchText))
return true;
return Name.ToLower().Contains(ScreenVM.SearchText.ToLower());
diff --git a/GUI/ViewModels/SettingPropertyGroup.cs b/GUI/ViewModels/SettingPropertyGroup.cs
index b152ae38..3d43a278 100644
--- a/GUI/ViewModels/SettingPropertyGroup.cs
+++ b/GUI/ViewModels/SettingPropertyGroup.cs
@@ -30,9 +30,10 @@ public bool SatisfiesSearch
{
get
{
- if (ScreenVM == null || ScreenVM.SearchText == "")
+ if (ScreenVM == null || string.IsNullOrWhiteSpace(ScreenVM.SearchText))
return true;
- return GroupName.ToLower().Contains(ScreenVM.SearchText.ToLower()) || AnyChildSettingSatisfiesSearch;
+ else
+ return GroupName.ToLower().Contains(ScreenVM.SearchText.ToLower()) || AnyChildSettingSatisfiesSearch;
}
}
public bool AnyChildSettingSatisfiesSearch
@@ -156,6 +157,7 @@ public override void RefreshValues()
public void Add(SettingProperty sp)
{
+ if (sp == null) throw new ArgumentNullException(nameof(sp));
SettingProperties.Add(sp);
sp.Group = this;
diff --git a/GUI/Views/EditValueTextWidget.cs b/GUI/Views/EditValueTextWidget.cs
index 3030fa83..e48bbff0 100644
--- a/GUI/Views/EditValueTextWidget.cs
+++ b/GUI/Views/EditValueTextWidget.cs
@@ -27,6 +27,7 @@ public override void HandleInput(IReadOnlyList lastKeysPressed)
{
if (Input.IsKeyDown(InputKey.LeftControl) && Input.IsKeyPressed(InputKey.V))
return;
+ if (lastKeysPressed == null) return;
if (lastKeysPressed.Count > 0)
{
@@ -57,17 +58,19 @@ public override void HandleInput(IReadOnlyList lastKeysPressed)
}
base.HandleInput(lastKeysPressed);
float value;
- float.TryParse(RealText, out value);
- float newVal = value;
- if (value > MaxValue)
- newVal = MaxValue;
- else if (value < MinValue)
- newVal = MinValue;
- if (newVal != value)
+ if (float.TryParse(RealText, out value))
{
- string format = SettingType == SettingType.Int ? "0" : "0.00";
- RealText = newVal.ToString(format);
- editableText.SetCursorPosition(0, true);
+ float newVal = value;
+ if (value > MaxValue)
+ newVal = MaxValue;
+ else if (value < MinValue)
+ newVal = MinValue;
+ if (newVal != value)
+ {
+ string format = SettingType == SettingType.Int ? "0" : "0.00";
+ RealText = newVal.ToString(format);
+ editableText.SetCursorPosition(0, true);
+ }
}
}
}
diff --git a/GUI/Views/ModLibSliderWidget.cs b/GUI/Views/ModLibSliderWidget.cs
index e68e999f..b4d24700 100644
--- a/GUI/Views/ModLibSliderWidget.cs
+++ b/GUI/Views/ModLibSliderWidget.cs
@@ -18,7 +18,7 @@ public float FinalisedFloatValue
set
{
_finalisedFloatValue = value;
- OnPropertyChanged(value, "FinalisedFloatValue");
+ OnPropertyChanged(value, nameof(FinalisedFloatValue));
}
}
public int FinalisedIntValue
@@ -30,7 +30,7 @@ public int FinalisedIntValue
set
{
_finalisedIntValue = value;
- OnPropertyChanged(value, "FinalisedIntValue");
+ OnPropertyChanged(value, nameof(FinalisedIntValue));
}
}
diff --git a/GlobalSuppressions.cs b/GlobalSuppressions.cs
new file mode 100644
index 00000000..d1624d39
--- /dev/null
+++ b/GlobalSuppressions.cs
@@ -0,0 +1,6 @@
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Security", "CA2119:Seal methods that satisfy private interfaces", Justification = "", Scope = "member", Target = "~P:ModLib.SettingsBase.SubFolder")]
diff --git a/Interfaces/IAction.cs b/Interfaces/IAction.cs
index a66fb8ec..93e8abda 100644
--- a/Interfaces/IAction.cs
+++ b/Interfaces/IAction.cs
@@ -4,7 +4,7 @@ public interface IAction
{
Ref Context { get; }
object Value { get; }
- void Do();
- void Undo();
+ void DoAction();
+ void UndoAction();
}
}
diff --git a/ModLib.Patches/GlobalSuppressions.cs b/ModLib.Patches/GlobalSuppressions.cs
new file mode 100644
index 00000000..d0996fb0
--- /dev/null
+++ b/ModLib.Patches/GlobalSuppressions.cs
@@ -0,0 +1,6 @@
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "", Scope = "member", Target = "~M:ModLib.Patches.OnApplicationTickPatch.Finalizer(System.Exception)")]
diff --git a/ModLib.Patches/ModLib.Patches.csproj b/ModLib.Patches/ModLib.Patches.csproj
new file mode 100644
index 00000000..1336fd2e
--- /dev/null
+++ b/ModLib.Patches/ModLib.Patches.csproj
@@ -0,0 +1,83 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ {F81C97FE-515A-4177-B14E-98933F62E56B}
+ Library
+ Properties
+ ModLib.Patches
+ ModLib.Patches
+ v4.7.2
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+ 7.1
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ x64
+
+
+
+
+ 2.9.6
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(MOUNT_AND_BLADE_DIR)\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll
+
+
+
+
+
+
+
+
+
+
+
+ .editorconfig
+
+
+
+
+
+ {d0d189a7-42c9-4cab-b182-488c2293a11b}
+ ModLib
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ModLib.Patches/ModLibPatchesSubModule.cs b/ModLib.Patches/ModLibPatchesSubModule.cs
new file mode 100644
index 00000000..e24bc027
--- /dev/null
+++ b/ModLib.Patches/ModLibPatchesSubModule.cs
@@ -0,0 +1,29 @@
+using HarmonyLib;
+using ModLib.Debugging;
+using System;
+using TaleWorlds.MountAndBlade;
+
+namespace ModLib.Patches
+{
+ public class ModLibPatchesSubModule : MBSubModuleBase
+ {
+ protected override void OnSubModuleLoad()
+ {
+ base.OnSubModuleLoad();
+ try
+ {
+ Settings settings = FileDatabase.Get(Settings.SettingsInstanceID);
+ if (settings == null) settings = new Settings();
+ SettingsDatabase.RegisterSettings(settings);
+
+ var harmony = new Harmony("mod.modlib.patches.mipen");
+ harmony.PatchAll();
+
+ }
+ catch (Exception ex)
+ {
+ ModDebug.ShowError($"An error occurred whilst initialising ModLib", "Error during initialisation", ex);
+ }
+ }
+ }
+}
diff --git a/Patches/ModulePatches.cs b/ModLib.Patches/Patches/ModulePatches.cs
similarity index 100%
rename from Patches/ModulePatches.cs
rename to ModLib.Patches/Patches/ModulePatches.cs
diff --git a/ModLib.Patches/Properties/AssemblyInfo.cs b/ModLib.Patches/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..5daa4563
--- /dev/null
+++ b/ModLib.Patches/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ModLib.Patches")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ModLib.Patches")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f81c97fe-515a-4177-b14e-98933f62e56b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Settings.cs b/ModLib.Patches/Settings.cs
similarity index 94%
rename from Settings.cs
rename to ModLib.Patches/Settings.cs
index 46135c2c..68251ff9 100644
--- a/Settings.cs
+++ b/ModLib.Patches/Settings.cs
@@ -1,13 +1,13 @@
using ModLib.Attributes;
using System.Xml.Serialization;
-namespace ModLib
+namespace ModLib.Patches
{
public class Settings : SettingsBase
{
public override string ModName => "ModLib";
public override string ModuleFolderName => ModLibSubModule.ModuleFolderName;
- public const string SettingsInstanceID = "ModLibSettings";
+ public const string SettingsInstanceID = "ModLibPatchesSettings";
public static Settings Instance
{
get
diff --git a/ModLib.Patches/packages.config b/ModLib.Patches/packages.config
new file mode 100644
index 00000000..3cbe20b5
--- /dev/null
+++ b/ModLib.Patches/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/ModLib.csproj b/ModLib.csproj
index 9ebb2d73..d3d1ba83 100644
--- a/ModLib.csproj
+++ b/ModLib.csproj
@@ -1,5 +1,10 @@
+
+
+
+
+
@@ -35,9 +40,6 @@
prompt
4
-
-
-
@@ -100,6 +102,7 @@
+
@@ -126,10 +129,8 @@
-
-
@@ -157,9 +158,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
<_GUIViews Include="$(ProjectDir)\GUI\Views\*.xml" />
@@ -170,4 +184,14 @@
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ModLib.sln b/ModLib.sln
index 417b2c39..ff8e22e8 100644
--- a/ModLib.sln
+++ b/ModLib.sln
@@ -5,6 +5,13 @@ VisualStudioVersion = 16.0.29519.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModLib", "ModLib.csproj", "{D0D189A7-42C9-4CAB-B182-488C2293A11B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModLib.Patches", "ModLib.Patches\ModLib.Patches.csproj", "{F81C97FE-515A-4177-B14E-98933F62E56B}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A153651A-686A-465C-A4DB-CEF73418ABA1}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +22,10 @@ Global
{D0D189A7-42C9-4CAB-B182-488C2293A11B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0D189A7-42C9-4CAB-B182-488C2293A11B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0D189A7-42C9-4CAB-B182-488C2293A11B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F81C97FE-515A-4177-B14E-98933F62E56B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F81C97FE-515A-4177-B14E-98933F62E56B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F81C97FE-515A-4177-B14E-98933F62E56B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F81C97FE-515A-4177-B14E-98933F62E56B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ModLibSubModule.cs b/ModLibSubModule.cs
index 9535a36c..56f57727 100644
--- a/ModLibSubModule.cs
+++ b/ModLibSubModule.cs
@@ -1,5 +1,4 @@
-using HarmonyLib;
-using ModLib.Debugging;
+using ModLib.Debugging;
using ModLib.GUI.GauntletUI;
using System;
using TaleWorlds.Engine.Screens;
@@ -17,19 +16,15 @@ protected override void OnSubModuleLoad()
try
{
FileDatabase.Initialise(ModuleFolderName);
- Settings settings = FileDatabase.Get(Settings.SettingsInstanceID);
- if (settings == null) settings = new Settings();
- SettingsDatabase.RegisterSettings(settings);
-
- var harmony = new Harmony("mod.modlib.mipen");
- harmony.PatchAll();
Module.CurrentModule.AddInitialStateOption(new InitialStateOption("ModOptionsMenu", new TextObject("Mod Options"), 9990, () =>
{
ScreenManager.PushScreen(new ModOptionsGauntletScreen());
}, false));
}
+#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
+#pragma warning restore CA1031 // Do not catch general exception types
{
ModDebug.ShowError($"An error occurred whilst initialising ModLib", "Error during initialisation", ex);
}
diff --git a/Ref.cs b/Ref.cs
index aab1c057..87c1b854 100644
--- a/Ref.cs
+++ b/Ref.cs
@@ -5,10 +5,10 @@ namespace ModLib
{
public class Ref
{
- private Func