Skip to content

Commit

Permalink
🚧 NotionData adjustments and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMCarter committed Oct 24, 2024
1 parent 5e8b8ab commit d141ca4
Show file tree
Hide file tree
Showing 36 changed files with 344 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ private static bool IsCategoriesExpanded


private static SerializedObject ObjectRef =>
ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().ObjectRef;
ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().ObjectRef;

private static DataAssetCartGlobalRuntimeSettings AssetRef =>
ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().AssetRef;
private static DataAssetCoreRuntimeSettings AssetRef =>
ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().AssetRef;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@

using System.Linq;
using System.Reflection;
using CarterGames.Cart.Core.Data;
using CarterGames.Cart.Core.Logs.Editor;
using CarterGames.Cart.Core.Random.Editor;
using CarterGames.Cart.Modules.Settings;
using UnityEditor;
using UnityEngine;

Expand All @@ -35,7 +31,7 @@ namespace CarterGames.Cart.Core.Management.Editor
/// <summary>
/// Handles the custom editor for the runtime settings asset.
/// </summary>
[CustomEditor(typeof(DataAssetCartGlobalRuntimeSettings))]
[CustomEditor(typeof(DataAssetCoreRuntimeSettings))]
public sealed class DataAssetCartRuntimeSettingsInspector : UnityEditor.Editor
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Expand All @@ -48,7 +44,7 @@ public sealed class DataAssetCartRuntimeSettingsInspector : UnityEditor.Editor
public override void OnInspectorGUI()
{
GUILayout.Space(4f);
GeneralUtilEditor.DrawSoScriptSection((DataAssetCartGlobalRuntimeSettings)target);
GeneralUtilEditor.DrawSoScriptSection((DataAssetCoreRuntimeSettings)target);
GUILayout.Space(10f);

EditorGUILayout.LabelField("Core", EditorStyles.boldLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@

namespace CarterGames.Cart.Core.Editor
{
public class ScriptableDefCoreSettings : IScriptableAssetDef<DataAssetCartGlobalRuntimeSettings>
public class ScriptableDefCoreSettings : IScriptableAssetDef<DataAssetCoreRuntimeSettings>
{
private static DataAssetCartGlobalRuntimeSettings cache;
private static DataAssetCoreRuntimeSettings cache;
private static SerializedObject objCache;

public Type AssetType => typeof(DataAssetCartGlobalRuntimeSettings);
public Type AssetType => typeof(DataAssetCoreRuntimeSettings);
public string DataAssetFileName => "[Cart] Core Runtime Settings.asset";
public string DataAssetFilter => $"t:{typeof(DataAssetCartGlobalRuntimeSettings).FullName}";
public string DataAssetFilter => $"t:{typeof(DataAssetCoreRuntimeSettings).FullName}";
public string DataAssetPath => $"{ScriptableRef.FullPathData}{DataAssetFileName}";

public DataAssetCartGlobalRuntimeSettings AssetRef => ScriptableRef.GetOrCreateAsset(this, ref cache);
public DataAssetCoreRuntimeSettings AssetRef => ScriptableRef.GetOrCreateAsset(this, ref cache);
public SerializedObject ObjectRef => ScriptableRef.GetOrCreateAssetObject(this, ref objCache);

public void TryCreate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
* THE SOFTWARE.
*/

using UnityEditor;

namespace CarterGames.Cart.Core.Management.Editor
{
/// <summary>
Expand All @@ -37,7 +35,7 @@ public class ScriptableObjectInitialize : IAssetEditorInitialize, IAssetEditorRe
/// <summary>
/// Defines the order that this initializer run at.
/// </summary>
public int InitializeOrder => -1;
public int InitializeOrder => 0;


/// <summary>
Expand All @@ -61,13 +59,5 @@ public void OnEditorReloaded()
if (ScriptableRef.HasAllAssets()) return;
ScriptableRef.TryCreateAssets();
}


[InitializeOnLoadMethod]
private static void TryInit()
{
if (ScriptableRef.HasAllAssets()) return;
ScriptableRef.TryCreateAssets();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static class UtilEditor
/// <summary>
/// Gets/Sets the save manager settings asset.
/// </summary>
public static DataAssetCartGlobalRuntimeSettings Settings => ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().AssetRef;
public static DataAssetCoreRuntimeSettings Settings => ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().AssetRef;


/// <summary>
Expand All @@ -69,7 +69,7 @@ public static class UtilEditor
/// <summary>
/// Gets/Sets the save manager editor settings asset.
/// </summary>
public static SerializedObject SettingsObject => ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().ObjectRef;
public static SerializedObject SettingsObject => ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().ObjectRef;


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ private static bool IsExpanded


private static SerializedObject ObjectRef =>
ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().ObjectRef;
ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().ObjectRef;

private static DataAssetCartGlobalRuntimeSettings AssetRef =>
ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().AssetRef;
private static DataAssetCoreRuntimeSettings AssetRef =>
ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().AssetRef;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private static bool IsExpanded


private static SerializedObject ObjectRef =>
ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().ObjectRef;
ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().ObjectRef;


public void OnInspectorSettingsGUI()
Expand Down Expand Up @@ -60,7 +60,7 @@ public void OnProjectSettingsGUI()
var typeString = ObjectRef.Fp("saveMethodTypeDef").Fpr("type").stringValue;

SearchProviderSaveMethod.GetProvider().SelectionMade.Add(HandleSelection);
SearchProviderSaveMethod.GetProvider().Open(ScriptableRef.GetAssetDef<DataAssetCartGlobalRuntimeSettings>().AssetRef.SaveMethodType);
SearchProviderSaveMethod.GetProvider().Open(ScriptableRef.GetAssetDef<DataAssetCoreRuntimeSettings>().AssetRef.SaveMethodType);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

using System;
using System.Linq;
using CarterGames.Cart.Core.Data;
using CarterGames.Cart.Core.Random;
using CarterGames.Cart.Core.Save;
Expand All @@ -33,7 +32,7 @@ namespace CarterGames.Cart.Core.Management
/// <summary>
/// Handles any runtime specific settings for the package.
/// </summary>
public sealed class DataAssetCartGlobalRuntimeSettings : DataAsset
public sealed class DataAssetCoreRuntimeSettings : DataAsset
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public static class CartSaveHandler
{
private static ISaveMethod SaveMethod => CoreSettings.SaveMethodType;

private static DataAssetCartGlobalRuntimeSettings CoreSettings =>
DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>();
private static DataAssetCoreRuntimeSettings CoreSettings =>
DataAccess.GetAsset<DataAssetCoreRuntimeSettings>();


public static T Get<T>(string key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static class UtilRuntime

// Caches
/* ────────────────────────────────────────────────────────────────────────────────────────────────────────── */
private static DataAssetCartGlobalRuntimeSettings settingsCache;
private static DataAssetCoreRuntimeSettings settingsCache;

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Properties
Expand All @@ -45,12 +45,12 @@ public static class UtilRuntime
/// <summary>
/// The runtime settings asset.
/// </summary>
public static DataAssetCartGlobalRuntimeSettings Settings
public static DataAssetCoreRuntimeSettings Settings
{
get
{
if (settingsCache != null) return settingsCache;
settingsCache = DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>();
settingsCache = DataAccess.GetAsset<DataAssetCoreRuntimeSettings>();
return settingsCache;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public sealed class AleaRngProvider : ISeededRngProvider
/// <remarks>This is intended to help with debugging as you can replicate the seed & get the same results as a user.</remarks>
public static string Seed
{
get => DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>().RngAleaRngSeed;
private set => DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>().RngAleaRngSeed = value;
get => DataAccess.GetAsset<DataAssetCoreRuntimeSettings>().RngAleaRngSeed;
private set => DataAccess.GetAsset<DataAssetCoreRuntimeSettings>().RngAleaRngSeed = value;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public sealed class SystemRngProvider : ISeededRngProvider
/// <remarks>This is intended to help with debugging as you can replicate the seed & get the same results as a user.</remarks>
public static int Seed
{
get => DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>().RngSystemRngSeed;
private set => DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>().RngSystemRngSeed = value;
get => DataAccess.GetAsset<DataAssetCoreRuntimeSettings>().RngSystemRngSeed;
private set => DataAccess.GetAsset<DataAssetCoreRuntimeSettings>().RngSystemRngSeed = value;
}


Expand Down
2 changes: 1 addition & 1 deletion Carter Games/The Cart/Core/Runtime/Random/Rng.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static class Rng
/// <summary>
/// Gets the current random provider in use.
/// </summary>
public static IRngProvider Provider => DataAccess.GetAsset<DataAssetCartGlobalRuntimeSettings>().RngProvider;
public static IRngProvider Provider => DataAccess.GetAsset<DataAssetCoreRuntimeSettings>().RngProvider;

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ public static string GetCopy(string id)

return copy;
}


public static LocalizationData GetRawData(string id)
{
return GetCopyData(id);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#if CARTERGAMES_CART_MODULE_LOCALIZATION && CARTERGAMES_CART_MODULE_NOTIONDATA

/*
* 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;
using CarterGames.Cart.Modules.NotionData;

namespace CarterGames.Cart.Modules.Localization
{
/// <summary>
/// Use to convert a localization id into its data in a NotionDataAsset through standard database parsing.
/// </summary>
public class NotionDataWrapperLocalizationData : NotionDataWrapper<LocalizationData>
{
public NotionDataWrapperLocalizationData(string id) : base(id) { }

protected override void Assign()
{
try
{
value = LocalizationManager.GetRawData(id);
}
#pragma warning disable
catch (Exception e)
{
CartLogger.LogWarning<LogCategoryModules>($"Unable to wrap {id} as Localized text, make sure the id exists.");
throw;
}
#pragma warning restore
}
}
}

#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ public void OnEditorReloaded()
if (ModulesScriptableRef.HasAllAssets()) return;
ModulesScriptableRef.TryCreateAssets();
}


[InitializeOnLoadMethod]
private static void TryInit()
{
if (ModulesScriptableRef.HasAllAssets()) return;
ModulesScriptableRef.TryCreateAssets();
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Carter Games/The Cart/Modules/Notion/Art.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d141ca4

Please sign in to comment.