1.4.0a2 Merge #23

Merged
Hesham merged 16 commits from release/1.4 into master 2018-09-20 10:35:46 +02:00
4 changed files with 49 additions and 90 deletions
Showing only changes of commit 500f9c5852 - Show all commits

View File

@ -47,41 +47,17 @@ namespace OWTrack
private void loadSave() private void loadSave()
{ {
Directory.CreateDirectory("saves"); Directory.CreateDirectory("saves");
if (saveExist()) if (saveManeger.saveExist())
{
tr.wins = savedTracker().wins;
tr.losses = savedTracker().losses;
tr.newSR = savedTracker().newSR;
tr.startSR = savedTracker().startSR;
tr.gamePath = savedTracker().gamePath;
update();
}
}
private bool saveExist()
{ {
try try
{
if (File.Exists(savesPath))
{ {
using (StreamReader st = new StreamReader(savesPath)) using (StreamReader st = new StreamReader(savesPath))
{ {
string line = st.ReadLine(); string line = st.ReadLine();
if (line.Contains("Overwatch.exe")) if (line.Contains("Overwatch.exe"))
{ {
tr = saveManeger.GetSavedTracker();
st.Close(); st.Close();
return true;
}
else
{
if (!tr.LoacteOW())
{
st.Close();
tr.gamePath = getGamePath();
}
return true;
}
}
} }
else else
{ {
@ -89,13 +65,20 @@ namespace OWTrack
{ {
tr.gamePath = getGamePath(); tr.gamePath = getGamePath();
} }
return false; st.Close();
}
} }
} }
catch (Exception e) catch (Exception e)
{ {
MessageBox.Show(e.Message); MessageBox.Show(e.Message);
return false; }
update();
}
else if (!tr.LoacteOW())
{
tr.gamePath = getGamePath();
} }
} }
@ -104,23 +87,19 @@ namespace OWTrack
openFileDialog1.Title = "Select Overwatch.exe"; openFileDialog1.Title = "Select Overwatch.exe";
openFileDialog1.DefaultExt = "exe"; openFileDialog1.DefaultExt = "exe";
openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*";
//openFileDialog1.CheckFileExists = true;
//openFileDialog1.CheckPathExists = true;
DialogResult result = openFileDialog1.ShowDialog(); DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK) if (result == DialogResult.OK)
{ {
//tr.gamePath = openFileDialog1.FileName; //tr.gamePath = openFileDialog1.FileName;
MessageBox.Show("Saved Overwatch.exe location.\nPress Clear to rest\n" + openFileDialog1.FileName );
return openFileDialog1.FileName; return openFileDialog1.FileName;
} }
else else
{ {
update();
return null; return null;
//Close();
} }
//Show();
//update();
} }
private Tracker savedTracker() private Tracker savedTracker()

View File

@ -18,7 +18,7 @@ namespace OWTrack
Application.Run(new MainForm()); Application.Run(new MainForm());
} }
public static string Version { get; } = "1.4.0a1"; public static string Version { get; } = "1.4.0a2";
//public static string Version = Application.ProductVersion; //public static string Version = Application.ProductVersion;
//public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

View File

@ -13,7 +13,7 @@ namespace OWTrack
public string gamePath; public string gamePath;
public void Track() { } public void Track() { }
public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; gamePath = null; }
public void addWin() { wins++; } public void addWin() { wins++; }
public void addLoss() { losses++; } public void addLoss() { losses++; }
public void reduceWin() { wins--; } public void reduceWin() { wins--; }

View File

@ -10,11 +10,13 @@ namespace OWTrack
{ {
class saveManeger class saveManeger
{ {
private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json";
public static Tracker GetSavedTracker() public static Tracker GetSavedTracker()
{ {
try try
{ {
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(savesPath));
} }
catch (Exception e) catch (Exception e)
{ {
@ -48,45 +50,23 @@ namespace OWTrack
} }
} }
//private bool saveExist() public static bool saveExist()
//{ {
// try try
// { {
// if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) if (File.Exists(savesPath))
// { {
// using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) return true;
// { }
// string line = st.ReadLine(); else
// if (line.Contains("Overwatch.exe")) {
// { return false;
// st.Close(); }
// return true; }
// } catch (Exception e)
// else {
// { throw e;
// if (!tr.LoacteOW()) }
// { }
// st.Close();
// getGamePath();
// }
// return true;
// }
// }
// }
// else
// {
// if (!tr.LoacteOW())
// {
// getGamePath();
// }
// return false;
// }
// }
// catch (Exception e)
// {
// MessageBox.Show(e.Message);
// return false;
// }
//}
} }
} }