From 7084d96cc1ae9862bcc2c67f2011a17a988984ce Mon Sep 17 00:00:00 2001 From: minenice55 Date: Sat, 3 Sep 2022 21:51:37 -0400 Subject: [PATCH] fix nasty bugs with saving / loading - duplicate property names no longer soft crash loading (thanks, tap trial) - fix remix saving nothing music --- Assets/Scenes/Editor.unity | 16 ++-- .../Scripts/BeatmapFormats/DynamicBeatmap.cs | 74 ++++++++++++------- Assets/Scripts/LevelEditor/Editor.cs | 17 ++++- .../RemixPropertiesDialog.cs | 9 ++- 4 files changed, 77 insertions(+), 39 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 6fa4c5a1..0036ba7e 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -12254,7 +12254,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -40} + m_AnchoredPosition: {x: 0, y: -25} m_SizeDelta: {x: 134, y: 40} m_Pivot: {x: 0, y: 0.5} --- !u!114 &506932090 @@ -23924,7 +23924,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: -31.000061, y: -91.21527} - m_SizeDelta: {x: 1000, y: 80} + m_SizeDelta: {x: 1000, y: 50} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &937032844 MonoBehaviour: @@ -29713,7 +29713,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 129.9111} + m_AnchoredPosition: {x: 0, y: 129.91107} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1154875944 @@ -46272,8 +46272,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 14 - m_fontSizeBase: 14 + m_fontSize: 16 + m_fontSizeBase: 16 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 @@ -51696,8 +51696,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 137, y: -40} - m_SizeDelta: {x: 1000, y: 80} + m_AnchoredPosition: {x: 137, y: -25} + m_SizeDelta: {x: 1000, y: 50} m_Pivot: {x: 0, y: 0.5} --- !u!114 &2094676610 MonoBehaviour: @@ -51756,7 +51756,7 @@ MonoBehaviour: m_HideSoftKeyboard: 0 m_CharacterValidation: 0 m_RegexValue: - m_GlobalPointSize: 14 + m_GlobalPointSize: 16 m_CharacterLimit: 0 m_OnEndEdit: m_PersistentCalls: diff --git a/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs b/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs index 699a94ca..d8dda044 100644 --- a/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs +++ b/Assets/Scripts/BeatmapFormats/DynamicBeatmap.cs @@ -234,6 +234,8 @@ namespace HeavenStudio game = EventCaller.instance.GetMinigame(e.datamodel.Split(0)); action = EventCaller.instance.GetGameAction(game, e.datamodel.Split(1)); + // Debug.Log($"{game.name} {action.displayName} @ beat {e.beat}"); + Dictionary dynamicData = new Dictionary(); //check each param of the action if (action.parameters != null) @@ -242,25 +244,34 @@ namespace HeavenStudio { type = param.parameter.GetType(); pType = e[param.propertyName].GetType(); - if (pType == type) + // Debug.Log($"adding parameter {param.propertyName} of type {type}"); + if (!dynamicData.ContainsKey(param.propertyName)) { - dynamicData.Add(param.propertyName, e[param.propertyName]); + if (pType == type) + { + dynamicData.Add(param.propertyName, e[param.propertyName]); + } + else + { + if (type == typeof(EntityTypes.Integer)) + dynamicData.Add(param.propertyName, (int) e[param.propertyName]); + else if (type == typeof(EntityTypes.Float)) + dynamicData.Add(param.propertyName, (float) e[param.propertyName]); + else if (type.IsEnum && param.propertyName != "ease") + dynamicData.Add(param.propertyName, (int) e[param.propertyName]); + else if (pType == typeof(Newtonsoft.Json.Linq.JObject)) + dynamicData.Add(param.propertyName, e[param.propertyName].ToObject(type)); + else + dynamicData.Add(param.propertyName, Convert.ChangeType(e[param.propertyName], type)); + } } else { - if (type == typeof(EntityTypes.Integer)) - dynamicData.Add(param.propertyName, (int) e[param.propertyName]); - else if (type == typeof(EntityTypes.Float)) - dynamicData.Add(param.propertyName, (float) e[param.propertyName]); - else if (type.IsEnum && param.propertyName != "ease") - dynamicData.Add(param.propertyName, (int) e[param.propertyName]); - else if (pType == typeof(Newtonsoft.Json.Linq.JObject)) - dynamicData.Add(param.propertyName, e[param.propertyName].ToObject(type)); - else - dynamicData.Add(param.propertyName, Convert.ChangeType(e[param.propertyName], type)); + Debug.LogWarning($"Property {param.propertyName} already exists in the entity's dynamic data! Skipping..."); } } } + dynamicBeatmap.entities.Add(new DynamicEntity() { beat = e.beat, @@ -333,26 +344,33 @@ namespace HeavenStudio { foreach (var param in action.parameters) { - type = param.parameter.GetType(); - pType = e[param.propertyName].GetType(); - if (pType == type) + if (!dynamicData.ContainsKey(param.propertyName)) { - dynamicData.Add(param.propertyName, e[param.propertyName]); + type = param.parameter.GetType(); + pType = e[param.propertyName].GetType(); + if (pType == type) + { + dynamicData.Add(param.propertyName, e[param.propertyName]); + } + else + { + if (type == typeof(EntityTypes.Integer)) + dynamicData.Add(param.propertyName, (int)e[param.propertyName]); + else if (type == typeof(EntityTypes.Float)) + dynamicData.Add(param.propertyName, (float)e[param.propertyName]); + else if (type == typeof(EasingFunction.Ease) && pType == typeof(string)) + dynamicData.Add(param.propertyName, Enum.Parse(typeof(EasingFunction.Ease), (string)e[param.propertyName])); + else if (type.IsEnum) + dynamicData.Add(param.propertyName, (int)e[param.propertyName]); + else if (pType == typeof(Newtonsoft.Json.Linq.JObject)) + dynamicData.Add(param.propertyName, e[param.propertyName].ToObject(type)); + else + dynamicData.Add(param.propertyName, Convert.ChangeType(e[param.propertyName], type)); + } } else { - if (type == typeof(EntityTypes.Integer)) - dynamicData.Add(param.propertyName, (int) e[param.propertyName]); - else if (type == typeof(EntityTypes.Float)) - dynamicData.Add(param.propertyName, (float) e[param.propertyName]); - else if (type == typeof(EasingFunction.Ease) && pType == typeof(string)) - dynamicData.Add(param.propertyName, Enum.Parse(typeof(EasingFunction.Ease), (string) e[param.propertyName])); - else if (type.IsEnum) - dynamicData.Add(param.propertyName, (int) e[param.propertyName]); - else if (pType == typeof(Newtonsoft.Json.Linq.JObject)) - dynamicData.Add(param.propertyName, e[param.propertyName].ToObject(type)); - else - dynamicData.Add(param.propertyName, Convert.ChangeType(e[param.propertyName], type)); + Debug.LogWarning($"Property {param.propertyName} already exists in the entity's dynamic data! Skipping..."); } } } diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index 9cbd1bfd..46ae9194 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -307,18 +307,31 @@ namespace HeavenStudio.Editor try { if (clip != null) - MusicBytes = OggVorbis.VorbisPlugin.GetOggVorbis(Conductor.instance.musicSource.clip, 1); + MusicBytes = OggVorbis.VorbisPlugin.GetOggVorbis(clip, 1); else { MusicBytes = null; Debug.LogWarning("Failed to load music file! The stream is currently empty."); } } - catch (System.Exception) + catch (System.ArgumentNullException) { + clip = null; MusicBytes = null; Debug.LogWarning("Failed to load music file! The stream is currently empty."); } + catch (System.ArgumentOutOfRangeException) + { + clip = null; + MusicBytes = null; + Debug.LogWarning("Failed to load music file! The stream is malformed."); + } + catch (System.ArgumentException) + { + clip = null; + MusicBytes = null; + Debug.LogWarning("Failed to load music file! Only 1 or 2 channels are supported!."); + } return clip; } diff --git a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/RemixPropertiesDialog.cs b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/RemixPropertiesDialog.cs index 4e2047b3..975aae6e 100644 --- a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/RemixPropertiesDialog.cs +++ b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/RemixPropertiesDialog.cs @@ -58,7 +58,6 @@ namespace HeavenStudio.Editor { if (chart.properties.ContainsKey(property.tag)) { - Debug.Log($"Found property: {property.tag} with label {property.label}"); infoContainer.AddParam(this, property.tag, chart.properties[property.tag], property.label, property.isReadOnly); } else @@ -67,6 +66,14 @@ namespace HeavenStudio.Editor { infoContainer.AddDivider(this); } + else if (property.tag == "heading") + { + infoContainer.AddDivider(this); + } + else if (property.tag == "subheading") + { + infoContainer.AddDivider(this); + } else { Debug.LogWarning("Property Menu generation Warning: Property " + property.tag + " not found, skipping...");