diff --git a/Carter Games/The Cart/Code/Editor/Core/Attributes.meta b/Carter Games/The Cart/Code/Editor/Core/Attributes.meta new file mode 100644 index 00000000..7318183e --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Attributes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 326b21d1d48a40dea33b5e4237637515 +timeCreated: 1716363193 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly.meta b/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly.meta new file mode 100644 index 00000000..2cecd86e --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 61eaa557209747de858db9ad3d3255bb +timeCreated: 1720029219 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly/ReadonlyAttributePropertyDrawer.cs b/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly/ReadonlyAttributePropertyDrawer.cs new file mode 100644 index 00000000..299829a5 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly/ReadonlyAttributePropertyDrawer.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Cart.Core; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.TheCart.Core.Editor +{ + [CustomPropertyDrawer(typeof(ReadonlyAttribute), true)] + public class ReadonlyPropertyDrawer : PropertyDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + EditorGUI.BeginProperty(position, label, property); + + EditorGUI.BeginDisabledGroup(true); + EditorGUI.PropertyField(position, property, label); + EditorGUI.EndDisabledGroup(); + + EditorGUI.EndProperty(); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/AssetIndexHandler.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly/ReadonlyAttributePropertyDrawer.cs.meta similarity index 86% rename from Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/AssetIndexHandler.cs.meta rename to Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly/ReadonlyAttributePropertyDrawer.cs.meta index ecc28e6f..28f4bd4c 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/AssetIndexHandler.cs.meta +++ b/Carter Games/The Cart/Code/Editor/Core/Attributes/Readonly/ReadonlyAttributePropertyDrawer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3169e224661246b0858356cec045c032 +guid: b3502d6a43654d1c85c838a7db6ca113 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/The Cart/Code/Editor/Core/Data.meta b/Carter Games/The Cart/Code/Editor/Core/Data.meta new file mode 100644 index 00000000..f7ddb6e7 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6f3e850b2a6645398859387d10960d43 +timeCreated: 1720002567 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool.meta new file mode 100644 index 00000000..9bc0d21d --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c21c38561d6c4badb9edd2d52e6c7e3c +timeCreated: 1706562393 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetCreator.cs b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetCreator.cs new file mode 100644 index 00000000..f0758253 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetCreator.cs @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.IO; +using CarterGames.Cart.Core.Management.Editor; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Cart.Core.Data.Editor +{ + /// + /// Creates data asset for the user. + /// + public sealed class DataAssetCreator : EditorWindow + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private string dataAssetName; + private bool makeDataAssetWhenGenerated; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Menu Items + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Makes a menu item for the creator to open. + /// + [MenuItem("Tools/Carter Games/The Cart/Core/Data/Asset Creator", priority = 515)] + private static void ShowWindow() + { + var window = GetWindow(); + window.titleContent = new GUIContent("Data Asset Creator"); + window.Show(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Draws the GUI. + /// + private void OnGUI() + { + GUILayout.Space(4f); + + EditorGUILayout.BeginVertical("HelpBox"); + GUILayout.Space(1.5f); + + EditorGUILayout.LabelField("Data Asset Name", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + dataAssetName = EditorGUILayout.TextField(dataAssetName); + + GUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + + GUILayout.Space(4f); + + EditorGUILayout.BeginVertical("HelpBox"); + GUILayout.Space(1.5f); + + EditorGUILayout.LabelField("Will create:", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.LabelField(new GUIContent("DataAsset: "), + new GUIContent("DataAsset" + dataAssetName + ".cs")); + + GUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + + GUILayout.Space(4f); + + if (GUILayout.Button("Create")) + { + CreateAssetFile(out string path); + + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + + EditorUtility.RequestScriptReload(); + + if (Dialogue.Display("Data Asset Creator", + "Would you like to open the newly created files for editing?", "Yes", "No")) + { + AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath(path)); + } + } + } + + + /// + /// Creates the asset file for the data class the user is making. + /// + /// The path to create at. + private void CreateAssetFile(out string filePath) + { + filePath = EditorUtility.SaveFilePanelInProject("Save New Data Asset Class", + $"DataAsset{dataAssetName}", "cs", ""); + + var script = AssetDatabase.FindAssets($"t:Script {nameof(DataAssetCreator)}")[0]; + var pathToTextFile = AssetDatabase.GUIDToAssetPath(script); + pathToTextFile = pathToTextFile.Replace("DataAssetCreator.cs", "DataAssetTemplate.txt"); + + TextAsset template = AssetDatabase.LoadAssetAtPath(pathToTextFile); + template = new TextAsset(template.text); + var replace = template.text.Replace("%DataAssetName%", "DataAsset" + dataAssetName); + replace = replace.Replace("%DataTypeName%", "Data" + dataAssetName); + + File.WriteAllText(filePath, replace); + EditorUtility.SetDirty(AssetDatabase.LoadAssetAtPath(pathToTextFile)); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors/CartSoLibraryAssetIndexEditor.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetCreator.cs.meta similarity index 86% rename from Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors/CartSoLibraryAssetIndexEditor.cs.meta rename to Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetCreator.cs.meta index 5e356f85..73d90439 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors/CartSoLibraryAssetIndexEditor.cs.meta +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetCreator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3236d95d75ca4ecb9336f356f8e53f36 +guid: b4d78b0bd77e4acd81b66ea884271f55 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetTemplate.txt b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetTemplate.txt new file mode 100644 index 00000000..09def6de --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetTemplate.txt @@ -0,0 +1,12 @@ +using CarterGames.Cart.Core.Data; +using UnityEngine; + + +namespace Data +{ + [CreateAssetMenu(fileName = "%DataAssetName%")] + public class %DataAssetName% : DataAsset + { + + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetTemplate.txt.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetTemplate.txt.meta new file mode 100644 index 00000000..afb9b363 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Creator Tool/DataAssetTemplate.txt.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 06110f6da461479f9e42d2347a10b442 +timeCreated: 1705435296 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors.meta new file mode 100644 index 00000000..69a73f33 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7b9d7cca72d141a2bf8f67b576990efd +timeCreated: 1706562361 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors.meta new file mode 100644 index 00000000..b29fe5d7 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b3403f2c3f3548839266153bd047b013 +timeCreated: 1706562373 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors/CartSoLibraryAssetIndexEditor.cs b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors/DataAssetIndexEditor.cs similarity index 91% rename from Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors/CartSoLibraryAssetIndexEditor.cs rename to Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors/DataAssetIndexEditor.cs index f62f8eeb..85405093 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors/CartSoLibraryAssetIndexEditor.cs +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors/DataAssetIndexEditor.cs @@ -14,7 +14,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN @@ -22,16 +22,14 @@ */ using System.Collections.Generic; +using CarterGames.Cart.Core.Management.Editor; using UnityEditor; using UnityEngine; -namespace CarterGames.Cart.Core.Management.Editor +namespace CarterGames.Cart.Core.Data.Editor { - /// - /// Handles the custom inspector for the Audio Manager asset index. - /// - [CustomEditor(typeof(CartSoAssetIndex))] - public sealed class CartSoLibraryAssetIndexEditor : UnityEditor.Editor + [CustomEditor(typeof(DataAssetIndex))] + public class DataAssetIndexEditor : UnityEditor.Editor { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields @@ -63,7 +61,7 @@ public override void OnInspectorGUI() EditorGUILayout.BeginVertical("HelpBox"); GUILayout.Space(1.5f); - GeneralUtilEditor.DrawSoScriptSection((CartSoAssetIndex) target); + GeneralUtilEditor.DrawSoScriptSection((DataAssetIndex) target); GUILayout.Space(1.5f); EditorGUILayout.EndVertical(); @@ -77,7 +75,7 @@ public override void OnInspectorGUI() if (GUILayout.Button("Refresh Index")) { - AssetIndexHandler.UpdateIndex(); + DataAssetIndexHandler.UpdateIndex(); } GUILayout.Space(1.5f); @@ -107,11 +105,15 @@ private void DrawAllReferencesSection() GeneralUtilEditor.DrawHorizontalGUILine(); EditorGUI.indentLevel++; + + EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(Application.isPlaying); - EditorGUILayout.PropertyField(serializedObject.Fp("assets")); + EditorGUILayout.PropertyField(serializedObject.Fp("assets").Fpr("list")); EditorGUI.EndDisabledGroup(); + EditorGUILayout.EndHorizontal(); + EditorGUI.indentLevel--; GUILayout.Space(1.5f); diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleData.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors/DataAssetIndexEditor.cs.meta similarity index 86% rename from Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleData.cs.meta rename to Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors/DataAssetIndexEditor.cs.meta index b100cb57..9ae8569c 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleData.cs.meta +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Custom Editors/Inspectors/DataAssetIndexEditor.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e46278b4c19a43c3833a2a08dd0d3a91 +guid: 534d2b593fce4f48b06a40281a4c0831 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/AssetIndexHandler.cs b/Carter Games/The Cart/Code/Editor/Core/Data/DataAssetIndexHandler.cs similarity index 75% rename from Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/AssetIndexHandler.cs rename to Carter Games/The Cart/Code/Editor/Core/Data/DataAssetIndexHandler.cs index 6226cc51..767eca00 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/AssetIndexHandler.cs +++ b/Carter Games/The Cart/Code/Editor/Core/Data/DataAssetIndexHandler.cs @@ -22,43 +22,36 @@ */ using System.Collections.Generic; +using CarterGames.Cart.Core.Management.Editor; using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; -namespace CarterGames.Cart.Core.Management.Editor +namespace CarterGames.Cart.Core.Data.Editor { /// /// Handles the setup of the asset index for runtime references to scriptable objects used for the asset. /// - public sealed class AssetIndexHandler : IPreprocessBuildWithReport, IAssetEditorInitialize + public sealed class DataAssetIndexHandler : IPreprocessBuildWithReport { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static string AssetFilter => "t:" + nameof(CartSoAsset); + internal static readonly string DataAssetIndexPath = $"{ScriptableRef.AssetBasePath}/Carter Games/The Cart/Resources/Data Asset Index.asset"; + private static DataAssetIndex dataAssetIndexCache; + private static readonly string DataAssetIndexFilter = $"t:{typeof(DataAssetIndex).FullName}"; + private const string AssetFilter = "t:dataasset"; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── - | IAssetEditorInitialize Implementation + | Properties ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - - /// - /// Defines the order that this initializer run at. - /// - public int InitializeOrder => 1; - /// - /// Runs when the asset initialize flow is used. + /// The data asset index for the asset. /// - public void OnEditorInitialized() - { - EditorApplication.update -= OnEditorUpdate; - EditorApplication.update += OnEditorUpdate; - - UpdateIndex(); - } + public static DataAssetIndex DataAssetIndex => + FileEditorUtil.CreateSoGetOrAssignAssetCache(ref dataAssetIndexCache, DataAssetIndexFilter, DataAssetIndexPath, "The Cart", $"The Cart/Resources/Data Asset Index.asset"); /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | IPreprocessBuildWithReport Implementation @@ -105,13 +98,30 @@ private static void OnEditorUpdate() } + /// + /// Tries to make the asset index if it doesn't exist yet. + /// + internal static void TryMakeIndex() + { + if (dataAssetIndexCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref dataAssetIndexCache, + DataAssetIndexFilter, + DataAssetIndexPath, + "The Cart", "The Cart/Resources/Data Asset Index.asset"); + + } + } + + /// /// Updates the index with all the save manager asset scriptable objects in the project. /// - [MenuItem("Tools/Carter Games/The Cart/Management/Update Asset Index")] + [MenuItem("Tools/Carter Games/The Cart/Core/Data/Update Asset Index", priority = 516)] public static void UpdateIndex() { - var foundAssets = new List(); + var foundAssets = new List(); var asset = AssetDatabase.FindAssets(AssetFilter, null); if (asset == null || asset.Length <= 0) return; @@ -119,18 +129,19 @@ public static void UpdateIndex() foreach (var assetInstance in asset) { var assetPath = AssetDatabase.GUIDToAssetPath(assetInstance); - var assetObj = (CartSoAsset) AssetDatabase.LoadAssetAtPath(assetPath, typeof(CartSoAsset)); + var assetObj = (DataAsset) AssetDatabase.LoadAssetAtPath(assetPath, typeof(DataAsset)); // Doesn't include editor only or the index itself. if (assetObj == null) continue; - if (assetObj.GetType() == typeof(CartSoAssetIndex)) continue; - foundAssets.Add((CartSoAsset) AssetDatabase.LoadAssetAtPath(assetPath, typeof(CartSoAsset))); + if (assetObj.Equals(UtilEditor.AssetIndex)) continue; + + foundAssets.Add((DataAsset) AssetDatabase.LoadAssetAtPath(assetPath, typeof(DataAsset))); } - var indexProp = new SerializedObject(UtilEditor.AssetIndex); + var indexProp = new SerializedObject(DataAssetIndex); RemoveNullReferences(indexProp); - UpdateIndexReferences(foundAssets, indexProp); + UpdateIndexReferences(foundAssets ,indexProp); indexProp.ApplyModifiedProperties(); indexProp.Update(); @@ -163,13 +174,27 @@ private static void RemoveNullReferences(SerializedObject indexProp) /// /// The found assets to update. /// The property to base off. - private static void UpdateIndexReferences(IReadOnlyList foundAssets, SerializedObject indexProp) + private static void UpdateIndexReferences(IReadOnlyList foundAssets, SerializedObject indexProp) { - indexProp.Fp("assets").Fpr("list").ClearArray(); - - for (var i = 0; i < foundAssets.Count; i++) { + for (var j = 0; j < indexProp.Fp("assets").Fpr("list").arraySize; j++) + { + var entry = indexProp.Fp("assets").Fpr("list").GetIndex(j); + + if (entry.Fpr("key").stringValue.Equals(foundAssets[i].GetType().ToString())) + { + for (var k = 0; k < entry.Fpr("value").arraySize; k++) + { + if (entry.Fpr("value").GetIndex(k).objectReferenceValue == foundAssets[i]) goto AlreadyExists; + } + + entry.Fpr("value").InsertIndex(entry.Fpr("value").arraySize); + entry.Fpr("value").GetIndex(entry.Fpr("value").arraySize - 1).objectReferenceValue = foundAssets[i]; + goto AlreadyExists; + } + } + indexProp.Fp("assets").Fpr("list").InsertIndex(indexProp.Fp("assets").Fpr("list").arraySize); indexProp.Fp("assets").Fpr("list").GetIndex(indexProp.Fp("assets").Fpr("list").arraySize - 1).Fpr("key").stringValue = foundAssets[i].GetType().ToString(); @@ -182,6 +207,8 @@ private static void UpdateIndexReferences(IReadOnlyList foundAssets indexProp.Fp("assets").Fpr("list").GetIndex(indexProp.Fp("assets").Fpr("list").arraySize - 1).Fpr("value").InsertIndex(0); indexProp.Fp("assets").Fpr("list").GetIndex(indexProp.Fp("assets").Fpr("list").arraySize - 1) .Fpr("value").GetIndex(0).objectReferenceValue = foundAssets[i]; + + AlreadyExists: ; } } } diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetAccessor.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Data/DataAssetIndexHandler.cs.meta similarity index 86% rename from Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetAccessor.cs.meta rename to Carter Games/The Cart/Code/Editor/Core/Data/DataAssetIndexHandler.cs.meta index 79551a9a..7847e87d 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetAccessor.cs.meta +++ b/Carter Games/The Cart/Code/Editor/Core/Data/DataAssetIndexHandler.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5a35835c4f1b4d15a55ad8abcb4988d6 +guid: 15c69106a6bc4bf98bf8dec1a7a8db03 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Initialize.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Initialize.meta new file mode 100644 index 00000000..c14b98de --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Initialize.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 794a85d4157a48f18df55098aba9414d +timeCreated: 1713290032 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleData.cs b/Carter Games/The Cart/Code/Editor/Core/Data/Initialize/EditorInitializeData.cs similarity index 60% rename from Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleData.cs rename to Carter Games/The Cart/Code/Editor/Core/Data/Initialize/EditorInitializeData.cs index 8453e9c2..e21195e5 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleData.cs +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Initialize/EditorInitializeData.cs @@ -1,17 +1,17 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -21,53 +21,33 @@ * THE SOFTWARE. */ -using System; +using System.IO; using CarterGames.Cart.Core.Management.Editor; -namespace CarterGames.Cart.Modules +namespace CarterGames.Cart.Core.Data.Editor { /// - /// A definition for the data module + /// Handles the initialization of the data module index if needed. /// - public sealed class ModuleData : IModule + public sealed class EditorInitializeData : IAssetEditorInitialize { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── - | Properties + | IAssetEditorInitialize Implementation ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ /// - /// The name of the module. + /// The order to execute in. /// - public string ModuleName => "Data"; + public int InitializeOrder { get; } /// - /// A description of what the module does. + /// Runs when the editor is initialized. /// - public string ModuleDescription => "A setup to store data locally in scriptable objects generically with easy runtime referencing."; - - - /// - /// The namespace the module code is under. - /// - public string Namespace => "CarterGames.Cart.Modules.Data"; - - - /// - /// Any modules that are required for the module to work. - /// - public IModule[] PreRequisites => Array.Empty(); - - - /// - /// The path for the package of the module. - /// - public string ModulePackagePath => $"{ScriptableRef.AssetBasePath}/Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage"; - - - /// - /// The path for the installation of the module. - /// - public string ModuleInstallPath => $"{ScriptableRef.AssetBasePath}/Carter Games/The Cart/Modules/Data"; + public void OnEditorInitialized() + { + if (File.Exists(DataAssetIndexHandler.DataAssetIndexPath)) return; + DataAssetIndexHandler.TryMakeIndex(); + } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Initialize/EditorInitializeData.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Initialize/EditorInitializeData.cs.meta new file mode 100644 index 00000000..37442d76 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Initialize/EditorInitializeData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3b215ac0495e46b18ec67348b01ac9ed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Settings.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Settings.meta new file mode 100644 index 00000000..68530930 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Settings.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5222741a8afa417d9d83e7e83f3f298c +timeCreated: 1713252046 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Settings/EditorSettingsData.cs b/Carter Games/The Cart/Code/Editor/Core/Data/Settings/EditorSettingsData.cs new file mode 100644 index 00000000..93570b22 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Settings/EditorSettingsData.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Cart.Core.Management.Editor; + +namespace CarterGames.Cart.Core.Data.Editor +{ + /// + /// Handles the editor settings for the data module. + /// + public static class EditorSettingsData + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private static readonly string EditorDataExpandedId = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_Core_Data_IsExpanded"; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Should the data notion section be shown? + /// + public static bool EditorDataExpanded + { + get => (bool)PerUserSettings.GetOrCreateValue(EditorDataExpandedId, SettingType.EditorPref); + set => PerUserSettings.SetValue(EditorDataExpandedId, SettingType.EditorPref, value); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Data/Settings/EditorSettingsData.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Data/Settings/EditorSettingsData.cs.meta new file mode 100644 index 00000000..7de041b0 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Data/Settings/EditorSettingsData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 905a0e71fee6415cb7d6b99de9b6e82c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/Editors.meta b/Carter Games/The Cart/Code/Editor/Core/Logging/Editors.meta new file mode 100644 index 00000000..423061d3 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/Editors.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d50f3e7430ff4750b30a2612f30307e2 +timeCreated: 1720030410 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/Editors/DataAssetCartLogCategoriesEditor.cs b/Carter Games/The Cart/Code/Editor/Core/Logging/Editors/DataAssetCartLogCategoriesEditor.cs new file mode 100644 index 00000000..dea6e6b5 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/Editors/DataAssetCartLogCategoriesEditor.cs @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Cart.Core.Management.Editor; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Cart.Core.Logs.Editor +{ + /// + /// Handles the custom editor of the log categories data asset. + /// + [CustomEditor(typeof(DataAssetCartLogCategories))] + public sealed class DataAssetCartLogCategoriesEditor : UnityEditor.Editor + { + public override void OnInspectorGUI() + { + EditorGUILayout.Space(2.5f); + + GeneralUtilEditor.DrawSoScriptSection(target); + + EditorGUILayout.Space(2.5f); + + DrawVariantId(); + + EditorGUILayout.Space(2.5f); + + DrawCategories(); + } + + + + private void DrawVariantId() + { + EditorGUILayout.BeginVertical("HelpBox"); + EditorGUILayout.Space(1f); + + EditorGUILayout.LabelField("Data Asset", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + + EditorGUILayout.PropertyField(serializedObject.Fp("variantId")); + + EditorGUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + } + + + + private void DrawCategories() + { + EditorGUILayout.BeginVertical("HelpBox"); + EditorGUILayout.Space(1f); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Categories", EditorStyles.boldLabel); + + GUI.backgroundColor = Color.yellow; + + if (GUILayout.Button("Edit", GUILayout.Width(65))) + { + LibrarySettingsProvider.OpenSettings(); + LoggingSettingsDrawer.ExpandSection(false, true); + } + + GUI.backgroundColor = Color.white; + EditorGUILayout.EndHorizontal(); + + + GeneralUtilEditor.DrawHorizontalGUILine(); + + + for (var i = 0; i < serializedObject.Fp("lookup").Fpr("list").arraySize; i++) + { + EditorGUILayout.BeginHorizontal(); + EditorGUI.BeginDisabledGroup(true); + + EditorGUILayout.LabelField(serializedObject.Fp("lookup").Fpr("list").GetIndex(i).Fpr("key").stringValue); + EditorGUILayout.Toggle(serializedObject.Fp("lookup").Fpr("list").GetIndex(i).Fpr("value").boolValue, GUILayout.Width(15)); + + EditorGUI.EndDisabledGroup(); + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/Editors/DataAssetCartLogCategoriesEditor.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Logging/Editors/DataAssetCartLogCategoriesEditor.cs.meta new file mode 100644 index 00000000..b0d2c4f9 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/Editors/DataAssetCartLogCategoriesEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 432e6efd1f6f45ad80cb3c9fa93dfe4f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/LogCategoryHandler.cs b/Carter Games/The Cart/Code/Editor/Core/Logging/LogCategoryHandler.cs new file mode 100644 index 00000000..0dba4c61 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/LogCategoryHandler.cs @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Collections.Generic; +using System.Linq; +using CarterGames.Cart.Core.Management.Editor; +using CarterGames.Cart.Modules; + +namespace CarterGames.Cart.Core.Logs.Editor +{ + /// + /// Handles log category settings on editor reload. + /// + public sealed class LogCategoryHandler : IAssetEditorReload + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// The default categories for the setup. + /// + private static readonly List DefaultEnabled = new List() + { + typeof(LogCategoryCore).FullName, + typeof(LogCategoryModules).FullName, + "CarterGames.Cart.Modules.NotionData.LogCategoryNotionData", + "CarterGames.Cart.Modules.Panels.LogCategoryPanels", + }; + + + /// + /// The last data that was set, used as a cache before a reload. + /// + private static Dictionary oldData = new Dictionary(); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorReload Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Runs on editor reload after editor delay call. + /// + public void OnEditorReloaded() + { + UpdateCache(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Gets all the categories in the project currently. + /// + /// The found categories. + private static IEnumerable GetCategories() + { + return AssemblyHelper.GetClassesOfType(false).OrderBy(t => t.GetType().Name); + } + + + /// + /// Updates the cache of categories and their settings. + /// + private void UpdateCache() + { + var data = GetCategories(); + + oldData = new Dictionary(); + + for (var i = 0; i < ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list").arraySize; i++) + { + oldData.Add( + ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list").GetIndex(i).Fpr("key").stringValue, + ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list").GetIndex(i).Fpr("value").boolValue); + } + + var lookup = ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list"); + + lookup.ClearArray(); + + foreach (var category in data) + { + lookup.InsertIndex(lookup.arraySize); + + var newEntry = lookup.GetIndex(lookup.arraySize - 1); + + newEntry.Fpr("key").stringValue = category.GetType().FullName; + + var wasSet = false; + var toSetAs = false; + + foreach (var oldDataEntry in oldData) + { + if (oldDataEntry.Key != category.GetType().FullName) continue; + toSetAs = oldDataEntry.Value; + wasSet = true; + break; + } + + if (!wasSet) + { + if (DefaultEnabled.Contains(category.GetType().FullName)) + { + toSetAs = true; + } + } + + + newEntry.Fpr("value").boolValue = toSetAs; + } + + ScriptableRef.LogCategoriesObject.ApplyModifiedProperties(); + ScriptableRef.LogCategoriesObject.Update(); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/LogCategoryHandler.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Logging/LogCategoryHandler.cs.meta new file mode 100644 index 00000000..e1f25320 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/LogCategoryHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ed8196e37e594c2ca7ba23a6dc848d83 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LogCategoryDrawer.cs b/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LogCategoryDrawer.cs new file mode 100644 index 00000000..63ed34b3 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LogCategoryDrawer.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Linq; +using CarterGames.Cart.Core.Management.Editor; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Cart.Core.Logs.Editor +{ + public static class LogCategoryDrawer + { + public static void DrawLogCategories() + { + if (ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list").arraySize <= 0) return; + + for (var i = 0; i < ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list").arraySize; i++) + { + DrawLogCategory(ScriptableRef.LogCategoriesObject.Fp("lookup").Fpr("list").GetIndex(i)); + } + } + + + private static string TrimCategoryNameToLabel(string category) + { + return category.Split('.').Last().Replace("LogCategory", string.Empty); + } + + + private static string GetTooltip(string category) + { + return $"Toggle logs for: {category}"; + } + + + private static void DrawLogCategory(SerializedProperty category) + { + ScriptableRef.LogCategoriesObject.Update(); + + EditorGUI.BeginChangeCheck(); + + category.Fpr("value").boolValue = EditorGUILayout.Toggle(new GUIContent(TrimCategoryNameToLabel(category.Fpr("key").stringValue), GetTooltip(category.Fpr("key").stringValue)), category.Fpr("value").boolValue); + + if (EditorGUI.EndChangeCheck()) + { + ScriptableRef.LogCategoriesObject.ApplyModifiedProperties(); + ScriptableRef.LogCategoriesObject.Update(); + } + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LogCategoryDrawer.cs.meta b/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LogCategoryDrawer.cs.meta new file mode 100644 index 00000000..7142543e --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LogCategoryDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc4db8ba8fd243b69c1b6b8f4f434c9e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LoggingSettingsDrawer.cs b/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LoggingSettingsDrawer.cs index 4cac4aad..744fd7ec 100644 --- a/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LoggingSettingsDrawer.cs +++ b/Carter Games/The Cart/Code/Editor/Core/Logging/Settings/LoggingSettingsDrawer.cs @@ -32,27 +32,88 @@ namespace CarterGames.Cart.Core.Logs.Editor /// public static class LoggingSettingsDrawer { + private static readonly string LoggingExpanded = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_Settings_Core_Logging_Expanded"; + private static readonly string LoggingSettingsExpanded = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_Settings_Core_Logging_SettingsExpanded"; + private static readonly string LoggingCategoriesExpanded = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_Settings_Core_Logging_CategoriesExpanded"; + + + private static bool IsExpanded + { + get => PerUserSettings.GetValue(LoggingExpanded, SettingType.EditorPref, false); + set => PerUserSettings.SetValue(LoggingExpanded, SettingType.EditorPref, value); + } + + + private static bool IsSettingsExpanded + { + get => PerUserSettings.GetValue(LoggingSettingsExpanded, SettingType.EditorPref, false); + set => PerUserSettings.SetValue(LoggingSettingsExpanded, SettingType.EditorPref, value); + } + + + private static bool IsCategoriesExpanded + { + get => PerUserSettings.GetValue(LoggingCategoriesExpanded, SettingType.EditorPref, false); + set => PerUserSettings.SetValue(LoggingCategoriesExpanded, SettingType.EditorPref, value); + } + + + + public static void ExpandSection(bool showSettings, bool showCategories) + { + IsExpanded = true; + IsSettingsExpanded = showSettings; + IsCategoriesExpanded = showCategories; + } + + /// /// Draws the settings provider version of the settings. /// public static void DrawSettings() { - UtilEditor.SettingsObject.Fp("isLoggingExpanded").boolValue = - EditorGUILayout.Foldout(UtilEditor.SettingsObject.Fp("isLoggingExpanded").boolValue, Meta.Logs.Content(Meta.SectionTitle)); - + EditorGUI.BeginChangeCheck(); - if (!UtilEditor.SettingsObject.Fp("isLoggingExpanded").boolValue) return; + IsExpanded = EditorGUILayout.Foldout(IsExpanded, Meta.Logs.Content(Meta.SectionTitle)); + + if (!IsExpanded) return; EditorGUILayout.BeginVertical("Box"); EditorGUILayout.Space(1.5f); EditorGUI.indentLevel++; - - // Draw the provider enum field on the GUI... - EditorGUILayout.PropertyField(UtilEditor.SettingsObject.Fp("loggingUseCartLogs"), Meta.Logs.Content("useLogs")); - EditorGUILayout.PropertyField(UtilEditor.SettingsObject.Fp("useLogsInProductionBuilds"), Meta.Logs.Content("useInProduction")); + IsSettingsExpanded = EditorGUILayout.Foldout(IsSettingsExpanded, Meta.Logs.Content("sectionSettingsTitle")); + if (IsSettingsExpanded) + { + EditorGUI.indentLevel++; + EditorGUILayout.BeginVertical("Box"); + + // Draw the provider enum field on the GUI... + EditorGUILayout.PropertyField(UtilEditor.SettingsObject.Fp("loggingUseCartLogs"), + Meta.Logs.Content("useLogs")); + EditorGUILayout.PropertyField(UtilEditor.SettingsObject.Fp("useLogsInProductionBuilds"), + Meta.Logs.Content("useInProduction")); + + EditorGUILayout.EndVertical(); + EditorGUI.indentLevel--; + } + + IsCategoriesExpanded = EditorGUILayout.Foldout(IsCategoriesExpanded, Meta.Logs.Content("sectionCategoriesTitle")); + + if (IsCategoriesExpanded) + { + EditorGUI.indentLevel++; + EditorGUILayout.BeginVertical("Box"); + + EditorGUILayout.HelpBox("Toggle categories here to define if logs of that type appear in the console.", MessageType.Info); + + LogCategoryDrawer.DrawLogCategories(); + + EditorGUILayout.EndVertical(); + EditorGUI.indentLevel--; + } EditorGUI.indentLevel--; EditorGUILayout.Space(1.5f); diff --git a/Carter Games/The Cart/Code/Editor/Core/Range/Property Drawers/RangeDrawer.cs b/Carter Games/The Cart/Code/Editor/Core/Range/Property Drawers/RangeDrawer.cs index 40603389..4211edc5 100644 --- a/Carter Games/The Cart/Code/Editor/Core/Range/Property Drawers/RangeDrawer.cs +++ b/Carter Games/The Cart/Code/Editor/Core/Range/Property Drawers/RangeDrawer.cs @@ -27,30 +27,30 @@ namespace CarterGames.Cart.Core.Editor { - public class RangeDrawer + public static class RangeDrawer { public static void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, label); - var _elementOne = property.Fpr("min"); - var _elementTwo = property.Fpr("max"); + var elementOne = property.Fpr("min"); + var elementTwo = property.Fpr("max"); EditorGUI.BeginChangeCheck(); - int indent = EditorGUI.indentLevel; + var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; - var _left = new Rect(position.x, position.y, (position.width / 6) - 1.5f, EditorGUIUtility.singleLineHeight); - var _leftLower = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight + 1.5f, (position.width / 6) - 1.5f, EditorGUIUtility.singleLineHeight); - var _right = new Rect(position.x + (position.width / 6) + 1.5f, position.y, (position.width / 6) * 5 - 1.5f, EditorGUIUtility.singleLineHeight); - var _rightLower = new Rect(position.x + (position.width / 6) + 1.5f, position.y + EditorGUIUtility.singleLineHeight + 1.5f, (position.width / 6) * 5 - 1.5f, EditorGUIUtility.singleLineHeight); + var left = new Rect(position.x, position.y, (position.width / 6) - 1.5f, EditorGUIUtility.singleLineHeight); + var leftLower = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight + 1.5f, (position.width / 6) - 1.5f, EditorGUIUtility.singleLineHeight); + var right = new Rect(position.x + (position.width / 6) + 1.5f, position.y, (position.width / 6) * 5 - 1.5f, EditorGUIUtility.singleLineHeight); + var rightLower = new Rect(position.x + (position.width / 6) + 1.5f, position.y + EditorGUIUtility.singleLineHeight + 1.5f, (position.width / 6) * 5 - 1.5f, EditorGUIUtility.singleLineHeight); - EditorGUI.LabelField(_left, "Min:"); - EditorGUI.LabelField(_leftLower, "Max:"); - EditorGUI.PropertyField(_right, _elementOne, GUIContent.none); - EditorGUI.PropertyField(_rightLower, _elementTwo, GUIContent.none); + EditorGUI.LabelField(left, "Min:"); + EditorGUI.LabelField(leftLower, "Max:"); + EditorGUI.PropertyField(right, elementOne, GUIContent.none); + EditorGUI.PropertyField(rightLower, elementTwo, GUIContent.none); if (EditorGUI.EndChangeCheck()) diff --git a/Carter Games/The Cart/Code/Editor/Core/Setup/ProjectFolderSetup.cs b/Carter Games/The Cart/Code/Editor/Core/Setup/ProjectFolderSetup.cs index 10e68f88..a969f217 100644 --- a/Carter Games/The Cart/Code/Editor/Core/Setup/ProjectFolderSetup.cs +++ b/Carter Games/The Cart/Code/Editor/Core/Setup/ProjectFolderSetup.cs @@ -32,9 +32,9 @@ namespace CarterGames.Cart.Core.Setup.Editor public static class ProjectFolderSetup { /// - /// Static | Adds the button to call to run the setup. + /// Adds the button to call to run the setup. /// - [MenuItem("Tools/Carter Games/The Cart/Setup Basic Folder Structure", priority = 2000)] + [MenuItem("Tools/Carter Games/The Cart/Core/Setup Basic Folder Structure", priority = 601)] public static void RunSetupProject() { CreateBasicProjectFolderStructure(); @@ -63,7 +63,7 @@ private static void CreateBasicProjectFolderStructure() TryCreateFolder("UI", "Assets/_Project/Scenes"); TryCreateFolder("Menu", "Assets/_Project/Scenes"); TryCreateFolder("Game", "Assets/_Project/Scenes"); - TryCreateFolder("_Dev", "Assets"); + TryCreateFolder("_Scratch", "Assets"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); diff --git a/Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/CartRuntimeSettingsInspector.cs b/Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/DataAssetCartRuntimeSettingsInspector.cs similarity index 91% rename from Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/CartRuntimeSettingsInspector.cs rename to Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/DataAssetCartRuntimeSettingsInspector.cs index fd4a047f..d5e85e79 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/CartRuntimeSettingsInspector.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/DataAssetCartRuntimeSettingsInspector.cs @@ -31,8 +31,8 @@ namespace CarterGames.Cart.Core.Management.Editor /// /// Handles the custom editor for the runtime settings asset. /// - [CustomEditor(typeof(CartGlobalRuntimeSettings))] - public sealed class CartRuntimeSettingsInspector : UnityEditor.Editor + [CustomEditor(typeof(DataAssetCartGlobalRuntimeSettings))] + public sealed class DataAssetCartRuntimeSettingsInspector : UnityEditor.Editor { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Unity Editor Methods @@ -44,14 +44,14 @@ public sealed class CartRuntimeSettingsInspector : UnityEditor.Editor public override void OnInspectorGUI() { GUILayout.Space(4f); - GeneralUtilEditor.DrawSoScriptSection((CartGlobalRuntimeSettings)target); + GeneralUtilEditor.DrawSoScriptSection((DataAssetCartGlobalRuntimeSettings)target); GUILayout.Space(2f); RngSettingsDrawer.DrawInspector(serializedObject); GUILayout.Space(2f); LoggingSettingsDrawer.DrawInspector(serializedObject); GUILayout.Space(2f); - + foreach (var providerKvp in SettingsProviderHandler.Providers) { providerKvp.Value.OnInspectorSettingsGUI(null); diff --git a/Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/CartRuntimeSettingsInspector.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/DataAssetCartRuntimeSettingsInspector.cs.meta similarity index 100% rename from Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/CartRuntimeSettingsInspector.cs.meta rename to Carter Games/The Cart/Code/Editor/Management/Asset Settings/Custom Editors/DataAssetCartRuntimeSettingsInspector.cs.meta diff --git a/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/Asset.json b/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/Asset.json index c2ffaf58..14af0141 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/Asset.json +++ b/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/Asset.json @@ -8,7 +8,7 @@ "list": [ { "key": "editorSection", "value": { "title": "Editor", "toolTip": "Any editor settings for the asset specifically." }}, { "key": "version", "value": { "title": "Version", "toolTip": "The version number of the asset you currently have imported." }}, - { "key": "releaseDate", "value": { "title": "Release date", "toolTip": "The date the version of the asset you are using was released on." }}, + { "key": "releaseDate", "value": { "title": "Release date (Y/M/D)", "toolTip": "The date the version of the asset you are using was released on. (Y/M/D)" }}, { "key": "autoVersionCheck", "value": { "title": "Update check on load", "toolTip": "Checks for any updates to the asset from the GitHub page when you load the project." }} ] } diff --git a/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/CartLogs.json b/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/CartLogs.json index a79a94cf..1b70f2f2 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/CartLogs.json +++ b/Carter Games/The Cart/Code/Editor/Management/Meta Data/Data/CartLogs.json @@ -7,6 +7,8 @@ "content": { "list": [ { "key": "sectionTitle", "value": { "title": "Logging", "toolTip": "The settings for the 'Cart Logger' system." }}, + { "key": "sectionSettingsTitle", "value": { "title": "Settings", "toolTip": "The settings for the 'Cart Logger' system." }}, + { "key": "sectionCategoriesTitle", "value": { "title": "Categories", "toolTip": "The categories the logging system has and their states." }}, { "key": "useLogs", "value": { "title": "Use logs", "toolTip": "Defines if the logs are shown at all." }}, { "key": "useInProduction", "value": { "title": "Production build logs", "toolTip": "Defines if the logs will show in production builds or not." }} ] diff --git a/Carter Games/The Cart/Code/Editor/Management/Meta Data/Meta.cs b/Carter Games/The Cart/Code/Editor/Management/Meta Data/Meta.cs index d868f390..9c4604a8 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Meta Data/Meta.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Meta Data/Meta.cs @@ -77,7 +77,7 @@ private static Dictionary Lookup /// /// Updates the meta data when called, in-case of edits without any script changes. /// - [MenuItem("Tools/Carter Games/The Cart/Editor/Meta Data/Force Update")] + [MenuItem("Tools/Carter Games/The Cart/Core/Meta Data/Force Update", priority = 502)] private static void ForceUpdate() { dataCache.Clear(); @@ -100,7 +100,7 @@ public static MetaData GetData(string key) if (asset == null) { - CartLogger.LogError(typeof(Meta), $"Unable to find JSON for {key}"); + CartLogger.LogError($"Unable to find JSON for {key}", typeof(Meta)); return null; } @@ -126,7 +126,7 @@ public static MetaData GetData(string path, string key) if (asset == null) { - CartLogger.LogError(typeof(Meta), $"Unable to find JSON for {key}"); + CartLogger.LogError($"Unable to find JSON for {key}", typeof(Meta)); return null; } diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleNotionData.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleNotionData.cs index 734003a8..61d7626e 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleNotionData.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Defenitions/ModuleNotionData.cs @@ -21,6 +21,7 @@ * THE SOFTWARE. */ +using System; using CarterGames.Cart.Core.Management.Editor; namespace CarterGames.Cart.Modules @@ -50,12 +51,12 @@ public sealed class ModuleNotionData : IModule /// The namespace the module code is under. /// public string Namespace => "CarterGames.Cart.Modules.NotionData"; - - + + /// /// Any modules that are required for the module to work. /// - public IModule[] PreRequisites => new IModule[] {new ModuleData()}; + public IModule[] PreRequisites => Array.Empty(); /// diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Editors.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/Editors.meta new file mode 100644 index 00000000..369522ef --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Editors.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 13f813d922b04082b1212013826743ef +timeCreated: 1720030876 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Editors/ModuleCacheEditor.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/Editors/ModuleCacheEditor.cs new file mode 100644 index 00000000..f5ba8679 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Editors/ModuleCacheEditor.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Cart.Core.Management.Editor; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Cart.Modules.Editors +{ + [CustomEditor(typeof(ModuleCache))] + public class ModuleCacheEditor : Editor + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Unity Editor Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public override void OnInspectorGUI() + { + EditorGUILayout.Space(2.5f); + + GeneralUtilEditor.DrawSoScriptSection(target); + + EditorGUILayout.Space(2.5f); + + DrawVariantId(); + + EditorGUILayout.Space(2.5f); + + DrawManifest(); + + EditorGUILayout.Space(2.5f); + + DrawModulesRevisions(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Drawer Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private void DrawVariantId() + { + EditorGUILayout.BeginVertical("HelpBox"); + EditorGUILayout.Space(1f); + + EditorGUILayout.LabelField("Data Asset", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + + EditorGUILayout.PropertyField(serializedObject.Fp("variantId")); + + EditorGUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + } + + + private void DrawModulesRevisions() + { + EditorGUILayout.BeginVertical("HelpBox"); + EditorGUILayout.Space(1f); + + EditorGUILayout.LabelField("Installed Modules", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + + + for (var i = 0; i < serializedObject.Fp("installedModuleReceipts").Fpr("list").arraySize; i++) + { + EditorGUILayout.BeginHorizontal(); + EditorGUI.BeginDisabledGroup(true); + + EditorGUILayout.LabelField(serializedObject.Fp("installedModuleReceipts").Fpr("list").GetIndex(i).Fpr("key").stringValue); + EditorGUILayout.IntField(serializedObject.Fp("installedModuleReceipts").Fpr("list").GetIndex(i).Fpr("value").Fpr("revision").intValue, GUILayout.Width(50)); + + EditorGUI.EndDisabledGroup(); + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + } + + + private void DrawManifest() + { + EditorGUILayout.BeginVertical("HelpBox"); + EditorGUILayout.Space(1f); + + EditorGUILayout.LabelField("Module Manifest", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + + EditorGUILayout.PropertyField(serializedObject.Fp("manifest")); + + EditorGUILayout.Space(1.5f); + EditorGUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Editors/ModuleCacheEditor.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/Editors/ModuleCacheEditor.cs.meta new file mode 100644 index 00000000..b95f0767 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Editors/ModuleCacheEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ec0421c2ad8e40cf8c4c569509655905 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Logging.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/Logging.meta new file mode 100644 index 00000000..4a0d6a3e --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Logging.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2610c4ddfce04470868747bef0fdc3f5 +timeCreated: 1720000953 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Logging/LogCategoryModules.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/Logging/LogCategoryModules.cs new file mode 100644 index 00000000..41f3a747 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Logging/LogCategoryModules.cs @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using CarterGames.Cart.Core.Logs; + +namespace CarterGames.Cart.Modules +{ + /// + /// Log category for module management systems. + /// + [Serializable] + public class LogCategoryModules : CartLogCategory { } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Logging/LogCategoryModules.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/Logging/LogCategoryModules.cs.meta new file mode 100644 index 00000000..e819832f --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Logging/LogCategoryModules.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd011d7114914adebb87dcba18a34149 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleManager.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleManager.cs index 878d44c8..048dbcbe 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleManager.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleManager.cs @@ -28,8 +28,8 @@ using System.Reflection; using CarterGames.Cart.Core; using CarterGames.Cart.Core.Json; -using CarterGames.Cart.Core.Management; using CarterGames.Cart.Core.Management.Editor; +using CarterGames.Cart.Core.Data; using UnityEditor; using UnityEngine; @@ -45,10 +45,10 @@ public static class ModuleManager /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ private static readonly string ModuleNamespacesSettingKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_ProjectNamespacesList"; private static readonly string CurrentlyUpdatingModuleNameKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_UpdateModuleName"; - private static readonly string InstallModulesQueueKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_InstallQueue"; private static readonly string IsProcessingKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_IsProcessing"; - private static readonly string CurrentProcessKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_CurrentProcess"; + private static readonly string ProcessQueueKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_ProcessQueue"; private static readonly string HasPromptedKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_HasPrompted"; + private static readonly string IsUpdatingKey = $"{PerUserSettings.UniqueId}_CarterGames_TheCart_ModuleManager_IsUpdatingCurrently"; // Icons @@ -116,17 +116,20 @@ public static bool HasPrompted set => PerUserSettings.SetValue(HasPromptedKey, SettingType.SessionState, value); } - + /// /// Gets the current process /// - public static string CurrentProcess + public static ModuleChangeStateElement CurrentProcess { - get => (string) PerUserSettings.GetOrCreateValue(CurrentProcessKey, SettingType.SessionState, string.Empty); - set => PerUserSettings.SetValue(CurrentProcessKey, SettingType.SessionState, value); + get + { + if (!ProcessQueue.HasNext) return null; + return ProcessQueue.CurrentProcess; + } } - - + + /// /// Gets the namespaces in the project /// @@ -136,10 +139,10 @@ public static string CurrentProcess /// /// Gets all the elements to process before the process is completed. /// - public static List ProcessQueue + public static ModuleProcessQueue ProcessQueue { - get => JsonUtility.FromJson>((string) PerUserSettings.GetOrCreateValue(InstallModulesQueueKey, SettingType.SessionState, JsonUtility.ToJson(new ListWrapper()))).Data; - set => PerUserSettings.SetValue(InstallModulesQueueKey, SettingType.SessionState, JsonUtility.ToJson(new ListWrapper(value))); + get => JsonUtility.FromJson((string) PerUserSettings.GetOrCreateValue(ProcessQueueKey, SettingType.EditorPref, JsonUtility.ToJson(new ModuleProcessQueue()))); + set => PerUserSettings.SetValue(ProcessQueueKey, SettingType.EditorPref, JsonUtility.ToJson(value)); } @@ -151,6 +154,12 @@ public static string UpdatingModule get => (string) PerUserSettings.GetOrCreateValue(CurrentlyUpdatingModuleNameKey, SettingType.SessionState, string.Empty); set => PerUserSettings.SetValue(CurrentlyUpdatingModuleNameKey, SettingType.SessionState, value); } + + public static bool IsUpdating + { + get => (bool) PerUserSettings.GetOrCreateValue(IsUpdatingKey, SettingType.SessionState, false); + set => PerUserSettings.SetValue(IsUpdatingKey, SettingType.SessionState, value); + } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Methods @@ -190,27 +199,34 @@ public static bool HasPackage(IModule module) /// Int public static int InstalledRevisionNumber(IModule module) { - if (IsProcessing) return CartSoAssetAccessor.GetAsset().Manifest.GetData(module).Revision; + if (IsProcessing) return DataAccess.GetAsset().Manifest.GetData(module).Revision; if (!IsInstalled(module)) return -1; - if (CartSoAssetAccessor.GetAsset().InstalledModulesInfo.ContainsKey(module.Namespace)) + if (DataAccess.GetAsset().InstalledModulesInfo.ContainsKey(module.Namespace)) { - if (CartSoAssetAccessor.GetAsset().InstalledModulesInfo[module.Namespace] == null) + if (DataAccess.GetAsset().InstalledModulesInfo[module.Namespace] == null) { - CartSoAssetAccessor.GetAsset().InstalledModulesInfo.Remove(module.Namespace); + DataAccess.GetAsset().InstalledModulesInfo.Remove(module.Namespace); return -1; } - return CartSoAssetAccessor.GetAsset().InstalledModulesInfo[module.Namespace].Revision; + return DataAccess.GetAsset().InstalledModulesInfo[module.Namespace].Revision; } else { - CartSoAssetAccessor.GetAsset().AddInstalledModuleInfo(module, AssetDatabase.LoadAssetAtPath(module.ModuleInstallPath + "/Installation.json")); - return CartSoAssetAccessor.GetAsset().InstalledModulesInfo[module.Namespace].Revision; + DataAccess.GetAsset().AddInstalledModuleInfo(module, AssetDatabase.LoadAssetAtPath(module.ModuleInstallPath + "/Installation.json")); + return DataAccess.GetAsset().InstalledModulesInfo[module.Namespace].Revision; } } + public static void UpdateModuleInstallInfo(IModule module) + { + if (!IsInstalled(module)) return; + DataAccess.GetAsset().UpdateInstalledModuleInfo(module, AssetDatabase.LoadAssetAtPath(module.ModuleInstallPath + "/Installation.json")); + } + + /// /// Gets if a module has an update or not. /// @@ -219,7 +235,7 @@ public static int InstalledRevisionNumber(IModule module) public static bool HasUpdate(IModule module) { if (!IsInstalled(module)) return false; - return InstalledRevisionNumber(module) < (CartSoAssetAccessor.GetAsset().Manifest.GetData(module).Revision); + return InstalledRevisionNumber(module) < (DataAccess.GetAsset().Manifest.GetData(module).Revision); } @@ -251,5 +267,34 @@ public static string GetModuleStatusIcon(IModule module) if (HasUpdate(module)) return UpdateIconColourised; return TickIconColourised; } + + + public static bool TryProcessNext() + { + var test = ProcessQueue; + test.IncrementIndex(); + + if (!test.HasNext) return false; + ProcessQueue = test; + + CurrentProcess.Process(); + return true; + } + + + public static void AddModuleToQueue(ModuleChangeStateElement changeStateElement) + { + var test = ProcessQueue; + test.AddToQueue(changeStateElement); + ProcessQueue = test; + } + + + public static void ClearProcessQueue() + { + var test = ProcessQueue; + test.ClearQueue(); + ProcessQueue = test; + } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleProcessQueue.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleProcessQueue.cs new file mode 100644 index 00000000..c6a2a4dc --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleProcessQueue.cs @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using CarterGames.Cart.Core.Logs; +using UnityEngine; + +namespace CarterGames.Cart.Modules +{ + [Serializable] + public sealed class ModuleProcessQueue + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + [SerializeField] private List data = new List(); + [SerializeField] private int currentIndex = 0; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public ModuleChangeStateElement CurrentProcess => data[currentIndex]; + public int Count => data.Count; + + + public bool HasNext => data.Count > currentIndex; + + public List ModulesEditing + { + get + { + if (data.Count <= 0) return new List(); + + var modules = new List(); + + foreach (var mod in data) + { + var elly = ModuleManager.AllModules.First(t => t.ModulePackagePath.Equals(mod.PackageFileLocation)); + + if (modules.Contains(elly)) continue; + + modules.Add(elly); + } + + return modules; + } + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public void IncrementIndex() + { + currentIndex++; + } + + + public void AddToQueue(ModuleChangeStateElement change) + { + if (data.Any(t => t.Package == change.Package && t.FlowInUse == change.FlowInUse)) return; + data.Add(change); + + CartLogger.Log($"Added module: {change.Package} to process queue.", typeof(ModuleProcessQueue)); + } + + + public void ClearQueue() + { + data.Clear(); + currentIndex = 0; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleProcessQueue.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleProcessQueue.cs.meta new file mode 100644 index 00000000..e00e33ec --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/ModuleProcessQueue.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8434ac5279e84948822d4b4f54296198 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Cache/ModuleCache.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Cache/ModuleCache.cs index a62049e1..041fd3cf 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Cache/ModuleCache.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Cache/ModuleCache.cs @@ -23,7 +23,7 @@ using System.Linq; using CarterGames.Cart.Core; -using CarterGames.Cart.Core.Management; +using CarterGames.Cart.Core.Data; using CarterGames.Cart.Core.Management.Editor; using UnityEditor; using UnityEngine; @@ -31,7 +31,7 @@ namespace CarterGames.Cart.Modules { [CreateAssetMenu(fileName = "Module Cache Asset", menuName = "Carter Games/The Cart/Modules/Cache Asset")] - public sealed class ModuleCache : CartSoAsset + public sealed class ModuleCache : DataAsset { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields @@ -99,6 +99,19 @@ public void AddInstalledModuleInfo(IModule module, TextAsset asset) } + /// + /// Updates the info when called. + /// + /// The module to update info for. + /// The test asset to read and update from. + public void UpdateInstalledModuleInfo(IModule module, TextAsset asset) + { + if (!installedModuleReceipts.ContainsKey(module.Namespace)) return; + installedModuleReceipts[module.Namespace] = JsonUtility.FromJson(asset.text); + EditorUtility.SetDirty(this); + } + + /// /// Removes a module info from the cache. /// diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifest.json b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifest.json index 41e28587..088d78ee 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifest.json +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifest.json @@ -5,11 +5,6 @@ "revision": 1, "author": "Carter Games" }, - { - "id": "Data", - "revision": 2, - "author": "Carter Games" - }, { "id": "Delayed Events", "revision": 2, @@ -32,17 +27,17 @@ }, { "id": "Mockup", - "revision": 1, + "revision": 2, "author": "Carter Games" }, { "id": "Notion Data", - "revision": 4, + "revision": 6, "author": "Carter Games" }, { "id": "Panels", - "revision": 1, + "revision": 2, "author": "Carter Games" }, { @@ -52,12 +47,12 @@ }, { "id": "Game Ticks", - "revision": 2, + "revision": 3, "author": "Carter Games" }, { "id": "Loading Screens", - "revision": 1, + "revision": 2, "author": "Carter Games" }, { diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifestWrapper.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifestWrapper.cs index 7143bffe..ada87069 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifestWrapper.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/Manifest/ModuleManifestWrapper.cs @@ -28,7 +28,7 @@ namespace CarterGames.Cart.Modules { /// - /// + /// A wrapper class for the module manifest for JSON parsing purposes. /// [Serializable] public sealed class ModuleManifestWrapper diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/ModuleChangeStateElement.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/ModuleChangeStateElement.cs new file mode 100644 index 00000000..7e824496 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/ModuleChangeStateElement.cs @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using UnityEngine; + +namespace CarterGames.Cart.Modules +{ + [Serializable] + public class ModuleChangeStateElement + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + [SerializeField] private string packageNamespace; + [SerializeField] private string packageFileLocation; + [SerializeField] private string packageInstallLocation; + [SerializeField] private string flow; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public string Package => packageNamespace; + public string PackageFileLocation => packageFileLocation; + public string PackageInstallLocation => packageInstallLocation; + public string FlowInUse => flow; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Constructors + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public ModuleChangeStateElement() {} + + + public ModuleChangeStateElement(IModule module, string flow) + { + packageNamespace = module.Namespace; + packageInstallLocation = module.ModuleInstallPath; + packageFileLocation = module.ModulePackagePath; + + this.flow = flow; + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public void Process() + { + switch (FlowInUse) + { + case ModuleOperations.Install: + ModuleInstaller.InstallNextInQueue(); + break; + case ModuleOperations.Uninstall: + ModuleUninstaller.UninstallFromQueue(); + break; + default: + break; + } + } + + + public void ResetData() + { + packageNamespace = string.Empty; + flow = string.Empty; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/ModuleChangeStateElement.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/ModuleChangeStateElement.cs.meta new file mode 100644 index 00000000..b3fec821 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Data/ModuleChangeStateElement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4cc3df7d361478e9d96bd8127881578 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleInstaller.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleInstaller.cs index dcbe7e1c..6e7432c1 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleInstaller.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleInstaller.cs @@ -22,10 +22,9 @@ */ using System; -using System.Collections.Generic; using System.Linq; using CarterGames.Cart.Core; -using CarterGames.Cart.Core.Management; +using CarterGames.Cart.Core.Logs; using CarterGames.Cart.Core.Management.Editor; using CarterGames.Cart.Modules.Window; using UnityEditor; @@ -59,99 +58,65 @@ public static void Install(IModule module) { InstallingModule = module; - AssetDatabase.importPackageStarted -= OnImportPackageStarted; - AssetDatabase.importPackageStarted += OnImportPackageStarted; - - AssetDatabase.importPackageCancelled -= OnImportPackageCancelled; - AssetDatabase.importPackageCancelled += OnImportPackageCancelled; - - AssetDatabase.importPackageFailed -= OnImportPackageFailed; - AssetDatabase.importPackageFailed += OnImportPackageFailed; - - AssetDatabase.importPackageCompleted -= OnImportPackageCompleted; - AssetDatabase.importPackageCompleted += OnImportPackageCompleted; - var toInstall = Array.Empty(); if (module.PreRequisites.Length > 0) { foreach (var preReq in module.PreRequisites) { + if (ModuleManager.IsInstalled(preReq)) continue; + toInstall = toInstall.Add(preReq); + ModuleManager.AddModuleToQueue(new ModuleChangeStateElement(preReq, ModuleOperations.Install)); } } - toInstall = toInstall.Add(module); - ModuleManager.ProcessQueue = toInstall.Select(t => t.ModulePackagePath).ToList(); + ModuleManager.AddModuleToQueue(new ModuleChangeStateElement(module, ModuleOperations.Install)); + + InstallNextInQueue(); + } + - if (!ModuleManager.CurrentProcess.Equals(ModuleOperations.Updating)) + public static void InstallNextInQueue() + { + try { - ModuleManager.CurrentProcess = ModuleOperations.Installing; - ModuleManager.IsProcessing = true; + AssetDatabase.StartAssetEditing(); + AssetDatabase.ImportPackage(ModuleManager.CurrentProcess.PackageFileLocation, false); + AssetDatabase.StopAssetEditing(); } - - AssetDatabase.StartAssetEditing(); - - foreach (var mod in toInstall) +#pragma warning disable + catch (Exception e) +#pragma warning restore { - AssetDatabase.ImportPackage(mod.ModulePackagePath, false); + CartLogger.LogError("Failed to install a module. Stopping the operation.", typeof(ModuleInstaller), true); + ModuleManager.RefreshNamespaceCache(); + ModuleManager.ClearProcessQueue(); + + if (ModuleManager.IsUpdating) + { + ModuleManager.IsUpdating = false; + } } - - AssetDatabase.StopAssetEditing(); } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Package Import Listeners ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static void OnImportPackageStarted(string packagename) - { - ModuleManager.IsProcessing = false; - } - - - private static void OnImportPackageCancelled(string packageName) + private static void OnImportPackageCompleted() { - ModuleManager.IsProcessing = false; - } + var module = ModuleManager.AllModules.First(t => + t.ModulePackagePath.Equals(ModuleManager.CurrentProcess.PackageFileLocation)); - - private static void OnImportPackageCompleted(string packagename) - { - if (!ScriptableRef.AssetBasePath.Equals(("Assets"))) + if (!PostImportFileMover.IsInRightPath(module)) { - AssetDatabase.StartAssetEditing(); - - foreach (var mod in ModuleManager.ProcessQueue) - { - // Skip if in the right path already - var path = "Assets/"; - path += ModuleManager.AllModules.First(t => t.ModulePackagePath.Equals(mod)).ModuleInstallPath - .Replace(ScriptableRef.AssetBasePath, string.Empty); - AssetDatabase.MoveAsset(path, - ModuleManager.AllModules.First(t => t.ModulePackagePath.Equals(mod)).ModuleInstallPath); - } - - // Remove left over directories... - AssetDatabase.DeleteAsset("Assets/Carter Games/The Cart/Modules"); - AssetDatabase.DeleteAsset("Assets/Carter Games/The Cart/"); - AssetDatabase.DeleteAsset("Assets/Carter Games/"); - - AssetDatabase.StopAssetEditing(); + CartLogger.Log("Module not in the right path, moving to the correct path.", typeof(ModuleInstaller), true); + PostImportFileMover.UpdateFileLocation(module); } ModuleManager.RefreshNamespaceCache(); ModulesWindow.RepaintWindow(); - - if (!ModuleManager.CurrentProcess.Equals(ModuleOperations.Installing)) return; - ModuleManager.IsProcessing = false; - ModuleManager.CurrentProcess = string.Empty; - } - - - private static void OnImportPackageFailed(string packagename, string errormessage) - { - ModuleManager.IsProcessing = false; } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -163,12 +128,19 @@ private static void OnImportPackageFailed(string packagename, string errormessag /// public void OnEditorReloaded() { - if (!ModuleManager.CurrentProcess.Equals(ModuleOperations.Installing)) return; + if (ModuleManager.IsUpdating) return; + if (ModuleManager.CurrentProcess == null) return; + if (!ModuleManager.CurrentProcess.FlowInUse.Equals(ModuleOperations.Install)) return; + + OnImportPackageCompleted(); ModuleManager.RefreshNamespaceCache(); - ModuleManager.CurrentProcess = string.Empty; - ModuleManager.IsProcessing = false; + CartLogger.Log($"Module {ModuleManager.CurrentProcess.Package} Installed.", typeof(ModuleInstaller), true); + + if (ModuleManager.TryProcessNext()) return; + + ModuleManager.ClearProcessQueue(); } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleOperations.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleOperations.cs index 38146465..5e166de2 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleOperations.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleOperations.cs @@ -31,13 +31,13 @@ public static class ModuleOperations /// /// When modules are been installed. /// - public const string Installing = "Install"; + public const string Install = "Install"; /// /// When modules are been uninstalled. /// - public const string Uninstalling = "Uninstall"; + public const string Uninstall = "Uninstall"; /// diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUninstaller.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUninstaller.cs index 98263b52..7dd1897a 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUninstaller.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUninstaller.cs @@ -21,12 +21,15 @@ * THE SOFTWARE. */ +using System; using System.Collections.Generic; using System.Linq; using System.Text; -using CarterGames.Cart.Core.Management; +using CarterGames.Cart.Core.Data; +using CarterGames.Cart.Core.Logs; using CarterGames.Cart.Core.Management.Editor; using UnityEditor; +using UnityEngine; namespace CarterGames.Cart.Modules { @@ -54,7 +57,6 @@ public static void Uninstall(IModule module) { var toUninstall = new List(); ModuleManager.HasPrompted = false; - ModuleManager.CurrentProcess = ModuleOperations.Uninstalling; if (ModuleManager.AllModules.Any(t => t.PreRequisites.Any(x => x.ModuleInstallPath.Equals(module.ModuleInstallPath)))) @@ -67,12 +69,25 @@ public static void Uninstall(IModule module) } toUninstall.Add(module.ModuleInstallPath); - ModuleManager.ProcessQueue = toUninstall; - if (toUninstall.Count > 1 && ModuleManager.CurrentProcess.Equals(ModuleOperations.Uninstalling) && !ModuleManager.HasPrompted) + + foreach (var toProcess in toUninstall) + { + var moduleData = ModuleManager.AllModules.First(t => t.ModuleInstallPath.Equals(toProcess)); + + if (!ModuleManager.IsInstalled(moduleData)) continue; + ModuleManager.AddModuleToQueue(new ModuleChangeStateElement(moduleData, ModuleOperations.Uninstall)); + } + + + if (toUninstall.Count > 1 && ModuleManager.CurrentProcess.FlowInUse.Equals(ModuleOperations.Uninstall) && !ModuleManager.HasPrompted) { Builder.Clear(); - Builder.Append("Uninstalling this module will also uninstall:"); + Builder.Append("This module is a dependency for some other modules."); + Builder.AppendLine(); + Builder.AppendLine(); + Builder.Append("Proceeding with the uninstall will also uninstall these modules:"); + Builder.AppendLine(); Builder.AppendLine(); for (var i = 0; i < toUninstall.Count - 1; i++) @@ -88,7 +103,7 @@ public static void Uninstall(IModule module) if (!Dialogue.Display("Uninstall " + module.ModuleName, Builder.ToString(), "Uninstall", "Cancel")) { - ModuleManager.ProcessQueue = new List(); + ModuleManager.ClearProcessQueue(); return; } else @@ -97,16 +112,26 @@ public static void Uninstall(IModule module) } } - ModuleManager.IsProcessing = true; - AssetDatabase.StartAssetEditing(); - - foreach (var toRemove in ModuleManager.ProcessQueue) + try { - DeleteDirectoryAndContents(ModuleManager.AllModules.First(t => t.ModuleInstallPath.Equals(toRemove))); + AssetDatabase.StartAssetEditing(); + DeleteDirectoryAndContents(ModuleManager.AllModules.First(t => t.ModuleInstallPath.Equals(ModuleManager.CurrentProcess.PackageInstallLocation))); + AssetDatabase.StopAssetEditing(); } +#pragma warning disable + catch (Exception e) +#pragma warning restore + { + CartLogger.LogError("Failed to uninstall a module. Stopping the operation.", typeof(ModuleUninstaller),true); + ModuleManager.RefreshNamespaceCache(); + ModuleManager.ClearProcessQueue(); - AssetDatabase.StopAssetEditing(); + if (ModuleManager.IsUpdating) + { + ModuleManager.IsUpdating = false; + } + } } @@ -117,7 +142,15 @@ public static void Uninstall(IModule module) private static void DeleteDirectoryAndContents(IModule module) { AssetDatabase.DeleteAsset(module.ModuleInstallPath); - CartSoAssetAccessor.GetAsset().RemoveInstalledInfo(module); + DataAccess.GetAsset().RemoveInstalledInfo(module); + } + + + public static void UninstallFromQueue() + { + AssetDatabase.StartAssetEditing(); + DeleteDirectoryAndContents(ModuleManager.AllModules.First(t => t.ModuleInstallPath.Equals(ModuleManager.CurrentProcess.PackageInstallLocation))); + AssetDatabase.StopAssetEditing(); } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -129,12 +162,17 @@ private static void DeleteDirectoryAndContents(IModule module) /// public void OnEditorReloaded() { - if (!ModuleManager.CurrentProcess.Equals(ModuleOperations.Uninstalling)) return; + if (ModuleManager.IsUpdating) return; + if (ModuleManager.CurrentProcess == null) return; + if (!ModuleManager.CurrentProcess.FlowInUse.Equals(ModuleOperations.Uninstall)) return; ModuleManager.RefreshNamespaceCache(); + + CartLogger.Log($"Module {ModuleManager.CurrentProcess.Package} uninstalled.", typeof(ModuleUninstaller),true); + + if (ModuleManager.TryProcessNext()) return; - ModuleManager.CurrentProcess = string.Empty; - ModuleManager.IsProcessing = false; + ModuleManager.ClearProcessQueue(); } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUpdater.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUpdater.cs index 20f2b03d..fabac548 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUpdater.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/Handlers/ModuleUpdater.cs @@ -21,13 +21,8 @@ * THE SOFTWARE. */ -using System.Collections.Generic; -using System.Linq; -using CarterGames.Cart.Core.Management; +using CarterGames.Cart.Core.Logs; using CarterGames.Cart.Core.Management.Editor; -using CarterGames.Cart.Modules.Window; -using UnityEditor; -using UnityEngine; namespace CarterGames.Cart.Modules { @@ -46,24 +41,15 @@ public sealed class ModuleUpdater : IAssetEditorReload /// The module to update. public static void UpdateModule(IModule module) { - ModuleManager.CurrentProcess = ModuleOperations.Updating; - ModuleManager.IsProcessing = true; ModuleManager.UpdatingModule = module.ModuleName; - AssetDatabase.StartAssetEditing(); + // Uninstall and re-install the module by hard delete of old first... + ModuleManager.IsUpdating = true; - ModuleManager.ProcessQueue = new List() - { - module.ModulePackagePath - }; - - AssetDatabase.DeleteAsset(module.ModuleInstallPath); - ModuleInstaller.Install(ModuleManager.AllModules.FirstOrDefault(t => t.ModulePackagePath.Equals(ModuleManager.ProcessQueue[0]))); - - CartSoAssetAccessor.GetAsset().AddInstalledModuleInfo(module, AssetDatabase.LoadAssetAtPath(module.ModuleInstallPath + "/Installation.json")); - ModuleManager.UpdatingModule = string.Empty; - - AssetDatabase.StopAssetEditing(); + ModuleManager.AddModuleToQueue(new ModuleChangeStateElement(module, ModuleOperations.Uninstall)); + ModuleManager.AddModuleToQueue(new ModuleChangeStateElement(module, ModuleOperations.Install)); + + ModuleManager.CurrentProcess.Process(); } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -75,19 +61,25 @@ public static void UpdateModule(IModule module) /// public void OnEditorReloaded() { + if (!ModuleManager.IsUpdating) return; + if (ModuleManager.CurrentProcess == null) return; + + ModuleManager.RefreshNamespaceCache(); - if (!ModuleManager.CurrentProcess.Equals(ModuleOperations.Updating)) return; + if (ModuleManager.TryProcessNext()) + { + CartLogger.Log("Continue to next step.", typeof(ModuleUpdater), true); + return; + } - var module = ModuleManager.AllModules.First(t => t.ModulePackagePath.Equals(ModuleManager.ProcessQueue.First())); - CartSoAssetAccessor.GetAsset().AddInstalledModuleInfo(module, AssetDatabase.LoadAssetAtPath(module.ModuleInstallPath + "/Installation.json")); - ModuleManager.ProcessQueue = new List(); - ModuleManager.RefreshNamespaceCache(); - ModulesWindow.RepaintWindow(); + ModuleManager.UpdateModuleInstallInfo(ModuleManager.ProcessQueue.ModulesEditing[0]); + + ModuleManager.ClearProcessQueue(); + ModuleManager.IsUpdating = false; - ModuleManager.CurrentProcess = string.Empty; - ModuleManager.IsProcessing = false; + CartLogger.Log($"Module {ModuleManager.CurrentProcess.Package} updated.", typeof(ModuleUpdater), true); } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/PostImportFileMover.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/System/PostImportFileMover.cs new file mode 100644 index 00000000..d948fb46 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/PostImportFileMover.cs @@ -0,0 +1,54 @@ +using System.Linq; +using CarterGames.Cart.Core.Management.Editor; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Cart.Modules +{ + public static class PostImportFileMover + { + private static string CorrectPathForModule(IModule module) + { + return module.ModuleInstallPath; + } + + + private static string CurrentPathForModule(IModule module) + { + var path = "Assets"; + path += module.ModuleInstallPath.Replace(ScriptableRef.AssetBasePath, string.Empty); + return path; + } + + + public static bool IsInRightPath(IModule module) + { + return AssetDatabase.IsValidFolder(CorrectPathForModule(module)) && (CurrentPathForModule(module) == CorrectPathForModule(module)); + } + + + public static void UpdateFileLocation(IModule module) + { + if (IsInRightPath(module)) return; + + AssetDatabase.StartAssetEditing(); + + AssetDatabase.MoveAsset(CurrentPathForModule(module), CorrectPathForModule(module)); + + if (ShouldDeleteExtraPaths()) + { + AssetDatabase.DeleteAsset("Assets/Carter Games/The Cart/Modules"); + AssetDatabase.DeleteAsset("Assets/Carter Games/The Cart/"); + AssetDatabase.DeleteAsset("Assets/Carter Games/"); + } + + AssetDatabase.StopAssetEditing(); + } + + + private static bool ShouldDeleteExtraPaths() + { + return !ScriptableRef.AssetBasePath.Equals("Assets"); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/System/PostImportFileMover.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/System/PostImportFileMover.cs.meta new file mode 100644 index 00000000..58493314 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/System/PostImportFileMover.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f2384617fe624b978695ed745c068ac2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModuleDisplay.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModuleDisplay.cs new file mode 100644 index 00000000..2614853c --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModuleDisplay.cs @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Cart.Core.Data; +using CarterGames.Cart.Core.Management; +using CarterGames.Cart.Core.Management.Editor; +using UnityEditor; +using UnityEngine; + +namespace CarterGames.Cart.Modules.Window +{ + public static class ModuleDisplay + { + private static GUIStyle labelStyle; + + + public static void DrawModule(IModule module) + { + TrySetupStyles(); + + EditorGUI.BeginDisabledGroup(ModuleManager.CurrentProcess != null); + + EditorGUILayout.BeginVertical(); + + if (ModuleManager.CurrentProcess != null) + { + EditorGUILayout.HelpBox("Processing...", MessageType.Info); + } + + if (ModuleManager.IsProcessing) + { + EditorGUILayout.HelpBox("Processing changes...", MessageType.None); + } + else + { + DrawModuleInfo(module); + GUILayout.Space(3.5f); + + // Update info if applicable... + if (ModuleManager.IsInstalled(module)) + { + if (ModuleManager.HasUpdate(module)) + { + DrawUpdateInfo(module); + GUILayout.Space(3.5f); + } + } + + DrawModuleOptions(module); + } + + EditorGUILayout.EndVertical(); + EditorGUI.EndDisabledGroup(); + } + + + + private static void TrySetupStyles() + { + labelStyle ??= new GUIStyle(EditorStyles.label); + labelStyle.wordWrap = true; + labelStyle.richText = true; + } + + + private static void DrawModuleInfo(IModule module) + { + if (string.IsNullOrEmpty(EditorSettingsModuleWindow.SelectedModuleName)) return; + if (module == null) return; + + EditorGUILayout.BeginVertical("HelpBox"); + + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField(module.ModuleName, EditorStyles.boldLabel); + DrawModuleStatusButton(module); + + EditorGUILayout.EndHorizontal(); + + // Author & revision will go here... + if (DataAccess.GetAsset().Manifest.GetData(module) != null) + { + var revisionLabel = DataAccess.GetAsset().InstalledModulesInfo + .ContainsKey(module.Namespace) + ? DataAccess.GetAsset().InstalledModulesInfo[module.Namespace] + .Revision + : DataAccess.GetAsset().Manifest.GetData(module).Revision; + + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.LabelField("Rev: " + revisionLabel, labelStyle); + EditorGUILayout.LabelField("Author: " + (DataAccess.GetAsset().Manifest.GetData(module).Author), labelStyle); + } + + // Pre-requirements.. + if (module.PreRequisites.Length > 0) + { + GeneralUtilEditor.DrawHorizontalGUILine(); + + EditorGUILayout.LabelField("Requires", EditorStyles.boldLabel); + + foreach (var preRequisite in module.PreRequisites) + { + EditorGUILayout.BeginHorizontal(); + + EditorGUILayout.LabelField("- " + preRequisite.ModuleName + " " + (ModuleManager.IsInstalled(preRequisite) ? "\u2714" : "\u2718"), labelStyle); + + EditorGUILayout.EndHorizontal(); + } + } + + GeneralUtilEditor.DrawHorizontalGUILine(); + + EditorGUILayout.LabelField(module.ModuleDescription, labelStyle); + + GeneralUtilEditor.DrawHorizontalGUILine(); + + EditorGUILayout.EndVertical(); + } + + + private static void DrawModuleStatusButton(IModule module) + { + if (ModuleManager.HasUpdate(module)) + { + GUI.backgroundColor = ModuleManager.UpdateCol; + + GUILayout.Label(ModuleManager.UpdateIcon + " Update Available", new GUIStyle("minibutton")); + } + else if (ModuleManager.IsInstalled(module)) + { + GUI.backgroundColor = ModuleManager.InstallCol; + + GUILayout.Label(ModuleManager.TickIcon + " Installed", new GUIStyle("minibutton")); + } + else + { + GUI.backgroundColor = ModuleManager.UninstallCol; + + GUILayout.Label(ModuleManager.CrossIcon + " Not Installed", new GUIStyle("minibutton")); + } + + GUI.backgroundColor = Color.white; + } + + + + private static void DrawModuleOptions(IModule module) + { + EditorGUILayout.BeginVertical("HelpBox"); + + EditorGUILayout.LabelField("Module Actions:", EditorStyles.boldLabel); + GeneralUtilEditor.DrawHorizontalGUILine(); + + if (ModuleManager.IsInstalled(module)) + { + if (ModuleManager.HasUpdate(module)) + { + DrawUpdateButton(module); + } + + DrawUninstallButton(module); + } + else + { + DrawInstallButton(module); + } + + EditorGUILayout.EndVertical(); + } + + + + private static void DrawInstallButton(IModule module) + { + EditorGUI.BeginDisabledGroup(!ModuleManager.HasPackage(module)); + GUI.backgroundColor = ModuleManager.InstallCol; + + if (GUILayout.Button(ModuleManager.TickIcon + " Install")) + { + ModuleInstaller.Install(module); + } + + GUI.backgroundColor = Color.white; + EditorGUI.EndDisabledGroup(); + } + + + private static void DrawUpdateButton(IModule module) + { + GUI.backgroundColor = ModuleManager.UpdateCol; + + if (GUILayout.Button(ModuleManager.UpdateIcon + " Update")) + { + ModuleUpdater.UpdateModule(module); + } + + GUI.backgroundColor = Color.white; + } + + + private static void DrawUpdateInfo(IModule module) + { + EditorGUILayout.BeginVertical("HelpBox"); + + EditorGUILayout.LabelField("This module has an update available.", labelStyle); + GeneralUtilEditor.DrawHorizontalGUILine(); + EditorGUILayout.LabelField($"Current: Rev.{ModuleManager.InstalledRevisionNumber(module)}\nLatest: Rev.{DataAccess.GetAsset().Manifest.GetData(module).Revision}", labelStyle); + + EditorGUILayout.EndVertical(); + } + + + private static void DrawUninstallButton(IModule module) + { + GUI.backgroundColor = ModuleManager.UninstallCol; + + if (GUILayout.Button(ModuleManager.CrossIcon + " Uninstall")) + { + ModuleManager.HasPrompted = false; + ModuleUninstaller.Uninstall(module); + } + + GUI.backgroundColor = Color.white; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModuleDisplay.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModuleDisplay.cs.meta new file mode 100644 index 00000000..c32bdea4 --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModuleDisplay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 54628805989248058dbc285bebdbfd28 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModulesWindow.cs b/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModulesWindow.cs index 5ac7bc8b..cf57253f 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModulesWindow.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Modules/Window/ModulesWindow.cs @@ -47,11 +47,11 @@ public sealed class ModulesWindow : EditorWindow | Menu Items ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - [MenuItem("Tools/Carter Games/The Cart/Modules/Window")] + [MenuItem("Tools/Carter Games/The Cart/Modules/Module Manager", priority = 1000)] private static void ShowWindow() { var window = GetWindow(); - window.titleContent = new GUIContent("Modules"); + window.titleContent = new GUIContent("Cart Modules"); window.maxSize = new Vector2(750, 600); window.Show(); } @@ -123,24 +123,11 @@ private void OnLeftGUI() /// - /// Handles the right GUI for the window, showing the infomation for the selected module. + /// Handles the right GUI for the window, showing the information for the selected module. /// private void OnRightGUI() { - EditorGUILayout.BeginVertical(); - - if (ModuleManager.IsProcessing) - { - EditorGUILayout.HelpBox("Processing changes...", MessageType.None); - } - else - { - DrawModuleControls(); - GUILayout.Space(5f); - DrawModule(); - } - - EditorGUILayout.EndVertical(); + ModuleDisplay.DrawModule(selectedModule); } @@ -149,120 +136,5 @@ public static void RepaintWindow() { GetWindow().Repaint(); } - - - private void DrawModuleControls() - { - if (string.IsNullOrEmpty(EditorSettingsModuleWindow.SelectedModuleName)) return; - if (selectedModule == null) return; - - EditorGUILayout.BeginVertical("HelpBox"); - EditorGUILayout.BeginHorizontal(); - - if (!ModuleManager.IsInstalled(selectedModule)) - { - EditorGUI.BeginDisabledGroup(!ModuleManager.HasPackage(selectedModule)); - GUI.backgroundColor = ModuleManager.InstallCol; - - if (GUILayout.Button(ModuleManager.TickIcon + " Install", GUILayout.Height(25f))) - { - ModuleInstaller.Install(selectedModule); - } - - GUI.backgroundColor = Color.white; - EditorGUI.EndDisabledGroup(); - } - else - { - if (ModuleManager.HasUpdate(selectedModule)) - { - EditorGUILayout.BeginVertical(); - GUI.backgroundColor = ModuleManager.UpdateCol; - - if (GUILayout.Button(ModuleManager.UpdateIcon + " Update", GUILayout.Height(25f))) - { - ModuleUpdater.UpdateModule(selectedModule); - } - - GUI.backgroundColor = Color.white; - GUILayout.Space(1.75f); - - EditorGUILayout.LabelField("This module has an update available.", labelStyle); - GeneralUtilEditor.DrawHorizontalGUILine(); - EditorGUILayout.LabelField($"Current: Rev.{ModuleManager.InstalledRevisionNumber(selectedModule)}\nLatest: Rev.{CartSoAssetAccessor.GetAsset().Manifest.GetData(selectedModule).Revision}", labelStyle); - - EditorGUILayout.EndVertical(); - } - else - { - GUI.backgroundColor = ModuleManager.UninstallCol; - - if (GUILayout.Button(ModuleManager.CrossIcon + " Uninstall", GUILayout.Height(25f))) - { - ModuleManager.HasPrompted = false; - ModuleUninstaller.Uninstall(selectedModule); - } - - GUI.backgroundColor = Color.white; - } - } - - EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); - } - - - - private void DrawModule() - { - if (string.IsNullOrEmpty(EditorSettingsModuleWindow.SelectedModuleName)) return; - if (selectedModule == null) return; - - EditorGUILayout.BeginVertical("HelpBox"); - - EditorGUILayout.LabelField(selectedModule.ModuleName, EditorStyles.boldLabel); - - // Author & revision will go here... - if (CartSoAssetAccessor.GetAsset().Manifest.GetData(selectedModule) != null) - { - var revisionLabel = CartSoAssetAccessor.GetAsset().InstalledModulesInfo - .ContainsKey(selectedModule.Namespace) - ? CartSoAssetAccessor.GetAsset().InstalledModulesInfo[selectedModule.Namespace] - .Revision - : CartSoAssetAccessor.GetAsset().Manifest.GetData(selectedModule).Revision; - - GeneralUtilEditor.DrawHorizontalGUILine(); - EditorGUILayout.LabelField("Rev: " + revisionLabel, labelStyle); - EditorGUILayout.LabelField("Author: " + (CartSoAssetAccessor.GetAsset().Manifest.GetData(selectedModule).Author), labelStyle); - } - - - // Pre-requirements.. - if (selectedModule.PreRequisites.Length > 0) - { - GeneralUtilEditor.DrawHorizontalGUILine(); - - EditorGUILayout.LabelField("Requires", EditorStyles.boldLabel); - - foreach (var preRequisite in selectedModule.PreRequisites) - { - EditorGUILayout.BeginHorizontal(); - - EditorGUILayout.LabelField("- " + preRequisite.ModuleName + " " + (ModuleManager.IsInstalled(preRequisite) ? "\u2714" : "\u2718"), labelStyle); - - EditorGUILayout.EndHorizontal(); - } - } - - GeneralUtilEditor.DrawHorizontalGUILine(); - - EditorGUILayout.LabelField(selectedModule.ModuleDescription, labelStyle); - - GeneralUtilEditor.DrawHorizontalGUILine(); - - - - EditorGUILayout.EndVertical(); - } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing.meta b/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing.meta deleted file mode 100644 index 7a56637f..00000000 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1a713f86f2a64a9e9b750306085dd904 -timeCreated: 1686237006 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors.meta b/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors.meta deleted file mode 100644 index 9007f707..00000000 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 64cf348083584486bbadd196b3cc51d6 -timeCreated: 1706562471 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors.meta b/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors.meta deleted file mode 100644 index 830cdb12..00000000 --- a/Carter Games/The Cart/Code/Editor/Management/Scriptable Asset Indexing/Custom Editors/Inspectors.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2b60da1074dd4481a0552e5e2444636c -timeCreated: 1706562476 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Settings Provider/LibrarySettingsProvider.cs b/Carter Games/The Cart/Code/Editor/Management/Settings Provider/LibrarySettingsProvider.cs index 86949a52..4ee920d1 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Settings Provider/LibrarySettingsProvider.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Settings Provider/LibrarySettingsProvider.cs @@ -74,8 +74,6 @@ public static SettingsProvider ScarletLibraryProvider() DrawAssetOptions(); GUILayout.Space(1.5f); DrawRuntimeOptions(); - // GUILayout.Space(1.5f); - // DrawEditorOptions(); GUILayout.Space(1.5f); DrawModuleOptions(); DrawButtons(); @@ -185,28 +183,13 @@ private static void DrawRuntimeOptions() } - /// - /// Draws the general options shown on the settings provider. - /// - // private static void DrawEditorOptions() - // { - // EditorGUILayout.BeginVertical("HelpBox"); - // GUILayout.Space(1.5f); - // EditorGUILayout.LabelField("Editor", EditorStyles.boldLabel); - // GeneralUtilEditor.DrawHorizontalGUILine(); - // - // EditorGUI.BeginChangeCheck(); - // - // GUILayout.Space(1.5f); - // EditorGUILayout.EndVertical(); - // } - - /// /// Draws all module settings on the settings provider. /// private static void DrawModuleOptions() { + if (SettingsProviderHandler.Providers.Count <= 0) return; + EditorGUILayout.BeginVertical("HelpBox"); GUILayout.Space(1.5f); EditorGUILayout.LabelField("Modules", EditorStyles.boldLabel); diff --git a/Carter Games/The Cart/Code/Editor/Management/Settings/SettingsProviderHandler.cs b/Carter Games/The Cart/Code/Editor/Management/Settings/SettingsProviderHandler.cs index f81285cd..90ab378e 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Settings/SettingsProviderHandler.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Settings/SettingsProviderHandler.cs @@ -39,17 +39,9 @@ public static class SettingsProviderHandler | Properties ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static int ProvidersInProject - { - get - { - return AppDomain.CurrentDomain - .GetAssemblies() - .SelectMany(x => x.GetTypes()).Count(x => x.IsClass && typeof(ISettingsProvider).IsAssignableFrom(x)); - } - } - - + private static int ProvidersInProject => AssemblyHelper.CountClassesOfType(); + + public static Dictionary Providers { get @@ -75,11 +67,8 @@ private static void UpdateCache() } if (providers.Count.Equals(ProvidersInProject)) return; - - var found = AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(x => x.GetTypes()) - .Where(x => x.IsClass && typeof(ISettingsProvider).IsAssignableFrom(x)) - .Select(type => (ISettingsProvider)Activator.CreateInstance(type)).ToArray(); + + var found = AssemblyHelper.GetClassesOfType().OrderBy(t => t.GetType().Name); providers = new Dictionary(); diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/CartVersionData.cs b/Carter Games/The Cart/Code/Editor/Management/Utility/CartVersionData.cs index d9c04492..25e93127 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Utility/CartVersionData.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/CartVersionData.cs @@ -31,7 +31,7 @@ public static class CartVersionData /// /// The version number of the asset. /// - public static string VersionNumber => "0.6.8"; + public static string VersionNumber => "0.7.0"; /// @@ -40,6 +40,6 @@ public static class CartVersionData /// /// Asset owner is in the UK, so its D/M/Y format. /// - public static string ReleaseDate => "17/06/2024"; + public static string ReleaseDate => "2024/07/14"; } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/Editor Helper Classes/AssemblyHelper.cs b/Carter Games/The Cart/Code/Editor/Management/Utility/Editor Helper Classes/AssemblyHelper.cs new file mode 100644 index 00000000..7ae7ae6d --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/Editor Helper Classes/AssemblyHelper.cs @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace CarterGames.Cart.Core.Management.Editor +{ + public static class AssemblyHelper + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private static Assembly[] cartAssembliesCache; + private static Assembly[] CartAssemblies => CacheRef.GetOrAssign(ref cartAssembliesCache, GetCartAssemblies); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private static Assembly[] GetCartAssemblies() + { + return new Assembly[3] + { + Assembly.Load("CarterGames.TheCart.Modules"), + Assembly.Load("CarterGames.TheCart.Editor"), + Assembly.Load("CarterGames.TheCart.Runtime") + }; + } + + + public static int CountClassesOfType(bool internalCheckOnly = true) + { + var assemblies = internalCheckOnly ? CartAssemblies : AppDomain.CurrentDomain.GetAssemblies(); + + return assemblies.SelectMany(x => x.GetTypes()) + .Count(x => x.IsClass && typeof(ISettingsProvider).IsAssignableFrom(x)); + } + + + public static IEnumerable GetClassesOfType(bool internalCheckOnly = true) + { + var assemblies = internalCheckOnly ? CartAssemblies : AppDomain.CurrentDomain.GetAssemblies(); + + return assemblies.SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && typeof(T).IsAssignableFrom(x) && x.FullName != typeof(T).FullName) + .Select(type => (T)Activator.CreateInstance(type)); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/Editor Helper Classes/AssemblyHelper.cs.meta b/Carter Games/The Cart/Code/Editor/Management/Utility/Editor Helper Classes/AssemblyHelper.cs.meta new file mode 100644 index 00000000..5a6f241f --- /dev/null +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/Editor Helper Classes/AssemblyHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f6ad4999c9ab4e8c92499b35d104d89c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/Per User Settings (Editor)/PerUserSettings.cs b/Carter Games/The Cart/Code/Editor/Management/Utility/Per User Settings (Editor)/PerUserSettings.cs index c9774712..fa632aec 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Utility/Per User Settings (Editor)/PerUserSettings.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/Per User Settings (Editor)/PerUserSettings.cs @@ -42,8 +42,6 @@ public static class PerUserSettings private static readonly string AssetSettingsEditorExpandedId = $"{UniqueId}_CarterGames_TheCart_AssetSettings_Expanded"; - - private static readonly string RuntimeRngExpandedId = $"{UniqueId}_CarterGames_TheCart_Settings_Rng_Expanded"; private static readonly string RuntimeLoggingExpandedId = $"{UniqueId}_CarterGames_TheCart_Settings_Logging_Expanded"; @@ -114,6 +112,12 @@ public static bool MockupEnabled | Methods ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + public static T GetValue(string key, SettingType type, object defaultValue = null) + { + return (T) GetOrCreateValue(key, type, defaultValue); + } + + public static object GetOrCreateValue(string key, SettingType type, object defaultValue = null) { switch (type) diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/FileEditorUtil.cs b/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/FileEditorUtil.cs index 375969fa..57bee978 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/FileEditorUtil.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/FileEditorUtil.cs @@ -24,6 +24,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using CarterGames.Cart.Core.Data.Editor; using UnityEditor; using UnityEngine; @@ -242,7 +243,7 @@ public static T CreateSoGetOrAssignAssetCache(ref T cache, string filter, str cache = CreateScriptableObject(path); } - AssetIndexHandler.UpdateIndex(); + DataAssetIndexHandler.UpdateIndex(); return cache; } diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/ScriptableRef.cs b/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/ScriptableRef.cs index b7020958..846e0b4b 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/ScriptableRef.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/Scriptable Assets/ScriptableRef.cs @@ -22,6 +22,8 @@ */ using System.IO; +using CarterGames.Cart.Core.Data; +using CarterGames.Cart.Core.Logs; using UnityEditor; namespace CarterGames.Cart.Core.Management.Editor @@ -37,19 +39,22 @@ public static class ScriptableRef // Asset Paths /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static readonly string AssetIndexPath = $"{AssetBasePath}/Carter Games/{AssetName}/Resources/Asset Index.asset"; + private static readonly string AssetIndexPath = $"{AssetBasePath}/Carter Games/{AssetName}/Resources/Data Asset Index.asset"; private static readonly string SettingsAssetPath = $"{AssetBasePath}/Carter Games/{AssetName}/Data/Runtime Settings.asset"; + private static readonly string LogCategoriesAssetPath = $"{AssetBasePath}/Carter Games/{AssetName}/Data/Log Category Statuses.asset"; // Asset Filters /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static readonly string RuntimeSettingsFilter = $"t:{typeof(CartGlobalRuntimeSettings).FullName}"; - private static readonly string AssetIndexFilter = $"t:{typeof(CartSoAssetIndex).FullName}"; + private static readonly string RuntimeSettingsFilter = $"t:{typeof(DataAssetCartGlobalRuntimeSettings).FullName}"; + private static readonly string AssetIndexFilter = $"t:{typeof(DataAssetIndex).FullName}"; + private static readonly string LogFilter = $"t:{typeof(DataAssetCartLogCategories).FullName}"; // Asset Caches /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static CartGlobalRuntimeSettings settingsAssetRuntimeCache; - private static CartSoAssetIndex assetIndexCache; + private static DataAssetCartGlobalRuntimeSettings settingsAssetRuntimeCache; + private static DataAssetIndex assetIndexCache; + private static DataAssetCartLogCategories logCategoriesAssetCache; @@ -57,6 +62,7 @@ public static class ScriptableRef /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ private static SerializedObject settingsAssetRuntimeObjectCache; private static SerializedObject settingsAssetEditorObjectCache; + private static SerializedObject logCategoriesObjectCache; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Properties @@ -83,17 +89,21 @@ public static class ScriptableRef /// /// The asset index for the asset. /// - public static CartSoAssetIndex AssetIndex => - FileEditorUtil.CreateSoGetOrAssignAssetCache(ref assetIndexCache, AssetIndexFilter, AssetIndexPath, AssetName, $"{AssetName}/Resources/Asset Index.asset"); + public static DataAssetIndex AssetIndex => + FileEditorUtil.CreateSoGetOrAssignAssetCache(ref assetIndexCache, AssetIndexFilter, AssetIndexPath, AssetName, $"{AssetName}/Resources/Data Asset Index.asset"); /// /// The runtime settings for the asset. /// - public static CartGlobalRuntimeSettings RuntimeSettings => + public static DataAssetCartGlobalRuntimeSettings RuntimeSettings => FileEditorUtil.CreateSoGetOrAssignAssetCache(ref settingsAssetRuntimeCache, RuntimeSettingsFilter, SettingsAssetPath, AssetName, $"{AssetName}/Data/Runtime Settings.asset"); + private static DataAssetCartLogCategories LogCategories => + FileEditorUtil.CreateSoGetOrAssignAssetCache(ref logCategoriesAssetCache, LogFilter, LogCategoriesAssetPath, AssetName, $"{AssetName}/Data/Log Category Statuses.asset"); + + // Object Properties /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ @@ -102,6 +112,14 @@ public static class ScriptableRef /// public static SerializedObject RuntimeSettingsObject => FileEditorUtil.CreateGetOrAssignSerializedObjectCache(ref settingsAssetRuntimeObjectCache, RuntimeSettings); + + + /// + /// The log categories asset. + /// + public static SerializedObject LogCategoriesObject => + FileEditorUtil.CreateGetOrAssignSerializedObjectCache(ref logCategoriesObjectCache, LogCategories); + // Assets Initialized Check /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ @@ -124,7 +142,7 @@ public static void TryCreateAssets() ref assetIndexCache, AssetIndexFilter, AssetIndexPath, - AssetName, $"{AssetName}/Resources/Asset Index.asset"); + AssetName, $"{AssetName}/Resources/Data Asset Index.asset"); } diff --git a/Carter Games/The Cart/Code/Editor/Management/Utility/UtilEditor.cs b/Carter Games/The Cart/Code/Editor/Management/Utility/UtilEditor.cs index 93fda0a8..a13bb8ad 100644 --- a/Carter Games/The Cart/Code/Editor/Management/Utility/UtilEditor.cs +++ b/Carter Games/The Cart/Code/Editor/Management/Utility/UtilEditor.cs @@ -21,6 +21,8 @@ * THE SOFTWARE. */ +using CarterGames.Cart.Core.Data; +using CarterGames.Cart.Core.Data.Editor; using UnityEditor; using UnityEngine; @@ -54,13 +56,13 @@ public static class UtilEditor /// /// Gets/Sets the save manager settings asset. /// - public static CartGlobalRuntimeSettings Settings => ScriptableRef.RuntimeSettings; + public static DataAssetCartGlobalRuntimeSettings Settings => ScriptableRef.RuntimeSettings; /// /// Gets/Sets the save manager settings asset. /// - public static CartSoAssetIndex AssetIndex => ScriptableRef.AssetIndex; + public static DataAssetIndex AssetIndex => ScriptableRef.AssetIndex; @@ -89,7 +91,7 @@ public static void Initialize() var index = AssetIndex; var runtimeSettings = Settings; - AssetIndexHandler.UpdateIndex(); + DataAssetIndexHandler.UpdateIndex(); EditorUtility.SetDirty(AssetIndex); AssetDatabase.SaveAssets(); diff --git a/Carter Games/The Cart/Code/Runtime/Core/Attributes.meta b/Carter Games/The Cart/Code/Runtime/Core/Attributes.meta new file mode 100644 index 00000000..b096054c --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Attributes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7b88db023be146419cdc053867e7c870 +timeCreated: 1716363171 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Attributes/ReadonlyAttribute.cs b/Carter Games/The Cart/Code/Runtime/Core/Attributes/ReadonlyAttribute.cs new file mode 100644 index 00000000..d7c8672e --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Attributes/ReadonlyAttribute.cs @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using UnityEngine; + +namespace CarterGames.Cart.Core +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public sealed class ReadonlyAttribute : PropertyAttribute + { + public ReadonlyAttribute() { } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Attributes/ReadonlyAttribute.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Attributes/ReadonlyAttribute.cs.meta new file mode 100644 index 00000000..1b329b13 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Attributes/ReadonlyAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b830b930f9f4c52b2804daea2418981 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Data.meta b/Carter Games/The Cart/Code/Runtime/Core/Data.meta new file mode 100644 index 00000000..8ef76730 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Data.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 293f04168bf04f50a14441285c92c916 +timeCreated: 1720002549 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetAccessor.cs b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAccess.cs similarity index 81% rename from Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetAccessor.cs rename to Carter Games/The Cart/Code/Runtime/Core/Data/DataAccess.cs index 9bda9d99..1b1be17c 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetAccessor.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAccess.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2024 Carter Games * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,19 +25,19 @@ using System.Linq; using UnityEngine; -namespace CarterGames.Cart.Core.Management +namespace CarterGames.Cart.Core.Data { - public static class CartSoAssetAccessor + /// + /// Helper class to access data assets at runtime. + /// + public static class DataAccess { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - - private const string IndexPath = "Asset Index"; - // A cache of all the assets found... - private static CartSoAssetIndex indexCache; + private static DataAssetIndex indexCache; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Properties @@ -46,12 +46,12 @@ public static class CartSoAssetAccessor /// /// Gets all the assets from the build versions asset... /// - public static CartSoAssetIndex Index + private static DataAssetIndex Index { get { if (indexCache != null) return indexCache; - indexCache = (CartSoAssetIndex) Resources.Load(IndexPath, typeof(CartSoAssetIndex)); + indexCache = Resources.Load("Data Asset Index"); return indexCache; } } @@ -65,7 +65,7 @@ public static CartSoAssetIndex Index /// /// The save manager asset to get. /// The asset if it exists. - public static T GetAsset() where T : CartSoAsset + public static T GetAsset() where T : DataAsset { if (Index.Lookup.ContainsKey(typeof(T).ToString())) { @@ -81,7 +81,23 @@ public static T GetAsset() where T : CartSoAsset /// /// The save manager asset to get. /// The asset if it exists. - public static List GetAssets() where T : CartSoAsset + public static T GetAsset(string id) where T : DataAsset + { + if (Index.Lookup.ContainsKey(typeof(T).ToString())) + { + return (T)Index.Lookup[typeof(T).ToString()].FirstOrDefault(t => t.VariantId.Equals(id)); + } + + return null; + } + + + /// + /// Gets the Save Manager Asset requested. + /// + /// The save manager asset to get. + /// The asset if it exists. + public static List GetAssets() where T : DataAsset { if (Index.Lookup.ContainsKey(typeof(T).ToString())) { diff --git a/Carter Games/The Cart/Code/Runtime/Core/Data/DataAccess.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAccess.cs.meta new file mode 100644 index 00000000..d95afc1b --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAccess.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 310d4715c57c4b1ea64b49e693dca0f5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Data/DataAsset.cs b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAsset.cs new file mode 100644 index 00000000..516a8dc4 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAsset.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using UnityEngine; + +namespace CarterGames.Cart.Core.Data +{ + /// + /// Inherit from to define a data asset that the data system will detect and allow access at runtime. + /// + public abstract class DataAsset : ScriptableObject + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Defines a id for this data asset. + /// + [SerializeField] private string variantId = Guid.NewGuid().ToString(); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Override to define a custom variant id for the data asset. + /// + public virtual string VariantId => variantId; + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Data/DataAsset.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAsset.cs.meta new file mode 100644 index 00000000..7d17a918 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAsset.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2228f9f960c94161ba833fd875c631ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: d9022c31c92aca64280da3560ebcbc9c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetIndex.cs b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAssetIndex.cs similarity index 88% rename from Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetIndex.cs rename to Carter Games/The Cart/Code/Runtime/Core/Data/DataAssetIndex.cs index 2f19324d..59f2a8ea 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetIndex.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAssetIndex.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2024 Carter Games * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,17 +22,22 @@ */ using System.Collections.Generic; +using CarterGames.Cart.Core; +using CarterGames.Cart.Core.Management; using UnityEngine; -namespace CarterGames.Cart.Core.Management +namespace CarterGames.Cart.Core.Data { - public sealed class CartSoAssetIndex : CartSoAsset + /// + /// The index for all data assets in the project. + /// + public sealed class DataAssetIndex : DataAsset { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - [SerializeField] private SerializableDictionary> assets; + [SerializeField] private SerializableDictionary> assets; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Properties @@ -41,6 +46,6 @@ public sealed class CartSoAssetIndex : CartSoAsset /// /// A lookup of all the assets in the project that can be used at runtime. /// - public SerializableDictionary> Lookup => assets; + public SerializableDictionary> Lookup => assets; } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetIndex.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAssetIndex.cs.meta similarity index 86% rename from Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetIndex.cs.meta rename to Carter Games/The Cart/Code/Runtime/Core/Data/DataAssetIndex.cs.meta index 6703f52d..6631fa74 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access/CartSoAssetIndex.cs.meta +++ b/Carter Games/The Cart/Code/Runtime/Core/Data/DataAssetIndex.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0c7a6fbb5a214e2d8ee2e5ebe75859f2 +guid: 99fc8d49eca440a086cfbced3aec0857 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/The Cart/Code/Runtime/Core/Extensions/GameObjectExtensions.cs b/Carter Games/The Cart/Code/Runtime/Core/Extensions/GameObjectExtensions.cs new file mode 100644 index 00000000..71951d65 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Extensions/GameObjectExtensions.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace CarterGames.Cart.Core +{ + public static class GameObjectExtensions + { + public static T OrNull(this T obj) where T : Object + { + return obj ? obj : null; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Extensions/GameObjectExtensions.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Extensions/GameObjectExtensions.cs.meta new file mode 100644 index 00000000..d667af82 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Extensions/GameObjectExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 63c0ddcba299442ab8e190fded0d699e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/PositionFormat.cs b/Carter Games/The Cart/Code/Runtime/Core/Formatting/PositionFormat.cs index 3bd94585..910ba74e 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Formatting/PositionFormat.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/PositionFormat.cs @@ -31,7 +31,7 @@ public static class PositionFormat /// /// Returns the position entered formatted with the correct ending characters as a string... /// - /// The position to get + /// The position to get /// String of the position with the correct ending characters... public static string ToPosition(this int value) { diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time.meta b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time.meta new file mode 100644 index 00000000..05f64cf9 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2966e637273b4638aa42add746a4039a +timeCreated: 1717085644 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/ITimeFormatter.cs b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/ITimeFormatter.cs new file mode 100644 index 00000000..fb73cd09 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/ITimeFormatter.cs @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; + +namespace CarterGames.Cart.Core +{ + /// + /// Implement to make a time formatter the system will register. + /// + public interface ITimeFormatter + { + string Format(TimeSpan timeSpan); + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/ITimeFormatter.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/ITimeFormatter.cs.meta new file mode 100644 index 00000000..777dc0d2 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/ITimeFormatter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 18de1146f19f4717a33b137bd6a8c93e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormat.cs b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormat.cs new file mode 100644 index 00000000..a412d21d --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormat.cs @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Collections.Generic; + +namespace CarterGames.Cart.Core +{ + public static class TimeFormat + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private static Dictionary formatterLookupCache; + private static Dictionary FormatterLookup { get; } = CacheRef.GetOrAssign(ref formatterLookupCache, GetFormatters); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private static Dictionary GetFormatters() + { + return new Dictionary() + { + { typeof(TimeFormatterStopWatchSimple), new TimeFormatterStopWatchSimple() }, + { typeof(TimeFormatterDayHourMinSecSimple), new TimeFormatterDayHourMinSecSimple() }, + { typeof(TimeFormatterDayHourMinSecDetailed), new TimeFormatterDayHourMinSecDetailed() }, + }; + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Creates a new time formatter instance if one doesn't exist at the time of requesting. + /// + /// The type to create. + /// The formatter to use. + private static ITimeFormatter Create() where T : ITimeFormatter + { + var formatter = Activator.CreateInstance(); + FormatterLookup.Add(typeof(T), formatter); + return formatter; + } + + + /// + /// Gets or make the time formatter requested for use. + /// + /// The type to create. + /// The formatter to use. + private static ITimeFormatter Get() where T : ITimeFormatter + { + return FormatterLookup.ContainsKey(typeof(T)) + ? FormatterLookup[typeof(T)] + : Create(); + } + + + /// + /// Formats the int as a time formatter. + /// + /// The seconds to convert. + /// The time formatter type to use. + /// The formatted string + public static string FormatAsTime(this int secondsLeft) where T : ITimeFormatter + { + return Get().Format(TimeSpan.FromSeconds(secondsLeft)); + } + + + /// + /// Formats the double as a time formatter. + /// + /// The seconds to convert. + /// The time formatter type to use. + /// The formatted string + public static string FormatAsTime(this double secondsLeft) where T : ITimeFormatter + { + return Get().Format(TimeSpan.FromSeconds(secondsLeft)); + } + + + /// + /// Formats the float as a time formatter. + /// + /// The seconds to convert. + /// The time formatter type to use. + /// The formatted string + public static string FormatAsTime(this float secondsLeft) where T : ITimeFormatter + { + return Get().Format(TimeSpan.FromSeconds(secondsLeft)); + } + + + /// + /// Formats the timespan as a time formatter. + /// + /// The timespan to convert. + /// The time formatter type to use. + /// The formatted string + public static string FormatAsTime(this TimeSpan timeSpan) where T : ITimeFormatter + { + return Get().Format(timeSpan); + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormat.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormat.cs.meta new file mode 100644 index 00000000..45105bd0 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormat.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 70c7e6774bea408a94cd4d035ff98a3b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecDetailed.cs b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecDetailed.cs new file mode 100644 index 00000000..489d04d0 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecDetailed.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; + +namespace CarterGames.Cart.Core +{ + public class TimeFormatterDayHourMinSecDetailed : ITimeFormatter + { + public string Format(TimeSpan timeSpan) + { + if (timeSpan.Days > 0) + { + return $"{timeSpan.Days}d {timeSpan.Hours}hr {timeSpan.Minutes}m {timeSpan.Seconds}s"; + } + + if (timeSpan.Hours > 0) + { + return $"{timeSpan.Hours}hr {timeSpan.Minutes}m {timeSpan.Seconds}s"; + } + + return timeSpan.Minutes > 0 ? $"{timeSpan.Minutes}m {timeSpan.Seconds}s" : $"{timeSpan.Seconds}s"; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecDetailed.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecDetailed.cs.meta new file mode 100644 index 00000000..e498c422 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecDetailed.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23d1f3064e47447ea5423b45e1dd319c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecSimple.cs b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecSimple.cs new file mode 100644 index 00000000..02245c38 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecSimple.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; + +namespace CarterGames.Cart.Core +{ + public class TimeFormatterDayHourMinSecSimple : ITimeFormatter + { + public string Format(TimeSpan timeSpan) + { + if (timeSpan.Days > 0) + { + return timeSpan.Hours > 0 ? $"{timeSpan.Days}d {timeSpan.Hours}hr" : $"{timeSpan.Days}d"; + } + + if (timeSpan.Hours > 0) + { + return timeSpan.Minutes > 0 ? $"{timeSpan.Hours}hr {timeSpan.Minutes}m" : $"{timeSpan.Hours}hr"; + } + + return timeSpan.Minutes > 0 ? $"{timeSpan.Minutes}m" : $"{timeSpan.Seconds}s"; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecSimple.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecSimple.cs.meta new file mode 100644 index 00000000..5054d409 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterDayHourMinSecSimple.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f884f9c96de1413097d5f3f82749e27f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterStopWatchSimple.cs b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterStopWatchSimple.cs new file mode 100644 index 00000000..a1914e74 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterStopWatchSimple.cs @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; + +namespace CarterGames.Cart.Core +{ + public class TimeFormatterStopWatchSimple : ITimeFormatter + { + public string Format(TimeSpan timeSpan) + { + if (timeSpan.Hours > 0) + { + return timeSpan.Minutes > 0 ? $"{timeSpan.Hours:##}:{timeSpan.Minutes:##}" : $"{timeSpan.Hours:##}:00"; + } + + return timeSpan.Minutes > 0 ? $"{timeSpan.Minutes:##}:{timeSpan.Seconds:##}" : $"00:{timeSpan.Seconds:##}"; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterStopWatchSimple.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterStopWatchSimple.cs.meta new file mode 100644 index 00000000..84591cc7 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Formatting/Time/TimeFormatterStopWatchSimple.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 509d48c1f54b42fea8cfedc0820509ed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Management/CartSoAsset.cs b/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogCategory.cs similarity index 85% rename from Carter Games/The Cart/Code/Runtime/Management/CartSoAsset.cs rename to Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogCategory.cs index 316a20dc..eca7f2b6 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/CartSoAsset.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogCategory.cs @@ -21,12 +21,13 @@ * THE SOFTWARE. */ -using UnityEngine; +using System; -namespace CarterGames.Cart.Core.Management +namespace CarterGames.Cart.Core.Logs { /// - /// Defines a library asset that can be found via the asset index system. + /// Inherit from to make a cart log category. /// - public abstract class CartSoAsset : ScriptableObject { } + [Serializable] + public abstract class CartLogCategory { } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogCategory.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogCategory.cs.meta new file mode 100644 index 00000000..3efbdee8 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogCategory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3fc9a17d023441178694be95a4ecbc50 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogger.cs b/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogger.cs index 3f76e5e2..ea9b5193 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogger.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/CartLogger.cs @@ -23,6 +23,7 @@ using System; using System.Text; +using CarterGames.Cart.Core.Data; using CarterGames.Cart.Core.Management; using UnityEngine; @@ -39,10 +40,9 @@ public static class CartLogger private const string TypeColorPrefix = ""; private const string ColorSuffix = ""; - private const string WarningPrefix = "Warning | "; - private const string ErrorPrefix = "Error | "; private static readonly StringBuilder Builder = new StringBuilder(); + private static readonly StringBuilder MessageBuilder = new StringBuilder(); /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Properties @@ -83,62 +83,27 @@ private static bool CanShowLogs ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ /// - /// Creates the severity prefix for the log message. + /// Creates the category prefix for the log. /// - /// The severity of the log message. - /// The prefix if there is one. - private static string GetSeverityPrefix(LogType logType) + /// The sub-type for the message if used. + /// The log category type + /// The prefix ready for use. + private static string GetCategoryPrefix(Type additionalContext = null) { - if (logType == LogType.Log) - { - return string.Empty; - } - Builder.Clear(); - - switch (logType) - { - case LogType.Error: - case LogType.Assert: - case LogType.Exception: - Builder.Append(ErrorPrefix); - break; - case LogType.Warning: - Builder.Append(WarningPrefix); - break; - } - - return Builder.ToString(); - } - - - /// - /// Makes the location log prefix if needed. - /// - /// The main type string. - /// The sub-type string. - /// The prepared type prefix string. - private static string GetLogLocationString(string context, string additionalContext = null) - { - if (string.IsNullOrEmpty(context) && string.IsNullOrEmpty(additionalContext)) return string.Empty; - Builder.Clear(); Builder.Append(TypeColorPrefix); - Builder.Append(context); - - if (string.IsNullOrEmpty(additionalContext)) + Builder.Append(typeof(T).Name); + + if (additionalContext != null) { - Builder.Append(ColorSuffix); - Builder.Append(":"); - - return Builder.ToString(); + Builder.Append("/"); + Builder.Append(additionalContext.Name); } - Builder.Append("/"); - Builder.Append(additionalContext); Builder.Append(ColorSuffix); Builder.Append(":"); - + return Builder.ToString(); } @@ -147,27 +112,18 @@ private static string GetLogLocationString(string context, string additionalCont /// Generates the log message all together to show. /// /// The severity of the log message. - /// The target type for the message in string form. /// The message to show. /// The sub-type for the message if used. + /// The log category type /// The formatted log message. - private static string CreateLogMessage(LogType logType, string target, string msg, Type additionalContext) + private static string CreateLogMessage(LogType logType, string msg, Type additionalContext = null) where T : CartLogCategory { - var severityPrefix = GetSeverityPrefix(logType); - var prefix = GetLogLocationString(target, additionalContext == null ? string.Empty : additionalContext.Name); - - Builder.Clear(); - Builder.Append(severityPrefix); - Builder.Append(prefix); + MessageBuilder.Clear(); + MessageBuilder.Append(GetCategoryPrefix(additionalContext)); + MessageBuilder.Append(" "); + MessageBuilder.Append(msg); - if (!string.IsNullOrEmpty(severityPrefix) || !string.IsNullOrEmpty(prefix)) - { - Builder.Append(" "); - } - - Builder.Append(msg); - - return Builder.ToString(); + return MessageBuilder.ToString(); } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -184,44 +140,31 @@ private static string CreateLogMessage(LogType logType, string target, string ms /// /// The message to write. /// Should this log be in the editor only. - public static void Log(string message, bool editorOnlyLog = false) + /// The log type to display as. + public static void Log(string message, bool editorOnlyLog = false) where T : CartLogCategory { if (!CanShowLogs) return; + if (!DataAccess.GetAsset().IsEnabled()) return; if (!Application.isEditor && editorOnlyLog) return; - Debug.Log(CreateLogMessage(LogType.Log, string.Empty, message, null)); + Debug.Log(CreateLogMessage(LogType.Log, message)); } - /// - /// Creates a normal log message. - /// - /// The message to write. - /// The additional type context for the log. Such as system/class. - /// Should this log be in the editor only. - /// The type context for the log. - public static void Log(string message, Type typeContext = null, bool editorOnlyLog = false) - { - if (!CanShowLogs) return; - if (!Application.isEditor && editorOnlyLog) return; - - Debug.Log(CreateLogMessage(LogType.Log, typeof(T).Name, message, typeContext)); - } - - /// /// Displays a normal debug message. /// - /// The type this log is to show. /// The message to write. - /// The additional type context for the log. Such as system/class. + /// The additional type context for the log. Such as system/class. /// Should this log be in the editor only. - public static void Log(Type type, string message, Type typeContext = null, bool editorOnlyLog = false) + /// The log type to display as. + public static void Log(string message, Type additionalContext, bool editorOnlyLog = false) where T : CartLogCategory { if (!CanShowLogs) return; + if (!DataAccess.GetAsset().IsEnabled()) return; if (!Application.isEditor && editorOnlyLog) return; - Debug.Log(CreateLogMessage(LogType.Log, type.Name, message, typeContext)); + Debug.Log(CreateLogMessage(LogType.Log, message, additionalContext)); } @@ -234,44 +177,31 @@ public static void Log(Type type, string message, Type typeContext = null, bool /// /// The message to write. /// Should this log be in the editor only. - public static void LogWarning(string message, bool editorOnlyLog = false) + /// The log type to display as. + public static void LogWarning(string message, bool editorOnlyLog = false) where T : CartLogCategory { if (!CanShowLogs) return; + if (!DataAccess.GetAsset().IsEnabled()) return; if (!Application.isEditor && editorOnlyLog) return; - Debug.Log(CreateLogMessage(LogType.Warning, string.Empty, message, null)); + Debug.LogWarning(CreateLogMessage(LogType.Warning, message)); } - /// - /// Creates a warning log message. - /// - /// The message to write. - /// The additional type context for the log. Such as system/class. - /// Should this log be in the editor only. - /// The type context for the log. - public static void LogWarning(string message, Type typeContext = null, bool editorOnlyLog = false) - { - if (!CanShowLogs) return; - if (!Application.isEditor && editorOnlyLog) return; - - Debug.Log(CreateLogMessage(LogType.Warning, typeof(T).Name, message, typeContext)); - } - - /// /// Displays a warning debug message. /// - /// The type this log is to show. /// The message to write. - /// The additional type context for the log. Such as system/class. + /// The additional type context for the log. Such as system/class. /// Should this log be in the editor only. - public static void LogWarning(Type type, string message, Type typeContext = null, bool editorOnlyLog = false) + /// The log type to display as. + public static void LogWarning(string message, Type additionalContext, bool editorOnlyLog = false) where T : CartLogCategory { if (!CanShowLogs) return; + if (!DataAccess.GetAsset().IsEnabled()) return; if (!Application.isEditor && editorOnlyLog) return; - Debug.Log(CreateLogMessage(LogType.Warning, type.Name, message, typeContext)); + Debug.LogWarning(CreateLogMessage(LogType.Warning, message, additionalContext)); } @@ -284,44 +214,31 @@ public static void LogWarning(Type type, string message, Type typeContext = null /// /// The message to write. /// Should this log be in the editor only. - public static void LogError(string message, bool editorOnlyLog = false) + /// The log type to display as. + public static void LogError(string message, bool editorOnlyLog = false) where T : CartLogCategory { if (!CanShowLogs) return; + if (!DataAccess.GetAsset().IsEnabled()) return; if (!Application.isEditor && editorOnlyLog) return; - Debug.Log(CreateLogMessage(LogType.Error, string.Empty, message, null)); + Debug.LogError(CreateLogMessage(LogType.Error, message)); } - /// - /// Creates a error log message. - /// - /// The message to write. - /// The additional type context for the log. Such as system/class. - /// Should this log be in the editor only. - /// The type context for the log. - public static void LogError(string message, Type typeContext = null, bool editorOnlyLog = false) - { - if (!CanShowLogs) return; - if (!Application.isEditor && editorOnlyLog) return; - - Debug.Log(CreateLogMessage(LogType.Error, typeof(T).Name, message, typeContext)); - } - - /// /// Displays a error debug message. /// - /// The type this log is to show. /// The message to write. - /// The additional type context for the log. Such as system/class. + /// The additional type context for the log. Such as system/class. /// Should this log be in the editor only. - public static void LogError(Type type, string message, Type typeContext = null, bool editorOnlyLog = false) + /// The log type to display as. + public static void LogError(string message, Type additionalContext, bool editorOnlyLog = false) where T : CartLogCategory { if (!CanShowLogs) return; + if (!DataAccess.GetAsset().IsEnabled()) return; if (!Application.isEditor && editorOnlyLog) return; - Debug.Log(CreateLogMessage(LogType.Error, type.Name, message, typeContext)); + Debug.LogError(CreateLogMessage(LogType.Error, message, additionalContext)); } } } \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Logging/DataAssetCartLogCategories.cs b/Carter Games/The Cart/Code/Runtime/Core/Logging/DataAssetCartLogCategories.cs new file mode 100644 index 00000000..1a5a86ed --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/DataAssetCartLogCategories.cs @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using CarterGames.Cart.Core.Data; +using UnityEngine; + +namespace CarterGames.Cart.Core.Logs +{ + /// + /// A data asset to store the states of all the log categories. + /// + [CreateAssetMenu] + public sealed class DataAssetCartLogCategories : DataAsset + { + [SerializeField] private SerializableDictionary lookup; + + + public bool IsEnabled(CartLogCategory category) + { + if (!lookup.TryGetValue(category.GetType().FullName, out var enabled)) return false; + return enabled; + } + + + public bool IsEnabled() where T : CartLogCategory + { + if (!lookup.ContainsKey(typeof(T).FullName)) return false; + return lookup[typeof(T).FullName]; + } + } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Logging/DataAssetCartLogCategories.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Logging/DataAssetCartLogCategories.cs.meta new file mode 100644 index 00000000..1ef3158a --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/DataAssetCartLogCategories.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4400b2eba63b44fca0e1531b38c30259 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Logging/LogCategoryCore.cs b/Carter Games/The Cart/Code/Runtime/Core/Logging/LogCategoryCore.cs new file mode 100644 index 00000000..feb6e58b --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/LogCategoryCore.cs @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Cart.Core.Logs +{ + /// + /// The log category for the core library. + /// + public sealed class LogCategoryCore : CartLogCategory { } +} \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Core/Logging/LogCategoryCore.cs.meta b/Carter Games/The Cart/Code/Runtime/Core/Logging/LogCategoryCore.cs.meta new file mode 100644 index 00000000..8c36f710 --- /dev/null +++ b/Carter Games/The Cart/Code/Runtime/Core/Logging/LogCategoryCore.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8ab0e252e3fa4afb8f3e3f6d8a35492f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Core/Object Pooling/ObjectPoolGeneric.cs b/Carter Games/The Cart/Code/Runtime/Core/Object Pooling/ObjectPoolGeneric.cs index f50262b0..6f7e5355 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Object Pooling/ObjectPoolGeneric.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Object Pooling/ObjectPoolGeneric.cs @@ -34,6 +34,7 @@ public sealed class ObjectPoolGeneric : ObjectPoolBase /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Constructors ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + public ObjectPoolGeneric(GameObject prefab, Transform parent, int initialCount = 3, bool startActive = false) : base(prefab, parent, initialCount) { } diff --git a/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/Alea/AleaRngProvider.cs b/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/Alea/AleaRngProvider.cs index 8630baad..9637432d 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/Alea/AleaRngProvider.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/Alea/AleaRngProvider.cs @@ -22,6 +22,7 @@ */ using System; +using CarterGames.Cart.Core.Data; using CarterGames.Cart.Core.Management; namespace CarterGames.Cart.Core.Random @@ -34,8 +35,8 @@ public sealed class AleaRngProvider : ISeededRngProvider /// This is intended to help with debugging as you can replicate the seed & get the same results as a user. public static string Seed { - get => CartSoAssetAccessor.GetAsset().RngAleaRngSeed; - set => CartSoAssetAccessor.GetAsset().RngAleaRngSeed = value; + get => DataAccess.GetAsset().RngAleaRngSeed; + set => DataAccess.GetAsset().RngAleaRngSeed = value; } diff --git a/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/System/SystemRngProvider.cs b/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/System/SystemRngProvider.cs index a2ad4888..3d2dd57c 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/System/SystemRngProvider.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Random/Providers/System/SystemRngProvider.cs @@ -22,6 +22,7 @@ */ using System; +using CarterGames.Cart.Core.Data; using CarterGames.Cart.Core.Management; namespace CarterGames.Cart.Core.Random @@ -34,8 +35,8 @@ public sealed class SystemRngProvider : ISeededRngProvider /// This is intended to help with debugging as you can replicate the seed & get the same results as a user. public static int Seed { - get => CartSoAssetAccessor.GetAsset().RngSystemRngSeed; - set => CartSoAssetAccessor.GetAsset().RngSystemRngSeed = value; + get => DataAccess.GetAsset().RngSystemRngSeed; + set => DataAccess.GetAsset().RngSystemRngSeed = value; } diff --git a/Carter Games/The Cart/Code/Runtime/Core/Random/Rng.cs b/Carter Games/The Cart/Code/Runtime/Core/Random/Rng.cs index cf8ba243..1ff05f18 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Random/Rng.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Random/Rng.cs @@ -21,6 +21,7 @@ * THE SOFTWARE. */ +using CarterGames.Cart.Core.Data; using CarterGames.Cart.Core.Management; using UnityEngine; @@ -46,7 +47,7 @@ private static IRngProvider Provider get { if (providerCache != null) return providerCache; - providerCache = CartSoAssetAccessor.GetAsset().RngRngProvider switch + providerCache = DataAccess.GetAsset().RngRngProvider switch { RngProviders.Unity => new UnityRngProvider(), RngProviders.System => new SystemRngProvider(), diff --git a/Carter Games/The Cart/Code/Runtime/Core/Static Instancing/Instance.cs b/Carter Games/The Cart/Code/Runtime/Core/Static Instancing/Instance.cs index 51f92e39..66e6c695 100644 --- a/Carter Games/The Cart/Code/Runtime/Core/Static Instancing/Instance.cs +++ b/Carter Games/The Cart/Code/Runtime/Core/Static Instancing/Instance.cs @@ -85,7 +85,7 @@ public static implicit operator T(Instance instance) { if (instance.Value == null) { - CartLogger.LogError>("Instance is null. Please ensure the instance is initialised."); + CartLogger.LogError("Instance is null. Please ensure the instance is initialised.", typeof(Instance)); } return instance.Value; diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access.meta b/Carter Games/The Cart/Code/Runtime/Management/Assets/Access.meta deleted file mode 100644 index b1ac6e44..00000000 --- a/Carter Games/The Cart/Code/Runtime/Management/Assets/Access.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e54114f0c553446aa500f834f2ff828b -timeCreated: 1685132918 \ No newline at end of file diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/CartGlobalRuntimeSettings.cs b/Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/DataAssetCartGlobalRuntimeSettings.cs similarity index 98% rename from Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/CartGlobalRuntimeSettings.cs rename to Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/DataAssetCartGlobalRuntimeSettings.cs index 8a8025bf..675f563a 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/CartGlobalRuntimeSettings.cs +++ b/Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/DataAssetCartGlobalRuntimeSettings.cs @@ -22,6 +22,7 @@ */ using System; +using CarterGames.Cart.Core.Data; using CarterGames.Cart.Core.Random; using UnityEngine; @@ -30,7 +31,7 @@ namespace CarterGames.Cart.Core.Management /// /// Handles any runtime specific settings for the package. /// - public sealed class CartGlobalRuntimeSettings : CartSoAsset + public sealed class DataAssetCartGlobalRuntimeSettings : DataAsset { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields diff --git a/Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/CartGlobalRuntimeSettings.cs.meta b/Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/DataAssetCartGlobalRuntimeSettings.cs.meta similarity index 100% rename from Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/CartGlobalRuntimeSettings.cs.meta rename to Carter Games/The Cart/Code/Runtime/Management/Assets/Settings/DataAssetCartGlobalRuntimeSettings.cs.meta diff --git a/Carter Games/The Cart/Code/Runtime/Management/CartSoAsset.cs.meta b/Carter Games/The Cart/Code/Runtime/Management/CartSoAsset.cs.meta deleted file mode 100644 index ce77dbfb..00000000 --- a/Carter Games/The Cart/Code/Runtime/Management/CartSoAsset.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45b4f6e1231742f1a100bc932bb8a296 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Carter Games/The Cart/Code/Runtime/Management/Utility/UtilRuntime.cs b/Carter Games/The Cart/Code/Runtime/Management/Utility/UtilRuntime.cs index 8518bc05..51764297 100644 --- a/Carter Games/The Cart/Code/Runtime/Management/Utility/UtilRuntime.cs +++ b/Carter Games/The Cart/Code/Runtime/Management/Utility/UtilRuntime.cs @@ -21,6 +21,8 @@ * THE SOFTWARE. */ +using CarterGames.Cart.Core.Data; + namespace CarterGames.Cart.Core.Management { /// @@ -34,7 +36,7 @@ public static class UtilRuntime // Caches /* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - private static CartGlobalRuntimeSettings settingsCache; + private static DataAssetCartGlobalRuntimeSettings settingsCache; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Properties @@ -43,12 +45,12 @@ public static class UtilRuntime /// /// The runtime settings asset. /// - public static CartGlobalRuntimeSettings Settings + public static DataAssetCartGlobalRuntimeSettings Settings { get { if (settingsCache != null) return settingsCache; - settingsCache = CartSoAssetAccessor.GetAsset(); + settingsCache = DataAccess.GetAsset(); return settingsCache; } } diff --git a/Carter Games/The Cart/Data/Log Category Statuses.asset b/Carter Games/The Cart/Data/Log Category Statuses.asset new file mode 100644 index 00000000..c7e018fe --- /dev/null +++ b/Carter Games/The Cart/Data/Log Category Statuses.asset @@ -0,0 +1,21 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4400b2eba63b44fca0e1531b38c30259, type: 3} + m_Name: Log Category Statuses + m_EditorClassIdentifier: + variantId: 8c33a079-22a9-4908-b241-bef4b480cdae + lookup: + list: + - key: CarterGames.Cart.Core.Logs.LogCategoryCore + value: 1 + - key: CarterGames.Cart.Modules.LogCategoryModules + value: 1 diff --git a/Carter Games/The Cart/Resources/Asset Index.asset.meta b/Carter Games/The Cart/Data/Log Category Statuses.asset.meta similarity index 79% rename from Carter Games/The Cart/Resources/Asset Index.asset.meta rename to Carter Games/The Cart/Data/Log Category Statuses.asset.meta index aa9f6b8c..81db9eee 100644 --- a/Carter Games/The Cart/Resources/Asset Index.asset.meta +++ b/Carter Games/The Cart/Data/Log Category Statuses.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 735bf6f511b89564392d45f16f19d521 +guid: b8baa1849fb6f9b4fabce365e57a4e83 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Carter Games/The Cart/Data/Module Json Cache.asset b/Carter Games/The Cart/Data/Module Json Cache.asset index 1d928683..f051eb0c 100644 --- a/Carter Games/The Cart/Data/Module Json Cache.asset +++ b/Carter Games/The Cart/Data/Module Json Cache.asset @@ -12,6 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d7011008de024b598bbdac5ab5e5a933, type: 3} m_Name: Module Json Cache m_EditorClassIdentifier: + variantId: cdafe99a-64cc-4135-bb7f-906918c66a2d installedModuleReceipts: list: [] manifest: {fileID: 4900000, guid: e78d45899da84bbb98346843cea7b2e3, type: 3} diff --git a/Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage b/Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage deleted file mode 100644 index 9d1cb156..00000000 Binary files a/Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage and /dev/null differ diff --git a/Carter Games/The Cart/Data/Module Packages/CartModuleGameTicks.unitypackage b/Carter Games/The Cart/Data/Module Packages/CartModuleGameTicks.unitypackage index c8ed8191..b73a5133 100644 Binary files a/Carter Games/The Cart/Data/Module Packages/CartModuleGameTicks.unitypackage and b/Carter Games/The Cart/Data/Module Packages/CartModuleGameTicks.unitypackage differ diff --git a/Carter Games/The Cart/Data/Module Packages/CartModuleLoadingScreens.unitypackage b/Carter Games/The Cart/Data/Module Packages/CartModuleLoadingScreens.unitypackage index c7c45a70..309e8a29 100644 Binary files a/Carter Games/The Cart/Data/Module Packages/CartModuleLoadingScreens.unitypackage and b/Carter Games/The Cart/Data/Module Packages/CartModuleLoadingScreens.unitypackage differ diff --git a/Carter Games/The Cart/Data/Module Packages/CartModuleMockup.unitypackage b/Carter Games/The Cart/Data/Module Packages/CartModuleMockup.unitypackage index 9d515ebb..cc28148f 100644 Binary files a/Carter Games/The Cart/Data/Module Packages/CartModuleMockup.unitypackage and b/Carter Games/The Cart/Data/Module Packages/CartModuleMockup.unitypackage differ diff --git a/Carter Games/The Cart/Data/Module Packages/CartModuleNotionData.unitypackage b/Carter Games/The Cart/Data/Module Packages/CartModuleNotionData.unitypackage index c09c9ead..d76a5f99 100644 Binary files a/Carter Games/The Cart/Data/Module Packages/CartModuleNotionData.unitypackage and b/Carter Games/The Cart/Data/Module Packages/CartModuleNotionData.unitypackage differ diff --git a/Carter Games/The Cart/Data/Module Packages/CartModulePanels.unitypackage b/Carter Games/The Cart/Data/Module Packages/CartModulePanels.unitypackage index fcdbdceb..8cdce566 100644 Binary files a/Carter Games/The Cart/Data/Module Packages/CartModulePanels.unitypackage and b/Carter Games/The Cart/Data/Module Packages/CartModulePanels.unitypackage differ diff --git a/Carter Games/The Cart/Data/Runtime Settings.asset b/Carter Games/The Cart/Data/Runtime Settings.asset index 86af8f31..806fcee0 100644 --- a/Carter Games/The Cart/Data/Runtime Settings.asset +++ b/Carter Games/The Cart/Data/Runtime Settings.asset @@ -12,10 +12,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5c0e9236ccdde024485926cfcb9de3f4, type: 3} m_Name: Runtime Settings m_EditorClassIdentifier: + variantId: d0df3b06-bc08-4e37-a0cf-422ccba49c4b isRngExpanded: 0 rngRngProvider: 0 - rngSystemSeed: 427772247 - rngAleaSeed: ebcfe3f8-9811-4ef3-81ee-fd323d34dcee + rngSystemSeed: 1001727792 + rngAleaSeed: 8aee7ddd-d880-44c4-940c-47d48e8ff1ba isLoggingExpanded: 0 loggingUseCartLogs: 1 - useLogsInProductionBuilds: 1 + useLogsInProductionBuilds: 0 diff --git a/Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage.meta b/Carter Games/The Cart/Docs/Data.meta similarity index 67% rename from Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage.meta rename to Carter Games/The Cart/Docs/Data.meta index 3f04b43f..8e294dd5 100644 --- a/Carter Games/The Cart/Data/Module Packages/CartModuleData.unitypackage.meta +++ b/Carter Games/The Cart/Docs/Data.meta @@ -1,5 +1,6 @@ fileFormatVersion: 2 -guid: 2dab63fcf03e50a43a6b1824ee1e9a3d +guid: 7111af820091b2a44bbfb7d98c00648a +folderAsset: yes DefaultImporter: externalObjects: {} userData: diff --git a/Carter Games/The Cart/Docs/Data/Documentation - Core - Data.html b/Carter Games/The Cart/Docs/Data/Documentation - Core - Data.html new file mode 100644 index 00000000..3ea1c592 --- /dev/null +++ b/Carter Games/The Cart/Docs/Data/Documentation - Core - Data.html @@ -0,0 +1,55 @@ +Data System

Data System

System TypeCore
Revision1
Last Updated

+

The data setup is designed to aid in storing data related to the project in scriptable objects for ease of access at runtime. Without adding the overhead of needed to assign references for the assets.

+

+

-Usage

The data system has two main elements to it. The data assets and the data asset index. The assets are what hold the data you define. With you making classes that implement the class to store data. While the index keeps a reference of all the data assets in the project for use at runtime.

+

Creating data assets


To create a data asset, either inherit from the DataAsset class or use the provided tool that will create the necessary classes for you. You can find the creation tool under:

Tools/Carter Games/The Cart/Core/Data/Asset Creator

This will open an editor window that’ll let you make a new data asset class. To use the tool, you simple enter the name you want the class to have a press create. A popup will then appear to let you choose where it should be saved. After which you’ll get the chance to open the newly created class for editing in your chosen IDE.

+

+

You can also make the class manually by making a new class that inherit from DataAsset An example below:

[CreateAssetMenu] // So you can make an instance in the project. 
+public class DataAssetLevels : DataAsset
+{
+	// Your data here.    
+}

+

+

Referencing data assets


You can reference data assets in two main ways. Either a direct reference in the inspector like you normally would with any field. Or by getting the asset from the DataAccess class. The data access class

private void OnEnable()
+{
+	// Gets the first asset of the type found.
+	var asset = DataAccess.GetAsset<DataAssetLevels>();
+	
+	// Gets the asset of the matching variant id.
+	asset = DataAccess.GetAsset<DataAssetLevels>("MyAssetVariantId");
+	
+	// Gets all of the assets of the type found.
+	var assets = DataAccess.GetAssets<DataAssetLevels>();
+}

+

+

Data asset index


The data asset index is a scriptable object that stores a reference to all the data assets. This is used to performantly allow referencing to the assets through the DataAccess class. Avoiding expensive operations like Resources.Load(). The system will automatically make the data asset index if it doesn’t exist and update it with any new assets when entering play mode or before a build is made to ensure it is up to date. Should you need to update it manually, you can do so from the following menu item:

Tools/Carter Games/The Cart/Core/Data/Update Asset Index

+

+

- Scripting

Assembly

CarterGames.TheCart.Core

+

Namespace

CarterGames.Cart.Core.Data

- - API

+

- Data Access

+

GetAsset


Gets the data asset of the defined type. If there is more than one and you don’t define the id it will pick the first one it finds. Will return null if none are found.


DataAssetMyData dataAsset;
+
+private void OnEnable()
+{
+	// Gets the first one found.
+	dataAsset = DataAccess.GetAsset<DataAssetMyData>();
+	
+	// Gets the data asset with the variant id of "MyVariantId".
+	dataAsset = DataAccess.GetAsset<DataAssetMyData>("MyVariantId");
+}

+

+

GetAssets


Gets all the data assets of the defined type that are found in the project. Will return null if none are found.


List<DataAssetMyData> dataAssets;
+
+private void OnEnable()
+{
+	// Gets all the found assets of the entered type.
+	dataAssets = DataAccess.GetAssets<DataAssetMyData>();
+}

+

+

+

+

- Data Asset

+

VariantId


A unique Id that can be used to identify the data asset for use with the data access class. By default a random Guid will be used to populate the field.


+

+

+

\ No newline at end of file diff --git a/Carter Games/The Cart/Docs/Data/Documentation - Core - Data.html.meta b/Carter Games/The Cart/Docs/Data/Documentation - Core - Data.html.meta new file mode 100644 index 00000000..1df02f94 --- /dev/null +++ b/Carter Games/The Cart/Docs/Data/Documentation - Core - Data.html.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 00130e11deeba854d84fa2c2de892716 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/The Cart/Modules/Dummy.cs b/Carter Games/The Cart/Modules/Dummy.cs index 43e8daa4..0862dc32 100644 --- a/Carter Games/The Cart/Modules/Dummy.cs +++ b/Carter Games/The Cart/Modules/Dummy.cs @@ -1,3 +1,4 @@ + namespace CarterGames.Cart.Modules.DoNotUse { public class Dummy diff --git a/Carter Games/The Cart/Modules/Dummy.cs.meta b/Carter Games/The Cart/Modules/Dummy.cs.meta index 777ed435..f3f75d2f 100644 --- a/Carter Games/The Cart/Modules/Dummy.cs.meta +++ b/Carter Games/The Cart/Modules/Dummy.cs.meta @@ -5,7 +5,7 @@ MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 - icon: {instanceID: 0} + icon: {fileID: 2800000, guid: 487fa84bf5736884fbd892f402cff84c, type: 3} userData: assetBundleName: assetBundleVariant: diff --git a/Carter Games/The Cart/Resources/Asset Index.asset b/Carter Games/The Cart/Resources/Data Asset Index.asset similarity index 58% rename from Carter Games/The Cart/Resources/Asset Index.asset rename to Carter Games/The Cart/Resources/Data Asset Index.asset index e17d1d65..625895eb 100644 --- a/Carter Games/The Cart/Resources/Asset Index.asset +++ b/Carter Games/The Cart/Resources/Data Asset Index.asset @@ -9,14 +9,18 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0c7a6fbb5a214e2d8ee2e5ebe75859f2, type: 3} - m_Name: Asset Index + m_Script: {fileID: 11500000, guid: 99fc8d49eca440a086cfbced3aec0857, type: 3} + m_Name: Data Asset Index m_EditorClassIdentifier: + variantId: be732ef2-7827-4148-a5b5-2b336a852ec5 assets: list: + - key: CarterGames.Cart.Core.Logs.DataAssetCartLogCategories + value: + - {fileID: 11400000, guid: b8baa1849fb6f9b4fabce365e57a4e83, type: 2} - key: CarterGames.Cart.Modules.ModuleCache value: - {fileID: 11400000, guid: 990a87da3ce6aeb458c5c2de95818e99, type: 2} - - key: CarterGames.Cart.Core.Management.CartGlobalRuntimeSettings + - key: CarterGames.Cart.Core.Management.DataAssetCartGlobalRuntimeSettings value: - {fileID: 11400000, guid: 09b81cb71b0378045a50bc1fdd444cb4, type: 2} diff --git a/Carter Games/The Cart/Resources/Data Asset Index.asset.meta b/Carter Games/The Cart/Resources/Data Asset Index.asset.meta new file mode 100644 index 00000000..c7745501 --- /dev/null +++ b/Carter Games/The Cart/Resources/Data Asset Index.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b68869a560cf89649976451cf4287e21 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: