From 70a72a172b6386df94820373e9c21a1f8a1457d8 Mon Sep 17 00:00:00 2001 From: xiaoxiao921 Date: Thu, 24 Feb 2022 14:16:07 +0100 Subject: [PATCH 1/3] tentative fix for unity env exploding --- .github/workflows/github-release.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 852c2d6..e0dd5f0 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -18,43 +18,46 @@ jobs: - name: Dotnet Setup uses: actions/setup-dotnet@v1 + - name: Build Patcher + run: dotnet build .\BepInEx.GUI.Patcher\BepInEx.GUI.Patcher.csproj -c Release -o .\BepInEx_GUI_Patcher_${{github.ref_name}} + - name: Publish Windows x64 - run: dotnet publish -c Release --sc -r win-x64 --output ./BepInEx_GUI_win_x64_${{github.ref_name}} + run: dotnet publish .\BepInEx.GUI\BepInEx.GUI.csproj -c Release -p:PublishSingleFile=true --sc -r win-x64 --output ./BepInEx_GUI_win_x64_${{github.ref_name}} - name: Zip Windows x64 Release uses: papeloto/action-zip@v1 with: - files: BepInEx_GUI_win_x64_${{github.ref_name}}/ + files: BepInEx_GUI_win_x64_${{github.ref_name}}/ BepInEx_GUI_Patcher_${{github.ref_name}}/ recursive: false dest: BepInEx_GUI_win_x64_${{github.ref_name}}.zip - name: Publish Windows x86 - run: dotnet publish -c Release --sc -r win-x86 --output ./BepInEx_GUI_win_x86_${{github.ref_name}} + run: dotnet publish .\BepInEx.GUI\BepInEx.GUI.csproj -c Release -p:PublishSingleFile=true --sc -r win-x86 --output ./BepInEx_GUI_win_x86_${{github.ref_name}} - name: Zip Windows x86 Release uses: papeloto/action-zip@v1 with: - files: BepInEx_GUI_win_x86_${{github.ref_name}}/ + files: BepInEx_GUI_win_x86_${{github.ref_name}}/ BepInEx_GUI_Patcher_${{github.ref_name}}/ recursive: false dest: BepInEx_GUI_win_x86_${{github.ref_name}}.zip - name: Publish Linux x64 - run: dotnet publish -c Release --sc -r linux-x64 --output ./BepInEx_GUI_linux_x64_${{github.ref_name}} + run: dotnet publish .\BepInEx.GUI\BepInEx.GUI.csproj -c Release -p:PublishSingleFile=true --sc -r linux-x64 --output ./BepInEx_GUI_linux_x64_${{github.ref_name}} - name: Zip Linux x64 Release uses: papeloto/action-zip@v1 with: - files: BepInEx_GUI_linux_x64_${{github.ref_name}}/ + files: BepInEx_GUI_linux_x64_${{github.ref_name}}/ BepInEx_GUI_Patcher_${{github.ref_name}}/ recursive: false dest: BepInEx_GUI_linux_x64_${{github.ref_name}}.zip - name: Publish macOS x64 - run: dotnet publish -c Release --sc -r osx-x64 --output ./BepInEx_GUI_macOS_x64_${{github.ref_name}} + run: dotnet publish .\BepInEx.GUI\BepInEx.GUI.csproj -c Release -p:PublishSingleFile=true --sc -r osx-x64 --output ./BepInEx_GUI_macOS_x64_${{github.ref_name}} - name: Zip macOS x64 Release uses: papeloto/action-zip@v1 with: - files: BepInEx_GUI_macOS_x64_${{github.ref_name}}/ + files: BepInEx_GUI_macOS_x64_${{github.ref_name}}/ BepInEx_GUI_Patcher_${{github.ref_name}}/ recursive: false dest: BepInEx_GUI_macOS_x64_${{github.ref_name}}.zip From e43a64061481b536b6307229085638c72f4a1697 Mon Sep 17 00:00:00 2001 From: xiaoxiao921 Date: Thu, 24 Feb 2022 17:20:38 +0100 Subject: [PATCH 2/3] Add config option to disable the gui (for people who want neither the regular conhost and this) --- BepInEx.GUI.Config/MainConfig.cs | 6 ++++++ .../CloseGuiOnChainloaderDone.cs | 2 -- BepInEx.GUI.Patcher/Patcher.cs | 14 ++++++++++--- BepInEx.GUI/ViewModels/SettingsViewModel.cs | 13 ++++++++++++ BepInEx.GUI/Views/SettingsView.axaml | 21 ++++++++++++++++++- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/BepInEx.GUI.Config/MainConfig.cs b/BepInEx.GUI.Config/MainConfig.cs index 5b3d69b..905844d 100644 --- a/BepInEx.GUI.Config/MainConfig.cs +++ b/BepInEx.GUI.Config/MainConfig.cs @@ -63,6 +63,10 @@ public static bool ShowOneTimeOnlyDisclaimerConfig public const string CloseWindowWhenGameClosesConfigDescription = "Close the graphic user interface window when the game closes"; public static ConfigEntry CloseWindowWhenGameClosesConfig { get; private set; } + public const string EnableBepInExGUIConfigKey = "Enable BepInEx GUI"; + public const string EnableBepInExGUIConfigDescription = "Enable the custom BepInEx GUI"; + public static ConfigEntry EnableBepInExGUIConfig { get; private set; } + public static void Init(string configFilePath) { File = new ConfigFile(configFilePath, true); @@ -72,6 +76,8 @@ public static void Init(string configFilePath) CloseWindowWhenGameLoadedConfig = File.Bind("Settings", CloseWindowWhenGameLoadedConfigKey, false, CloseWindowWhenGameLoadedConfigDescription); CloseWindowWhenGameClosesConfig = File.Bind("Settings", CloseWindowWhenGameClosesConfigKey, true, CloseWindowWhenGameClosesConfigDescription); + + EnableBepInExGUIConfig = File.Bind("Settings", EnableBepInExGUIConfigKey, true, EnableBepInExGUIConfigDescription); } } diff --git a/BepInEx.GUI.Patcher/CloseGuiOnChainloaderDone.cs b/BepInEx.GUI.Patcher/CloseGuiOnChainloaderDone.cs index 073c326..9e9103c 100644 --- a/BepInEx.GUI.Patcher/CloseGuiOnChainloaderDone.cs +++ b/BepInEx.GUI.Patcher/CloseGuiOnChainloaderDone.cs @@ -1,7 +1,6 @@ using BepInEx.GUI.Config; using BepInEx.Logging; using System; -using System.IO; namespace BepInEx.GUI.Patcher { @@ -23,7 +22,6 @@ public void LogEvent(object sender, LogEventArgs eventArgs) if (eventArgs.Data.ToString() == "Chainloader startup complete" && eventArgs.Level.Equals(LogLevel.Message)) { - MainConfig.Init(Path.Combine(Paths.ConfigPath, MainConfig.FileName)); if (MainConfig.CloseWindowWhenGameLoadedConfig.Value) { Patcher.LogSource.LogMessage("Closing BepInEx.GUI"); diff --git a/BepInEx.GUI.Patcher/Patcher.cs b/BepInEx.GUI.Patcher/Patcher.cs index 7bef2e4..5d9e006 100644 --- a/BepInEx.GUI.Patcher/Patcher.cs +++ b/BepInEx.GUI.Patcher/Patcher.cs @@ -1,4 +1,5 @@ using BepInEx.Configuration; +using BepInEx.GUI.Config; using BepInEx.Logging; using Mono.Cecil; using MonoMod.Utils; @@ -24,16 +25,23 @@ public static void Initialize() { LogSource = Logger.CreateLogSource("BepInEx.GUI.Patcher"); + MainConfig.Init(Path.Combine(Paths.ConfigPath, MainConfig.FileName)); + var consoleConfig = (ConfigEntry)typeof(BepInPlugin).Assembly.GetType("BepInEx.ConsoleManager", true).GetField("ConfigConsoleEnabled", BindingFlags.Static | BindingFlags.Public).GetValue(null); if (consoleConfig.Value) { LogSource.LogMessage("Console is enabled, not using BepInEx.GUI"); LogSource.Dispose(); } - else + else if (MainConfig.EnableBepInExGUIConfig.Value) { FindAndLaunchGui(); } + else + { + LogSource.LogMessage("BepInEx.GUI is disabled in the config, aborting launch."); + LogSource.Dispose(); + } } private static void FindAndLaunchGui() @@ -84,9 +92,9 @@ private static string FindGuiExecutable() (isWindows && fileName == $"{GuiFileName}.exe" && filePathLower.Contains("86")) || (isWindows64 && fileName == $"{GuiFileName}.exe" && filePathLower.Contains("64")) || - (isLinux64 && fileName == GuiFileName && filePathLower.Contains("linux64")) || + (isLinux64 && fileName == GuiFileName && filePathLower.Contains("linux_x64")) || - (isMacOs64 && fileName == GuiFileName && filePathLower.Contains("macos64")) + (isMacOs64 && fileName == GuiFileName && filePathLower.Contains("macos_x64")) ) { return filePath; diff --git a/BepInEx.GUI/ViewModels/SettingsViewModel.cs b/BepInEx.GUI/ViewModels/SettingsViewModel.cs index 86e6c14..71f115f 100644 --- a/BepInEx.GUI/ViewModels/SettingsViewModel.cs +++ b/BepInEx.GUI/ViewModels/SettingsViewModel.cs @@ -43,6 +43,17 @@ public bool CloseWindowWhenGameCloses } } + private bool _enableBepInExGUI; + public bool EnableBepInExGUI + { + get { return _enableBepInExGUI; } + set + { + MainConfig.EnableBepInExGUIConfig.Value = this.RaiseAndSetIfChanged(ref _enableBepInExGUI, value); + MainConfig.File.Save(); + } + } + public CancellationTokenSource CancellationTokenSource { get; private set; } #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. @@ -64,6 +75,8 @@ private void SetConfigBindings() CloseWindowWhenGameLoaded = MainConfig.CloseWindowWhenGameLoadedConfig.Value; CloseWindowWhenGameCloses = MainConfig.CloseWindowWhenGameClosesConfig.Value; + + EnableBepInExGUI = MainConfig.EnableBepInExGUIConfig.Value; } private void InitBackgroundTask() diff --git a/BepInEx.GUI/Views/SettingsView.axaml b/BepInEx.GUI/Views/SettingsView.axaml index 1f670c7..ba9047b 100644 --- a/BepInEx.GUI/Views/SettingsView.axaml +++ b/BepInEx.GUI/Views/SettingsView.axaml @@ -11,6 +11,7 @@ + @@ -43,7 +44,7 @@ Name="StackPanel2" Orientation="Horizontal"> - + @@ -67,6 +68,24 @@ + + + + + + + + + + + + + + From 0034e457e46bd4f1e6c8fe4c64e85e8b0a86459a Mon Sep 17 00:00:00 2001 From: xiaoxiao921 Date: Thu, 24 Feb 2022 17:22:03 +0100 Subject: [PATCH 3/3] - add combobox in console view for filtering based on loaded mod names - fix color for warning and error log entries --- BepInEx.GUI/ViewModels/ConsoleViewModel.cs | 49 +++++++++++++++++----- BepInEx.GUI/ViewModels/GeneralViewModel.cs | 2 +- BepInEx.GUI/Views/ConsoleView.axaml | 27 ++++++++++-- 3 files changed, 63 insertions(+), 15 deletions(-) diff --git a/BepInEx.GUI/ViewModels/ConsoleViewModel.cs b/BepInEx.GUI/ViewModels/ConsoleViewModel.cs index 9630c25..cceffe3 100644 --- a/BepInEx.GUI/ViewModels/ConsoleViewModel.cs +++ b/BepInEx.GUI/ViewModels/ConsoleViewModel.cs @@ -13,12 +13,14 @@ public class ConsoleViewModel : ViewModelBase public class ColoredEntry { public string Text { get; set; } - public string Color { get; set; } + public string BackgroundColor { get; set; } + public string ForegroundColor { get; set; } - public ColoredEntry(string text, string color) + public ColoredEntry(string text, string backgroundColor, string foregroundColor) { Text = text; - Color = color; + BackgroundColor = backgroundColor; + ForegroundColor = foregroundColor; } } @@ -54,6 +56,8 @@ public bool ConsoleAutoScroll } } + private bool _justChangedSelectedMod; + private string _textFilter = ""; public string TextFilter { @@ -62,6 +66,31 @@ public string TextFilter { this.RaiseAndSetIfChanged(ref _textFilter, value); UpdateConsoleBox(); + + if (_justChangedSelectedMod) + { + _justChangedSelectedMod = false; + } + else + { + SelectedModFilter = null; + } + } + } + + private Mod? _selectedModFilter; + public Mod? SelectedModFilter + { + get { return _selectedModFilter; } + set + { + this.RaiseAndSetIfChanged(ref _selectedModFilter, value); + + if (value != null) + { + _justChangedSelectedMod = true; + TextFilter = _selectedModFilter!.Name; + } } } @@ -132,24 +161,24 @@ private void UpdateConsoleBox() { var logEntryString = logEntry.ToString(); - string color = logEntry.LevelCode switch + var (backgroundColor, foregroundColor) = logEntry.LevelCode switch { - Logging.LogLevel.Fatal => "Red", - Logging.LogLevel.Error => "Red", - Logging.LogLevel.Warning => "YellowGreen", - _ => "Transparent", + Logging.LogLevel.Fatal => ("Transparent", "Red"), + Logging.LogLevel.Error => ("Transparent", "Red"), + Logging.LogLevel.Warning => ("Transparent", "Yellow"), + _ => ("Transparent", "White"), }; if (TextFilter.Length > 0) { if (logEntryString.ToLowerInvariant().Contains(TextFilter.ToLowerInvariant())) { - consoleText.Add(new ColoredEntry(logEntryString, color)); + consoleText.Add(new ColoredEntry(logEntryString, backgroundColor, foregroundColor)); } } else { - consoleText.Add(new ColoredEntry(logEntryString, color)); + consoleText.Add(new ColoredEntry(logEntryString, backgroundColor, foregroundColor)); } } } diff --git a/BepInEx.GUI/ViewModels/GeneralViewModel.cs b/BepInEx.GUI/ViewModels/GeneralViewModel.cs index 900d867..48bd067 100644 --- a/BepInEx.GUI/ViewModels/GeneralViewModel.cs +++ b/BepInEx.GUI/ViewModels/GeneralViewModel.cs @@ -20,7 +20,7 @@ public class GeneralViewModel : ViewModelBase public string TargetIsLoadingCanCloseWindow { get; } - private string _loadedModCountText; + private string _loadedModCountText = ""; public string LoadedModCountText { get { return _loadedModCountText; } diff --git a/BepInEx.GUI/Views/ConsoleView.axaml b/BepInEx.GUI/Views/ConsoleView.axaml index dc31f79..2d98422 100644 --- a/BepInEx.GUI/Views/ConsoleView.axaml +++ b/BepInEx.GUI/Views/ConsoleView.axaml @@ -22,8 +22,27 @@ -