diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/Form1.Designer.cs index e7c457c..b781d6d 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/Form1.Designer.cs @@ -47,6 +47,7 @@ this.srBut = new System.Windows.Forms.Button(); this.srLabel = new System.Windows.Forms.Label(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.label5 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 @@ -139,21 +140,21 @@ // label2 // this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("Monospac821 BT", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.ForeColor = System.Drawing.Color.Black; this.label2.Location = new System.Drawing.Point(142, 76); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(42, 45); + this.label2.Size = new System.Drawing.Size(31, 42); this.label2.TabIndex = 5; this.label2.Text = "-"; // // label4 // this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Monospac821 BT", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(12, 217); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(35, 11); + this.label4.Size = new System.Drawing.Size(29, 12); this.label4.TabIndex = 7; this.label4.Text = "label4"; // @@ -210,11 +211,11 @@ this.srLabel.AutoSize = true; this.srLabel.Font = new System.Drawing.Font("Noto Mono", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.srLabel.ForeColor = System.Drawing.Color.DarkOrchid; - this.srLabel.Location = new System.Drawing.Point(183, 26); + this.srLabel.Location = new System.Drawing.Point(189, 36); this.srLabel.Name = "srLabel"; - this.srLabel.Size = new System.Drawing.Size(21, 23); + this.srLabel.Size = new System.Drawing.Size(65, 23); this.srLabel.TabIndex = 13; - this.srLabel.Text = "0"; + this.srLabel.Text = "0 - 0"; // // openFileDialog1 // @@ -222,11 +223,21 @@ this.openFileDialog1.InitialDirectory = "C:\\"; this.openFileDialog1.RestoreDirectory = true; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(190, 13); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(87, 13); + this.label5.TabIndex = 14; + this.label5.Text = "Start - Gain/Loss"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(332, 237); + this.Controls.Add(this.label5); this.Controls.Add(this.srLabel); this.Controls.Add(this.srBut); this.Controls.Add(this.srTextBox); @@ -273,6 +284,7 @@ private System.Windows.Forms.Button srBut; private System.Windows.Forms.Label srLabel; private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.Label label5; } } diff --git a/OWTrack/Form1.cs b/OWTrack/Form1.cs index a75d396..5544b32 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/Form1.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; using Newtonsoft.Json; using System.IO; + namespace OWTrack { public partial class Form1 : Form @@ -15,12 +16,13 @@ namespace OWTrack public Form1() { - InitializeComponent(); + InitializeComponent(); loadSave(); checkStatus(); update(); label4.Text = Program.Version.ToString(); - Text = "OWTrack " + Program.Version.ToString(); + Text = "OWTrack " + Program.Version.ToString(); + } private void checkStatus() @@ -50,19 +52,42 @@ namespace OWTrack tr.losses = savedTracker().losses; tr.newSR = savedTracker().newSR; tr.startSR = savedTracker().startSR; + tr.gamePath = savedTracker().gamePath; update(); - } - else MessageBox.Show("no save"); + } } private bool saveExist() { try { - if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) { return true; } + if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) + { + using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) + { + string line = st.ReadLine(); + if (line.Contains("Overwatch.exe")) + { + st.Close(); + return true; + } + else + { + if (!tr.LoacteOW()) + { + st.Close(); + getGamePath(); + } + return true; + } + } + } else { - getGamePath(); + if (!tr.LoacteOW()) + { + getGamePath(); + } return false; } } @@ -81,10 +106,18 @@ namespace OWTrack openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; - if (openFileDialog1.ShowDialog() == DialogResult.OK) + DialogResult result = openFileDialog1.ShowDialog(); + + if (result == DialogResult.OK) { tr.gamePath = openFileDialog1.FileName; } + else if (result == DialogResult.Cancel) + { + Close(); + } + FindForm(); + update(); } private Tracker savedTracker() diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index e87106e..5959d12 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -75,11 +75,17 @@ OWTrack_TemporaryKey.pfx - true + false true + + app.manifest + + + LocalIntranet + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll @@ -118,6 +124,7 @@ True Resources.resx + diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 12db818..33cb5a5 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -22,7 +22,7 @@ namespace OWTrack Application.Run(new Form1()); } - public static string Version = "1.2.4"; + public static string Version = "1.3.0"; //public static string Version = Application.ProductVersion; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 5f3ca97..7d3479a 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -2,13 +2,15 @@ using System.Diagnostics; using System.Linq; using System.IO; +using System.Windows.Forms; +using System.Collections.Generic; namespace OWTrack { class Tracker { public int wins, losses, startSR, newSR = 0; - public string gamePath; + public string gamePath; public void Track() { } public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } @@ -21,7 +23,6 @@ namespace OWTrack public void setNewSR(int SR) { newSR = SR; } public int srDiff() { return newSR - startSR; } - public bool owRunning() { try @@ -35,6 +36,70 @@ namespace OWTrack Exception ex = new Exception("Error in tracking Overwatch.exe"); throw ex; } - } + } + + /// + /// Not Working! + /// + /// + public bool LoacteOW() + { + try + { + List paths = new List(); + 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]); + } + } + } + + if (paths.Count > 1) + { + //TODO: ask about correct path + return true; + } + + else if (paths.Count == 1) + { + gamePath = paths[0]; + return true; + } + + else return false; + + } + catch (Exception e) + { + MessageBox.Show(e.Message); + return false; + } + } + + private bool ProgramFilesExist(char drive) + { + return Directory.Exists(drive+":\\Program Files"); + } } } diff --git a/OWTrack/app.manifest b/OWTrack/app.manifest new file mode 100644 index 0000000..2ef6a60 --- /dev/null +++ b/OWTrack/app.manifest @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file