From 550cf120f32f368258d953ae784493279b893907 Mon Sep 17 00:00:00 2001 From: shoushou <100991210+shoushou1106@users.noreply.github.com> Date: Thu, 16 May 2024 12:52:06 +0800 Subject: [PATCH] Initial commit --- AutoRunPlugin.csproj | 55 ++++++++ Execution/AutoRunExecutionAction.cs | 191 ++++++++++++++++++++++++++++ FrostyAutoRunPlugin.sln | 142 +++++++++++++++++++++ Options/AutoRunOptions.cs | 164 ++++++++++++++++++++++++ Properties/AssemblyInfo.cs | 29 +++++ 5 files changed, 581 insertions(+) create mode 100644 AutoRunPlugin.csproj create mode 100644 Execution/AutoRunExecutionAction.cs create mode 100644 FrostyAutoRunPlugin.sln create mode 100644 Options/AutoRunOptions.cs create mode 100644 Properties/AssemblyInfo.cs diff --git a/AutoRunPlugin.csproj b/AutoRunPlugin.csproj new file mode 100644 index 0000000..5258852 --- /dev/null +++ b/AutoRunPlugin.csproj @@ -0,0 +1,55 @@ + + + Developer - Debug;Release - Alpha;Release - Beta;Release - Final + x64 + net48 + AutoRunPlugin + AutoRunPlugin + MinimumRecommendedRules.ruleset + false + true + Library + shoushou1106 + + + + true + bin\Developer\Debug\ + DEBUG;TRACE + + + + bin\Release\Alpha\ + TRACE + true + + + + bin\Release\Beta\ + TRACE + true + + + + bin\Release\Final\ + TRACE + true + + + + + false + + + false + + + + + + + + + + + \ No newline at end of file diff --git a/Execution/AutoRunExecutionAction.cs b/Execution/AutoRunExecutionAction.cs new file mode 100644 index 0000000..dd34fe8 --- /dev/null +++ b/Execution/AutoRunExecutionAction.cs @@ -0,0 +1,191 @@ +using Frosty.Core; +using Frosty.Core.Controls; +using FrostySdk.Interfaces; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Threading; + +namespace AutoRunPlugin.Execution +{ + public class AutoRunExecutionAction : ExecutionAction + { + private void ReportProgress(ILogger logger, int current, int total) + { + if (total > 0) + logger.Log("progress:" + current / (float)total * 100d); + } + + public override Action PreLaunchAction => new Action((ILogger logger, PluginManagerType type, CancellationToken token) => + { + // Only run when AutoRun is enabled + if (Config.Get("AutoRun_Enabled", false, ConfigScope.Global) is false) + return; + token.ThrowIfCancellationRequested(); + + // Calculate total amount + logger.Log("Calculating total amount"); + List Files = new List(); + + // FrostyDir + logger.Log("Looking for files in Frosty directory"); + if (Config.Get("AutoRun_FrostyDir_AutoRunEnabled", false, ConfigScope.Global) is true && Config.Get("AutoRun_FrostyDir_PreLaunchEnabled", false, ConfigScope.Global) is true) + { + Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\AutoRun\\PreLaunch"); + Files.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory() + "\\AutoRun\\PreLaunch\\")); + } + token.ThrowIfCancellationRequested(); + + // GameDir + logger.Log("Looking for files in Game directory"); + if (Config.Get("AutoRun_GameDir_AutoRunEnabled", false, ConfigScope.Game) is true && Config.Get("AutoRun_GameDir_PreLaunchEnabled", false, ConfigScope.Game) is true) + { + Directory.CreateDirectory(App.FileSystem.BasePath + "AutoRun\\PreLaunch\\"); + Files.AddRange(Directory.GetFiles(App.FileSystem.BasePath + "AutoRun\\PreLaunch\\")); + } + token.ThrowIfCancellationRequested(); + + // PackDir (ModData) + logger.Log("Looking for files in Pack directory"); + try + { + if (Config.Get("AutoRun_PackDir_AutoRunEnabled", false, ConfigScope.Pack) is true && Config.Get("AutoRun_PackDir_PreLaunchEnabled", false, ConfigScope.Pack) is true) + { + Directory.CreateDirectory(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun\\PreLaunch\\"); + Files.AddRange(Directory.GetFiles(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun\\PreLaunch\\")); + } + } + catch (Exception e) + { + FrostyExceptionBox.Show(e, "Auto Run Plugin"); + } + token.ThrowIfCancellationRequested(); + + App.Logger.Log("[PreLaunch] " + Files.Count + " files found"); + + // (Debug) Print all file paths + if (Config.Get("AutoRun_Debug_LogAllFiles", false, ConfigScope.Global)) + { + logger.Log("[Debug] Printing all file paths"); + App.Logger.Log("[PreLaunch] [Debug] All file paths:"); + foreach (var path in Files) + { + App.Logger.Log("[PreLaunch] [Debug] " + path); + token.ThrowIfCancellationRequested(); + } + } + + GC.Collect(); + + // Run all files + int i = 0; + foreach (var path in Files) + { + try + { + logger.Log($"[{++i}/{Files.Count}] {Path.GetFileName(path)}"); + ReportProgress(logger, i, Files.Count); + token.ThrowIfCancellationRequested(); + Process.Start(path); + token.ThrowIfCancellationRequested(); + } + catch (Exception e) + { + FrostyExceptionBox.Show(e, "Auto Run Plugin"); + } + token.ThrowIfCancellationRequested(); + } + + logger.Log("Pre Launch Complete"); + App.Logger.Log("Pre Launch Complete"); + GC.Collect(); + }); + + public override Action PostLaunchAction => new Action((ILogger logger, PluginManagerType type, CancellationToken token) => + { + // Only run when AutoRun is enabled + if (Config.Get("AutoRun_Enabled", false, ConfigScope.Global) is false) + return; + token.ThrowIfCancellationRequested(); + + // Calculate total amount + logger.Log("Calculating total amount"); + List Files = new List(); + + // FrostyDir + logger.Log("Looking for files in Frosty directory"); + if (Config.Get("AutoRun_FrostyDir_AutoRunEnabled", false, ConfigScope.Global) is true && Config.Get("AutoRun_FrostyDir_PostLaunchEnabled", false, ConfigScope.Global) is true) + { + Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\AutoRun\\PostLaunch\\"); + Files.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory() + "\\AutoRun\\PostLaunch\\")); + } + token.ThrowIfCancellationRequested(); + + // GameDir + logger.Log("Looking for files in Game directory"); + if (Config.Get("AutoRun_GameDir_AutoRunEnabled", false, ConfigScope.Game) is true && Config.Get("AutoRun_GameDir_PostLaunchEnabled", false, ConfigScope.Game) is true) + { + Directory.CreateDirectory(App.FileSystem.BasePath + "AutoRun\\PostLaunch\\"); + Files.AddRange(Directory.GetFiles(App.FileSystem.BasePath + "AutoRun\\PostLaunch\\")); + } + token.ThrowIfCancellationRequested(); + + // PackDir (ModData) + logger.Log("Looking for files in Pack directory"); + try + { + if (Config.Get("AutoRun_PackDir_AutoRunEnabled", false, ConfigScope.Pack) is true && Config.Get("AutoRun_PackDir_PostLaunchEnabled", false, ConfigScope.Pack) is true) + { + Directory.CreateDirectory(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun\\PostLaunch\\"); + Files.AddRange(Directory.GetFiles(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun\\PostLaunch\\")); + } + } + catch (Exception e) + { + FrostyExceptionBox.Show(e, "Auto Run Plugin"); + } + token.ThrowIfCancellationRequested(); + + App.Logger.Log("[PostLaunch] " + Files.Count + " files found"); + + // (Debug) Print all file paths + if (Config.Get("AutoRun_Debug_LogAllFiles", false, ConfigScope.Global)) + { + logger.Log("[Debug] Printing all file paths"); + App.Logger.Log("[PostLaunch] [Debug] All file paths:"); + token.ThrowIfCancellationRequested(); + foreach (var path in Files) + { + App.Logger.Log("[PostLaunch] [Debug] " + path); + token.ThrowIfCancellationRequested(); + } + } + + GC.Collect(); + + // Run all files + int i = 0; + foreach (var path in Files) + { + try + { + logger.Log($"[{++i}/{Files.Count}] {Path.GetFileName(path)}"); + ReportProgress(logger, i, Files.Count); + token.ThrowIfCancellationRequested(); + Process.Start(path); + token.ThrowIfCancellationRequested(); + } + catch (Exception e) + { + FrostyExceptionBox.Show(e, "Auto Run Plugin"); + } + token.ThrowIfCancellationRequested(); + } + + logger.Log("Post Launch Complete"); + App.Logger.Log("Post Launch Complete"); + GC.Collect(); + }); + } +} diff --git a/FrostyAutoRunPlugin.sln b/FrostyAutoRunPlugin.sln new file mode 100644 index 0000000..efd4332 --- /dev/null +++ b/FrostyAutoRunPlugin.sln @@ -0,0 +1,142 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoRunPlugin", "AutoRunPlugin.csproj", "{C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FrostyToolsuite", "FrostyToolsuite", "{830B1FC8-40EF-46CD-B611-1FDDA3183B6B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrostyCore", "..\FrostyToolsuite\FrostyPlugin\FrostyCore.csproj", "{D86D23D9-DB93-4D4E-B383-5022F759ABA8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrostySdk", "..\FrostyToolsuite\FrostySdk\FrostySdk.csproj", "{93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FrostyHash", "..\FrostyToolsuite\FrostyHash\FrostyHash.vcxproj", "{D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrostyModSupport", "..\FrostyToolsuite\FrostyModSupport\FrostyModSupport.csproj", "{E703B059-36F3-4EBF-8F86-32561BC47DCB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrostyControls", "..\FrostyToolsuite\FrostyControls\FrostyControls.csproj", "{51D3305B-48D0-4D4C-9D64-727185420EAC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Developer - Debug|x64 = Developer - Debug|x64 + Developer - Debug|x86 = Developer - Debug|x86 + Release - Alpha|x64 = Release - Alpha|x64 + Release - Alpha|x86 = Release - Alpha|x86 + Release - Beta|x64 = Release - Beta|x64 + Release - Beta|x86 = Release - Beta|x86 + Release - Final|x64 = Release - Final|x64 + Release - Final|x86 = Release - Final|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Developer - Debug|x64.ActiveCfg = Developer - Debug|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Developer - Debug|x64.Build.0 = Developer - Debug|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Developer - Debug|x86.ActiveCfg = Developer - Debug|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Developer - Debug|x86.Build.0 = Developer - Debug|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Alpha|x64.ActiveCfg = Release - Alpha|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Alpha|x64.Build.0 = Release - Alpha|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Alpha|x86.ActiveCfg = Release - Alpha|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Alpha|x86.Build.0 = Release - Alpha|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Beta|x64.ActiveCfg = Release - Beta|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Beta|x64.Build.0 = Release - Beta|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Beta|x86.ActiveCfg = Release - Beta|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Beta|x86.Build.0 = Release - Beta|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Final|x64.ActiveCfg = Release - Final|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Final|x64.Build.0 = Release - Final|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Final|x86.ActiveCfg = Release - Final|x64 + {C87A3F4C-53D0-4BB8-AF95-2B0BF9E1F165}.Release - Final|x86.Build.0 = Release - Final|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Developer - Debug|x64.ActiveCfg = Developer - Debug|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Developer - Debug|x64.Build.0 = Developer - Debug|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Developer - Debug|x86.ActiveCfg = Developer - Debug|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Developer - Debug|x86.Build.0 = Developer - Debug|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Alpha|x64.ActiveCfg = Release - Alpha|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Alpha|x64.Build.0 = Release - Alpha|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Alpha|x86.ActiveCfg = Release - Alpha|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Alpha|x86.Build.0 = Release - Alpha|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Beta|x64.ActiveCfg = Release - Beta|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Beta|x64.Build.0 = Release - Beta|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Beta|x86.ActiveCfg = Release - Beta|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Beta|x86.Build.0 = Release - Beta|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Final|x64.ActiveCfg = Release - Final|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Final|x64.Build.0 = Release - Final|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Final|x86.ActiveCfg = Release - Final|x64 + {D86D23D9-DB93-4D4E-B383-5022F759ABA8}.Release - Final|x86.Build.0 = Release - Final|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Developer - Debug|x64.ActiveCfg = Developer - Debug|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Developer - Debug|x64.Build.0 = Developer - Debug|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Developer - Debug|x86.ActiveCfg = Developer - Debug|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Developer - Debug|x86.Build.0 = Developer - Debug|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Alpha|x64.ActiveCfg = Release - Alpha|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Alpha|x64.Build.0 = Release - Alpha|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Alpha|x86.ActiveCfg = Release - Alpha|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Alpha|x86.Build.0 = Release - Alpha|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Beta|x64.ActiveCfg = Release - Beta|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Beta|x64.Build.0 = Release - Beta|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Beta|x86.ActiveCfg = Release - Beta|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Beta|x86.Build.0 = Release - Beta|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Final|x64.ActiveCfg = Release - Final|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Final|x64.Build.0 = Release - Final|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Final|x86.ActiveCfg = Release - Final|x64 + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0}.Release - Final|x86.Build.0 = Release - Final|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Developer - Debug|x64.ActiveCfg = Developer - Debug|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Developer - Debug|x64.Build.0 = Developer - Debug|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Developer - Debug|x86.ActiveCfg = Developer - Debug|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Developer - Debug|x86.Build.0 = Developer - Debug|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Alpha|x64.ActiveCfg = Release - Alpha|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Alpha|x64.Build.0 = Release - Alpha|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Alpha|x86.ActiveCfg = Release - Alpha|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Alpha|x86.Build.0 = Release - Alpha|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Beta|x64.ActiveCfg = Release - Beta|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Beta|x64.Build.0 = Release - Beta|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Beta|x86.ActiveCfg = Release - Beta|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Beta|x86.Build.0 = Release - Beta|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Final|x64.ActiveCfg = Release - Final|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Final|x64.Build.0 = Release - Final|x64 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Final|x86.ActiveCfg = Release - Final|Win32 + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA}.Release - Final|x86.Build.0 = Release - Final|Win32 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Developer - Debug|x64.ActiveCfg = Developer - Debug|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Developer - Debug|x64.Build.0 = Developer - Debug|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Developer - Debug|x86.ActiveCfg = Developer - Debug|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Developer - Debug|x86.Build.0 = Developer - Debug|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Alpha|x64.ActiveCfg = Release - Alpha|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Alpha|x64.Build.0 = Release - Alpha|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Alpha|x86.ActiveCfg = Release - Alpha|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Alpha|x86.Build.0 = Release - Alpha|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Beta|x64.ActiveCfg = Release - Beta|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Beta|x64.Build.0 = Release - Beta|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Beta|x86.ActiveCfg = Release - Beta|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Beta|x86.Build.0 = Release - Beta|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Final|x64.ActiveCfg = Release - Final|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Final|x64.Build.0 = Release - Final|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Final|x86.ActiveCfg = Release - Final|x64 + {E703B059-36F3-4EBF-8F86-32561BC47DCB}.Release - Final|x86.Build.0 = Release - Final|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Developer - Debug|x64.ActiveCfg = Developer - Debug|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Developer - Debug|x64.Build.0 = Developer - Debug|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Developer - Debug|x86.ActiveCfg = Developer - Debug|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Developer - Debug|x86.Build.0 = Developer - Debug|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Alpha|x64.ActiveCfg = Release - Alpha|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Alpha|x64.Build.0 = Release - Alpha|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Alpha|x86.ActiveCfg = Release - Alpha|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Alpha|x86.Build.0 = Release - Alpha|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Beta|x64.ActiveCfg = Release - Beta|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Beta|x64.Build.0 = Release - Beta|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Beta|x86.ActiveCfg = Release - Beta|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Beta|x86.Build.0 = Release - Beta|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Final|x64.ActiveCfg = Release - Final|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Final|x64.Build.0 = Release - Final|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Final|x86.ActiveCfg = Release - Final|x64 + {51D3305B-48D0-4D4C-9D64-727185420EAC}.Release - Final|x86.Build.0 = Release - Final|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D86D23D9-DB93-4D4E-B383-5022F759ABA8} = {830B1FC8-40EF-46CD-B611-1FDDA3183B6B} + {93FB4A0C-DF89-4169-80B5-C4E2277FF7A0} = {830B1FC8-40EF-46CD-B611-1FDDA3183B6B} + {D1A29BF8-2E2E-47BE-845F-A6DD66D175BA} = {830B1FC8-40EF-46CD-B611-1FDDA3183B6B} + {E703B059-36F3-4EBF-8F86-32561BC47DCB} = {830B1FC8-40EF-46CD-B611-1FDDA3183B6B} + {51D3305B-48D0-4D4C-9D64-727185420EAC} = {830B1FC8-40EF-46CD-B611-1FDDA3183B6B} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {68E0ACB2-58D0-4316-81B8-8106CA8BDC8D} + EndGlobalSection +EndGlobal diff --git a/Options/AutoRunOptions.cs b/Options/AutoRunOptions.cs new file mode 100644 index 0000000..4c0520b --- /dev/null +++ b/Options/AutoRunOptions.cs @@ -0,0 +1,164 @@ +using Frosty.Core; +using Frosty.Core.Controls; +using FrostySdk.Attributes; +using System; +using System.IO; + +namespace AutoRunPlugin.Options +{ + [DisplayName("Auto Run Options")] + public class AutoRunOptions : OptionsExtension + { + [Category("_General")] + [Description("Main switch, enable to allow all others options\r\nWhen this option is turned off, all auto run options are disabled. However, it may not appear to be disabled in the Config window. That's just a display bug.")] + [DisplayName("Enable Auto Run")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + public bool AutoRunEnabled { get; set; } = false; + + [Category("Frosty Directory")] + [Description("Enables auto run for Frosty directory\r\nThis will create AutoRun folder in Frosty directory")] + [DisplayName("Enable Auto Run")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("AutoRunEnabled")] + public bool FrostyDir_AutoRunEnabled { get; set; } = false; + + [Category("Frosty Directory")] + [Description("Auto run pre launch files for Frosty directory\r\nThis will create AutoRun\\PreLaunch folder in Frosty directory")] + [DisplayName("Enable Pre Launch")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("FrostyDir_AutoRunEnabled")] + public bool FrostyDir_PreLaunchEnabled { get; set; } = false; + + [Category("Frosty Directory")] + [Description("Auto run post launch files for Frosty directory\r\nThis will create AutoRun\\PostLaunch folder in Frosty directory")] + [DisplayName("Enable Post Launch")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("FrostyDir_AutoRunEnabled")] + public bool FrostyDir_PostLaunchEnabled { get; set; } = false; + + [Category("Game Directory")] + [Description("Enables auto run for Game directory\r\nThis will create AutoRun folder in Game directory")] + [DisplayName("Enable Auto Run")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("AutoRunEnabled")] + public bool GameDir_AutoRunEnabled { get; set; } = false; + + [Category("Game Directory")] + [Description("Auto run pre launch files for Game directory\r\nThis will create AutoRun\\PreLaunch folder in Game directory")] + [DisplayName("Enable Pre Launch")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("GameDir_AutoRunEnabled")] + public bool GameDir_PreLaunchEnabled { get; set; } = false; + + [Category("Game Directory")] + [Description("Auto run post launch files for Game directory\r\nThis will create AutoRun\\PostLaunch folder in Game directory")] + [DisplayName("Enable Post Launch")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("GameDir_AutoRunEnabled")] + public bool GameDir_PostLaunchEnabled { get; set; } = false; + + [Category("Pack Directory")] + [Description("Warning: Experimental feature\r\nEnables auto run for Pack directory\r\nThis will create ModData\\\\AutoRun folder in Game directory")] + [DisplayName("Enable Auto Run")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("AutoRunEnabled")] + public bool PackDir_AutoRunEnabled { get; set; } = false; + + [Category("Pack Directory")] + [Description("Warning: Experimental feature\r\nAuto run pre launch files for Pack directory\r\nThis will create ModData\\\\AutoRun\\PreLaunch folder in Game directory")] + [DisplayName("Enable Pre Launch")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("PackDir_AutoRunEnabled")] + public bool PackDir_PreLaunchEnabled { get; set; } = false; + + [Category("Pack Directory")] + [Description("Warning: Experimental feature\r\nAuto run post launch files for Pack directory\r\nThis will create ModData\\\\AutoRun\\PostLaunch folder in Game directory")] + [DisplayName("Enable Post Launch")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + [DependsOn("PackDir_AutoRunEnabled")] + public bool PackDir_PostLaunchEnabled { get; set; } = false; + + [Category("Debug")] + [Description("When launching, print all found file paths to log")] + [DisplayName("Log All Files")] + [EbxFieldMeta(FrostySdk.IO.EbxFieldType.Boolean)] + public bool Debug_LogAllFiles { get; set; } = false; + + public override void Load() + { + AutoRunEnabled = Config.Get("AutoRun_Enabled", false, ConfigScope.Global); + FrostyDir_AutoRunEnabled = Config.Get("AutoRun_FrostyDir_AutoRunEnabled", false, ConfigScope.Global); + FrostyDir_PreLaunchEnabled = Config.Get("AutoRun_FrostyDir_PreLaunchEnabled", false, ConfigScope.Global); + FrostyDir_PostLaunchEnabled = Config.Get("AutoRun_FrostyDir_PostLaunchEnabled", false, ConfigScope.Global); + GameDir_AutoRunEnabled = Config.Get("AutoRun_GameDir_AutoRunEnabled", false, ConfigScope.Game); + GameDir_PreLaunchEnabled = Config.Get("AutoRun_GameDir_PreLaunchEnabled", false, ConfigScope.Game); + GameDir_PostLaunchEnabled = Config.Get("AutoRun_GameDir_PostLaunchEnabled", false, ConfigScope.Game); + PackDir_AutoRunEnabled = Config.Get("AutoRun_PackDir_AutoRunEnabled", false, ConfigScope.Pack); + PackDir_PreLaunchEnabled = Config.Get("AutoRun_PackDir_PreLaunchEnabled", false, ConfigScope.Pack); + PackDir_PostLaunchEnabled = Config.Get("AutoRun_PackDir_PostLaunchEnabled", false, ConfigScope.Pack); + + Debug_LogAllFiles = Config.Get("AutoRun_Debug_LogAllFiles", false, ConfigScope.Global); + } + + public override void Save() + { + Config.Add("AutoRun_Enabled", AutoRunEnabled, ConfigScope.Global); + Config.Add("AutoRun_FrostyDir_AutoRunEnabled", FrostyDir_AutoRunEnabled, ConfigScope.Global); + Config.Add("AutoRun_FrostyDir_PreLaunchEnabled", FrostyDir_PreLaunchEnabled, ConfigScope.Global); + Config.Add("AutoRun_FrostyDir_PostLaunchEnabled", FrostyDir_PostLaunchEnabled, ConfigScope.Global); + Config.Add("AutoRun_GameDir_AutoRunEnabled", GameDir_AutoRunEnabled, ConfigScope.Game); + Config.Add("AutoRun_GameDir_PreLaunchEnabled", GameDir_PreLaunchEnabled, ConfigScope.Game); + Config.Add("AutoRun_GameDir_PostLaunchEnabled", GameDir_PostLaunchEnabled, ConfigScope.Game); + try + { + Config.Add("AutoRun_PackDir_AutoRunEnabled", PackDir_AutoRunEnabled, ConfigScope.Pack); + Config.Add("AutoRun_PackDir_PreLaunchEnabled", PackDir_PreLaunchEnabled, ConfigScope.Pack); + Config.Add("AutoRun_PackDir_PostLaunchEnabled", PackDir_PostLaunchEnabled, ConfigScope.Pack); + } + catch {} + + Config.Add("AutoRun_Debug_LogAllFiles", Debug_LogAllFiles, ConfigScope.Global); + + try + { + if (AutoRunEnabled is true) + { + if (FrostyDir_AutoRunEnabled is true) + Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\AutoRun"); + if (FrostyDir_PreLaunchEnabled is true) + Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\AutoRun\\PreLaunch"); + if (FrostyDir_PostLaunchEnabled is true) + Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\AutoRun\\PostLaunch"); + + if (GameDir_AutoRunEnabled is true) + Directory.CreateDirectory(App.FileSystem.BasePath + "AutoRun"); + if (GameDir_PreLaunchEnabled is true) + Directory.CreateDirectory(App.FileSystem.BasePath + "AutoRun\\PreLaunch"); + if (GameDir_PostLaunchEnabled is true) + Directory.CreateDirectory(App.FileSystem.BasePath + "AutoRun\\PostLaunch"); + } + } + catch (Exception e) + { + FrostyExceptionBox.Show(e, "Auto Run Plugin"); + } + + try + { + if (AutoRunEnabled is true && String.IsNullOrEmpty(App.SelectedPack) is false) + { + if (PackDir_AutoRunEnabled is true) + Directory.CreateDirectory(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun"); + if (PackDir_PreLaunchEnabled is true) + Directory.CreateDirectory(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun\\PreLaunch"); + if (PackDir_PostLaunchEnabled is true) + Directory.CreateDirectory(App.FileSystem.BasePath + "\\ModData\\" + App.SelectedPack + "\\AutoRun\\PostLaunch"); + } + } + catch (Exception e) + { + FrostyExceptionBox.Show(e, "Auto Run Plugin"); + } + } + } +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..65c5818 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using AutoRunPlugin.Execution; +using AutoRunPlugin.Options; +using Frosty.Core.Attributes; +using System.Runtime.InteropServices; +using System.Windows; + +// 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)] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c81af64d-2715-0020-0638-75ab8fdb2e99")] + +[assembly: PluginDisplayName("Auto Run")] +[assembly: PluginAuthor("shoushou1106")] +[assembly: PluginVersion("1.0.0.0")] + +[assembly: RegisterOptionsExtension(typeof(AutoRunOptions), Frosty.Core.PluginManagerType.Both)] +[assembly: RegisterExecutionAction(typeof(AutoRunExecutionAction))]