Paths class
This commit is contained in:
parent
a77e5684c3
commit
ccc2028b7f
@ -32,7 +32,6 @@ namespace OWTrack
|
||||
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 MainForm()
|
||||
@ -82,7 +81,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamReader st = new StreamReader(savesPath))
|
||||
using (StreamReader st = new StreamReader(Paths.SAVES))
|
||||
{
|
||||
string line = st.ReadLine();
|
||||
if (line.Contains("Overwatch.exe"))
|
||||
@ -122,9 +121,8 @@ namespace OWTrack
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
//tr.gamePath = openFileDialog1.FileName;
|
||||
MessageBox.Show("Saved Overwatch.exe location.\nPress Clear to rest");
|
||||
return openFileDialog1.FileName;
|
||||
return openFileDialog1.FileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -137,7 +135,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(savesPath));
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.SAVES));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -157,7 +155,7 @@ namespace OWTrack
|
||||
}
|
||||
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
|
||||
srTextBox.Text = null;
|
||||
File.WriteAllText(Directory.GetCurrentDirectory() + "/saves/data.json", JsonConvert.SerializeObject(tr));
|
||||
File.WriteAllText(Paths.SAVES, JsonConvert.SerializeObject(tr));
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
@ -28,20 +28,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace OWTrack
|
||||
{
|
||||
class saveManeger
|
||||
static class Paths
|
||||
{
|
||||
public enum Paths
|
||||
{
|
||||
saves = "/saves/data.json",
|
||||
saveJsonFile = "/data.json",
|
||||
};
|
||||
private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json";
|
||||
private static string curDir = Directory.GetCurrentDirectory();
|
||||
public static string SAVES = curDir + "/saves/data.json";
|
||||
public static string JSON = curDir + "/data.json";
|
||||
}
|
||||
|
||||
class saveManeger
|
||||
{
|
||||
public static Tracker GetSavedTracker()
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(savesPath));
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.SAVES));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -54,7 +54,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(customPath + "/data.json"));
|
||||
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(customPath));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -66,7 +66,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tracker));
|
||||
File.WriteAllText(Paths.JSON, JsonConvert.SerializeObject(tracker));
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@ -79,7 +79,7 @@ namespace OWTrack
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(savesPath))
|
||||
if (File.Exists(Paths.SAVES))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user