Skip to content

Commit

Permalink
Added a fix for the null Steam path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
John committed Apr 9, 2020
1 parent cc25706 commit a65ccaf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
16 changes: 10 additions & 6 deletions DoomEternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DoomEternal
public const string GameName = "Doom Eternal";

public const int SteamGameID = 782330;
public static string SteamSavePath = Path.Combine(Utilities.GetSteamPath(), "userdata");
public static string SteamSavePath = "";
public static string BnetSavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Saved Games", "id Software", "DOOMEternal", "base", "savegame");

public static DoomEternalSavePathCollection Saves;
Expand All @@ -30,11 +30,15 @@ public static void EnumerateSaves() {
}
}

if (Directory.Exists(SteamSavePath)) {
foreach (var steamId3 in Directory.GetDirectories(SteamSavePath, "*.*", SearchOption.TopDirectoryOnly)) {
foreach (var single in Directory.GetDirectories(steamId3, "*.*", SearchOption.TopDirectoryOnly)) {
if (Path.GetFileNameWithoutExtension(single) == SteamGameID.ToString())
Saves.Add(new DoomEternalSavePath(Utilities.Id3ToId64(Path.GetFileNameWithoutExtension(steamId3)), DoomEternalSavePlatform.Steam));
string steamPath = Utilities.GetSteamPath();
if (!string.IsNullOrEmpty(steamPath)) {
SteamSavePath = Path.Combine(steamPath, "userdata");
if (Directory.Exists(SteamSavePath)) {
foreach (var steamId3 in Directory.GetDirectories(SteamSavePath, "*.*", SearchOption.TopDirectoryOnly)) {
foreach (var single in Directory.GetDirectories(steamId3, "*.*", SearchOption.TopDirectoryOnly)) {
if (Path.GetFileNameWithoutExtension(single) == SteamGameID.ToString())
Saves.Add(new DoomEternalSavePath(Utilities.Id3ToId64(Path.GetFileNameWithoutExtension(steamId3)), DoomEternalSavePlatform.Steam));
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions DoomEternalSavePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public DoomEternalSavePath(string id, DoomEternalSavePlatform platform, bool enc

public bool Exists() => Directory.Exists(FullPath);

public void Zip(string filename) {
public void Compress(string filename) {
using (var fsOut = File.Create(filename))
using (var zs = new ZipOutputStream(fsOut)) {
zs.SetLevel(3);
Expand Down Expand Up @@ -74,7 +74,7 @@ public void Zip(string filename) {
}
}

public void Extract(string filename) {
public void Decompress(string filename) {
using (Stream fsIn = File.OpenRead(filename))
using (var zf = new ZipFile(fsIn)) {

Expand Down
4 changes: 2 additions & 2 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void actionOkBtn_Click(object sender, EventArgs e) {
if (ofd.ShowDialog() == DialogResult.OK) {
var suf = new SelectForm("Select Import Destination");
if (suf.ShowDialog() == DialogResult.OK) {
suf.SelectedSave.Extract(ofd.FileName);
suf.SelectedSave.Decompress(ofd.FileName);
MessageBox.Show("Import success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Expand All @@ -49,7 +49,7 @@ private void actionOkBtn_Click(object sender, EventArgs e) {
sfd.FilterIndex = 0;
sfd.FileName = "backup.zip";
if (sfd.ShowDialog() == DialogResult.OK) {
suf.SelectedSave.Zip(sfd.FileName);
suf.SelectedSave.Compress(sfd.FileName);
MessageBox.Show("Export success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.4")]
[assembly: AssemblyFileVersion("1.3.0.4")]
[assembly: AssemblyVersion("1.3.0.5")]
[assembly: AssemblyFileVersion("1.3.0.5")]

0 comments on commit a65ccaf

Please sign in to comment.