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 d2cc397c69 - Show all commits

View File

@ -17,7 +17,7 @@ namespace OWTrack
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
loadSave(); loadSave();
checkStatus(); checkStatus();
update(); update();
@ -47,80 +47,59 @@ namespace OWTrack
private void loadSave() private void loadSave()
{ {
Directory.CreateDirectory("saves"); Directory.CreateDirectory("saves");
if (saveExist()) if (saveManeger.saveExist())
{ {
tr.wins = savedTracker().wins; try
tr.losses = savedTracker().losses; {
tr.newSR = savedTracker().newSR;
tr.startSR = savedTracker().startSR;
tr.gamePath = savedTracker().gamePath;
update();
}
}
private bool saveExist()
{
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"))
{ {
st.Close(); tr = saveManeger.GetSavedTracker();
return true; st.Close();
} }
else else
{ {
if (!tr.LoacteOW()) if (!tr.LoacteOW())
{ {
st.Close();
tr.gamePath = getGamePath(); tr.gamePath = getGamePath();
} }
return true; st.Close();
} }
}
}
else
{
if (!tr.LoacteOW())
{
tr.gamePath = getGamePath();
}
return false;
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
update();
}
else if (!tr.LoacteOW())
{
tr.gamePath = getGamePath();
}
}
private string getGamePath() private string getGamePath()
{ {
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;
// }
//}
} }
} }