Skip to content

Commit

Permalink
Simplify path settings
Browse files Browse the repository at this point in the history
  • Loading branch information
DarwinBaker committed Feb 18, 2022
1 parent 9d41df1 commit 7bd06dd
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 57 deletions.
1 change: 0 additions & 1 deletion AATool/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public enum TrackerSource
{
ActiveInstance,
DefaultAppData,
CustomSavesPath,
SpecificWorld,
}
Expand Down
4 changes: 1 addition & 3 deletions AATool/Exceptions/NoSavesFolderException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ private static string GetMessage()
: "Active instance missing saves folder";
}

return Config.Tracking.Source == TrackerSource.DefaultAppData
? "Default .minecraft saves folder doesn't exist"
: "Custom saves path doesn't exist";
return "Custom saves path doesn't exist";
}
}
}
5 changes: 1 addition & 4 deletions AATool/Exceptions/NoWorldException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ private static string GetMessage()
return $"Specified world invalid";
}
}

return Config.Tracking.Source == TrackerSource.DefaultAppData
? "No worlds in default .minecraft path"
: "No worlds in custom save path";
return "No worlds in custom save path";
}
}
}
9 changes: 3 additions & 6 deletions AATool/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ public static string CurrentFolder()
}
else
{
return Config.Tracking.Source.Value switch {
TrackerSource.ActiveInstance => ActiveInstance.SavesPath,
TrackerSource.DefaultAppData => DefaultAppDataSavesPath,
TrackerSource.CustomSavesPath => Config.Tracking.CustomSavesPath,
_ => string.Empty,
};
return Tracker.Source is TrackerSource.CustomSavesPath
? Config.Tracking.CustomSavesPath
: ActiveInstance.SavesPath;
}
}

Expand Down
91 changes: 52 additions & 39 deletions AATool/Winforms/Controls/CTrackerSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions AATool/Winforms/Controls/CTrackerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void LoadSettings()
this.worldLocal.Checked = !Config.Tracking.UseSftp;

this.trackActiveInstance.Checked = Tracker.Source is TrackerSource.ActiveInstance;
this.trackDefaultSaves.Checked = Tracker.Source is TrackerSource.DefaultAppData;
this.trackCustomSavesFolder.Checked = Tracker.Source is TrackerSource.CustomSavesPath;
this.TrackSpecificWorld.Checked = Tracker.Source is TrackerSource.SpecificWorld;

Expand Down Expand Up @@ -58,8 +57,6 @@ private void SaveSettings()
{
if (this.trackActiveInstance.Checked)
Config.Tracking.Source.Set(TrackerSource.ActiveInstance);
else if (this.trackDefaultSaves.Checked)
Config.Tracking.Source.Set(TrackerSource.DefaultAppData);
else if (this.trackCustomSavesFolder.Checked)
Config.Tracking.Source.Set(TrackerSource.CustomSavesPath);
else if (this.TrackSpecificWorld.Checked)
Expand All @@ -68,7 +65,13 @@ private void SaveSettings()
Config.Tracking.CustomSavesPath.Set(this.customSavesPath.Text);
Config.Tracking.CustomWorldPath.Set(this.customWorldPath.Text);

Config.Tracking.Source.Set(this.trackDefaultSaves.Checked);
TrackerSource source = this.trackActiveInstance.Checked
? TrackerSource.ActiveInstance
: this.trackCustomSavesFolder.Checked
? TrackerSource.CustomSavesPath
: TrackerSource.SpecificWorld;
Config.Tracking.Source.Set(source);

Config.Tracking.UseSftp.Set(this.worldRemote.Checked);
Config.Tracking.AutoDetectVersion.Set(this.autoVersion.Checked);
Config.Tracking.BroadcastProgress.Set(this.enableOpenTracker.Checked);
Expand Down

0 comments on commit 7bd06dd

Please sign in to comment.