diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..64cb63a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,228 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = true +dotnet_style_allow_statement_immediately_after_block_experimental = true + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false +csharp_style_var_for_built_in_types = false +csharp_style_var_when_type_is_apparent = false + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true +csharp_style_expression_bodied_constructors = false +csharp_style_expression_bodied_indexers = true +csharp_style_expression_bodied_lambdas = true +csharp_style_expression_bodied_local_functions = false +csharp_style_expression_bodied_methods = false +csharp_style_expression_bodied_operators = false +csharp_style_expression_bodied_properties = true + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_prefer_extended_property_pattern = true +csharp_style_prefer_not_pattern = true +csharp_style_prefer_pattern_matching = true +csharp_style_prefer_switch_expression = true + +# Null-checking preferences +csharp_style_conditional_delegate_call = true + +# Modifier preferences +csharp_prefer_static_local_function = true +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true + +# Code-block preferences +csharp_prefer_braces = true +csharp_prefer_simple_using_statement = true +csharp_style_namespace_declarations = block_scoped +csharp_style_prefer_method_group_conversion = true +csharp_style_prefer_top_level_statements = true + +# Expression-level preferences +csharp_prefer_simple_default_expression = true +csharp_style_deconstructed_variable_declaration = true +csharp_style_implicit_object_creation_when_type_is_apparent = true +csharp_style_inlined_variable_declaration = true +csharp_style_prefer_index_operator = true +csharp_style_prefer_local_over_anonymous_function = true +csharp_style_prefer_null_check_over_type_check = true +csharp_style_prefer_range_operator = true +csharp_style_prefer_tuple_swap = true +csharp_style_prefer_utf8_string_literals = true +csharp_style_throw_expression = true +csharp_style_unused_value_assignment_preference = discard_variable +csharp_style_unused_value_expression_statement_preference = discard_variable + +# 'using' directive preferences +csharp_using_directive_placement = outside_namespace + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case diff --git a/Assets/Accounts/Scripts/Progress.cs b/Assets/Accounts/Scripts/Progress.cs index dccaf17..b54ef7f 100644 --- a/Assets/Accounts/Scripts/Progress.cs +++ b/Assets/Accounts/Scripts/Progress.cs @@ -4,15 +4,26 @@ using System.IO; using System.Runtime.Serialization.Formatters.Binary; using UnityEngine; +/// +/// A class for holding all progress belonging to a user +/// [Serializable] -// Can not be created from Editor public class Progress { + /// + /// A helper class for handling the stored progress + /// [Serializable] - // Helper class to serialize into byte[] protected class DataEntry { + /// + /// The key, used to reference the data object + /// public string key; + + /// + /// The object, representated as a list of byte (which can be serialized) + /// public List bytes = new List(); public DataEntry(string key, byte[] data) @@ -22,13 +33,21 @@ public class Progress } } - [Header("Course or Minigame")] + /// + /// Entries in the Progress object + /// [SerializeField] - // values belonging to a certain key, in List (which can be serialized) private List entries = new List(); - // Add new `key` := `value`, returns `true` if successful + /// + /// Update the value of a certain key, + /// or add a new value if the key was not present + /// + /// The type of the data to be added/updated + /// The key, used for referencing the data + /// The object of type + /// true if successful, false otherwise public bool AddOrUpdate(string key, T data) { if (data == null) @@ -55,6 +74,13 @@ public class Progress } // Get the value of type `T` belonging to `key` + /// + /// Get the data object of a certain key + /// + /// The type of the data object + /// The key referencing the data object + /// The data, cast to a type + /// public T Get(string key) { BinaryFormatter bf = new BinaryFormatter(); diff --git a/Assets/Accounts/Scripts/User.cs b/Assets/Accounts/Scripts/User.cs index e6ef53f..046ba21 100644 --- a/Assets/Accounts/Scripts/User.cs +++ b/Assets/Accounts/Scripts/User.cs @@ -2,29 +2,45 @@ using System; using System.Collections.Generic; using UnityEngine; +/// +/// A class holding all information of a user +/// [Serializable] public class User { - [Header("Personal data")] - // User nickname + /// + /// User nickname + /// public string username; - // User avatar + + /// + /// The avatar of the user + /// public Sprite avatar; - [Header("Personal settings")] - // TODO: set personal settings and preferences - - [Header("Progress")] - // Total playtime + /// + /// The total playtime of the user + /// + /// TODO: needs to be implemented public double playtime; + + /// + /// List of courses a user started/completed + /// [SerializeField] - // List of courses a user started/completed public List courses = new List(); + + /// + /// List of minigames a user played + /// [SerializeField] - // List of minigames a user played public List minigames = new List(); - // Get a list of all recently started courses, returns a list of tuples of `` + /// + /// Get a list of all recently started courses + /// + /// A List of Tuples, containing the CourseIndex + /// and a float holding the progress (value between 0 and 1) of the user in this course public List> GetRecentCourses() { // TODO: return better results (for now only return all courses) @@ -38,7 +54,11 @@ public class User return recentCourses; } - // Get a list of all recommended courses, returns a list of tuples of `` + /// + /// Get a list of all recommended courses + /// + /// A List of Tuples, containing the CourseIndex + /// and a float holding the progress (value between 0 and 1) of the user in this course public List> GetRecommendedCourses() { List> recommenedCourses = new List>(); @@ -59,4 +79,24 @@ public class User return recommenedCourses; } + + /// + /// Get the progress of a certain course + /// + /// Index of course + /// Progress belonging to the courseIndex, null if course was not found + public Progress GetCourseProgress(CourseIndex courseIndex) + { + return courses.Find((p) => p.Get("courseIndex") == courseIndex); + } + + /// + /// Get the progress of certain minigame + /// + /// Index of the minigame + /// Progress belonging to the minigameIndex, null if minigame was not found + public Progress GetMinigameProgress(MinigameIndex minigameIndex) + { + return minigames.Find((p) => p.Get("minigameIndex") == minigameIndex); + } } diff --git a/Assets/Accounts/Scripts/UserCreationScreen.cs b/Assets/Accounts/Scripts/UserCreationScreen.cs index 4a97cee..bf3aabb 100644 --- a/Assets/Accounts/Scripts/UserCreationScreen.cs +++ b/Assets/Accounts/Scripts/UserCreationScreen.cs @@ -5,34 +5,56 @@ using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +/// +/// UserCreationScreen scene manager +/// public class UserCreationScreen : MonoBehaviour { - // Max length of a username + /// + /// Maximum lenght of a username + /// private const int MAX_USERNAME_LENGTH = 12; - [Header("UI References")] - // Reference to the input text field for username + /// + /// Reference to the input text field for username + /// public TMP_InputField inputName; - // Reference to the avatar-list container + + /// + /// Reference to the avatar-list container + /// public Transform avatarsContainer; - [Header("Prefab")] - // Avatar prefab + /// + /// Avatar prefab + /// public GameObject avatarPrefab; - // List of all sprites that are supported as avatars + + /// + /// List of all sprites that are supported as avatars + /// public List sprites = new List(); - [Header("Users List")] - // Reference to the UserList ScriptableObject + /// + /// Reference to the UserList ScriptableObject + /// public UserList users; + /// + /// Current selected avatar + /// [SerializeField] - // Current selected avatar private int selectedAvatar = 0; - // List of references to avatar background sprites (so we can color them nicely) + + /// + /// List of references to avatar background sprites (so we can color them nicely) + /// private List avatars = new List(); + /// + /// Start is called before the first frame update + /// void Start() { for (int i = 0; i < sprites.Count; i++) @@ -60,7 +82,10 @@ public class UserCreationScreen : MonoBehaviour } } - // Update the current selected avatar + /// + /// Update the current selected avatar + /// + /// Index to the new avatar in the this.avatars list private void UpdateAvatar(int newAvatar) { avatars[selectedAvatar].color = Color.gray; @@ -68,13 +93,20 @@ public class UserCreationScreen : MonoBehaviour avatars[selectedAvatar].color = Color.blue; } - // Check if a given string is a correct username (using Regex) + /// + /// Check if a given string is a correct username (using Regex) + /// + /// The username to be checked + /// true if the username was valid, false otherwise static public bool IsValidUsername(string username) { return new Regex($@"^[abcdefghijklmnopqrstuvwxyz]{{1,{MAX_USERNAME_LENGTH}}}$").IsMatch(username); } - // Create a new user (will be called by button) + /// + /// Create a new user + /// (this method will be called by a button callback) + /// public void CreateUser() { string username = inputName.text; diff --git a/Assets/Accounts/Scripts/UserList.cs b/Assets/Accounts/Scripts/UserList.cs index d568d28..01a01d2 100644 --- a/Assets/Accounts/Scripts/UserList.cs +++ b/Assets/Accounts/Scripts/UserList.cs @@ -3,31 +3,55 @@ using System.Collections.Generic; using System.IO; using UnityEngine; +/// +/// Keep track of all users +/// [CreateAssetMenu(menuName = "Create new Scriptable/UserList")] public class UserList : ScriptableObject { - // Serializable UserList content + /// + /// Helper class to enable serialization of the UserList class + /// (ScriptableObkects cannot be serialized) + /// [Serializable] public class StoredUserList { + /// + /// The index of the current/last logged in user in the storedUsers list + /// public int currentUserIndex; + /// + /// A list containing all users (which can be serialized) + /// public List storedUsers = new List(); } - [Header("Users")] + + /// + /// Reference to the serializable version of UserList + /// [SerializeField] - // Reference to serializable version of UserList private StoredUserList storedUserList = new StoredUserList(); - // Path to .json file + /// + /// Path of the .json-file to store all serialized data + /// public static string PATH = null; + /// + /// OnEnable will make sure the PATH-variable is correctly initialized + /// void OnEnable() { PATH = $"{Application.dataPath}/users.json"; Load(); } - // Create a new User + /// + /// Create a new user + /// + /// The username of the new user + /// Reference to the user avatar + /// A newly created user public User CreateNewUser(string name, Sprite avatar) { User user = new User(); @@ -36,7 +60,12 @@ public class UserList : ScriptableObject return user; } - // Create a new User and add to list + /// + /// Create a new user and save (add to list) + /// + /// The username of the new user + /// Reference to the user avatar + /// A newly created user public User CreateAndAddNewUser(string name, Sprite avatar) { User user = CreateNewUser(name, avatar); @@ -45,7 +74,11 @@ public class UserList : ScriptableObject return user; } - // Get user by username, returns `null` if no user can be found with such name + /// + /// Get a user by username + /// + /// The username of the user + /// User-object if a user with such username was found, null otherwise public User GetUserByUsername(string username) { foreach (User user in storedUserList.storedUsers) @@ -54,19 +87,27 @@ public class UserList : ScriptableObject return null; } - // Get a list of all users + /// + /// Get a list of all users currently stored + /// + /// A list of all users public List GetUsers() { return storedUserList.storedUsers; } - // Get the current active user + /// + /// Get the current logged in user + /// + /// The current logged in user public User GetCurrentUser() { return storedUserList.storedUsers[storedUserList.currentUserIndex]; } - // Save the userList + /// + /// Save the users + /// public void Save() { string json = JsonUtility.ToJson(storedUserList); @@ -74,7 +115,9 @@ public class UserList : ScriptableObject File.WriteAllText(PATH, json); } - // Load the userList into this object + /// + /// Override the current content of the userlist by what is stored on disk + /// public void Load() { try diff --git a/Assets/Accounts/Tests/TestProgress.cs b/Assets/Accounts/Tests/TestProgress.cs index e24ea06..42ba708 100644 --- a/Assets/Accounts/Tests/TestProgress.cs +++ b/Assets/Accounts/Tests/TestProgress.cs @@ -3,24 +3,34 @@ using System.Collections.Generic; using System.Runtime.Serialization; using UnityEngine; +/// +/// Test the Progress class +/// public class TestProgress : MonoBehaviour { + /// + /// A dummy serializable struct to perform test operations on + /// [Serializable] - // Dummy struct private struct SerializableStruct { public int r, g, b; public float x, y, z; } + /// + /// A dummy non-serializable struct to perform test operations on + /// private struct NonSerializableStruct { public int r, g, b; public float x, y, z; } - - // Helper method, returns true if `Progress.Get(...)` throws a `KeyNotFoundException` + /// + /// Helper method + /// + /// true if Progress.AddOrUpdate(...) throws a SerializationException private bool AddNonSerializableStruct() { Progress progress = new Progress(); @@ -30,7 +40,10 @@ public class TestProgress : MonoBehaviour return false; } - // Helper method, returns true if `Progress.Get(...)` throws a `KeyNotFoundException` + /// + /// Helper method + /// + /// true if Progress.Get(...) throws a KeyNotFoundException private bool AccessInvalidKey() { Progress progress = new Progress(); @@ -39,7 +52,10 @@ public class TestProgress : MonoBehaviour return false; } - // Helper method, returns true if `Progress.Get(...)` throws a `InvalidCastException` + /// + /// Helper method + /// + /// true if Progress.Get(...) throws a InvalidCastException private bool AccessInvalidType() { Progress progress = new Progress(); @@ -49,6 +65,9 @@ public class TestProgress : MonoBehaviour return false; } + /// + /// Start is called before the first frame update + /// void Start() { TestNewProgress(); @@ -68,18 +87,27 @@ public class TestProgress : MonoBehaviour TestProgressGetStruct(); } + /// + /// Test for creation of a new progress + /// public void TestNewProgress() { Progress progress = new Progress(); Debug.Assert(progress != null); } + /// + /// Test whether invalid data will not be added + /// public void TestProgressAddInvalidData() { Progress progress = new Progress(); Debug.Assert(!progress.AddOrUpdate("key", null)); } + /// + /// Test whether a duplicated key will be added + /// public void TestProgressAddDuplicateKey() { Progress progress = new Progress(); @@ -87,45 +115,69 @@ public class TestProgress : MonoBehaviour Debug.Assert(progress.AddOrUpdate("key 1", 1)); } + /// + /// Test whether a int value can be added + /// public void TestProgressAddInt() { Progress progress = new Progress(); Debug.Assert(progress.AddOrUpdate("key", 1)); } + /// + /// Test whether a double value can be added + /// public void TestProgressAddDouble() { Progress progress = new Progress(); Debug.Assert(progress.AddOrUpdate("key", 1.0)); } + /// + /// Test whether a string value can be added + /// public void TestProgressAddString() { Progress progress = new Progress(); Debug.Assert(progress.AddOrUpdate("key", "Hello World!")); } + /// + /// Test whether a serializable struct can be added + /// public void TestProgressAddSerializableStruct() { Progress progress = new Progress(); Debug.Assert(progress.AddOrUpdate("key", new SerializableStruct())); } + /// + /// Test whether a non-serializable struct will throw an error + /// public void TestProgressAddNonSerializableStruct() { Debug.Assert(AddNonSerializableStruct()); } + /// + /// Test whether an invalid key will throw an error + /// public void TestProgressGetInvalidKey() { Debug.Assert(AccessInvalidKey()); } + /// + /// Test whether an invalid type will throw an error + /// public void TestProgressGetInvalidType() { Debug.Assert(AccessInvalidType()); } + /// + /// Test whether a value is correctly updated + /// public void TestProgressUpdate() { Progress progress = new Progress(); @@ -135,6 +187,9 @@ public class TestProgress : MonoBehaviour Debug.Assert(progress.Get("key") == 2); } + /// + /// Test whether a int value can be read + /// public void TestProgressGetInt() { Progress progress = new Progress(); @@ -142,6 +197,9 @@ public class TestProgress : MonoBehaviour Debug.Assert(progress.Get("key") == 1); } + /// + /// Test whether a double value can be read + /// public void TestProgressGetDouble() { Progress progress = new Progress(); @@ -149,6 +207,9 @@ public class TestProgress : MonoBehaviour Debug.Assert(progress.Get("key") == 1.0); } + /// + /// Test whether a string value can be read + /// public void TestProgressGetString() { Progress progress = new Progress(); @@ -156,6 +217,9 @@ public class TestProgress : MonoBehaviour Debug.Assert(progress.Get("key") == "Hello World!"); } + /// + /// Test whether a serializable struct can be read + /// public void TestProgressGetStruct() { Progress progress = new Progress(); diff --git a/Assets/Accounts/Tests/TestUser.cs b/Assets/Accounts/Tests/TestUser.cs new file mode 100644 index 0000000..cdd2d97 --- /dev/null +++ b/Assets/Accounts/Tests/TestUser.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +/// +/// Test the User class +/// +public class TestUser : MonoBehaviour +{ + /// + /// Start is called before the first frame update + /// + void Start() + { + TestNewUser(); + TestUserAddCourse(); + TestUserAddMinigame(); + TestGetRecentCoursesEmpty(); + TestGetRecentCoursesAll(); + TestGetRecommendedCoursesEmpty(); + TestGetRecommendedCoursesAll(); + TestGetCourseProgressNull(); + TestGetCourseProgressValid(); + TestGetMinigameProgressNull(); + TestGetMinigameProgressValid(); + } + + /// + /// Test for the creation of a new user + /// + public void TestNewUser() + { + User user = new User(); + Debug.Assert(user != null); + Debug.Assert(user.courses.Count == 0); + Debug.Assert(user.minigames.Count == 0); + } + + /// + /// Test whether progress on a new course can be added + /// + public void TestUserAddCourse() + { + User user = new User(); + Progress p = new Progress(); + user.courses.Add(p); + Debug.Assert(user.courses.Count == 1); + Debug.Assert(user.minigames.Count == 0); + } + + /// + /// Test whether progress on a new minigame can be added + /// + public void TestUserAddMinigame() + { + User user = new User(); + Progress p = new Progress(); + user.minigames.Add(p); + Debug.Assert(user.courses.Count == 0); + Debug.Assert(user.minigames.Count == 1); + } + + /// + /// Test GetRecentCourses will return empty when no progress is stored + /// + public void TestGetRecentCoursesEmpty() + { + User user = new User(); + Debug.Assert(user.GetRecentCourses().Count == 0); + } + + /// + /// Temporary test for GetRecentCourses will return all progress that is stored + /// + public void TestGetRecentCoursesAll() + { + User user = new User(); + Progress p = new Progress(); + p.AddOrUpdate("courseIndex", CourseIndex.FINGERSPELLING); + p.AddOrUpdate("courseProgress", 0.5f); + user.courses.Add(p); + List> list = user.GetRecentCourses(); + Debug.Assert(list.Count == 1); + Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING); + Debug.Assert(list[0].Item2 == 0.5f); + } + + /// + /// Test GetRecommendedCourses will return Tuple when no progress is stored + /// + public void TestGetRecommendedCoursesEmpty() + { + User user = new User(); + List> list = user.GetRecommendedCourses(); + Debug.Assert(list.Count == 1); + Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING); + Debug.Assert(list[0].Item2 == 0.0f); + } + + /// + /// Temporary test for GetRecommenedCourses will return all progress that is stored + /// + public void TestGetRecommendedCoursesAll() + { + User user = new User(); + Progress p = new Progress(); + p.AddOrUpdate("courseIndex", CourseIndex.FINGERSPELLING); + p.AddOrUpdate("courseProgress", 0.5f); + user.courses.Add(p); + List> list = user.GetRecommendedCourses(); + Debug.Assert(list.Count == 1); + Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING); + Debug.Assert(list[0].Item2 == 0.5f); + } + + /// + /// Test GetCourseProgress returns null when course cannot be found + /// + public void TestGetCourseProgressNull() + { + User user = new User(); + Debug.Assert(user.GetCourseProgress(CourseIndex.FINGERSPELLING) == null); + Debug.Assert(user.GetCourseProgress((CourseIndex)100) == null); + } + + /// + /// Test GetCourseProgress returns correct progress object + /// + public void TestGetCourseProgressValid() + { + User user = new User(); + Progress p = new Progress(); + p.AddOrUpdate("courseIndex", CourseIndex.FINGERSPELLING); + p.AddOrUpdate("courseProgress", 3.14159265f); + user.courses.Add(p); + Progress q = user.GetCourseProgress(CourseIndex.FINGERSPELLING); + Debug.Assert(q.Get("courseIndex") == CourseIndex.FINGERSPELLING); + Debug.Assert(q.Get("courseProgress") == 3.14159265f); + } + + /// + /// Test GetMinigameProgress returns null when minigame cannot be found + /// + public void TestGetMinigameProgressNull() + { + User user = new User(); + Debug.Assert(user.GetMinigameProgress(MinigameIndex.SPELLING_BEE) == null); + Debug.Assert(user.GetMinigameProgress((MinigameIndex)100) == null); + + Progress p = new Progress(); + p.AddOrUpdate("minigameIndex", MinigameIndex.SPELLING_BEE); + user.minigames.Add(p); + Debug.Assert(user.GetMinigameProgress(MinigameIndex.HANGMAN) == null); + } + + /// + /// Test GetMinigameProgress returns correct progress object + /// + public void TestGetMinigameProgressValid() + { + User user = new User(); + Progress p = new Progress(); + p.AddOrUpdate("minigameIndex", MinigameIndex.SPELLING_BEE); + user.minigames.Add(p); + Progress q = user.GetMinigameProgress(MinigameIndex.SPELLING_BEE); + Debug.Assert(q.Get("minigameIndex") == CourseIndex.FINGERSPELLING); + } +} diff --git a/Assets/Accounts/Tests/TestUser.cs.meta b/Assets/Accounts/Tests/TestUser.cs.meta new file mode 100644 index 0000000..60f1ad2 --- /dev/null +++ b/Assets/Accounts/Tests/TestUser.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 97bd2549f1c48d34db7cbccca17fc336 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Accounts/Tests/TestUserCreationScreen.cs b/Assets/Accounts/Tests/TestUserCreationScreen.cs index f0166c7..8eb4efd 100644 --- a/Assets/Accounts/Tests/TestUserCreationScreen.cs +++ b/Assets/Accounts/Tests/TestUserCreationScreen.cs @@ -1,13 +1,22 @@ using UnityEngine; +/// +/// Test the UserCreationScreen class +/// public class TestUserCreationScreen : MonoBehaviour { + /// + /// Start is called before the first frame update + /// void Start() { TestIsValidUsernameTrue(); TestIsValidUsernameFalse(); } + /// + /// Tets IsValidUsername will return true for an valid username + /// public void TestIsValidUsernameTrue() { foreach (char c in "abcdefghijklmnopqrstuvwxyz") @@ -16,6 +25,9 @@ public class TestUserCreationScreen : MonoBehaviour Debug.Assert(UserCreationScreen.IsValidUsername("abcdefghijkl")); } + /// + /// Tets IsValidUsername will return false for an invalid username + /// public void TestIsValidUsernameFalse() { Debug.Assert(!UserCreationScreen.IsValidUsername(string.Empty)); diff --git a/Assets/Common/Scripts/ChangeSceneOnClick.cs b/Assets/Common/Scripts/ChangeSceneOnClick.cs index 9cd6c42..7e7b0d9 100644 --- a/Assets/Common/Scripts/ChangeSceneOnClick.cs +++ b/Assets/Common/Scripts/ChangeSceneOnClick.cs @@ -1,21 +1,33 @@ using UnityEngine; using UnityEngine.SceneManagement; +/// +/// Class to handle scene loading callbacks +/// public class ChangeSceneOnClick : MonoBehaviour { - // Load scene from path name + /// + /// Method used as callback for gameobject onClick events + /// + /// The path to the new scene (path == $"Assets/{sceneName}") public void LoadScene(string sceneName) { SceneManager.LoadScene(sceneName); } - // Load scene from reference + /// + /// Method used as callback for gameobject onClick events + /// + /// Reference to a scene public void LoadScene(Scene scene) { SceneManager.LoadScene(scene.buildIndex); } - // Load scene from build index + /// + /// Method used as callback from gameobject onClick events + /// + /// Build index of the scene to be loaded public void LoadScene(int buildIndex) { SceneManager.LoadScene(buildIndex); diff --git a/Assets/Common/Scripts/CourseItem.cs b/Assets/Common/Scripts/CourseItem.cs index b00e9d0..4b709c7 100644 --- a/Assets/Common/Scripts/CourseItem.cs +++ b/Assets/Common/Scripts/CourseItem.cs @@ -3,33 +3,58 @@ using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +/// +/// Handles the display of courses in the ListCourseScreen and CourseScreenManager scene +/// public class CourseItem : MonoBehaviour { - [Header("Course")] - // Reference to the course + /// + /// Reference to the course object + /// public Course course; - // Progress of the current user on this course + + /// + /// Progress of the current user on this specific course + /// public float progress; - [Header("UI references")] - // Reference to thumbnail object + /// + /// UI Reference to the image for displaying the course thumbnail + /// public Image thumbnail; - // Reference to title object + + /// + /// UI Reference to the gameobject for displaying the course title + /// public TMP_Text title; - // Refetence to object so correct callback can be trigger on click + + /// + /// UI Reference to the button so the correct callback can be trigger on click + /// public Button button; - // Reference to progress bar + + /// + /// Reference to the slider that displays the progress of the user + /// public GameObject slider; - // Reference to `COMPLETED` + + /// + /// Reference to the gameobject that holds the text 'COMPLETED' + /// public GameObject completed; - + /// + /// Start is called before the first frame update + /// void Start() { // Use public function so that this component can get Instantiated GenerateContent(); } + /// + /// (Re)generate the CourseItem object and update its appearance + /// public void GenerateContent() { // Set appearance diff --git a/Assets/Common/Scripts/CourseListManager.cs b/Assets/Common/Scripts/CourseListManager.cs index d953f1d..40548a1 100644 --- a/Assets/Common/Scripts/CourseListManager.cs +++ b/Assets/Common/Scripts/CourseListManager.cs @@ -1,20 +1,29 @@ using UnityEngine; using UnityEngine.SceneManagement; +/// +/// ListCourseScreen scene manager +/// public class CourseListManager : MonoBehaviour { - [Header("Course list UI components")] - // Reference to course-list holder object + /// + /// Reference to the course-list container object + /// public Transform courseContainer; - [Header("Prefabs")] - // Prefab of item + /// + /// Prefab of the course item object + /// public GameObject courseItemPrefab; - [Header("Courses")] - // Reference to the list of all courses + /// + /// Reference to the list of all courses + /// public CourseList courseList; + /// + /// Start is called before the first frame update + /// void Start() { foreach (Course course in courseList.courses) @@ -28,7 +37,10 @@ public class CourseListManager : MonoBehaviour } } - // Method used as callback for on click events + /// + /// Method used as callback for course item onClick events + /// + /// The path to the new scene (path == $"Assets/{sceneName}") public void LoadScene(string sceneName) { SceneManager.LoadScene(sceneName); diff --git a/Assets/Common/Scripts/CourseScreenManager.cs b/Assets/Common/Scripts/CourseScreenManager.cs index e542a94..9b223a5 100644 --- a/Assets/Common/Scripts/CourseScreenManager.cs +++ b/Assets/Common/Scripts/CourseScreenManager.cs @@ -3,26 +3,44 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; +/// +/// CourseScreen scene manager +/// public class CourseScreenManager : MonoBehaviour { - [Header("Course Screen Components")] - // Reference to text that displays when there are no recent courses + /// + /// Reference to text that displays when there are no recent courses + /// public GameObject noRecentCourses; - // Reference to recent-courses-list holder object + + /// + /// Reference to recent-courses-list container object + /// public Transform recentCoursesContainer; - // Reference to recommended-courses-list holder object + + /// + /// Reference to recommended-courses-list container object + /// public Transform recommendedCoursesContainer; - [Header("Prefabs")] - // CourseItem prefab + /// + /// Prefab of the course item object + /// public GameObject courseItem; - [Header("User")] - // Reference to the users so we can get the current user; + /// + /// Reference to the users so we can get the current user; + /// public UserList userList; - // Reference to the courses + + /// + /// Reference to the courses + /// public CourseList courseList; + /// + /// Start is called before the first frame update + /// void Start() { User user = userList.GetCurrentUser(); @@ -55,7 +73,10 @@ public class CourseScreenManager : MonoBehaviour } } - // Method used as callback for on click events + /// + /// Method used as callback for course item onClick events + /// + /// The path to the new scene (path == $"Assets/{sceneName}") public void LoadScene(string sceneName) { SceneManager.LoadScene(sceneName); diff --git a/Assets/Common/Scripts/Minigame.cs b/Assets/Common/Scripts/Minigame.cs index c479817..7217fef 100644 --- a/Assets/Common/Scripts/Minigame.cs +++ b/Assets/Common/Scripts/Minigame.cs @@ -1,19 +1,33 @@ using UnityEngine; +/// +/// Class for holding all (static) data about a certain minigame +/// [CreateAssetMenu(menuName = "Create new Scriptable/Minigame")] public class Minigame : ScriptableObject { - [Header("Minigame info")] - // Minigame index + /// + /// Index of the minigame + /// public MinigameIndex index; - // Minigame title + + /// + /// The minigame title + /// public string title; - // Short desciption of the course + + /// + /// A short description of the minigame + /// public string description; - // Thumbnail of the course + + /// + /// Reference to the minigame thumbnail + /// public Sprite thumbnail; - [Header("Scene")] - // Reference to the minigame starting scene + /// + /// The path to the minigame starting scene (path == $"Assets/{minigameEntryPoint}") + /// public string minigameEntryPoint; } diff --git a/Assets/Common/Scripts/MinigameIndex.cs b/Assets/Common/Scripts/MinigameIndex.cs index 8019e99..9588381 100644 --- a/Assets/Common/Scripts/MinigameIndex.cs +++ b/Assets/Common/Scripts/MinigameIndex.cs @@ -1,5 +1,7 @@ -// TODO: add other courses +/// +/// Enum for easy indexing and checking if a minigame is of a certain kind +/// public enum MinigameIndex { SPELLING_BEE, diff --git a/Assets/Common/Scripts/MinigameItem.cs b/Assets/Common/Scripts/MinigameItem.cs index 398e284..0497a73 100644 --- a/Assets/Common/Scripts/MinigameItem.cs +++ b/Assets/Common/Scripts/MinigameItem.cs @@ -3,27 +3,43 @@ using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; +/// +/// Handles the display of minigames in the ListMinigameScreen scene +/// public class MinigameItem : MonoBehaviour { - // TODO: change to ScriptableObject Minigame; - [Header("ScriptableObject Course")] + /// + /// Reference to the minigame object + /// public Minigame minigame; - [Header("UI references")] - // Reference to thumbnail object + /// + /// UI Reference to the image for displaying the minigame thumbnail + /// public Image thumbnail; - // Reference to title object + + /// + /// UI Reference to the gameobject for displaying the minigame title + /// public TMP_Text title; - // Refetence to object so correct callback can be trigger on click + + /// + /// UI Reference to the button so the correct callback can be trigger on click + /// public Button button; - + /// + /// Start is called before the first frame update + /// void Start() { // Use public function so that this component can get Instantiated GenerateContent(); } + /// + /// (Re)generate the MinigameItem object and update its appearance + /// public void GenerateContent() { // Set appearance diff --git a/Assets/Common/Scripts/MinigameList.cs b/Assets/Common/Scripts/MinigameList.cs index aa62b30..59b9588 100644 --- a/Assets/Common/Scripts/MinigameList.cs +++ b/Assets/Common/Scripts/MinigameList.cs @@ -1,14 +1,20 @@ using System.Collections.Generic; using UnityEngine; + +/// +/// Keep track off installed minigames +/// [CreateAssetMenu(menuName = "Create new Scriptable/MinigameList")] public class MinigameList : ScriptableObject { - [Header("Current Minigame")] - // Index of the current course + /// + /// Index of the active/to be loaded/current minigame + /// public int currentMinigameIndex = 0; - [Header("Minigames")] - // List of minigames + /// + /// List of all installed minigames + /// public List minigames = new List(); } diff --git a/Assets/Common/Scripts/MinigameListManager.cs b/Assets/Common/Scripts/MinigameListManager.cs index daf4d07..44fb9f6 100644 --- a/Assets/Common/Scripts/MinigameListManager.cs +++ b/Assets/Common/Scripts/MinigameListManager.cs @@ -1,20 +1,29 @@ using UnityEngine; using UnityEngine.SceneManagement; +/// +/// ListMinigameScreen scene manager +/// public class MinigameListManager : MonoBehaviour { - [Header("Minigame list UI components")] - // Reference to minigame-list holder object + /// + /// Reference to minigame-list container object + /// public Transform minigameContainer; - [Header("Prefabs")] - // Prefab of item + /// + /// Prefab of the minigame item object + /// public GameObject minigameItemPrefab; - [Header("Minigames")] - // Reference to the list of all minigames + /// + /// Reference to the list of all minigames + /// public MinigameList minigameList; + /// + /// Start is called before the first frame update + /// void Start() { foreach (Minigame minigame in minigameList.minigames) @@ -28,7 +37,10 @@ public class MinigameListManager : MonoBehaviour } } - // Method used as callback for on click events + /// + /// Method used as callback for minigame item onClick events + /// + /// The path to the new scene (path == $"Assets/{sceneName}") public void LoadScene(string sceneName) { SceneManager.LoadScene(sceneName); diff --git a/Assets/Common/Scripts/StartScreenManager.cs b/Assets/Common/Scripts/StartScreenManager.cs index 40a8cfb..45b4046 100644 --- a/Assets/Common/Scripts/StartScreenManager.cs +++ b/Assets/Common/Scripts/StartScreenManager.cs @@ -1,14 +1,21 @@ -using System.Collections; -using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.SceneManagement; +/// +/// StartScreen scene manager +/// public class StartScreenManager : MonoBehaviour { - + /// + /// Referece to the userlist to check whether an user account is present + /// public UserList userList; + /// + /// Check on load whether a user is already present, + /// if not load the UserCreationScreen scene so the user can create a new account + /// void Awake() { if (!File.Exists(UserList.PATH) || userList.GetUsers().Count <= 0) diff --git a/Assets/Common/Scripts/UserButton.cs b/Assets/Common/Scripts/UserButton.cs index 0468eb1..f7ea71c 100644 --- a/Assets/Common/Scripts/UserButton.cs +++ b/Assets/Common/Scripts/UserButton.cs @@ -2,18 +2,29 @@ using TMPro; using UnityEngine; using UnityEngine.UI; +/// +/// Handles actions when a user presses the account button (upper left corner) +/// public class UserButton : MonoBehaviour { - [Header("User")] - // Reference to the user list, so we can extract the current user + /// + /// Reference to the user list, so we can extract the current user + /// public UserList userList; - [Header("UI References")] - // Reference to the avatar object + /// + /// UI Reference to the avatar object + /// public Image avatar; - // Reference to the username object + + /// + /// UI Reference to the username object + /// public TMP_Text username; + /// + /// Start is called before the first frame update + /// void Start() { User user = userList.GetCurrentUser(); diff --git a/Assets/Courses/Scripts/Course.cs b/Assets/Courses/Scripts/Course.cs index 6b6f6af..8275335 100644 --- a/Assets/Courses/Scripts/Course.cs +++ b/Assets/Courses/Scripts/Course.cs @@ -3,32 +3,56 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.Video; +/// +/// Class for holding all (static) data about a certain course +/// [CreateAssetMenu(menuName = "Create new Scriptable/Course")] public class Course : ScriptableObject { + /// + /// Small class to hold information about a single learnable (e.g., a word or a letter) + /// [Serializable] - // Small class to hold information about a single learnable (e.g., a word or a letter) public class Learnable { - // Name of the word/letter to learn + /// + /// Name of the word/letter to learn + /// public string name; - // Sprite of this word/letter + + /// + /// Sprite of this word/letter + /// public Sprite image; - // Example video clip + + /// + /// Example video clip + /// public VideoClip clip; } - [Header("Course info")] - // Course index + /// + /// Index of the course + /// public CourseIndex index; - // Course title + + /// + /// The course title + /// public string title; - // Short desciption of the course + + /// + /// A short description of the course + /// public string description; - // Thumbnail of the course + + /// + /// Reference to the course thumbnail + /// public Sprite thumbnail; - [Header("Learnable words")] - // List of learnable words/letters + /// + /// List of all learnable words/letters + /// public List learnables = new List(); } diff --git a/Assets/Courses/Scripts/CourseIndex.cs b/Assets/Courses/Scripts/CourseIndex.cs index 1917461..418dda4 100644 --- a/Assets/Courses/Scripts/CourseIndex.cs +++ b/Assets/Courses/Scripts/CourseIndex.cs @@ -1,5 +1,7 @@ -// TODO: add other courses +/// +/// Enum for easy indexing and checking if a course is of a certain kind +/// public enum CourseIndex { FINGERSPELLING diff --git a/Assets/Courses/Scripts/CourseList.cs b/Assets/Courses/Scripts/CourseList.cs index cb15777..a5b4539 100644 --- a/Assets/Courses/Scripts/CourseList.cs +++ b/Assets/Courses/Scripts/CourseList.cs @@ -1,14 +1,19 @@ using System.Collections.Generic; using UnityEngine; +/// +/// Keep track of all courses +/// [CreateAssetMenu(menuName = "Create new Scriptable/CourseList")] public class CourseList : ScriptableObject { - [Header("Current Course")] - // Index of the current course + /// + /// Index of the active/to be loaded/current course + /// public int currentCourseIndex = 0; - [Header("Courses")] - // List of courses + /// + /// List of all installed courses + /// public List courses = new List(); } diff --git a/Assets/Courses/Scripts/StartPause.cs b/Assets/Courses/Scripts/StartPause.cs index 86216cd..991b1c7 100644 --- a/Assets/Courses/Scripts/StartPause.cs +++ b/Assets/Courses/Scripts/StartPause.cs @@ -1,7 +1,7 @@ -using UnityEngine; -using UnityEngine.Video; -using UnityEngine.UI; using TMPro; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.Video; public class StartPause : MonoBehaviour { diff --git a/Assets/Courses/Scripts/Webcam.cs b/Assets/Courses/Scripts/Webcam.cs index 605985d..5bc00dd 100644 --- a/Assets/Courses/Scripts/Webcam.cs +++ b/Assets/Courses/Scripts/Webcam.cs @@ -1,7 +1,7 @@ -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.SceneManagement; using TMPro; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; public class Webcam : MonoBehaviour { @@ -13,7 +13,8 @@ public class Webcam : MonoBehaviour public GameObject popup; public TextMeshProUGUI dynamic; - void Awake(){ + void Awake() + { popup.SetActive(false); WebCamDevice device = WebCamTexture.devices[camdex]; @@ -55,20 +56,25 @@ public class Webcam : MonoBehaviour SceneManager.LoadScene(sceneName); } - public void Show_feedback(){ - if(popup.activeSelf){ + public void Show_feedback() + { + if (popup.activeSelf) + { dynamic.text = ""; popup.SetActive(false); return; } double index = UnityEngine.Random.value; - if(index < 0.5){ + if (index < 0.5) + { dynamic.text = "Poor"; } - else if(index > 0.8){ + else if (index > 0.8) + { dynamic.text = "Excellent"; } - else{ + else + { dynamic.text = "Good"; } popup.SetActive(true); diff --git a/Assets/EditModeTests/BasicTest.cs b/Assets/EditModeTests/BasicTest.cs index ac439c1..6c756b8 100644 --- a/Assets/EditModeTests/BasicTest.cs +++ b/Assets/EditModeTests/BasicTest.cs @@ -1,8 +1,4 @@ -using System.Collections; -using System.Collections.Generic; using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; public class BasicTest { diff --git a/Assets/PlayModeTests/BasicTest.cs b/Assets/PlayModeTests/BasicTest.cs index 6b2425c..1aee8e9 100644 --- a/Assets/PlayModeTests/BasicTest.cs +++ b/Assets/PlayModeTests/BasicTest.cs @@ -1,8 +1,4 @@ -using System.Collections; -using System.Collections.Generic; using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; public class BasicTest { diff --git a/Assets/SpellingBee/Scripts/GameController.cs b/Assets/SpellingBee/Scripts/GameController.cs index b0aa81f..d4f61b1 100644 --- a/Assets/SpellingBee/Scripts/GameController.cs +++ b/Assets/SpellingBee/Scripts/GameController.cs @@ -1,6 +1,6 @@ +using System; using System.Collections; using System.Collections.Generic; -using System; using TMPro; using UnityEngine; using UnityEngine.UI; diff --git a/Assets/SpellingBee/Scripts/SpellingBeeWebcam.cs b/Assets/SpellingBee/Scripts/SpellingBeeWebcam.cs index b2964ce..4db4025 100644 --- a/Assets/SpellingBee/Scripts/SpellingBeeWebcam.cs +++ b/Assets/SpellingBee/Scripts/SpellingBeeWebcam.cs @@ -1,9 +1,7 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.SceneManagement; using TMPro; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; public class SpellingBeeWebcam : MonoBehaviour { @@ -13,7 +11,8 @@ public class SpellingBeeWebcam : MonoBehaviour public RawImage display; public TextMeshProUGUI dynamic; - void Awake(){ + void Awake() + { //popup.SetActive(false); WebCamDevice device = WebCamTexture.devices[camdex]; diff --git a/Assets/SpellingBee/Scripts/ThemeItem.cs b/Assets/SpellingBee/Scripts/ThemeItem.cs index af2a9b1..c0c3697 100644 --- a/Assets/SpellingBee/Scripts/ThemeItem.cs +++ b/Assets/SpellingBee/Scripts/ThemeItem.cs @@ -3,29 +3,54 @@ using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; +/// +/// Handles the display of themes in the ThemeSelectionController scene +/// public class ThemeItem : MonoBehaviour { - // TODO: change to ScriptableObject Theme; - [Header("ScriptableObject Theme")] + /// + /// The theme title + /// public string themeTitle; + + /// + /// A short description of the theme + /// public string themeDescription; + + /// + /// The callback function to start the game with the correct theme loaded + /// public UnityAction startGameCallback; - [Header("UI references")] - // Reference to thumbnail object + /// + /// UI reference to the gameobject for displaying the theme title + /// public TMP_Text title; - // Reference to description object + + /// + /// UI reference to the gameobject for displaying the description + /// public TMP_Text description; - // Refetence to object so correct callback can be trigger on click + + /// + /// UI reference to the button so the correct callback can be trigger on click + /// public Button button; + /// + /// Start is called before the first frame update + /// void Start() { // Use public function so that this component can get Instantiated GenerateContent(); } + /// + /// (Re)generate the ThemeItem object and update its appearance + /// public void GenerateContent() { // Set appearance