diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs
index 078b25e..61466f3 100644
--- a/OWTrack/MainForm.cs
+++ b/OWTrack/MainForm.cs
@@ -31,21 +31,21 @@ namespace OWTrack
private const string IS_RUNNING = "Running";
private const string NOT_RUNNING = " Not running";
private bool SRonce = false;
- int dummy = 0;
+ private string Version = Program.Version.ToString();
public MainForm()
- {
+ {
InitializeComponent();
- tr = new Tracker();
+ tr = new Tracker();
loadSave();
checkStatus();
update();
- label4.Text = Program.Version.ToString();
- Text = "OWTrack " + Program.Version.ToString();
+ label4.Text = Version;
+ Text = "OWTrack " + Version;
}
-
+
private void checkStatus()
- {
+ {
Time.Text = DateTime.Now.ToString("h:mm tt");
try
{
@@ -56,7 +56,7 @@ namespace OWTrack
}
else
{
- if (tr.TrackOW)
+ if (tr.settings.TrackOW)
{
status.Text = NOT_RUNNING;
status.ForeColor = Color.Black;
@@ -71,6 +71,7 @@ namespace OWTrack
}
}
+ //Move to saveManeger.cs ?
private void loadSave()
{
try
@@ -84,64 +85,62 @@ namespace OWTrack
if (saveManeger.saveExist())
{
try
- {
- using (StreamReader st = new StreamReader(Paths.GetSaves()))
+ {
+ try
{
- string line = st.ReadLine();
- if (line.Contains("Overwatch.exe"))
- {
- tr = saveManeger.GetSavedTracker();
- if (tr.startSR > 0) SRonce = true;
- }
- else
- {
- if (!tr.LoacteOW())
- {
- tr.gamePath = getGamePath();
- }
- }
- st.Close();
+ tr = saveManeger.GetSavedTracker();
}
- }
+ catch (Exception)
+ {
+ MessageBox.Show("Could not load Save.\n" +
+ "Starting new save.");
+ tr = new Tracker();
+ }
+ if (tr.startSR > 0) SRonce = true;
+ if (tr.settings.GamePath == "" || tr.settings.GamePath == null)
+ {
+ if (!tr.LoacteOW())
+ {
+ tr.settings.GamePath = askForGamePath();
+ }
+ }
+ }
catch (Exception e)
{
MessageBox.Show(e.Message);
- }
+ }
}
else if (!tr.LoacteOW())
{
- tr.gamePath = getGamePath();
+ tr.settings.GamePath = askForGamePath();
}
- ExeTrackCheckBx.Checked = tr.TrackOW;
- SRCheckBx.Checked = tr.TrackSR;
- update();
+ ExeTrackCheckBx.Checked = tr.settings.TrackOW;
+ SRCheckBx.Checked = tr.settings.TrackSR;
+ tr.StartNewSeission();
}
- private string getGamePath()
+ private string askForGamePath()
{
openFileDialog1.Title = "Select Overwatch.exe";
openFileDialog1.DefaultExt = "exe";
- openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*";
+ openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*";
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
MessageBox.Show("Saved Overwatch.exe location.\nPress Clear to rest");
return openFileDialog1.FileName;
}
- else return null;
- }
+ else return null;
+ }
private void SRSystem(bool state)
{
srBut.Enabled = state;
srTextBox.Enabled = state;
- tr.TrackSR = state;
+ tr.settings.TrackSR = state;
}
- private void OWTrackFunc(bool state)
- {
- tr.TrackOW = state;
- }
+ private void OWTrackFunc(bool state) => tr.settings.TrackOW = state;
private void update()
{
@@ -155,7 +154,19 @@ namespace OWTrack
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
srTextBox.Text = null;
saveManeger.SaveJSON(tr);
- }
+ }
+
+ private void AddMatch()
+ {
+ Match match = new Match
+ {
+ StartSR = tr.startSR,
+ newSR = tr.newSR,
+ ChangeInSR = tr.srDiff(),
+ dateTime = DateTime.Now.Date
+ };
+ tr.GetCurrentSession().AddMatch(match);
+ }
#region Events
private void timer1_Tick(object sender, EventArgs e) => checkStatus();
@@ -188,13 +199,13 @@ namespace OWTrack
tr.rediceLoss();
update();
}
- }
+ }
private void clearBut_Click(object sender, EventArgs e)
{
tr.reset();
update();
- }
+ }
private void srBut_Click(object sender, EventArgs e)
{
@@ -222,6 +233,7 @@ namespace OWTrack
}
else tr.newSR = sr;
}
+ AddMatch();
update();
}
@@ -239,14 +251,14 @@ namespace OWTrack
private void ChngOWPathBtn_Click(object sender, EventArgs e)
{
- tr.gamePath = getGamePath();
+ tr.settings.GamePath = askForGamePath();
update();
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
notifyIcon1.Icon = null;
- notifyIcon1.Dispose();
+ notifyIcon1.Dispose();
}
#endregion
}
diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj
index 9a402fc..a6997e9 100644
--- a/OWTrack/OWTrack.csproj
+++ b/OWTrack/OWTrack.csproj
@@ -113,12 +113,6 @@
MainForm.cs
-
- Form
-
-
- Splash.cs
-
@@ -134,9 +128,6 @@
True
Resources.resx
-
- Splash.cs
-
diff --git a/OWTrack/Splash.Designer.cs b/OWTrack/Splash.Designer.cs
deleted file mode 100644
index ca13c55..0000000
--- a/OWTrack/Splash.Designer.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-namespace OWTrack
-{
- partial class Splash
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
- this.progressBar1 = new System.Windows.Forms.ProgressBar();
- this.splashLabel = new System.Windows.Forms.Label();
- this.versionLabel = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // progressBar1
- //
- this.progressBar1.Location = new System.Drawing.Point(95, 57);
- this.progressBar1.Name = "progressBar1";
- this.progressBar1.Size = new System.Drawing.Size(196, 12);
- this.progressBar1.TabIndex = 0;
- //
- // splashLabel
- //
- this.splashLabel.AutoSize = true;
- this.splashLabel.Location = new System.Drawing.Point(171, 31);
- this.splashLabel.Name = "splashLabel";
- this.splashLabel.Size = new System.Drawing.Size(0, 13);
- this.splashLabel.TabIndex = 1;
- this.splashLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- //
- // versionLabel
- //
- this.versionLabel.AutoSize = true;
- this.versionLabel.Location = new System.Drawing.Point(13, 91);
- this.versionLabel.Name = "versionLabel";
- this.versionLabel.Size = new System.Drawing.Size(0, 13);
- this.versionLabel.TabIndex = 2;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label1.ForeColor = System.Drawing.Color.Gray;
- this.label1.Location = new System.Drawing.Point(13, 13);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(89, 24);
- this.label1.TabIndex = 3;
- this.label1.Text = "OWtrack";
- //
- // Splash
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(402, 116);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.versionLabel);
- this.Controls.Add(this.splashLabel);
- this.Controls.Add(this.progressBar1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- this.Name = "Splash";
- this.Text = "Splash";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
- private System.Windows.Forms.ProgressBar progressBar1;
- private System.Windows.Forms.Label splashLabel;
- private System.Windows.Forms.Label versionLabel;
- private System.Windows.Forms.Label label1;
- }
-}
\ No newline at end of file
diff --git a/OWTrack/Splash.cs b/OWTrack/Splash.cs
deleted file mode 100644
index 84789ca..0000000
--- a/OWTrack/Splash.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace OWTrack
-{
- public partial class Splash : Form
- {
- public Splash()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/OWTrack/Splash.resx b/OWTrack/Splash.resx
deleted file mode 100644
index 6a68c91..0000000
--- a/OWTrack/Splash.resx
+++ /dev/null
@@ -1,123 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs
index a2003e0..b7f56ea 100644
--- a/OWTrack/Tracker.cs
+++ b/OWTrack/Tracker.cs
@@ -30,37 +30,63 @@ namespace OWTrack
class Tracker
{
public int wins, losses, startSR, newSR, totalMatches = 0;
- public string gamePath;
- public void Track() { }//Deserailize here
- public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; gamePath = null; }
+
public void addWin() => wins++;
public void addLoss() => losses++;
public void reduceWin() => wins--;
public void rediceLoss() => losses--;
public int GetWins() { return wins; }
public int GetLosses() { return losses; }
- public int GetTotalMatches() { return wins + losses; }
public void setNewSR(int SR) { newSR = SR; }
public int srDiff() { return newSR - startSR; }
- public bool TrackOW = true;
- public bool TrackSR = true;
-
- struct ProgramFiles
+ public Settings settings = new Settings();
+ public List sessions = new List();
+ public int GetTotalMatches()
{
- public static readonly string C = "C:\\Program Files";
- public static readonly string D = "D:\\Program Files";
- public static readonly string E = "E:\\Program Files";
- public static readonly string F = "F:\\Program Files";
+ int number = 0;
+ foreach (var session in sessions)
+ {
+ number += session.TotalMatches;
+ }
+ return number;
+ }
+
+ public int GetCurrentSessionMatches()
+ {
+ return sessions.Last().TotalMatches;
+ }
+
+ public void reset()
+ {
+ wins = 0;
+ losses = 0;
+ startSR = 0;
+ newSR = 0;
+ settings.Reset();
+ sessions.Clear();
+ StartNewSeission();
+ }
+
+ public void StartNewSeission()
+ {
+ Session ses = new Session(startSR);
+ sessions.Add(ses);
+ //Re do SR input!!
+ }
+
+ public Session GetCurrentSession()
+ {
+ return sessions.Last();
}
public bool owRunning()
{
- if (TrackOW)
+ if (settings.TrackOW)
{
try
{
bool isRunning = Process.GetProcessesByName("Overwatch")
- .FirstOrDefault(p => p.MainModule.FileName.StartsWith(gamePath)) != default(Process);
+ .FirstOrDefault(p => p.MainModule.FileName.StartsWith(settings.GamePath)) != default(Process);
return isRunning;
}
catch (Exception)
@@ -71,20 +97,20 @@ namespace OWTrack
}
else return false;
}
-
- public bool LoacteOW()
+
+ public bool LoacteOW()
{
- try
+ try
{
DriveInfo[] driveInfo = DriveInfo.GetDrives();
List paths = new List();
//Searches all drives (too long)
- foreach (var drive in driveInfo)
- {
- //paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe"));
- }
- paths.AddRange(GetFiles(ProgramFiles.C, "Overwatch.exe"));
- paths.AddRange(GetFiles(ProgramFiles.D, "Overwatch.exe"));
+ //foreach (var drive in driveInfo)
+ //{
+ //paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe"));
+ //}
+ paths.AddRange(GetFiles(Paths.ProgramFiles.C, "Overwatch.exe"));
+ paths.AddRange(GetFiles(Paths.ProgramFiles.D, "Overwatch.exe"));
if (paths.Count > 1)
{
@@ -93,19 +119,20 @@ namespace OWTrack
return true;
}
- else if (paths.Count == 1)
+ else if (paths.Count == 1
+ && paths[0].Contains("Overwatch.exe"))
{
- gamePath = paths[0];
+ settings.GamePath = paths[0];
return true;
}
- else return false;
+ else return false;
}
catch (Exception e)
{
- MessageBox.Show(e.Message);
+ MessageBox.Show(e.Message);
return false;
- }
- }
+ }
+ }
public static IEnumerable GetFiles(string root, string searchPattern)
{
@@ -132,10 +159,64 @@ namespace OWTrack
}
}
-
- struct Settings
+ class Settings
{
- bool TrackSR, TrackOW;
- string OWpath;
+ public bool TrackSR, TrackOW = true;
+ public string GamePath = "";
+
+ ///
+ /// Reset All values to defult
+ ///
+ public void Reset()
+ {
+ TrackOW = true;
+ TrackSR = true;
+ GamePath = "";
+ }
+ }
+
+ class Session
+ {
+ public int TotalMatches;
+ public int SkillChange;
+ public int StartSR;
+ public DateTime date;
+ public List Matches = new List();
+
+ ///
+ /// Start a new session with a starting Skill Rating
+ ///
+ public Session(int StartSR)
+ {
+ this.StartSR = StartSR;
+ date = DateTime.Now.Date;
+ TotalMatches = 0;
+ }
+
+ public bool IsNewSession()
+ {
+ if (Matches.Count == 0) return true;
+ else return false;
+ }
+
+ public Match GetLastMatch()
+ {
+ return Matches.Last();
+ }
+
+ public void AddMatch(Match match)
+ {
+ this.Matches.Add(match);
+ this.TotalMatches = Matches.Count();
+ }
+ }
+
+ class Match
+ {
+ public Match() { }
+ public DateTime dateTime { get; set; }
+ public int StartSR;
+ public int newSR;
+ public int ChangeInSR;
}
}
diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs
index 0bae377..8cb03e0 100644
--- a/OWTrack/saveManeger.cs
+++ b/OWTrack/saveManeger.cs
@@ -24,7 +24,7 @@ using System.IO;
namespace OWTrack
{
- public static class Paths
+ public static class Paths
{
private static string curDir = Directory.GetCurrentDirectory();
private static string SAVES = curDir + "/saves/data.json";
@@ -32,10 +32,19 @@ namespace OWTrack
public static string GetJSON() { return JSON; }
public static string GetSaves() { return SAVES; }
public static string GetCurrentDir() { return curDir; }
+
+ public static class ProgramFiles
+ {
+ public static readonly string C = "C:\\Program Files";
+ public static readonly string D = "D:\\Program Files";
+ public static readonly string E = "E:\\Program Files";
+ public static readonly string F = "F:\\Program Files";
+ }
+
}
class saveManeger
- {
+ {
///
/// Deserialize saved tracker instance.
///
@@ -46,12 +55,18 @@ namespace OWTrack
{
return JsonConvert.DeserializeObject(File.ReadAllText(Paths.GetSaves()));
}
- catch (Exception e)
+ catch (Exception)
{
- throw e;
+ Exception ex = new Exception("json");
+ throw ex;
}
}
-
+
+ ///
+ /// Deserialize saved tracker instance from a Custom path
+ ///
+ ///
+ ///
public static Tracker GetSavedTracker(string customPath)
{
try
@@ -72,7 +87,7 @@ namespace OWTrack
public static bool SaveJSON(Tracker tracker)
{
try
- {
+ {
File.WriteAllText(Paths.GetSaves(), JsonConvert.SerializeObject(tracker, Formatting.Indented));
return true;
}
diff --git a/README.md b/README.md
index 787a240..0e2a7db 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# OWtrack ![CI status](https://img.shields.io/badge/build-passing-brightgreen.svg) [![GitHub](https://img.shields.io/badge/Version-1.4.2-blue.svg)] (https://heshamgit.ddns.net/Hesham/OWtrack/releases) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)
+# OWtrack ![CI status](https://img.shields.io/badge/build-passing-brightgreen.svg) [![GitHub](https://img.shields.io/badge/Version-1.4.3-blue.svg)] (https://heshamgit.ddns.net/Hesham/OWtrack/releases) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)
Track your Overwatch preformance with a shi#ty UI