Compare commits

...

60 Commits

Author SHA1 Message Date
ffa385d3c8 Update 'README.md' 2020-05-01 23:58:56 +03:00
a3a4cf267e Update 'README.md' 2020-05-01 23:57:10 +03:00
1c157c5dd1 Update 'README.md' 2020-05-01 23:54:22 +03:00
3e1d0b2fee Ex and API 2019-01-23 12:34:14 +03:00
0ed3830d9c todo 2019-01-23 12:18:34 +03:00
2b23479079 Move Paths Struct with Comments and Version bump 2019-01-23 12:16:27 +03:00
6a8019c1ac Remove Meesage box invoke from Tracker class 2019-01-23 11:58:44 +03:00
d0745d1bec Merge branch 'release/1.4.3' of Hesham/OWtrack into master 2018-12-22 10:14:19 +03:00
0632fe5b8f Merge branch 'Redo-SR' into release/1.4.3 2018-12-22 10:06:55 +03:00
bc3c84c984 Fixed #40 2018-12-22 10:04:45 +03:00
8d00ee0720 Paths to struct 2018-12-22 09:22:02 +03:00
5905ec0122 ProgramFiles class to struct 2018-12-22 09:18:39 +03:00
5caf393ea8 Merge branch 'release/1.4.3' of Hesham/OWtrack into master
Fixed:

    #39
    #33
    #11
    #37
2018-12-22 00:19:53 +03:00
44595496be Fixed #37 2018-12-22 00:17:23 +03:00
9176bf903c Merge branch 'session-class' into release/1.4.3 2018-12-21 23:30:45 +03:00
fbfd7740a2 Merge remote-tracking branch 'origin/session-class' into session-class 2018-12-21 23:30:23 +03:00
ec9def19c4 Fixed bug and organize #39 #33 #11 2018-12-21 23:29:28 +03:00
003668dea4 Fixed bug and organize 2018-12-21 23:23:59 +03:00
a28e09de89 Formatting White Space Clean 2018-12-21 22:00:33 +03:00
52fce485f8 Matches not saved in JSON Bug fixed 2018-12-21 22:00:11 +03:00
035d9979d1 Formatting (White space) 2018-12-21 21:57:56 +03:00
2d5771beb8 Start new session and other fixes 2018-12-21 18:44:48 +03:00
5d7640c0f0 Improved LoadSave Function 2018-12-21 18:17:47 +03:00
20d6844f2d follow up 2018-12-21 17:30:47 +03:00
7b3348a723 add match function
Adds a match to the last session in the sessions list
2018-12-21 17:30:16 +03:00
7f10e36e25 Total matches functions 2018-12-21 17:29:17 +03:00
470e2399f1 incomplete implementation of sessions class 2018-12-21 15:51:42 +03:00
4906361a56 Session class (Not Implemented) 2018-12-21 15:34:11 +03:00
0434fc1f40 clean 2018-12-21 12:56:15 +03:00
7ba2694c95 cleanup 2018-12-21 12:52:50 +03:00
5b4578fede Settings & Match classes
- Added settings class
- Added Match class
2018-12-21 11:13:48 +03:00
b23cc399b4 Docs update 2018-12-20 19:13:15 +03:00
98031dbe48 Rename function GetGamePath 2018-12-20 19:13:03 +03:00
aa4a08c525 Merge branch 'saveNotLoading' into release/1.4.3 2018-12-20 19:11:56 +03:00
e788aaeea3 Fixed Readline Bug (MultiLine) 2018-12-20 19:11:31 +03:00
86efb124c6 Merge branch 'master' into saveNotLoading 2018-12-20 19:03:39 +03:00
20ea1ae1df Version 2018-12-18 07:17:12 +03:00
ece2a122dd fixed notify icon bug 2018-12-13 22:32:33 +03:00
c959fc2d84 clean & Check paths string 2018-12-10 15:55:26 +03:00
5818104335 cleanup 2018-12-10 11:06:32 +03:00
008b889ccd resolve 2018-12-10 10:56:29 +03:00
264ca744f3 removed messagebox 2018-12-10 10:48:55 +03:00
632325fcd0 Merge branch 'Improve-search' of Hesham/OWtrack into release/1.4.3 2018-12-10 10:44:02 +03:00
1ea9bf531c search function rework 2018-12-10 10:42:14 +03:00
bbd855af11 Merge branch 'indent-json' of Hesham/OWtrack into master 2018-12-10 09:31:58 +03:00
9a05516dad corrected 2018-12-10 09:23:47 +03:00
b9f9dd7cff Link 2018-12-09 16:53:35 +03:00
f1831c78a8 Rough code. Not tested. 2018-12-09 16:45:22 +03:00
0bbdf3eade Encapsulate 2018-12-08 20:52:26 +03:00
4916456924 Version bump 2018-12-08 08:50:52 +03:00
c279b98621 Refactor search loops 2018-12-08 08:44:49 +03:00
5136773351 new structs 2018-12-08 08:41:46 +03:00
c2f9d4a782 Merge branch 'Badges' of Hesham/OWtrack into master 2018-11-25 04:42:32 +03:00
f1fa5f944d Update 'README.md' 2018-11-25 04:41:36 +03:00
8c9bce0a2a Version bump 2018-11-24 03:39:54 +03:00
5314344474 Merge branch 'release/1.4.2' of Hesham/OWtrack into master 2018-11-24 03:34:43 +03:00
6e7de80233 Fixed #29 2018-11-24 03:24:50 +03:00
fdfd400d0a dummy 2018-10-04 09:08:41 +03:00
885d235b33 clean 2018-10-04 09:03:54 +03:00
19c1c1cd5d Update 'README.md' 2018-09-27 11:40:40 +03:00
12 changed files with 304 additions and 388 deletions

