Skip to content

Commit

Permalink
🚧 Update with community report fix
Browse files Browse the repository at this point in the history
- Pushed out a tad early so this bug fix can go out.
- Also includes some initialization work that should sort library regen finally if all goes well.
  • Loading branch information
JonathanMCarter committed May 13, 2024
1 parent fe99b99 commit 995231a
Show file tree
Hide file tree
Showing 87 changed files with 1,130 additions and 422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override void DrawInspector(SerializedObject targetObject, int index)
if (delay < 0)
{
delay = 0;
AmLog.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nDelay edit cannot have a value below 0.");
AmDebugLogger.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nDelay edit cannot have a value below 0.");
}

EditModuleInspectorHelper.SetValue(targetObject, index, "delay",delay.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public override void DrawInspector(SerializedObject targetObject, int index)
if (loopCount < 0)
{
loopCount = 0;
AmLog.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nLoop count cannot have a value below 0 when using x times mode.");
AmDebugLogger.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nLoop count cannot have a value below 0 when using x times mode.");
}

EditModuleInspectorHelper.SetValue(targetObject, index, "loopCount", loopCount.ToString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private static void DrawHeader()
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();

if (GUILayout.Button(UtilEditor.OpenBookIcon, GUIStyle.none, GUILayout.MaxHeight(110)))
if (GUILayout.Button(UtilEditor.OpenBookIcon, GUIStyle.none, GUILayout.MaxHeight(75)))
{
GUI.FocusControl(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected override void LeftSectionControl()
EditorGUILayout.BeginVertical("Box", GUILayout.MaxWidth(250));

GUI.backgroundColor = UtilEditor.Yellow;
if (GUILayout.Button("Update Track Struct", GUILayout.MaxHeight(25)))
if (GUILayout.Button("Update Playlist Struct", GUILayout.MaxHeight(25)))
{
StructHandler.RefreshTracks();
}
Expand All @@ -115,7 +115,7 @@ protected override void LeftSectionControl()

if (PerUserSettings.ShowHelpBoxes)
{
EditorGUILayout.HelpBox("Press ^^^ to update the Track.??? struct to have the latest changes",
EditorGUILayout.HelpBox("Press ^^^ to update the Playlist.??? struct to have the latest changes",
MessageType.None);
}

Expand All @@ -124,7 +124,7 @@ protected override void LeftSectionControl()
GUILayout.Space(7.5f);

GUI.backgroundColor = UtilEditor.Green;
if (GUILayout.Button("+ Add New Track"))
if (GUILayout.Button("+ Add New Playlist"))
{
AddNewBlankTrack();
GUI.FocusControl(null);
Expand Down Expand Up @@ -203,7 +203,7 @@ protected override void OnRightGUI()
{
EditorGUILayout.BeginVertical("Box");
EditorGUILayout.BeginVertical("Box");
EditorGUILayout.LabelField("Select a track list to see its contents here.");
EditorGUILayout.LabelField("Select a playlist to see its contents here.");
EditorGUILayout.EndVertical();
EditorGUILayout.EndVertical();
return;
Expand Down Expand Up @@ -250,10 +250,10 @@ protected override void OnRightGUI()
}


EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("trackListType"));
// EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("playlistType"));
EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("loop"));

if (SelectedProperty.Fpr("value").Fpr("trackListType").intValue == 1)
if (SelectedProperty.Fpr("value").Fpr("tracks").arraySize > 1)
{
EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("shuffle"));
}
Expand Down Expand Up @@ -293,10 +293,10 @@ protected override void OnRightGUI()
GUILayout.Space(1.5f);
GUI.backgroundColor = UtilEditor.Red;

if (GUILayout.Button("Delete Track List"))
if (GUILayout.Button("Delete Playlist"))
{
if (!EditorUtility.DisplayDialog("Delete Track List",
"Are you sure you want to delete this track list?", "Delete List", "Cancel")) return;
if (!EditorUtility.DisplayDialog("Delete Playlist",
"Are you sure you want to delete this playlist?", "Delete", "Cancel")) return;

var oldKey = UtilEditor.LibraryObject.Fp("tracks").Fpr("list").GetIndex(PerUserSettings.LastLibMusicEntry).Fpr("key").stringValue;
UtilEditor.LibraryObject.Fp("tracks").Fpr("list").DeleteIndex(PerUserSettings.LastLibMusicEntry);
Expand Down Expand Up @@ -346,8 +346,8 @@ private static void AddNewBlankTrack()
var newTrackProp = tracksProp.GetIndex(tracksProp.arraySize - 1);

newTrackProp.Fpr("key").stringValue = Guid.NewGuid().ToString();
newTrackProp.Fpr("value").Fpr("listKey").stringValue = "New Track List " + newTrackProp.Fpr("key").stringValue.Substring(0, 7);
newTrackProp.Fpr("value").Fpr("trackListType").intValue = 0;
newTrackProp.Fpr("value").Fpr("listKey").stringValue = "New Playlist " + newTrackProp.Fpr("key").stringValue.Substring(0, 7);
newTrackProp.Fpr("value").Fpr("playlistType").intValue = 0;
newTrackProp.Fpr("value").Fpr("loop").boolValue = false;
newTrackProp.Fpr("value").Fpr("shuffle").boolValue = false;
newTrackProp.Fpr("value").Fpr("tracks").ClearArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public static class MusicTrackListDrawer
public static void DrawTracks(SerializedProperty prop)
{
var list = prop.Fpr("value").Fpr("tracks");
var playType = prop.Fpr("value").Fpr("trackListType");
// var playType = prop.Fpr("value").Fpr("playlistType");

EditorGUILayout.BeginVertical("HelpBox");

GUI.color = UtilEditor.Yellow;
EditorGUILayout.LabelField("Clips Assigned", EditorStyles.boldLabel);
EditorGUILayout.LabelField("Tracks", EditorStyles.boldLabel);
GUI.color = Color.white;

UtilEditor.DrawHorizontalGUILine();
Expand Down Expand Up @@ -102,7 +102,8 @@ public static void DrawTracks(SerializedProperty prop)
EditorGUILayout.BeginHorizontal();
GUILayout.Space(1.5f);

EditorGUI.BeginDisabledGroup(playType.intValue == 0 && i > 0);
EditorGUI.BeginDisabledGroup(list.arraySize == 1 && i > 0);
// EditorGUI.BeginDisabledGroup(playType.intValue == 0 && i > 0);

if (string.IsNullOrEmpty(list.GetIndex(i).Fpr("clipId").stringValue))
{
Expand Down Expand Up @@ -141,7 +142,8 @@ public static void DrawTracks(SerializedProperty prop)
GUILayout.Space(1.5f);

EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(playType.intValue == 0);
// EditorGUI.BeginDisabledGroup(list.arraySize == 1);
// EditorGUI.BeginDisabledGroup(playType.intValue == 0);

GUI.backgroundColor = UtilEditor.Green;
if (GUILayout.Button(" + ", GUILayout.MaxWidth(22.5f)))
Expand All @@ -155,7 +157,7 @@ public static void DrawTracks(SerializedProperty prop)
return;
}

EditorGUI.EndDisabledGroup();
// EditorGUI.EndDisabledGroup();

GUI.backgroundColor = UtilEditor.Red;
if (GUILayout.Button(" - ", GUILayout.MaxWidth(22.5f)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static void DrawButtons()
if (UtilEditor.FileExistsByFilter(UtilEditor.AudioPrefabName))
audioPrefab = UtilEditor.AudioPrefab;
else
AmLog.Error("Unable to find the default audio prefab, setting to null.");
AmDebugLogger.Error("Unable to find the default audio prefab, setting to null.");

AudioManagerEditorEvents.OnSettingsReset.Raise();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void OnInspectorGUI()

GUILayout.Space(5f);

EditorGUILayout.LabelField("Track Info", EditorStyles.boldLabel);
EditorGUILayout.LabelField("Playlist Info", EditorStyles.boldLabel);
UtilEditor.DrawHorizontalGUILine();

EditorGUILayout.BeginVertical("HelpBox");
Expand All @@ -43,7 +43,7 @@ public override void OnInspectorGUI()
{
EditorGUILayout.BeginHorizontal();

if (GUILayout.Button("Select Track List"))
if (GUILayout.Button("Select Playlist"))
{
trackSearchProvider ??= CreateInstance<TrackSearchProvider>();

Expand All @@ -63,7 +63,7 @@ public override void OnInspectorGUI()

if (!string.IsNullOrEmpty(serializedObject.Fp("trackListId").stringValue))
{
EditorGUILayout.TextField("Track List Id", UtilEditor.Library
EditorGUILayout.TextField("Playlist Id", UtilEditor.Library
.MusicTrackLookup[serializedObject.Fp("trackListId").stringValue].ListKey);
}
else
Expand Down Expand Up @@ -97,7 +97,7 @@ public override void OnInspectorGUI()
if (UtilEditor.Library.MusicTrackLookup.ContainsKey(serializedObject.Fp("trackListId").stringValue))
{
if (UtilEditor.Library.MusicTrackLookup[serializedObject.Fp("trackListId").stringValue]
.TrackListType != TrackType.Single)
.GetTracksRaw().Count > 1)
{
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(serializedObject.Fp("firstTrackId"));
Expand Down Expand Up @@ -202,7 +202,7 @@ public override void OnInspectorGUI()
{
if (serializedObject.Fp("inTransitionDuration").floatValue < 0f)
{
AmLog.Warning($"{AudioManagerErrorCode.InvalidMusicInspectorInput}\nTransition in cannot be a value below 0.");
AmDebugLogger.Warning($"{AudioManagerErrorCode.InvalidMusicInspectorInput}\nTransition in cannot be a value below 0.");
serializedObject.Fp("inTransitionDuration").floatValue = 0f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private static void DrawAudioPrefabOptions()
}
else
{
AmLog.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioSequence class attached.");
AmDebugLogger.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioSequence class attached.");
}
}
else
Expand Down Expand Up @@ -281,7 +281,7 @@ private static void DrawAudioPrefabOptions()
}
else
{
AmLog.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioPlayer class attached.");
AmDebugLogger.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioPlayer class attached.");
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,35 @@ namespace CarterGames.Assets.AudioManager.Editor
/// <summary>
/// Handles the setup of the asset index for runtime references to scriptable objects used for the asset.
/// </summary>
public sealed class AssetIndexHandler : IPreprocessBuildWithReport
public sealed class AssetIndexHandler : IPreprocessBuildWithReport, IAssetEditorInitialize
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Fields
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

private const string AssetFilter = "t:audiomanagerasset";

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| IAssetEditorInitialize Implementation
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

/// <summary>
/// Defines the order that this initializer run at.
/// </summary>
public int InitializeOrder => 1;


/// <summary>
/// Runs when the asset initialize flow is used.
/// </summary>
public void OnEditorInitialized()
{
EditorApplication.update -= OnEditorUpdate;
EditorApplication.update += OnEditorUpdate;

UpdateIndex();
}

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| IPreprocessBuildWithReport Implementation
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public override void Generate()

if (data == null)
{
AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData));
AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData));
}
else
{
if (data.Count <= 0)
{
AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData));
AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData));
}
else
{
Expand All @@ -87,7 +87,7 @@ public override void Generate()
DupeLookup[parsedName]++;
dupeChangedName = $"{parsedName}{DupeLookup[parsedName]}";

AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists));
AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists));
}


Expand All @@ -102,7 +102,7 @@ public override void Generate()
#pragma warning disable
catch (Exception e)
{
AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed));
AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed));
}
#pragma warning restore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override void Generate()

if (UtilEditor.Library.GroupsLookup.Count <= 0)
{
AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData));
AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData));
StructHandler.WriteFooter(file);
return;
}
Expand All @@ -83,7 +83,7 @@ public override void Generate()
groupDupNameLookup[parsedName]++;
dupeChangedName = $"{parsedName}{groupDupNameLookup[parsedName]}";

AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists));
AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists));
}

try
Expand All @@ -100,7 +100,7 @@ public override void Generate()
#pragma warning disable
catch (Exception e)
{
AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed));
AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed));
}
#pragma warning restore
}
Expand All @@ -121,7 +121,7 @@ public override void Generate()
#pragma warning disable
catch (Exception e)
{
AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed));
AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed));
}
#pragma warning restore
}
Expand Down
Loading

0 comments on commit 995231a

Please sign in to comment.