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 68c1802e87
commit 7084d96cc1
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,6 +244,9 @@ namespace HeavenStudio
{
type = param.parameter.GetType();
pType = e[param.propertyName].GetType();
// Debug.Log($"adding parameter {param.propertyName} of type {type}");
if (!dynamicData.ContainsKey(param.propertyName))
{
if (pType == type)
{
dynamicData.Add(param.propertyName, e[param.propertyName]);
@ -260,7 +265,13 @@ namespace HeavenStudio
dynamicData.Add(param.propertyName, Convert.ChangeType(e[param.propertyName], type));
}
}
else
{
Debug.LogWarning($"Property {param.propertyName} already exists in the entity's dynamic data! Skipping...");
}
}
}
dynamicBeatmap.entities.Add(new DynamicEntity()
{
beat = e.beat,
@ -332,6 +343,8 @@ namespace HeavenStudio
if (action.parameters != null)
{
foreach (var param in action.parameters)
{
if (!dynamicData.ContainsKey(param.propertyName))
{
type = param.parameter.GetType();
pType = e[param.propertyName].GetType();
@ -342,19 +355,24 @@ namespace HeavenStudio
else
{
if (type == typeof(EntityTypes.Integer))
dynamicData.Add(param.propertyName, (int) e[param.propertyName]);
dynamicData.Add(param.propertyName, (int)e[param.propertyName]);
else if (type == typeof(EntityTypes.Float))
dynamicData.Add(param.propertyName, (float) e[param.propertyName]);
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]));
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]);
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
{
Debug.LogWarning($"Property {param.propertyName} already exists in the entity's dynamic data! Skipping...");
}
}
}
e.DynamicData = dynamicData;
}

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