Skip to content

Commit

Permalink
Merge pull request #125 from goatcorp/manual-injection-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Blooym authored Mar 14, 2024
2 parents 0e69121 + c24ee34 commit 731b88d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public override void Draw()
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 100f);
ImGui.PushFont(FontManager.IconFont);

var invalid = this.tabs.Any(x => x.Entries.Any(y => !y.IsValid));
var invalid = this.tabs.Any(x => x.Entries.Any(y => y.IsVisible && !y.IsValid));
if (invalid)
{
ImGui.BeginDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,29 @@ public SettingsTabDalamud()
return;
}
if (Directory.Exists(Program.Config.DalamudManualInjectPath) && Directory.GetFiles(Program.Config.DalamudManualInjectPath).FirstOrDefault(x => x == "Dalamud.Injector.exe") is not null)
if (Program.Config.DalamudManualInjectPath is not null &&
Program.Config.DalamudManualInjectPath.Exists &&
Program.Config.DalamudManualInjectPath.GetFiles().FirstOrDefault(x => x.Name == Program.DALAMUD_INJECTOR_NAME) is not null)
{
Program.DalamudUpdater.RunnerOverride = new FileInfo(Path.Combine(Program.Config.DalamudManualInjectPath, Program.DALAMUD_INJECTOR_NAME));
}
}),
Program.DalamudUpdater.RunnerOverride = new FileInfo(Path.Combine(Program.Config.DalamudManualInjectPath.FullName, Program.DALAMUD_INJECTOR_NAME));
}
}),

new SettingsEntry<string>("Manual Injection Path", "The path to the local version of Dalamud where Dalamud.Injector.exe is located", () => Program.Config.DalamudManualInjectPath, (input) =>
new SettingsEntry<DirectoryInfo>("Manual Injection Path", "The path to the local version of Dalamud where Dalamud.Injector.exe is located", () => Program.Config.DalamudManualInjectPath, (input) =>
{
if (enableManualInjection.Value == false) return;
Program.Config.DalamudManualInjectPath = input;
Program.DalamudUpdater.RunnerOverride = new FileInfo(Path.Combine(input, Program.DALAMUD_INJECTOR_NAME));
Program.DalamudUpdater.RunnerOverride = new FileInfo(Path.Combine(input.FullName, Program.DALAMUD_INJECTOR_NAME));
})
{
CheckVisibility = () => enableManualInjection.Value == true,
CheckVisibility = () => enableManualInjection.Value,
CheckValidity = input =>
{
if (!Directory.Exists(input))
if (input is null || !input.Exists)
{
return "There is no directory at that path.";
}
if (Directory.GetFiles(input).FirstOrDefault(x => x == Program.DALAMUD_INJECTOR_NAME) is not null)
else if (input.GetFiles().FirstOrDefault(x => x.Name == Program.DALAMUD_INJECTOR_NAME) is null)
{
return "Dalamud.Injector.exe was not found inside of the provided directory.";
}
Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher.Core/Configuration/ILauncherConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public interface ILauncherConfig

public DalamudLoadMethod? DalamudLoadMethod { get; set; }
public bool? DalamudManualInjectionEnabled { get; set; }
public string? DalamudManualInjectPath { get; set; }
public DirectoryInfo? DalamudManualInjectPath { get; set; }

public int DalamudLoadDelay { get; set; }

Expand Down
12 changes: 5 additions & 7 deletions src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,16 @@ private static void LoadConfig(Storage storage)
/// <returns>A <see cref="DalamudUpdater"/> instance.</returns>
private static DalamudUpdater CreateDalamudUpdater()
{
if (Config.DalamudManualInjectionEnabled == true &&
Directory.Exists(Config.DalamudManualInjectPath) &&
Directory.GetFiles(Config.DalamudManualInjectPath).FirstOrDefault(f => f == DALAMUD_INJECTOR_NAME) is not null)
if (Config.DalamudManualInjectPath is not null &&
Config.DalamudManualInjectPath.Exists &&
Config.DalamudManualInjectPath.GetFiles().FirstOrDefault(x => x.Name == DALAMUD_INJECTOR_NAME) is not null)
{
var updater = new DalamudUpdater(new DirectoryInfo(Config.DalamudManualInjectPath), storage.GetFolder("runtime"), storage.GetFolder("dalamudAssets"), storage.Root, null, null)
return new DalamudUpdater(Config.DalamudManualInjectPath, storage.GetFolder("runtime"), storage.GetFolder("dalamudAssets"), storage.Root, null, null)
{
Overlay = DalamudLoadInfo,
RunnerOverride = new FileInfo(Path.Combine(Config.DalamudManualInjectPath.FullName, DALAMUD_INJECTOR_NAME))
};
DalamudUpdater.RunnerOverride = new FileInfo(Path.Combine(Config.DalamudManualInjectPath, DALAMUD_INJECTOR_NAME));
return updater;
}

return new DalamudUpdater(storage.GetFolder("dalamud"), storage.GetFolder("runtime"), storage.GetFolder("dalamudAssets"), storage.Root, null, null)
{
Overlay = DalamudLoadInfo,
Expand Down

0 comments on commit 731b88d

Please sign in to comment.