use of save maneger
This commit is contained in:
parent
f4c56e2bc2
commit
3500430109
@ -157,7 +157,7 @@ namespace OWTrack
|
|||||||
}
|
}
|
||||||
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
|
else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff();
|
||||||
srTextBox.Text = null;
|
srTextBox.Text = null;
|
||||||
File.WriteAllText(Directory.GetCurrentDirectory() + "/saves/data.json", JsonConvert.SerializeObject(tr));
|
saveManeger.SaveJSON(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
@ -32,6 +32,10 @@ namespace OWTrack
|
|||||||
{
|
{
|
||||||
private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json";
|
private static string savesPath = Directory.GetCurrentDirectory() + "/saves/data.json";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deserialize saved tracker instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public static Tracker GetSavedTracker()
|
public static Tracker GetSavedTracker()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -44,7 +48,6 @@ namespace OWTrack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: use para
|
|
||||||
public static Tracker GetSavedTracker(string customPath)
|
public static Tracker GetSavedTracker(string customPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -57,11 +60,16 @@ namespace OWTrack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///Saves the Tracker Object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tracker"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static bool SaveJSON(Tracker tracker)
|
public static bool SaveJSON(Tracker tracker)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(Directory.GetCurrentDirectory() + "/data.json", JsonConvert.SerializeObject(tracker));
|
File.WriteAllText(savesPath, JsonConvert.SerializeObject(tracker));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@ -70,6 +78,10 @@ namespace OWTrack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if a 'data.json' exists in the default location '../saves/data.json'.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Boolean Value</returns>
|
||||||
public static bool saveExist()
|
public static bool saveExist()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user