View File

@ -322,6 +322,7 @@
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "OWTrack";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.SettingsGroup.ResumeLayout(false);
this.SettingsGroup.PerformLayout();
this.ResumeLayout(false);

View File

@ -21,30 +21,31 @@ SOFTWARE.*/
using System;
using System.Drawing;
using System.Windows.Forms;
using Newtonsoft.Json;
using System.IO;
namespace OWTrack
{
public partial class MainForm : Form
{
Tracker tr = new Tracker();
Tracker tr;
private const string IS_RUNNING = "Running";
private const string NOT_RUNNING = " Not running";
private bool SRonce = false;
private string Version = Program.Version.ToString();
public MainForm()
{
{
InitializeComponent();
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
{
@ -55,7 +56,7 @@ namespace OWTrack
}
else
{
if (tr.TrackOW)
if (tr.settings.TrackOW)
{
status.Text = NOT_RUNNING;
status.ForeColor = Color.Black;
@ -70,6 +71,7 @@ namespace OWTrack
}
}
//Move to saveManeger.cs ?
private void loadSave()
{
try
@ -83,69 +85,62 @@ namespace OWTrack
if (saveManeger.saveExist())
{
try
{
using (StreamReader st = new StreamReader(Paths.SAVES))
{
try
{
string line = st.ReadLine();
if (line.Contains("Overwatch.exe"))
{
tr = saveManeger.GetSavedTracker();
st.Close();
}
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;
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()
{
@ -161,6 +156,18 @@ namespace OWTrack
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();
@ -192,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)
{
@ -219,13 +226,18 @@ namespace OWTrack
}
finally
{
if (!SRonce)
{
//if (!SRonce)
//{
// tr.startSR = sr;
// SRonce = true;
//}
//else tr.newSR = sr;
if (tr.GetCurrentSession().IsNewSession())
tr.startSR = sr;
SRonce = true;
}
else tr.newSR = sr;
else
tr.newSR = sr;
}
AddMatch();
update();
}
@ -243,12 +255,15 @@ namespace OWTrack
private void ChngOWPathBtn_Click(object sender, EventArgs e)
{
tr.gamePath = getGamePath();
tr.settings.GamePath = askForGamePath();
update();
}
#endregion
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
notifyIcon1.Icon = null;
notifyIcon1.Dispose();
}
#endregion
}
}

View File

@ -90,8 +90,8 @@
<ApplicationIcon>assets\Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@ -112,13 +112,8 @@
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Paths.cs" />
<Compile Include="saveManeger.cs" />
<Compile Include="Splash.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Splash.Designer.cs">
<DependentUpon>Splash.cs</DependentUpon>
</Compile>
<Compile Include="Tracker.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -134,9 +129,6 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Splash.resx">
<DependentUpon>Splash.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="OWTrack_TemporaryKey.pfx" />
<None Include="packages.config" />

67
OWTrack/Paths.cs Normal file
View File

@ -0,0 +1,67 @@
/*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.IO;
namespace OWTrack
{
public struct Paths
{
/// <summary>
/// Current Application directory.
/// </summary>
private static string curDir = Directory.GetCurrentDirectory();
/// <summary>
/// Saves Folder relative path. \n Relative to Application Directory.
/// </summary>
private static string SAVES = curDir + "/saves/data.json";
/// <summary>
/// Saves Folder relative path. \n Relative to Application Directory.
/// </summary>
private static string JSON = curDir + "/data.json";
public static string GetJSON() { return JSON; }//TODO: Unused var
/// <summary>
/// Get Saves file Path.
/// </summary>
/// <returns></returns>
public static string GetSaves() { return SAVES; }
/// <summary>
/// Get Current Application directory.
/// </summary>
/// <returns></returns>
public static string GetCurrentDir() { return curDir; }
/// <summary>
/// "Program Files" standered constant paths.
/// </summary>
public struct ProgramFiles
{
public const string C = "C:\\Program Files";
public const string D = "D:\\Program Files";
public const string E = "E:\\Program Files";
public const string F = "F:\\Program Files";
}
}
}

View File

@ -17,10 +17,6 @@ namespace OWTrack
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public static string Version { get; } = "1.4.1";
//public static string Version = Application.ProductVersion;
//public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
public static string Version { get; } = "1.4.4.a1";
}
}

View File

@ -1,98 +0,0 @@
namespace OWTrack
{
partial class Splash
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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();
}
}
}

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="pageSetupDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1,4 +1,4 @@
/*Copyright(c) 2018 Hesham Systems LLC.
/*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
@ -22,107 +22,199 @@ using System;
using System.Diagnostics;
using System.Linq;
using System.IO;
using System.Windows.Forms;
using System.Collections.Generic;
namespace OWTrack
{
class Tracker
{
//TODO: Encapsulate
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;
public Settings settings = new Settings();
public List<Session> sessions = new List<Session>();
public int GetTotalMatches()
{
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);
}
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)
{
Exception ex = new Exception("Error");
throw ex;
catch (Exception e)
{
throw e;
}
}
else return false;
}
public bool LoacteOW()
public bool LoacteOW()
{
try
try
{
DriveInfo[] driveInfo = DriveInfo.GetDrives();
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)
{
for (int i = 0; i < filesC.Length; i++)
{
if (filesC[i].Contains("Overwatch.exe"))
{
paths.Add(filesC[i]);
}
}
}
if (filesD != null)
{
for (int i = 0; i < filesD.Length - 1; i++)
{
if (filesD[i].Contains("Overwatch.exe"))
{
paths.Add(filesD[i]);
}
}
}
//Searches all drives (too long)
//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)
{
//TODO: ask about correct path
//New Form??
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;
}
catch (Exception e)
catch (Exception)
{
MessageBox.Show(e.Message);
return false;
}
}
}
private bool ProgramFilesExist(char drive)
public static IEnumerable<string> GetFiles(string root, string searchPattern)
{
return Directory.Exists(drive+":\\Program Files");
Stack<string> pending = new Stack<string>();
pending.Push(root);
while (pending.Count != 0)
{
var path = pending.Pop();
string[] next = null;
try
{
next = Directory.GetFiles(path, searchPattern);
}
catch { }
if (next != null && next.Length != 0)
foreach (var file in next) yield return file;
try
{
next = Directory.GetDirectories(path);
foreach (var subdir in next) pending.Push(subdir);
}
catch { }
}
}
}
class Settings
{
public bool TrackSR, TrackOW = true;
public string GamePath = "";
/// <summary>
/// Reset All values to defult
/// </summary>
public void Reset()
{
TrackOW = true;
TrackSR = true;
GamePath = "";
}
}
class Session
{
public int TotalMatches;
public int SkillChange;
public int StartSR;
public DateTime date;
public List<Match> Matches = new List<Match>();
/// <summary>
/// Start a new session with a starting Skill Rating
///</summary>
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 LastMatchSR;
public int newSR;
public int ChangeInSR;
}
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net461" />
</packages>

View File

@ -20,39 +20,33 @@ SOFTWARE.*/
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OWTrack
{
static class Paths
{
private static string curDir = Directory.GetCurrentDirectory();
public static string SAVES = curDir + "/saves/data.json";
public static string JSON = curDir + "/data.json";
}
class saveManeger
{
{
/// <summary>
/// Deserialize saved tracker instance.
/// </summary>
/// <returns></returns>
/// <returns>Tracker Object</returns>
public static Tracker GetSavedTracker()
{
try
{
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.SAVES));
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.GetSaves()));
}
catch (Exception e)
{
throw e;
}
}
/// <summary>
/// Deserialize saved tracker instance from a Custom path
/// </summary>
/// <param name="customPath"></param>
/// <returns></returns>
public static Tracker GetSavedTracker(string customPath)
{
try
@ -66,15 +60,15 @@ namespace OWTrack
}
/// <summary>
///Saves the Tracker Object.
/// Deserializes and Saves the Tracker Object.
/// </summary>
/// <param name="tracker"></param>
/// <returns></returns>
/// <returns>Boolean value that represents the success or failuer</returns>
public static bool SaveJSON(Tracker tracker)
{
try
{
File.WriteAllText(Paths.SAVES, JsonConvert.SerializeObject(tracker));
File.WriteAllText(Paths.GetSaves(), JsonConvert.SerializeObject(tracker, Formatting.Indented));
return true;
}
catch (Exception)
@ -91,7 +85,7 @@ namespace OWTrack
{
try
{
if (File.Exists(Paths.SAVES))
if (File.Exists(Paths.GetSaves()))
{
return true;
}

View File

@ -1,4 +1,4 @@
# OWtrack ![CI status](https://img.shields.io/badge/build-passing-brightgreen.svg) [![GitHub](https://img.shields.io/badge/Version-1.3.0-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://apollo-server.ddns.net/gitea/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