mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 10:37:37 +02:00
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:
@ -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...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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...");
|
||||
|
Reference in New Issue
Block a user