Skip to content

Commit

Permalink
Merge pull request #147 from mattak/fix/minijson
Browse files Browse the repository at this point in the history
Move MiniJSON and rename namespace for avoiding conflict
  • Loading branch information
mattak authored Aug 11, 2021
2 parents 099f259 + f499ba8 commit a44018b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
3 changes: 1 addition & 2 deletions Assets/Plugins/MiniJSON.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
using System.IO;
using System.Text;

namespace MiniJSON {
namespace Unidux.Experimental.Editor.MiniJSON {
// Example usage:
//
// using UnityEngine;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.Linq;
using System.Text;
using MiniJSON;
using Unidux.Experimental.Editor.MiniJSON;
using UnityEditor;
using UnityEngine;

Expand All @@ -20,7 +20,7 @@ public class StateJsonFileWrapperInspector : UnityEditor.Editor

public override void OnInspectorGUI()
{
StateJsonFileWrapper wrapper = (StateJsonFileWrapper) target;
StateJsonFileWrapper wrapper = (StateJsonFileWrapper)target;

RenderHeader(wrapper);

Expand Down Expand Up @@ -73,11 +73,13 @@ private void RenderHeader(StateJsonFileWrapper wrapper)
{
System.Diagnostics.Process.Start("/usr/bin/open", wrapper.FileName);
}

if (GUILayout.Button("OpenDir", EditorStyles.miniButton))
{
System.Diagnostics.Process.Start("/usr/bin/open", Path.GetDirectoryName(wrapper.FileName));
}
}

EditorGUILayout.EndHorizontal();
}

Expand Down Expand Up @@ -105,13 +107,13 @@ private bool RenderJsonDictionary(string[] parentsKey, Dictionary<string, object
else if (_value is long)
{
// XXX: There are no DelayedLongField
long __value = (long) _value;
long __value = (long)_value;
if (__value > int.MaxValue || __value < int.MinValue)
{
Debug.LogWarning("StateJsonEditor not handled long size value => " + __value);
}

int value = (int) __value;
int value = (int)__value;
int newValue = EditorGUILayout.DelayedIntField(key, value);

if (newValue != value)
Expand All @@ -122,7 +124,7 @@ private bool RenderJsonDictionary(string[] parentsKey, Dictionary<string, object
}
else if (_value is double)
{
double value = (double) _value;
double value = (double)_value;
double newValue = EditorGUILayout.DelayedDoubleField(key, value);

if (newValue != value)
Expand All @@ -133,7 +135,7 @@ private bool RenderJsonDictionary(string[] parentsKey, Dictionary<string, object
}
else if (_value is bool)
{
bool value = (bool) _value;
bool value = (bool)_value;
bool newValue = EditorGUILayout.Toggle(key, value);

if (newValue != value)
Expand All @@ -154,7 +156,7 @@ private bool RenderJsonDictionary(string[] parentsKey, Dictionary<string, object

if (ShouldFoldout(displayName, foldoutKey))
{
dirty = RenderJsonArray(newParentsKey, key, (List<object>) _value);
dirty = RenderJsonArray(newParentsKey, key, (List<object>)_value);
}
}
else if (_value is Dictionary<string, object>)
Expand All @@ -165,7 +167,7 @@ private bool RenderJsonDictionary(string[] parentsKey, Dictionary<string, object

if (ShouldFoldout(displayName, foldoutKey))
{
dirty = RenderJsonDictionary(newParentsKey, (Dictionary<string, object>) _value);
dirty = RenderJsonDictionary(newParentsKey, (Dictionary<string, object>)_value);
}
}
else
Expand Down Expand Up @@ -200,13 +202,13 @@ private bool RenderJsonArray(string[] parentsKey, string arrayKey, List<object>
else if (_value is long)
{
// XXX: There are no DelayedLongField
long __value = (long) _value;
long __value = (long)_value;
if (__value > int.MaxValue || __value < int.MinValue)
{
Debug.LogWarning("StateJsonEditor not handled long size value => " + __value);
}

int value = (int) __value;
int value = (int)__value;
int newValue = EditorGUILayout.DelayedIntField(key, value);

if (newValue != value)
Expand All @@ -217,7 +219,7 @@ private bool RenderJsonArray(string[] parentsKey, string arrayKey, List<object>
}
else if (_value is double)
{
double value = (double) _value;
double value = (double)_value;
double newValue = EditorGUILayout.DelayedDoubleField(key, value);

if (newValue != value)
Expand All @@ -228,7 +230,7 @@ private bool RenderJsonArray(string[] parentsKey, string arrayKey, List<object>
}
else if (_value is bool)
{
bool value = (bool) _value;
bool value = (bool)_value;
bool newValue = EditorGUILayout.Toggle(key, value);

if (newValue != value)
Expand Down Expand Up @@ -302,7 +304,7 @@ private bool CustomFold(string title, bool display)

private string[] CreateParentsKey(string[] parentsKey, string key)
{
if (parentsKey == null) return new string[] {key};
if (parentsKey == null) return new string[] { key };
var list = new List<string>(parentsKey);
list.Add(key);
return list.ToArray();
Expand All @@ -316,7 +318,8 @@ private string CreateFoldoutKey(string[] parentsKey)
private string CreateDisplayKey(string[] parentsKey)
{
if (parentsKey.Length == 1) return parentsKey[0];
return new StringBuilder(new string('.', parentsKey.Length-1)).Append(parentsKey.LastOrDefault()).ToString();
return new StringBuilder(new string('.', parentsKey.Length - 1)).Append(parentsKey.LastOrDefault())
.ToString();
}

private bool ShouldFoldout(string name, string foldoutKey)
Expand All @@ -327,4 +330,4 @@ private bool ShouldFoldout(string name, string foldoutKey)
return this.foldoutMap[foldoutKey];
}
}
}
}

0 comments on commit a44018b

Please sign in to comment.