fix nasty bugs with saving / loading

- duplicate property names no longer soft crash loading (thanks, tap trial)
- fix remix saving nothing music
This commit is contained in:
minenice55 2022-09-03 21:51:37 -04:00
parent aa4f9440cd
commit 45bbcc8fba
4 changed files with 77 additions and 39 deletions

View file

@ -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:

View file

@ -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<string, dynamic> dynamicData = new Dictionary<string, dynamic>();
//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...");
}
}
}

View file

@ -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;
}

View file

@ -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...");