Merge branch 'exeSearch' of Hesham/OWtrack into Dev
This commit is contained in:
		
						commit
						cab6bfd573
					
				@ -50,19 +50,42 @@ namespace OWTrack
 | 
				
			|||||||
                tr.losses = savedTracker().losses;
 | 
					                tr.losses = savedTracker().losses;
 | 
				
			||||||
                tr.newSR = savedTracker().newSR;
 | 
					                tr.newSR = savedTracker().newSR;
 | 
				
			||||||
                tr.startSR = savedTracker().startSR;
 | 
					                tr.startSR = savedTracker().startSR;
 | 
				
			||||||
 | 
					                tr.gamePath = savedTracker().gamePath;
 | 
				
			||||||
                update();
 | 
					                update();
 | 
				
			||||||
            }            
 | 
					            }            
 | 
				
			||||||
            else MessageBox.Show("no save");
 | 
					 | 
				
			||||||
        }       
 | 
					        }       
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private bool saveExist()
 | 
					        private bool saveExist()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            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
 | 
					                        else
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            if (!tr.LoacteOW())
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                getGamePath();
 | 
					                                getGamePath();
 | 
				
			||||||
 | 
					                                st.Close();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            return true;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    if (!tr.LoacteOW())
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        getGamePath(); 
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    return false;
 | 
					                    return false;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -84,6 +107,7 @@ namespace OWTrack
 | 
				
			|||||||
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
 | 
					            if (openFileDialog1.ShowDialog() == DialogResult.OK)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                tr.gamePath = openFileDialog1.FileName;
 | 
					                tr.gamePath = openFileDialog1.FileName;
 | 
				
			||||||
 | 
					                update();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,6 +2,8 @@
 | 
				
			|||||||
using System.Diagnostics;
 | 
					using System.Diagnostics;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
using System.IO;
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using System.Windows.Forms;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OWTrack
 | 
					namespace OWTrack
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -21,7 +23,6 @@ namespace OWTrack
 | 
				
			|||||||
        public void setNewSR(int SR) { newSR = SR; }
 | 
					        public void setNewSR(int SR) { newSR = SR; }
 | 
				
			||||||
        public int srDiff() { return newSR - startSR; }
 | 
					        public int srDiff() { return newSR - startSR; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        public bool owRunning()
 | 
					        public bool owRunning()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
@ -36,5 +37,69 @@ namespace OWTrack
 | 
				
			|||||||
                throw ex;
 | 
					                throw ex;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Not Working!
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        public bool LoacteOW() 
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try 
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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]);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    } 
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                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");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user