Skip to content

Commit

Permalink
Remove passing a static string
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePixelGamer committed Mar 15, 2022
1 parent 187d93f commit e32032c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions ZenovaLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void AppStart(object sender, StartupEventArgs e)
SetupEnvironment();
Trace.Listeners.Add(new TextWriterTraceListener(new FileStream(Path.Combine(DataDirectory, "log.txt"), FileMode.Create)));
Trace.AutoFlush = true;
ZenovaUpdater.instance = new ZenovaUpdater(DataDirectory);
ZenovaUpdater.instance = new ZenovaUpdater();
Trace.WriteLine("ZenovaUpdater.instance " + sw.ElapsedMilliseconds + " ms");
VersionDownloader.standard = new VersionDownloader();
Trace.WriteLine("VersionDownloader.standard " + sw.ElapsedMilliseconds + " ms");
Expand All @@ -97,7 +97,7 @@ public void AppStart(object sender, StartupEventArgs e)
Trace.WriteLine("ModManager.LoadMods " + sw.ElapsedMilliseconds + " ms");
ProfileManager.instance.ImportProfiles();
Trace.WriteLine("ProfileManager.ImportProfiles " + sw.ElapsedMilliseconds + " ms");
Preferences.LoadPreferences(DataDirectory);
Preferences.LoadPreferences();
Trace.WriteLine("Preferences.LoadPreferences " + sw.ElapsedMilliseconds + " ms");
VersionManager.instance.RemoveUnusedVersions();
Trace.WriteLine("VersionManager.RemoveUnusedVersions " + sw.ElapsedMilliseconds + " ms");
Expand Down
4 changes: 2 additions & 2 deletions ZenovaLauncher/Utils/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public string SelectedProfile
}


public static void LoadPreferences(string dataDir)
public static void LoadPreferences()
{
Trace.WriteLine("Loading Preferences");
_preferencesFile = Path.Combine(dataDir, _preferencesFile);
_preferencesFile = Path.Combine(App.DataDirectory, _preferencesFile);
jsonSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
if (File.Exists(_preferencesFile))
{
Expand Down
10 changes: 4 additions & 6 deletions ZenovaLauncher/Utils/ZenovaUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class ZenovaUpdater : NotifyPropertyChangedBase
public static AssemblyType InstallerAssembly;
public static AssemblyType ApiAssembly;

private string DataDirectory { get; set; }
private GitHubClient Client { get; set; }
private HttpClient DownloadClient { get; set; }

Expand Down Expand Up @@ -60,9 +59,8 @@ public string DisplayText

public ICommand CancelCommand { get; set; }

public ZenovaUpdater(string dataDirectory)
public ZenovaUpdater()
{
DataDirectory = dataDirectory;
Client = new GitHubClient(new ProductHeaderValue("ZenovaLauncher"));
DownloadClient = new HttpClient();
if (InstallerAssembly == null)
Expand All @@ -87,20 +85,20 @@ public void InitializeAssemblyTypes()
Process.Start(psi);
await App.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)delegate () { App.Current.Shutdown(); });
}, Assembly.GetEntryAssembly().GetName().Version);
ApiAssembly = new AssemblyType("ZenovaAPI", (type, assetNumber) => Path.Combine(DataDirectory, type.LatestRelease.Assets[assetNumber].Name),
ApiAssembly = new AssemblyType("ZenovaAPI", (type, assetNumber) => Path.Combine(App.DataDirectory, type.LatestRelease.Assets[assetNumber].Name),
async (dlPath) =>
{
if (dlPath.EndsWith(".zip"))
{
string devPath = Path.Combine(DataDirectory, "dev");
string devPath = Path.Combine(App.DataDirectory, "dev");
if (Directory.Exists(devPath))
Utils.Empty(devPath);
else
Directory.CreateDirectory(devPath);
await Task.Run(() => { ZipFile.ExtractToDirectory(dlPath, devPath); });
File.Delete(dlPath);
}
}, AssemblyType.GetVersionFromPath(Path.Combine(DataDirectory, "ZenovaAPI.dll")), 2);
}, AssemblyType.GetVersionFromPath(Path.Combine(App.DataDirectory, "ZenovaAPI.dll")), 2);
}
catch (Exception e)
{
Expand Down

0 comments on commit e32032c

Please sign in to comment.