diff --git a/RotationSolver.Basic/Actions/BaseAction_Target.cs b/RotationSolver.Basic/Actions/BaseAction_Target.cs index 6ec28dc6c..38b2ea029 100644 --- a/RotationSolver.Basic/Actions/BaseAction_Target.cs +++ b/RotationSolver.Basic/Actions/BaseAction_Target.cs @@ -300,7 +300,8 @@ private bool TargetHostileManual(BattleChara b, bool mustUse, int aoeCount, out return true; } - if (Service.Config.UseAOEAction && Service.Config.UseAOEWhenManual || mustUse) + if (Service.Config.GetValue(SettingsCommand.UseAOEAction) + && Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) || mustUse) { if (GetMostObjects(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), aoeCount).Contains(b)) { @@ -324,7 +325,7 @@ private bool TargetSelf(bool mustUse, int aoeCount) //如果不用自动找目标,那就不打AOE if (DataCenter.StateType == StateCommandType.Manual) { - if (!Service.Config.UseAOEWhenManual && !mustUse) return false; + if (!Service.Config.GetValue(SettingsCommand.UseAOEWhenManual) && !mustUse) return false; } var tars = TargetFilter.GetObjectInRadius(TargetFilterFuncEot(DataCenter.HostileTargets, mustUse), _action.EffectRange); @@ -490,7 +491,7 @@ private static bool NoAOE { get { - if (!Service.Config.UseAOEAction) return true; + if (!Service.Config.GetValue(SettingsCommand.UseAOEAction)) return true; return Service.Config.ChooseAttackMark && !Service.Config.CanAttackMarkAOE diff --git a/RotationSolver/RotationHelper.cs b/RotationSolver/RotationHelper.cs index d30228f61..113559f90 100644 --- a/RotationSolver/RotationHelper.cs +++ b/RotationSolver/RotationHelper.cs @@ -1,13 +1,79 @@ using Dalamud.Interface.Colors; using Dalamud.Logging; +using Dalamud.Plugin; +using FFXIVClientStructs.Interop; +using Lumina.Excel; using RotationSolver.Updaters; using System.Diagnostics; +using System.Runtime.Loader; using System.Text; namespace RotationSolver; internal static class RotationHelper { + private class RotationLoadContext : AssemblyLoadContext + { + DirectoryInfo _directory; + + + + static Dictionary _handledAssemblies; + public RotationLoadContext(DirectoryInfo directoryInfo) : base(true) + { + _directory = directoryInfo; + } + + static RotationLoadContext() + { + _handledAssemblies = new Dictionary() + { + ["RotationSolver"] = typeof(RotationSolverPlugin).Assembly, + ["FFXIVClientStructs"] = typeof(Resolver).Assembly, + ["Dalamud"] = typeof(DalamudPluginInterface).Assembly, + ["RotationSolver.Basic"] = typeof(DataCenter).Assembly, + ["Lumina"] = typeof(SheetAttribute).Assembly, + ["Lumina.Excel"] = typeof(ExcelRow).Assembly, + }; + } + + protected override Assembly Load(AssemblyName assemblyName) + { + if (assemblyName.Name != null && _handledAssemblies.ContainsKey(assemblyName.Name)) + { + return _handledAssemblies[assemblyName.Name]; + } + + var file = Path.Join(_directory.FullName, $"{assemblyName.Name}.dll"); + if (File.Exists(file)) + { + try + { + return LoadFromFile(file); + } + catch + { + // + } + } + return base.Load(assemblyName); + } + + internal Assembly LoadFromFile(string filePath) + { + using var file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); + var pdbPath = Path.ChangeExtension(filePath, ".pdb"); + if (!File.Exists(pdbPath)) return LoadFromStream(file); + using var pdbFile = File.Open(pdbPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var assembly = LoadFromStream(file, pdbFile); + return assembly; + } + + + } + + public static Dictionary AssemblyPaths = new Dictionary(); + public static string[] AllowedAssembly { get; private set; } = new string[0]; static readonly SortedList _authors = new SortedList(); public static async void LoadList() @@ -53,7 +119,7 @@ public static string GetAuthor(this Assembly assembly) { var name = assembly.GetName().Name; return _authors[assembly] = - (RotationLoadContext.AssemblyPaths.TryGetValue(name, out var path) + (AssemblyPaths.TryGetValue(name, out var path) ? FileVersionInfo.GetVersionInfo(path)?.CompanyName : name) ?? name ?? "Unknown"; } @@ -62,4 +128,12 @@ public static string GetAuthor(this Assembly assembly) return "Unknown"; } } + + public static Assembly LoadFrom(string filePath) + { + var loadContext = new RotationLoadContext(new FileInfo(filePath).Directory); + var assembly = loadContext.LoadFromFile(filePath); + AssemblyPaths[assembly.GetName().Name] = filePath; + return assembly; + } } diff --git a/RotationSolver/RotationLoadContext.cs b/RotationSolver/RotationLoadContext.cs deleted file mode 100644 index 196c37e53..000000000 --- a/RotationSolver/RotationLoadContext.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Dalamud.Plugin; -using FFXIVClientStructs.Interop; -using Lumina.Excel; -using System.Reflection; -using System.Runtime.Loader; - -namespace RotationSolver; - -public class RotationLoadContext : AssemblyLoadContext -{ - DirectoryInfo _directory; - - public static Dictionary AssemblyPaths = new Dictionary(); - - static Dictionary _handledAssemblies; - public RotationLoadContext(DirectoryInfo directoryInfo) : base(true) - { - _directory = directoryInfo; - } - - static RotationLoadContext() - { - _handledAssemblies = new Dictionary() - { - ["RotationSolver"] = typeof(RotationSolverPlugin).Assembly, - ["FFXIVClientStructs"] = typeof(Resolver).Assembly, - ["Dalamud"] = typeof(DalamudPluginInterface).Assembly, - ["RotationSolver.Basic"] = typeof(DataCenter).Assembly, - ["Lumina"] = typeof(SheetAttribute).Assembly, - ["Lumina.Excel"] = typeof(ExcelRow).Assembly, - }; - } - - protected override Assembly Load(AssemblyName assemblyName) - { - if (assemblyName.Name != null && _handledAssemblies.ContainsKey(assemblyName.Name)) - { - return _handledAssemblies[assemblyName.Name]; - } - - var file = Path.Join(_directory.FullName, $"{assemblyName.Name}.dll"); - if (File.Exists(file)) - { - try - { - return LoadFromFile(file); - } - catch - { - // - } - } - return base.Load(assemblyName); - } - - private Assembly LoadFromFile(string filePath) - { - using var file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); - var pdbPath = Path.ChangeExtension(filePath, ".pdb"); - if (!File.Exists(pdbPath)) return LoadFromStream(file); - using var pdbFile = File.Open(pdbPath, FileMode.Open, FileAccess.Read, FileShare.Read); - var assembly = LoadFromStream(file, pdbFile); - return assembly; - } - - public static Assembly LoadFrom(string filePath) - { - var loadContext = new RotationLoadContext(new FileInfo(filePath).Directory); - var assembly = loadContext.LoadFromFile(filePath); - AssemblyPaths[assembly.GetName().Name] = filePath; - return assembly; - } -} diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index 5528d083c..df4f763f1 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -394,7 +394,7 @@ private void DrawParamTarget() DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ChooseAttackMark, ref Service.Config.ChooseAttackMark, Service.Default.ChooseAttackMark); - if (Service.Config.ChooseAttackMark && Service.Config.UseAOEAction) + if (Service.Config.ChooseAttackMark && Service.Config.GetValue(SettingsCommand.UseAOEAction)) { ImGui.Indent(); diff --git a/RotationSolver/UI/RotationConfigWindow_RotationDev.cs b/RotationSolver/UI/RotationConfigWindow_RotationDev.cs index 379254470..78680b164 100644 --- a/RotationSolver/UI/RotationConfigWindow_RotationDev.cs +++ b/RotationSolver/UI/RotationConfigWindow_RotationDev.cs @@ -99,7 +99,7 @@ private void DrawAssemblyInfos() ImGui.TableNextRow(); if (ImGui.Button(assembly.GetName().Name + assembly.GetName().Version)) { - if (!RotationLoadContext.AssemblyPaths.TryGetValue(assembly.GetName().Name, out var path)) + if (!RotationHelper.AssemblyPaths.TryGetValue(assembly.GetName().Name, out var path)) path = assembly.Location; Process.Start("explorer.exe", path); diff --git a/RotationSolver/Updaters/PreviewUpdater.cs b/RotationSolver/Updaters/PreviewUpdater.cs index ef4567136..96330f350 100644 --- a/RotationSolver/Updaters/PreviewUpdater.cs +++ b/RotationSolver/Updaters/PreviewUpdater.cs @@ -119,6 +119,10 @@ internal static unsafe void PulseActionBar(uint actionID) { LoopAllSlotBar((bar, hot, index) => { + //Pulse Check +#if DEBUG + return true; +#endif return IsActionSlotRight(bar, hot, actionID); }); } diff --git a/RotationSolver/Updaters/RotationUpdater.cs b/RotationSolver/Updaters/RotationUpdater.cs index ecab5df5e..80372fa01 100644 --- a/RotationSolver/Updaters/RotationUpdater.cs +++ b/RotationSolver/Updaters/RotationUpdater.cs @@ -97,7 +97,7 @@ private static void LoadRotationsFromLocal(string relayFolder) var assemblies = from dir in directories where Directory.Exists(dir) from l in Directory.GetFiles(dir, "*.dll") - select RotationLoadContext.LoadFrom(l); + select RotationHelper.LoadFrom(l); PluginLog.Log("Try to load rotations from these assemblies.\n" + string.Join('\n', assemblies.Select(a => "- " + a.FullName)));