Skip to content

Commit

Permalink
Merge pull request antonpup#1987 from Wibble199/fix/gamestatepicker
Browse files Browse the repository at this point in the history
Game State Parameter Picker + Enum Game State fixes
  • Loading branch information
diogotr7 authored Apr 30, 2020
2 parents 11d2eb9 + 358eb34 commit a577fa1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static void SelectedPathDPChanged(DependencyObject sender, DependencyPro
}

// Raise an event informing subscribers
picker.SelectedPathChanged?.Invoke(picker, new SelectedPathChangedEventArgs(e.OldValue.ToString(), e.NewValue.ToString()));
picker.SelectedPathChanged?.Invoke(picker, new SelectedPathChangedEventArgs(e.OldValue?.ToString() ?? "", e.NewValue?.ToString() ?? ""));
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void stackModeCb_SelectionChanged(object sender, SelectionChangedEventAr

private void btnInfo_Click(object sender, RoutedEventArgs e) {
// Open the online documentation for the Animation Trigger properties
Process.Start(new ProcessStartInfo(@"https://wibble199.github.io/Aurora-Docs/docs/advanced-topics/animation-editor.html"));
Process.Start(new ProcessStartInfo(@"https://wibble199.github.io/Aurora-Docs/advanced-topics/animation-editor/"));
}

private void whileKeyHeldTerminate_Checked(object sender, RoutedEventArgs e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void ForcePropertyListUpdate() {

private void HelpButton_Click(object sender, RoutedEventArgs e) {
// Open the overrides page on the documentation page
Process.Start(new ProcessStartInfo(@"https://wibble199.github.io/Aurora-Docs/docs/advanced-topics/overrides-system.html"));
Process.Start(new ProcessStartInfo(@"https://wibble199.github.io/Aurora-Docs/advanced-topics/overrides-system/"));
}
#endregion
}
Expand Down
24 changes: 15 additions & 9 deletions Project-Aurora/Project-Aurora/Utils/JSONUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,23 @@ public class TypeAnnotatedObjectConverter : JsonConverter {
public override bool CanConvert(Type objectType) => true;

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
// TODO: add some sort of error handling, e.g. in case of the targetType being inaccessible?
// If this is a null token, then the original value was null.
if (reader.TokenType == JsonToken.Null) return null;

reader.Read(); // Read "$type" property name
reader.Read(); // Read "$type" value
var typeName = reader.Value?.ToString(); // Find the type based on the fully-qualified name from the $type. This will be null if the original value was null
reader.Read(); // Read "$value" property name
reader.Read(); // Read "$value" value
var value = typeName == null ? null : JsonConvert.DeserializeObject(reader.Value.ToString(), Type.GetType(typeName)); // The $value is a JSON-encoded string, so decode as the requested type
reader.Read(); // Read end of object (if this is not done, it breaks the next converter)
// Read "$type" property
reader.Read(); // Property name
reader.Read(); // Property value
var typeName = reader.Value.ToString(); // Find the type based on the fully-qualified name from the $type. This will be null if the original value was null

return value;
// Read "$value" property
reader.Read(); // Property name
reader.Read(); // Property value
var value = reader.Value.ToString();

// Read end of object '}' (if this is not done, it breaks the next converter)
reader.Read();

return JsonConvert.DeserializeObject(value.ToString(), Type.GetType(typeName)); // The $value is a JSON-encoded string, so decode as the requested type;
}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
Expand Down

0 comments on commit a577fa1

Please sign in to comment.