Sprint 6
This commit is contained in:
@@ -19,7 +19,7 @@ public class PersistentDataController
|
||||
/// Current implementation version of the PersistentDataController
|
||||
/// </summary>
|
||||
/// <remarks>MSB represent sprint version, LSB represent subversion</remarks>
|
||||
public const int VERSION = 0x04_03;
|
||||
public const int VERSION = 0x06_01;
|
||||
|
||||
/// <summary>
|
||||
/// Path of the <c>.json</c>-file to store all serialized data
|
||||
@@ -48,9 +48,17 @@ public class PersistentDataController
|
||||
/// </summary>
|
||||
public List<byte> data = new List<byte>();
|
||||
|
||||
/// <summary>
|
||||
/// Create a new PersistentDataEntry
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="data"></param>
|
||||
public PersistentDataEntry(string key, byte[] data) : this(key, data.ToList())
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new PersistentDataEntry
|
||||
/// </summary>
|
||||
public PersistentDataEntry(string key, List<byte> data)
|
||||
{
|
||||
this.key = key;
|
||||
@@ -171,10 +179,30 @@ public class PersistentDataController
|
||||
[Serializable]
|
||||
public class SavedUserData : PersistentDataContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// The user's username
|
||||
/// </summary>
|
||||
public string username = null;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the user's avatar in the UserList.AVATARS list
|
||||
/// </summary>
|
||||
public int avatarIndex = -1;
|
||||
|
||||
/// <summary>
|
||||
/// The total playtime of the user
|
||||
/// </summary>
|
||||
/// <remarks>Not implemented yet</remarks>
|
||||
public double playtime = 0.0;
|
||||
|
||||
/// <summary>
|
||||
/// A list of progress on minigames the user has
|
||||
/// </summary>
|
||||
public List<SavedMinigameProgress> minigames = new List<SavedMinigameProgress>();
|
||||
|
||||
/// <summary>
|
||||
/// A list of progress on courses the user has
|
||||
/// </summary>
|
||||
public List<SavedCourseProgress> courses = new List<SavedCourseProgress>();
|
||||
}
|
||||
|
||||
@@ -210,9 +238,9 @@ public class PersistentDataController
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Check whether there are enough inUse Learnables
|
||||
/// </summary>
|
||||
/// <returns> bool which indicates if there are enough inUseLearnables </returns>
|
||||
/// <returns></returns>
|
||||
private bool EnoughLearnables()
|
||||
{
|
||||
// There need to be more then 5 non completed learnables
|
||||
@@ -297,9 +325,24 @@ public class PersistentDataController
|
||||
[Serializable]
|
||||
public class SavedLearnableProgress : PersistentDataContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of the Learnbable in its Theme
|
||||
/// </summary>
|
||||
public int index;
|
||||
|
||||
/// <summary>
|
||||
/// Bool that indicated whether the user already started learning this Learnable
|
||||
/// </summary>
|
||||
public bool inUse = false;
|
||||
|
||||
/// <summary>
|
||||
/// Display name of the Learnable
|
||||
/// </summary>
|
||||
public string name;
|
||||
|
||||
/// <summary>
|
||||
/// Progress of the learnabe, a number between -5.0 and +5.0
|
||||
/// </summary>
|
||||
public float progress = 0.0f;
|
||||
}
|
||||
|
||||
@@ -309,8 +352,19 @@ public class PersistentDataController
|
||||
[Serializable]
|
||||
public class SavedMinigameProgress : PersistentDataContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of the minigame
|
||||
/// </summary>
|
||||
public MinigameIndex minigameIndex;
|
||||
|
||||
/// <summary>
|
||||
/// The 10 last scores of a user
|
||||
/// </summary>
|
||||
public List<Score> latestScores = new List<Score>();
|
||||
|
||||
/// <summary>
|
||||
/// Top 10 scores of a user
|
||||
/// </summary>
|
||||
public List<Score> highestScores = new List<Score>();
|
||||
}
|
||||
|
||||
@@ -320,12 +374,56 @@ public class PersistentDataController
|
||||
[Serializable]
|
||||
private class SavedDataStructure
|
||||
{
|
||||
/// <summary>
|
||||
/// The version of the PersistentDataController with which this savefile is created
|
||||
/// </summary>
|
||||
public int version = VERSION;
|
||||
|
||||
/// <summary>
|
||||
/// A list of all users
|
||||
/// </summary>
|
||||
public List<SavedUserData> users = new List<SavedUserData>();
|
||||
|
||||
/// <summary>
|
||||
/// The index of the current user in the this.users list
|
||||
/// </summary>
|
||||
public int currentUser = -1;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the current minigame
|
||||
/// </summary>
|
||||
public MinigameIndex currentMinigame;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the current course
|
||||
/// </summary>
|
||||
public CourseIndex currentCourse;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the current theme
|
||||
/// </summary>
|
||||
public ThemeIndex currentTheme;
|
||||
|
||||
/// <summary>
|
||||
/// The use hardware acceleration user preferences
|
||||
/// </summary>
|
||||
public bool useGPU = false;
|
||||
|
||||
/// <summary>
|
||||
/// Initiate the SavedDataStructure, by setting the user preferences
|
||||
/// </summary>
|
||||
public SavedDataStructure()
|
||||
{
|
||||
RestoreSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the user preferences to the default values
|
||||
/// </summary>
|
||||
public void RestoreSettings()
|
||||
{
|
||||
useGPU = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -364,6 +462,7 @@ public class PersistentDataController
|
||||
{
|
||||
json.users.Clear();
|
||||
json.currentUser = -1;
|
||||
json.useGPU = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -539,4 +638,37 @@ public class PersistentDataController
|
||||
if (save)
|
||||
Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the user wants to use hardware acceleration or not
|
||||
/// </summary>
|
||||
public bool IsUsingGPU()
|
||||
{
|
||||
return json.useGPU;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the preference of the user for hardware acceleration
|
||||
/// </summary>
|
||||
/// <param name="value">Value of the preference</param>
|
||||
/// <param name="save">Whether to save the change immediately to disk</param>
|
||||
public void SetGPUUsage(bool value, bool save = true)
|
||||
{
|
||||
json.useGPU = value;
|
||||
|
||||
if (save)
|
||||
Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore preferences to default factory settings
|
||||
/// </summary>
|
||||
/// <param name="save">Whether to save the change immediately to disk</param>
|
||||
public void RestoreSettings(bool save = true)
|
||||
{
|
||||
json.RestoreSettings();
|
||||
|
||||
if (save)
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,14 @@
|
||||
[Serializable]
|
||||
public class Score
|
||||
{
|
||||
/// <summary>
|
||||
/// The actual score
|
||||
/// </summary>
|
||||
public int scoreValue;
|
||||
|
||||
/// <summary>
|
||||
/// The time when the score is achieved, in string format
|
||||
/// </summary>
|
||||
public string time;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,8 @@ public enum ThemeIndex
|
||||
SIGN_HOBBIES,
|
||||
SIGN_HOUSE,
|
||||
SIGN_FAMILY,
|
||||
SPELLING_GEOGRAPY,
|
||||
SPELLING_BUILDINGS,
|
||||
SPELLING_SPORTS,
|
||||
SPELLING_BASICS,
|
||||
SPELLING_HOBBIES,
|
||||
SPELLING_PEOPLE,
|
||||
SPELLING_FRUIT,
|
||||
SPELLING_VEGGIES,
|
||||
SPELLING_COUNTRIES,
|
||||
SPELLING_WILD,
|
||||
SPELLING_FARM
|
||||
SPELLING_FARM,
|
||||
SPELLING_CAPITALS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user