2018-09-22 11:54:00 +02:00
|
|
|
|
/*Copyright(c) 2018 Hesham Systems LLC.
|
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
SOFTWARE.*/
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-07-13 03:57:29 +02:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2018-08-12 01:21:12 +02:00
|
|
|
|
using System.IO;
|
2018-09-03 21:11:05 +02:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Collections.Generic;
|
2018-07-13 03:57:29 +02:00
|
|
|
|
|
|
|
|
|
namespace OWTrack
|
|
|
|
|
{
|
|
|
|
|
class Tracker
|
|
|
|
|
{
|
2018-09-23 14:14:11 +02:00
|
|
|
|
public int wins, losses, startSR, newSR, totalMatches = 0;
|
2018-09-03 21:11:05 +02:00
|
|
|
|
public string gamePath;
|
2018-07-13 03:57:29 +02:00
|
|
|
|
|
2018-09-23 14:14:11 +02:00
|
|
|
|
public void Track() { }//Deserailize here
|
2018-09-20 10:23:47 +02:00
|
|
|
|
public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; gamePath = null; }
|
2018-08-15 10:32:42 +02:00
|
|
|
|
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; }
|
2018-09-23 14:14:11 +02:00
|
|
|
|
public int GetTotalMatches() { return wins + losses; }
|
2018-08-15 10:32:42 +02:00
|
|
|
|
public void setNewSR(int SR) { newSR = SR; }
|
|
|
|
|
public int srDiff() { return newSR - startSR; }
|
2018-08-12 01:21:12 +02:00
|
|
|
|
|
2018-07-13 03:57:29 +02:00
|
|
|
|
public bool owRunning()
|
2018-07-15 21:22:02 +02:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool isRunning = Process.GetProcessesByName("Overwatch")
|
2018-08-31 19:17:26 +02:00
|
|
|
|
.FirstOrDefault(p => p.MainModule.FileName.StartsWith(gamePath)) != default(Process);
|
2018-07-15 21:22:02 +02:00
|
|
|
|
return isRunning;
|
|
|
|
|
}
|
2018-09-14 13:53:54 +02:00
|
|
|
|
catch (Exception)
|
2018-07-15 21:22:02 +02:00
|
|
|
|
{
|
2018-09-22 11:41:42 +02:00
|
|
|
|
Exception ex = new Exception("Error");
|
2018-07-15 21:22:02 +02:00
|
|
|
|
throw ex;
|
|
|
|
|
}
|
2018-09-02 13:24:55 +02:00
|
|
|
|
}
|
2018-09-14 13:53:54 +02:00
|
|
|
|
|
2018-09-03 21:11:05 +02:00
|
|
|
|
public bool LoacteOW()
|
2018-09-02 13:24:55 +02:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2018-09-03 21:11:05 +02:00
|
|
|
|
List<string> paths = new List<string>();
|
|
|
|
|
string[] filesC = null;
|
|
|
|
|
string[] filesD = null;
|
|
|
|
|
|
|
|
|
|
if (ProgramFilesExist('c')) { filesC = Directory.GetFiles("C:\\Program Files", "Overwatch.exe", SearchOption.AllDirectories); }
|
|
|
|
|
if (ProgramFilesExist('d')) { filesD = Directory.GetFiles("D:\\Program Files", "Overwatch.exe", SearchOption.AllDirectories); }
|
|
|
|
|
|
|
|
|
|
if (filesC != null)
|
2018-09-02 13:24:55 +02:00
|
|
|
|
{
|
2018-09-03 21:11:05 +02:00
|
|
|
|
for (int i = 0; i < filesC.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (filesC[i].Contains("Overwatch.exe"))
|
|
|
|
|
{
|
|
|
|
|
paths.Add(filesC[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-02 13:24:55 +02:00
|
|
|
|
}
|
2018-09-03 21:11:05 +02:00
|
|
|
|
|
|
|
|
|
if (filesD != null)
|
2018-09-02 13:24:55 +02:00
|
|
|
|
{
|
2018-09-03 21:11:05 +02:00
|
|
|
|
for (int i = 0; i < filesD.Length - 1; i++)
|
2018-09-02 13:24:55 +02:00
|
|
|
|
{
|
2018-09-03 21:11:05 +02:00
|
|
|
|
if (filesD[i].Contains("Overwatch.exe"))
|
|
|
|
|
{
|
|
|
|
|
paths.Add(filesD[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-02 13:24:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-03 21:11:05 +02:00
|
|
|
|
if (paths.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
//TODO: ask about correct path
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (paths.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
gamePath = paths[0];
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else return false;
|
|
|
|
|
|
2018-09-02 13:24:55 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2018-09-03 21:11:05 +02:00
|
|
|
|
MessageBox.Show(e.Message);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ProgramFilesExist(char drive)
|
|
|
|
|
{
|
|
|
|
|
return Directory.Exists(drive+":\\Program Files");
|
|
|
|
|
}
|
2018-07-13 03:57:29 +02:00
|
|
|
|
}
|
|
|
|
|
}
|