Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving when hidden config option is invalid + Local dalamud fixes #125

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading