diff --git a/OWTrack/Form1.Designer.cs b/OWTrack/MainForm.Designer.cs similarity index 98% rename from OWTrack/Form1.Designer.cs rename to OWTrack/MainForm.Designer.cs index f37c593..1e31cf7 100644 --- a/OWTrack/Form1.Designer.cs +++ b/OWTrack/MainForm.Designer.cs @@ -1,6 +1,6 @@ namespace OWTrack { - partial class Form1 + partial class MainForm { /// /// Required designer variable. @@ -29,7 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.label1 = new System.Windows.Forms.Label(); this.status = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); @@ -126,7 +126,7 @@ this.WinBut.TabIndex = 6; this.WinBut.Text = "win"; this.WinBut.UseVisualStyleBackColor = true; - this.WinBut.Click += new System.EventHandler(this.button1_Click); + this.WinBut.Click += new System.EventHandler(this.WinBtn_Click); // // button2 // @@ -136,7 +136,7 @@ this.button2.TabIndex = 6; this.button2.Text = "loss"; this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.button2.Click += new System.EventHandler(this.LossBtn_Click); // // label2 // diff --git a/OWTrack/Form1.cs b/OWTrack/MainForm.cs similarity index 66% rename from OWTrack/Form1.cs rename to OWTrack/MainForm.cs index ccf8ea5..cbb4641 100644 --- a/OWTrack/Form1.cs +++ b/OWTrack/MainForm.cs @@ -7,22 +7,22 @@ using System.IO; namespace OWTrack { - public partial class Form1 : Form + public partial class MainForm : Form { Tracker tr = new Tracker(); private const string IS_RUNNING = "Running"; private const string NOT_RUNNING = " Not running"; + private string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json"; private bool SRonce = false; - public Form1() + public MainForm() { - InitializeComponent(); + InitializeComponent(); loadSave(); checkStatus(); update(); label4.Text = Program.Version.ToString(); - Text = "OWTrack " + Program.Version.ToString(); - + Text = "OWTrack " + Program.Version.ToString(); } private void checkStatus() @@ -46,85 +46,67 @@ namespace OWTrack private void loadSave() { - if (saveExist()) + Directory.CreateDirectory("saves"); + if (saveManeger.saveExist()) { - tr.wins = savedTracker().wins; - tr.losses = savedTracker().losses; - tr.newSR = savedTracker().newSR; - tr.startSR = savedTracker().startSR; - tr.gamePath = savedTracker().gamePath; - update(); - } - } - - private bool saveExist() - { - try - { - if (File.Exists(Directory.GetCurrentDirectory() + "/data.json")) - { - using (StreamReader st = new StreamReader(Directory.GetCurrentDirectory() + "/data.json")) + try + { + using (StreamReader st = new StreamReader(savesPath)) { string line = st.ReadLine(); if (line.Contains("Overwatch.exe")) { - st.Close(); - return true; + tr = saveManeger.GetSavedTracker(); + st.Close(); } else { if (!tr.LoacteOW()) - { - st.Close(); - getGamePath(); + { + tr.gamePath = getGamePath(); } - return true; + st.Close(); } - } - } - else - { - if (!tr.LoacteOW()) - { - getGamePath(); - } - return false; - } - } - catch (Exception e) - { - MessageBox.Show(e.Message); - return false; - } - } - private void getGamePath() + } + } + catch (Exception e) + { + MessageBox.Show(e.Message); + } + update(); + } + else if (!tr.LoacteOW()) + { + tr.gamePath = getGamePath(); + } + } + + private string getGamePath() { openFileDialog1.Title = "Select Overwatch.exe"; openFileDialog1.DefaultExt = "exe"; - openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; - openFileDialog1.CheckFileExists = true; - openFileDialog1.CheckPathExists = true; - + openFileDialog1.Filter = "exe Files (*.exe)|*.exe|All files (*.*)|*.*"; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { - tr.gamePath = openFileDialog1.FileName; + //tr.gamePath = openFileDialog1.FileName; + MessageBox.Show("Saved Overwatch.exe location.\nPress Clear to rest\n" + openFileDialog1.FileName ); + return openFileDialog1.FileName; } - else if (result == DialogResult.Cancel) + else { - Close(); - } - FindForm(); - update(); + update(); + return null; + } } private Tracker savedTracker() { try { - return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + return JsonConvert.DeserializeObject(File.ReadAllText(savesPath)); } catch (Exception e) { @@ -132,35 +114,6 @@ namespace OWTrack return null; } } - - private void timer1_Tick(object sender, EventArgs e) - { - checkStatus(); - } - - private void button1_Click(object sender, EventArgs e) - { - tr.addWin(); - update(); - } - - private void button2_Click(object sender, EventArgs e) - { - tr.addLoss(); - update(); - } - - private void reduceWinBut_Click(object sender, EventArgs e) - { - tr.reduceWin(); - update(); - } - - private void reduceLossBut_Click(object sender, EventArgs e) - { - tr.rediceLoss(); - update(); - } private void update() { @@ -173,9 +126,42 @@ namespace OWTrack } else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); srTextBox.Text = null; - File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tr)); + File.WriteAllText(Directory.GetCurrentDirectory() + "/saves/data.json", JsonConvert.SerializeObject(tr)); } + #region Events + private void timer1_Tick(object sender, EventArgs e) => checkStatus(); + + private void WinBtn_Click(object sender, EventArgs e) + { + tr.addWin(); + update(); + } + + private void LossBtn_Click(object sender, EventArgs e) + { + tr.addLoss(); + update(); + } + + private void reduceWinBut_Click(object sender, EventArgs e) + { + if (tr.wins > 0) + { + tr.reduceWin(); + update(); + } + } + + private void reduceLossBut_Click(object sender, EventArgs e) + { + if (tr.losses > 0) + { + tr.rediceLoss(); + update(); + } + } + private void clearBut_Click(object sender, EventArgs e) { tr.reset(); @@ -209,6 +195,7 @@ namespace OWTrack else tr.newSR = sr; } update(); - } + } + #endregion } } diff --git a/OWTrack/Form1.resx b/OWTrack/MainForm.resx similarity index 100% rename from OWTrack/Form1.resx rename to OWTrack/MainForm.resx diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index d3e8d57..a482454 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -13,7 +13,7 @@ true false publish\ - true + false Disk false Foreground @@ -87,7 +87,7 @@ LocalIntranet - Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico + assets\Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico @@ -106,17 +106,24 @@ - + Form - - Form1.cs + + MainForm.cs + + + + Form + + + Splash.cs - - Form1.cs + + MainForm.cs ResXFileCodeGenerator @@ -127,6 +134,9 @@ True Resources.resx + + Splash.cs + @@ -156,7 +166,7 @@ - + \ No newline at end of file diff --git a/OWTrack/Program.cs b/OWTrack/Program.cs index 33cb5a5..963e7e6 100644 --- a/OWTrack/Program.cs +++ b/OWTrack/Program.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Deployment.Application; -using System.Linq; -using System.Threading.Tasks; using System.Windows.Forms; using System.Deployment.Application; @@ -19,10 +15,10 @@ namespace OWTrack { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + Application.Run(new MainForm()); } - public static string Version = "1.3.0"; + public static string Version { get; } = "1.4.0a2"; //public static string Version = Application.ProductVersion; //public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; diff --git a/OWTrack/Properties/AssemblyInfo.cs b/OWTrack/Properties/AssemblyInfo.cs index 1f9aa77..a7ead64 100644 --- a/OWTrack/Properties/AssemblyInfo.cs +++ b/OWTrack/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("OWTrack")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Shitty SR Tracker")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Hesham Systems LLC")] [assembly: AssemblyProduct("OWTrack")] @@ -35,8 +35,8 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyVersion("2.0.*")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.3.0.3")] +[assembly: AssemblyFileVersion("1.3.0.3")] [assembly: NeutralResourcesLanguage("")] diff --git a/OWTrack/Splash.Designer.cs b/OWTrack/Splash.Designer.cs new file mode 100644 index 0000000..ca13c55 --- /dev/null +++ b/OWTrack/Splash.Designer.cs @@ -0,0 +1,98 @@ +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 new file mode 100644 index 0000000..84789ca --- /dev/null +++ b/OWTrack/Splash.cs @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..6a68c91 --- /dev/null +++ b/OWTrack/Splash.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 7d3479a..a278053 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -13,7 +13,7 @@ namespace OWTrack public string gamePath; public void Track() { } - public void reset() { wins = 0; losses = 0; startSR = 0; newSR = 0; } + 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--; } @@ -31,17 +31,13 @@ namespace OWTrack .FirstOrDefault(p => p.MainModule.FileName.StartsWith(gamePath)) != default(Process); return isRunning; } - catch (Exception e) + catch (Exception) { Exception ex = new Exception("Error in tracking Overwatch.exe"); throw ex; } } - - /// - /// Not Working! - /// - /// + public bool LoacteOW() { try diff --git a/OWTrack/app.manifest b/OWTrack/app.manifest index 80d5e99..1bb0779 100644 --- a/OWTrack/app.manifest +++ b/OWTrack/app.manifest @@ -20,7 +20,7 @@ - + diff --git a/OWTrack/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico b/OWTrack/assets/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico similarity index 100% rename from OWTrack/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico rename to OWTrack/assets/Jeanette-Foshee-Simpsons-11-Rollover-Homer-donut-1.ico diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs new file mode 100644 index 0000000..b903c23 --- /dev/null +++ b/OWTrack/saveManeger.cs @@ -0,0 +1,72 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OWTrack +{ + class saveManeger + { + private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json"; + + public static Tracker GetSavedTracker() + { + try + { + return JsonConvert.DeserializeObject(File.ReadAllText(savesPath)); + } + catch (Exception e) + { + throw e; + } + } + + //TODO: use para + public static Tracker GetSavedTracker(string customPath) + { + try + { + return JsonConvert.DeserializeObject(File.ReadAllText(Directory.GetCurrentDirectory() + "/data.json")); + } + catch (Exception e) + { + throw e; + } + } + + public static bool SaveJSON(Tracker tracker) + { + try + { + File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tracker)); + return true; + } + catch (Exception) + { + return false; + } + } + + public static bool saveExist() + { + try + { + if (File.Exists(savesPath)) + { + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + throw e; + } + } + } +}