1.4.3 #38

Merged
Hesham merged 25 commits from release/1.4.3 into master 2018-12-21 22:19:53 +01:00
3 changed files with 66 additions and 33 deletions
Showing only changes of commit 5b4578fede - Show all commits

View File

@ -56,7 +56,7 @@ namespace OWTrack
}
else
{
if (tr.TrackOW)
if (tr.settings.TrackOW)
{
status.Text = NOT_RUNNING;
status.ForeColor = Color.Black;
@ -90,6 +90,7 @@ namespace OWTrack
string line = st.ReadToEnd();
if (line.Contains("Overwatch.exe"))
{
MessageBox.Show(line);
tr = saveManeger.GetSavedTracker();
if (tr.startSR > 0) SRonce = true;
}
@ -97,7 +98,7 @@ namespace OWTrack
{
if (!tr.LoacteOW())
{
tr.gamePath = askForGamePath();
tr.settings.GamePath = askForGamePath();
}
}
st.Close();
@ -110,10 +111,10 @@ namespace OWTrack
}
else if (!tr.LoacteOW())
{
tr.gamePath = askForGamePath();
tr.settings.GamePath = askForGamePath();
}
ExeTrackCheckBx.Checked = tr.TrackOW;
SRCheckBx.Checked = tr.TrackSR;
ExeTrackCheckBx.Checked = tr.settings.TrackOW;
SRCheckBx.Checked = tr.settings.TrackSR;
update();
}
@ -135,12 +136,12 @@ namespace OWTrack
{
srBut.Enabled = state;
srTextBox.Enabled = state;
tr.TrackSR = state;
tr.settings.TrackSR = state;
}
private void OWTrackFunc(bool state)
{
tr.TrackOW = state;
tr.settings.TrackOW = state;
}
private void update()
@ -155,7 +156,19 @@ namespace OWTrack
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
srTextBox.Text = null;
saveManeger.SaveJSON(tr);
}
}
private void AddMatch()
{
Match match = new Match
{
oldSR = tr.startSR,
newSR = tr.newSR,
ChangeInSR = tr.srDiff(),
dateTime = DateTime.Now
};
tr.matches.Add(match);
}
#region Events
private void timer1_Tick(object sender, EventArgs e) => checkStatus();
@ -222,6 +235,7 @@ namespace OWTrack
}
else tr.newSR = sr;
}
AddMatch();
update();
}
@ -239,7 +253,7 @@ namespace OWTrack
private void ChngOWPathBtn_Click(object sender, EventArgs e)
{
tr.gamePath = askForGamePath();
tr.settings.GamePath = askForGamePath();
update();
}

View File

@ -30,9 +30,9 @@ namespace OWTrack
class Tracker
{
public int wins, losses, startSR, newSR, totalMatches = 0;
public string gamePath;
//public string gamePath;
public void Track() { }//Deserailize here
public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; gamePath = null; }
public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; settings.Reset(); }
public void addWin() => wins++;
public void addLoss() => losses++;
public void reduceWin() => wins--;
@ -41,26 +41,18 @@ namespace OWTrack
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 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";
}
public int srDiff() { return newSR - startSR; }
public Settings settings = new Settings();
public List<Match> matches = new List<Match>();
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)
@ -83,8 +75,8 @@ namespace OWTrack
//{
//paths.AddRange(GetFiles(drive.ToString(),"Overwatch.exe"));
//}
paths.AddRange(GetFiles(ProgramFiles.C, "Overwatch.exe"));
paths.AddRange(GetFiles(ProgramFiles.D, "Overwatch.exe"));
paths.AddRange(GetFiles(Paths.ProgramFiles.C, "Overwatch.exe"));
paths.AddRange(GetFiles(Paths.ProgramFiles.D, "Overwatch.exe"));
if (paths.Count > 1)
{
@ -96,7 +88,7 @@ namespace OWTrack
else if (paths.Count == 1
&& paths[0].Contains("Overwatch.exe"))
{
gamePath = paths[0];
settings.GamePath = paths[0];
return true;
}
else return false;
@ -133,10 +125,28 @@ namespace OWTrack
}
}
struct Settings
class Settings
{
bool TrackSR, TrackOW;
string OWpath;
public bool TrackSR, TrackOW = true;
public string GamePath = "";
/// <summary>
/// Reset All values to defult
/// </summary>
public void Reset()
{
TrackOW = true;
TrackSR = true;
GamePath = "";
}
}
public class Match
{
public Match() { }
public DateTime dateTime { get; set; }
public int oldSR;
public int newSR;
public int ChangeInSR;
}
}

View File

@ -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
{
{
/// <summary>
/// Deserialize saved tracker instance.
/// </summary>