diff --git a/README.md b/README.md
index 4e46c6d..fa2dc94 100644
--- a/README.md
+++ b/README.md
@@ -44,16 +44,23 @@
The Bannerlord Software Extender (BLSE) is a tool for Bannerlord mods that expands modding capabilities and adds additional functionality to the game.
-Once installed, no additional steps are needed to launch Bannerlord with BLSE's added functionality.
-You can start the game using **Bannerlord.BLSE.Launcher.exe** for the Vanilla Launcher or **Bannerlord.BLSE.LauncherEx.exe** for the Extended Launcher (BUTRLoader).
-Mod Developers can use **Bannerlord.BLSE.Standalone.exe** to use the CLI to launch the game.
+Once installed, no additional steps are needed to launch Bannerlord with BLSE's added functionality.
+You can start the game using **Bannerlord.BLSE.Launcher.exe** for the Vanilla Launcher or **Bannerlord.BLSE.LauncherEx.exe** for the Extended Launcher (BUTRLoader).
+Mod Developers can use **Bannerlord.BLSE.Standalone.exe** to use the CLI to launch the game.
-Credits to [Pickysaurus](https://www.nexusmods.com/users/31179975) for the BLSE and BUTR Logos!
+Credits to [Pickysaurus](https://www.nexusmods.com/users/31179975) for the BLSE and BUTR Logos!
## Features
+* **Unblocking Files**
+ * **Launcher** and **LauncherEx** will automatically unblock files on launch.
+Can be opted-out via passing **/nounblock** in command-line args.
+ * Standalone will not automatically unblock files on launch.
+Can opted-in by passing **/unblock** in command-line args.
+* **Continue Save File** - Allows to specify the save file to load when launching the game.
+Can be used by passing **/continuesave _mysavegame_** in command-line args.
+* **Assembly Resolver** - Changes the game's assembly loading priority.
+If an assembly is available in one of the loaded modules, it will be loaded from there instead, even if the assembly is available in the main **/bin** folder.
* **Interceptor** - BLSE checks if the is a class with a custom attribute named ***BLSEInterceptorAttribute***. If it's found it checks if there are the following signatures:
* **static void OnInitializeSubModulesPrefix()** - will execute just before the game starts to initialize the SubModules. This gives us the ability to add SubModules declared in other programming languages like [Python](https://github.com/BUTR/Bannerlord.Python) and [Lua](https://github.com/BUTR/Bannerlord.Lua)
* **static void OnLoadSubModulesPostfix()** - will execute just after all SubModules were initialized
-* **Continue Save File** - Allows to specify the save file to load when launching the game. Use */continuesave **mysavegame** *(save file should be specified without the extension)
-* **Assembly Resolver** - Changes the assembly loading priority. Is an assembly is available in one of the loaded modules, it will be loaded from there instead.
diff --git a/changelog.txt b/changelog.txt
index 7b44229..2c9ab06 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
+Version: 1.0.3
+Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1
+* Always try to unblock .dll files on startup
+---------------------------------------------------------------------------------------------------
Version: 1.0.2
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1
* Should fix MessageBox dialog not being shown
diff --git a/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj b/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj
index 3660f8c..d91d667 100644
--- a/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj
+++ b/src/Bannerlord.BLSE.Shared/Bannerlord.BLSE.Shared.csproj
@@ -26,6 +26,7 @@
+
diff --git a/src/Bannerlord.BLSE.Shared/ModuleInitializer.cs b/src/Bannerlord.BLSE.Shared/ModuleInitializer.cs
index 6858acd..6900e06 100644
--- a/src/Bannerlord.BLSE.Shared/ModuleInitializer.cs
+++ b/src/Bannerlord.BLSE.Shared/ModuleInitializer.cs
@@ -1,4 +1,5 @@
using Bannerlord.BLSE.Shared;
+using Bannerlord.BLSE.Shared.Utils;
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ModuleManager;
@@ -15,8 +16,8 @@
using TaleWorlds.Core;
-using MessageBoxButtons = Bannerlord.BLSE.Shared.MessageBoxButtons;
-using MessageBoxIcon = Bannerlord.BLSE.Shared.MessageBoxIcon;
+using MessageBoxButtons = Bannerlord.BLSE.Shared.Utils.MessageBoxButtons;
+using MessageBoxIcon = Bannerlord.BLSE.Shared.Utils.MessageBoxIcon;
internal static class ModuleInitializer
{
@@ -120,7 +121,7 @@ internal static void Action()
Environment.Exit(1);
return null;
}
-
+
var harmonyBinFolder = Path.Combine(harmonyModuleFolder, "bin", configName);
var harmonyBinSteamFolder = Path.Combine(harmonySteamModuleFolder, "bin", configName);
if (!Directory.Exists(harmonyBinFolder) && !Directory.Exists(harmonyBinSteamFolder))
@@ -138,10 +139,10 @@ internal static void Action()
Environment.Exit(1);
return null;
}
-
+
return File.Exists(assemblyFile) ? assemblyFile : File.Exists(assemblySteamFile) ? assemblySteamFile : string.Empty;
}
-
+
private static Assembly? ResolveHarmonyAssembly(AssemblyName assemblyName)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
diff --git a/src/Bannerlord.BLSE.Shared/NativeMethods.txt b/src/Bannerlord.BLSE.Shared/NativeMethods.txt
new file mode 100644
index 0000000..516ca18
--- /dev/null
+++ b/src/Bannerlord.BLSE.Shared/NativeMethods.txt
@@ -0,0 +1,4 @@
+MessageBox
+DeleteFile
+GetConsoleWindow
+ShowWindow
\ No newline at end of file
diff --git a/src/Bannerlord.BLSE.Shared/NoExceptions/ProgramEx.cs b/src/Bannerlord.BLSE.Shared/NoExceptions/ProgramEx.cs
index d5f253c..ae03c09 100644
--- a/src/Bannerlord.BLSE.Shared/NoExceptions/ProgramEx.cs
+++ b/src/Bannerlord.BLSE.Shared/NoExceptions/ProgramEx.cs
@@ -1,4 +1,5 @@
-using Bannerlord.LauncherEx;
+using Bannerlord.BUTR.Shared.Helpers;
+using Bannerlord.LauncherEx;
using HarmonyLib;
using HarmonyLib.BUTR.Extensions;
@@ -21,7 +22,7 @@ private record LauncherExContext(GraphicsForm GraphicsForm, StandaloneUIDomain S
public static LauncherExContext Create()
{
var resourceDepot = new ResourceDepot();
- resourceDepot.AddLocation(BasePath.Name, "Modules/Native/LauncherGUI/");
+ resourceDepot.AddLocation(BasePath.Name, $"{ModuleInfoHelper.ModulesFolder}/Native/LauncherGUI/");
resourceDepot.CollectResources();
resourceDepot.StartWatchingChangesInDepot();
diff --git a/src/Bannerlord.BLSE.Shared/Program.cs b/src/Bannerlord.BLSE.Shared/Program.cs
index dc43633..3f6a328 100644
--- a/src/Bannerlord.BLSE.Shared/Program.cs
+++ b/src/Bannerlord.BLSE.Shared/Program.cs
@@ -1,43 +1,40 @@
-using System;
+using Bannerlord.BLSE.Shared.Utils;
+
+using System;
using System.Linq;
using System.Runtime.InteropServices;
+using Windows.Win32;
+using Windows.Win32.UI.WindowsAndMessaging;
+
namespace Bannerlord.BLSE.Shared;
public static class Program
{
- /*
- [DllImport("kernel32.dll")]
- private static extern IntPtr GetConsoleWindow();
-
- [DllImport("user32.dll")]
- private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
-
- private const int SW_HIDE = 0;
- private const int SW_SHOW = 5;
- */
-
public static void Main(string[] args)
{
- /*
- var handle = GetConsoleWindow();
- ShowWindow(handle, SW_HIDE);
- */
+ //PInvoke.ShowWindow(PInvoke.GetConsoleWindow(), SHOW_WINDOW_CMD.SW_HIDE);
switch (args[0])
{
case "launcher":
{
+ // Users can opt-out of unblocking for I guess performance reasons?
+ if (!args.Contains("/nounblock")) Unblocker.Unblock();
Launcher.Launch(args.Skip(1).ToArray());
break;
}
case "launcherex":
{
+ // Users can opt-out of unblocking for I guess performance reasons?
+ if (!args.Contains("/nounblock")) Unblocker.Unblock();
LauncherEx.Launch(args.Skip(1).ToArray());
break;
}
case "standalone":
{
+ // Since standalone is for external tools, they might unlock the files themselves
+ if (args.Contains("/unblock")) Unblocker.Unblock();
Standalone.Launch(args.Skip(1).ToArray());
break;
}
diff --git a/src/Bannerlord.BLSE.Shared/Standalone.cs b/src/Bannerlord.BLSE.Shared/Standalone.cs
index 58954af..21df2b3 100644
--- a/src/Bannerlord.BLSE.Shared/Standalone.cs
+++ b/src/Bannerlord.BLSE.Shared/Standalone.cs
@@ -3,6 +3,7 @@
using Bannerlord.BLSE.Features.ContinueSaveFile;
using Bannerlord.BLSE.Features.Interceptor;
using Bannerlord.BLSE.Features.Xbox;
+using Bannerlord.BLSE.Shared.Utils;
using Bannerlord.BUTR.Shared.Helpers;
using Bannerlord.ModuleManager;
@@ -17,6 +18,10 @@
using TaleWorlds.MountAndBlade.Launcher.Library;
using TaleWorlds.SaveSystem;
+using MessageBoxButtons = Bannerlord.BLSE.Shared.Utils.MessageBoxButtons;
+using MessageBoxDefaultButton = Bannerlord.BLSE.Shared.Utils.MessageBoxDefaultButton;
+using MessageBoxIcon = Bannerlord.BLSE.Shared.Utils.MessageBoxIcon;
+
namespace Bannerlord.BLSE.Shared;
public static class Standalone
diff --git a/src/Bannerlord.BLSE.Shared/MessageBoxDialog.cs b/src/Bannerlord.BLSE.Shared/Utils/MessageBoxDialog.cs
similarity index 86%
rename from src/Bannerlord.BLSE.Shared/MessageBoxDialog.cs
rename to src/Bannerlord.BLSE.Shared/Utils/MessageBoxDialog.cs
index 6afae39..6cbe9d9 100644
--- a/src/Bannerlord.BLSE.Shared/MessageBoxDialog.cs
+++ b/src/Bannerlord.BLSE.Shared/Utils/MessageBoxDialog.cs
@@ -1,30 +1,28 @@
-using System;
-using System.Runtime.InteropServices;
+using Windows.Win32;
+using Windows.Win32.Foundation;
+using Windows.Win32.UI.WindowsAndMessaging;
-namespace Bannerlord.BLSE.Shared;
+namespace Bannerlord.BLSE.Shared.Utils;
public static class MessageBoxDialog
{
- [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
- private static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
-
public static MessageBoxResult Show(string text) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, "\0", (uint)MessageBoxButtons.Ok);
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, "\0", (MESSAGEBOX_STYLE) MessageBoxButtons.Ok);
public static MessageBoxResult Show(string text, string caption) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, (uint)MessageBoxButtons.Ok);
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, (MESSAGEBOX_STYLE) MessageBoxButtons.Ok);
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, (uint)buttons);
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, (MESSAGEBOX_STYLE) buttons);
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, ((uint)buttons) | ((uint)icon));
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, ((MESSAGEBOX_STYLE) buttons) | ((MESSAGEBOX_STYLE) icon));
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton button) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, ((uint)buttons) | ((uint)icon) | ((uint)button));
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, ((MESSAGEBOX_STYLE) buttons) | ((MESSAGEBOX_STYLE) icon) | ((MESSAGEBOX_STYLE) button));
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton button, MessageBoxModal modal) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, ((uint)buttons) | ((uint)icon) | ((uint)button) | ((uint)modal));
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, ((MESSAGEBOX_STYLE) buttons) | ((MESSAGEBOX_STYLE) icon) | ((MESSAGEBOX_STYLE) button) | ((MESSAGEBOX_STYLE) modal));
}
public enum MessageBoxButtons
diff --git a/src/Bannerlord.BLSE.Shared/Utils/NtfsUnblocker.cs b/src/Bannerlord.BLSE.Shared/Utils/NtfsUnblocker.cs
new file mode 100644
index 0000000..70ebf21
--- /dev/null
+++ b/src/Bannerlord.BLSE.Shared/Utils/NtfsUnblocker.cs
@@ -0,0 +1,14 @@
+using System.IO;
+using System.Threading.Tasks;
+
+using Windows.Win32;
+
+namespace Bannerlord.BLSE.Shared.Utils
+{
+ internal static class NtfsUnblocker
+ {
+ public static void UnblockDirectory(string path, string wildcard = "*") => Parallel.ForEach(Directory.EnumerateFiles(path, wildcard, SearchOption.AllDirectories), UnblockFile);
+
+ public static void UnblockFile(string fileName) => PInvoke.DeleteFile($"{fileName}:Zone.Identifier");
+ }
+}
\ No newline at end of file
diff --git a/src/Bannerlord.BLSE.Shared/Utils/Unblocker.cs b/src/Bannerlord.BLSE.Shared/Utils/Unblocker.cs
new file mode 100644
index 0000000..cc06978
--- /dev/null
+++ b/src/Bannerlord.BLSE.Shared/Utils/Unblocker.cs
@@ -0,0 +1,61 @@
+using Bannerlord.BUTR.Shared.Helpers;
+
+using HarmonyLib;
+using HarmonyLib.BUTR.Extensions;
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+
+namespace Bannerlord.BLSE.Shared.Utils;
+
+public static class Unblocker
+{
+ private static readonly Harmony _harmony = new("Bannerlord.BLSE.Shared.Patches.Unblocker");
+ private static Thread? _currentUnblockingThread;
+
+
+ public static void Unblock()
+ {
+ if (_currentUnblockingThread is not null)
+ return;
+
+ Assembly.Load(new AssemblyName("TaleWorlds.Starter.Library"));
+
+ var result = _harmony.TryPatch(
+ AccessTools2.DeclaredMethod("TaleWorlds.Starter.Library.Program:Main"),
+ prefix: AccessTools2.Method(typeof(Unblocker), nameof(MainPrefix)));
+
+ if (result)
+ {
+ _currentUnblockingThread = new Thread(UnblockFiles);
+ _currentUnblockingThread.Start();
+ }
+ }
+
+ private static void MainPrefix()
+ {
+ // We prevent the game from being started if we didn't finish with unblocking
+ try
+ {
+ _currentUnblockingThread?.Join();
+ }
+ catch (Exception) { /* ignore */ }
+
+ _harmony.Unpatch(AccessTools2.DeclaredMethod("TaleWorlds.Starter.Library.Program:Main"), AccessTools2.Method(typeof(Unblocker), nameof(MainPrefix)));
+ }
+
+ private static void UnblockFiles()
+ {
+ var modulesPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "../", "../", ModuleInfoHelper.ModulesFolder));
+ if (Directory.Exists(modulesPath))
+ {
+ try
+ {
+ NtfsUnblocker.UnblockDirectory(modulesPath, "*.dll");
+ }
+ catch { /* ignore */ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Bannerlord.BLSE/Features/Xbox/Patches/ModulePatch.cs b/src/Bannerlord.BLSE/Features/Xbox/Patches/ModulePatch.cs
index d6c14f1..5b2c2b2 100644
--- a/src/Bannerlord.BLSE/Features/Xbox/Patches/ModulePatch.cs
+++ b/src/Bannerlord.BLSE/Features/Xbox/Patches/ModulePatch.cs
@@ -19,12 +19,12 @@ public static bool Enable(Harmony harmony)
AccessTools2.Constructor(typeof(Module)),
prefix: AccessTools2.Method(typeof(ModulePatch), nameof(ShowedLoginScreenPrefix)));
if (!res1) return false;
-
+
var res2 = harmony.TryPatch(
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Platform.GDK.PlatformGDKSubModule:OnSubModuleLoad"),
prefix: AccessTools2.Method(typeof(ModulePatch), nameof(OnSubModuleLoadPrefix)));
if (!res2) return false;
-
+
var res3 = harmony.TryPatch(
AccessTools2.DeclaredMethod("TaleWorlds.MountAndBlade.Platform.GDK.PlatformGDKSubModule:OnApplicationTick"),
prefix: AccessTools2.Method(typeof(ModulePatch), nameof(OnApplicationTickPrefix)));
@@ -38,14 +38,14 @@ private static void ShowedLoginScreenPrefix(ref bool ___ShowedLoginScreen)
{
___ShowedLoginScreen = true;
}
-
+
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool OnSubModuleLoadPrefix()
{
Common.PlatformFileHelper = new PlatformFileHelperPC("Mount and Blade II Bannerlord");
return false;
}
-
+
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool OnApplicationTickPrefix()
{
diff --git a/src/Bannerlord.LauncherEx/BUTRLauncherManagerHandler.cs b/src/Bannerlord.LauncherEx/BUTRLauncherManagerHandler.cs
index 464d707..78dadb1 100644
--- a/src/Bannerlord.LauncherEx/BUTRLauncherManagerHandler.cs
+++ b/src/Bannerlord.LauncherEx/BUTRLauncherManagerHandler.cs
@@ -220,7 +220,7 @@ public LoadOrder LoadTWLoadOrder()
{
BetaSorting = LauncherSettings.BetaSorting,
FixCommonIssues = LauncherSettings.FixCommonIssues,
- UnblockFiles = LauncherSettings.UnblockFiles,
+ UnblockFiles = true, // TODO: Remove. Always unblock
Language = Manager.GetActiveLanguage(),
};
diff --git a/src/Bannerlord.LauncherEx/Helpers/Input/MessageBoxDialog.cs b/src/Bannerlord.LauncherEx/Helpers/Input/MessageBoxDialog.cs
index fce4401..c4deb9c 100644
--- a/src/Bannerlord.LauncherEx/Helpers/Input/MessageBoxDialog.cs
+++ b/src/Bannerlord.LauncherEx/Helpers/Input/MessageBoxDialog.cs
@@ -1,30 +1,28 @@
-using System;
-using System.Runtime.InteropServices;
+using Windows.Win32;
+using Windows.Win32.Foundation;
+using Windows.Win32.UI.WindowsAndMessaging;
namespace Bannerlord.LauncherEx.Helpers.Input;
public static class MessageBoxDialog
{
- [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
- private static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
-
public static MessageBoxResult Show(string text) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, "\0", (uint)MessageBoxButtons.Ok);
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, "\0", (MESSAGEBOX_STYLE) MessageBoxButtons.Ok);
public static MessageBoxResult Show(string text, string caption) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, (uint)MessageBoxButtons.Ok);
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, (MESSAGEBOX_STYLE) MessageBoxButtons.Ok);
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, (uint)buttons);
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, (MESSAGEBOX_STYLE) buttons);
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, ((uint)buttons) | ((uint)icon));
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, ((MESSAGEBOX_STYLE) buttons) | ((MESSAGEBOX_STYLE) icon));
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton button) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, ((uint)buttons) | ((uint)icon) | ((uint)button));
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, ((MESSAGEBOX_STYLE) buttons) | ((MESSAGEBOX_STYLE) icon) | ((MESSAGEBOX_STYLE) button));
public static MessageBoxResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton button, MessageBoxModal modal) =>
- (MessageBoxResult) MessageBox(IntPtr.Zero, text, caption, ((uint)buttons) | ((uint)icon) | ((uint)button) | ((uint)modal));
+ (MessageBoxResult) PInvoke.MessageBox(HWND.Null, text, caption, ((MESSAGEBOX_STYLE) buttons) | ((MESSAGEBOX_STYLE) icon) | ((MESSAGEBOX_STYLE) button) | ((MESSAGEBOX_STYLE) modal));
}
public enum MessageBoxButtons
diff --git a/src/Bannerlord.LauncherEx/Helpers/NtfsUnblocker.cs b/src/Bannerlord.LauncherEx/Helpers/NtfsUnblocker.cs
deleted file mode 100644
index 567042e..0000000
--- a/src/Bannerlord.LauncherEx/Helpers/NtfsUnblocker.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System.IO;
-
-using Windows.Win32;
-
-namespace Bannerlord.LauncherEx.Helpers
-{
- ///
- /// https://stackoverflow.com/a/21266072
- ///
- internal static class NtfsUnblocker
- {
- public static void UnblockPath(string path, string wildcard = "*")
- {
- foreach (var file in Directory.GetFiles(path, wildcard))
- UnblockFile(file);
-
- foreach (var dir in Directory.GetDirectories(path))
- UnblockPath(dir);
- }
-
- public static bool UnblockFile(string fileName) => PInvoke.DeleteFile($"{fileName}:Zone.Identifier");
- }
-}
\ No newline at end of file
diff --git a/src/Bannerlord.LauncherEx/LauncherSettings.cs b/src/Bannerlord.LauncherEx/LauncherSettings.cs
index 4558a9a..9b3df27 100644
--- a/src/Bannerlord.LauncherEx/LauncherSettings.cs
+++ b/src/Bannerlord.LauncherEx/LauncherSettings.cs
@@ -7,7 +7,6 @@ namespace Bannerlord.LauncherEx
internal sealed class LauncherSettings
{
public static bool AutomaticallyCheckForUpdates { get; set; }
- public static bool UnblockFiles { get; set; }
public static bool FixCommonIssues { get; set; }
public static bool CompactModuleList { get; set; }
public static bool DisableBinaryCheck { get; set; }
diff --git a/src/Bannerlord.LauncherEx/Manager.cs b/src/Bannerlord.LauncherEx/Manager.cs
index 3cb3f7b..61bcc14 100644
--- a/src/Bannerlord.LauncherEx/Manager.cs
+++ b/src/Bannerlord.LauncherEx/Manager.cs
@@ -1,4 +1,5 @@
-using Bannerlord.LauncherEx.Helpers;
+using Bannerlord.BUTR.Shared.Helpers;
+using Bannerlord.LauncherEx.Helpers;
using Bannerlord.LauncherEx.Patches;
using Bannerlord.LauncherEx.ResourceManagers;
using Bannerlord.LauncherEx.TPac;
@@ -71,7 +72,7 @@ public static void Enable()
SpriteDataManager.CreateAndRegister("launcher_search");
SpriteDataManager.CreateAndRegister("warm_overlay");
- var asset = new AssetPackage(Path.Combine(BasePath.Name, "Modules/Native/AssetPackages/gauntlet_ui.tpac"));
+ var asset = new AssetPackage(Path.Combine(BasePath.Name, ModuleInfoHelper.ModulesFolder, "Native/AssetPackages/gauntlet_ui.tpac"));
switch (BUTRLocalizationManager.ActiveLanguage)
{
case BUTRLocalizationManager.ChineseTraditional or BUTRLocalizationManager.ChineseSimple when asset.GetTexture("ui_fonts_1") is { } chinese:
diff --git a/src/Bannerlord.LauncherEx/NativeMethods.txt b/src/Bannerlord.LauncherEx/NativeMethods.txt
index a4de349..ad06a09 100644
--- a/src/Bannerlord.LauncherEx/NativeMethods.txt
+++ b/src/Bannerlord.LauncherEx/NativeMethods.txt
@@ -8,4 +8,5 @@ DeleteFile
CreateToolhelp32Snapshot
Process32First
Process32Next
-CloseHandle
\ No newline at end of file
+CloseHandle
+MessageBox
\ No newline at end of file
diff --git a/src/Bannerlord.LauncherEx/Options/LauncherExData.cs b/src/Bannerlord.LauncherEx/Options/LauncherExData.cs
index 7a1e4b7..23339fd 100644
--- a/src/Bannerlord.LauncherEx/Options/LauncherExData.cs
+++ b/src/Bannerlord.LauncherEx/Options/LauncherExData.cs
@@ -3,7 +3,6 @@
public sealed class LauncherExData
{
public bool AutomaticallyCheckForUpdates { get; set; }
- public bool UnblockFiles { get; set; } = true;
public bool FixCommonIssues { get; set; }
public bool CompactModuleList { get; set; }
public bool DisableBinaryCheck { get; set; }
@@ -14,12 +13,14 @@ public sealed class LauncherExData
public LauncherExData() { }
public LauncherExData(
bool automaticallyCheckForUpdates,
- bool unblockFiles, bool fixCommonIssues, bool compactModuleList,
- bool hideRandomImage, bool disableBinaryCheck, bool betaSorting,
+ bool fixCommonIssues,
+ bool compactModuleList,
+ bool hideRandomImage,
+ bool disableBinaryCheck,
+ bool betaSorting,
bool bigMode)
{
AutomaticallyCheckForUpdates = automaticallyCheckForUpdates;
- UnblockFiles = unblockFiles;
FixCommonIssues = fixCommonIssues;
CompactModuleList = compactModuleList;
DisableBinaryCheck = disableBinaryCheck;
diff --git a/src/Bannerlord.LauncherEx/Patches/ProgramPatch.cs b/src/Bannerlord.LauncherEx/Patches/ProgramPatch.cs
index c808315..59d10d2 100644
--- a/src/Bannerlord.LauncherEx/Patches/ProgramPatch.cs
+++ b/src/Bannerlord.LauncherEx/Patches/ProgramPatch.cs
@@ -1,20 +1,14 @@
-using Bannerlord.LauncherEx.Helpers;
-using Bannerlord.LauncherManager.Utils;
+using Bannerlord.LauncherManager.Utils;
using HarmonyLib;
using HarmonyLib.BUTR.Extensions;
-using System.IO;
-
-using TaleWorlds.Library;
using TaleWorlds.MountAndBlade.Launcher.Library;
namespace Bannerlord.LauncherEx.Patches
{
internal static class ProgramPatch
{
- private static string PathPrefix() => Path.Combine(BasePath.Name, "Modules");
-
public static bool Enable(Harmony harmony)
{
var res1 = harmony.TryPatch(
@@ -27,19 +21,6 @@ public static bool Enable(Harmony harmony)
private static void AuxFinalizePrefix()
{
- var pathPrefix = PathPrefix();
- if (LauncherSettings.UnblockFiles)
- {
- if (Directory.Exists(pathPrefix))
- {
- try
- {
- NtfsUnblocker.UnblockPath(pathPrefix, "*.dll");
- }
- catch { /* ignore */ }
- }
- }
-
if (LauncherSettings.FixCommonIssues)
{
BUTRLauncherManagerHandler.Default.CheckForRootHarmony();
diff --git a/src/Bannerlord.LauncherEx/Patches/UserDataManagerPatch.cs b/src/Bannerlord.LauncherEx/Patches/UserDataManagerPatch.cs
index 104c724..7feefc2 100644
--- a/src/Bannerlord.LauncherEx/Patches/UserDataManagerPatch.cs
+++ b/src/Bannerlord.LauncherEx/Patches/UserDataManagerPatch.cs
@@ -51,7 +51,6 @@ private static bool LoadUserDataPrefix(string ____filePath)
using var xmlReader = XmlReader.Create(____filePath);
var userDataOptions = (LauncherExData) xmlSerializer.Deserialize(xmlReader);
LauncherSettings.AutomaticallyCheckForUpdates = userDataOptions.AutomaticallyCheckForUpdates;
- LauncherSettings.UnblockFiles = userDataOptions.UnblockFiles;
LauncherSettings.FixCommonIssues = userDataOptions.FixCommonIssues;
LauncherSettings.CompactModuleList = userDataOptions.CompactModuleList;
LauncherSettings.HideRandomImage = userDataOptions.HideRandomImage;
@@ -85,7 +84,6 @@ private static void SaveUserDataPostfix(string ____filePath)
{
xmlSerializer.Serialize(writer, new LauncherExData(
LauncherSettings.AutomaticallyCheckForUpdates,
- LauncherSettings.UnblockFiles,
LauncherSettings.FixCommonIssues,
LauncherSettings.CompactModuleList,
LauncherSettings.HideRandomImage,
diff --git a/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs b/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs
index 1231528..e8cfb21 100644
--- a/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs
+++ b/src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs
@@ -64,7 +64,6 @@ private void RefreshLauncherOptions()
{
_launcherExData = new LauncherExData(
LauncherSettings.AutomaticallyCheckForUpdates,
- LauncherSettings.UnblockFiles,
LauncherSettings.FixCommonIssues,
LauncherSettings.CompactModuleList,
LauncherSettings.HideRandomImage,
@@ -72,13 +71,6 @@ private void RefreshLauncherOptions()
LauncherSettings.BetaSorting,
LauncherSettings.BigMode);
- SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
- {
- DisplayName = new BUTRTextObject("{=zHo3tzQT}Unblock Files on Start").ToString(),
- HintText = new BUTRTextObject("{=sOInYH9V}Automatically unblock's .dll files on start").ToString(),
- SettingType = SettingType.Bool,
- PropertyReference = new PropertyRef(typeof(LauncherSettings).GetProperty(nameof(LauncherSettings.UnblockFiles))!, this)
- }));
SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
{
DisplayName = new BUTRTextObject("{=LXlsSS8t}Fix Common Issues").ToString(),
@@ -108,16 +100,6 @@ private void RefreshLauncherOptions()
PropertyReference = new PropertyRef(typeof(LauncherSettings).GetProperty(nameof(LauncherSettings.HideRandomImage))!, this)
}));
SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
- {
- DisplayName = new BUTRTextObject("{=JT7QnJJA}Unblock Files").ToString(),
- HintText = new BUTRTextObject("{=VMIp4503}Unblock all .dll files on /Modules folder").ToString(),
- SettingType = SettingType.Button,
- PropertyReference = new ProxyRef(() => new BUTRTextObject("{=RDLKkiVk}Unblock").ToString(), _ =>
- {
- NtfsUnblocker.UnblockPath(Path.Combine(BasePath.Name, ModuleInfoHelper.ModulesFolder));
- })
- }));
- SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
{
DisplayName = new BUTRTextObject("{=QJSBiZdJ}Beta Sorting").ToString(),
HintText = new BUTRTextObject("{=HVhaqeb4}Uses the new sorting algorithm after v1.12.x. Disable to use the old algorithm").ToString(),
@@ -221,12 +203,6 @@ private void SaveLauncherOptions()
return;
}
- if (_launcherExData.UnblockFiles != LauncherSettings.UnblockFiles)
- {
- _saveUserData();
- return;
- }
-
if (_launcherExData.FixCommonIssues != LauncherSettings.FixCommonIssues)
{
_saveUserData();