Browse Source

Isolated rotorz to CommandListAdaptor and VariableListAdaptor

-some lists/arrays were reorderable when they did not need to be and thus are removed for right now
master
desktop-maesty/steve 7 years ago
parent
commit
265b1b2f83
  1. 5
      Assets/Fungus/Scripts/Commands/SetCollider.cs
  2. 16
      Assets/Fungus/Scripts/Editor/BlockEditor.cs
  3. 4
      Assets/Fungus/Scripts/Editor/CharacterEditor.cs
  4. 33
      Assets/Fungus/Scripts/Editor/CommandEditor.cs
  5. 18
      Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs
  6. 13
      Assets/Fungus/Scripts/Editor/FlowchartEditor.cs
  7. 34
      Assets/Fungus/Scripts/Editor/SaveDataEditor.cs
  8. 12
      Assets/Fungus/Scripts/Editor/SaveDataEditor.cs.meta
  9. 1
      Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs
  10. 30
      Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs
  11. 12
      Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs.meta
  12. 40
      Assets/Fungus/Scripts/Editor/SetColliderEditor.cs
  13. 12
      Assets/Fungus/Scripts/Editor/SetColliderEditor.cs.meta
  14. 10
      Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
  15. 4
      Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs

5
Assets/Fungus/Scripts/Commands/SetCollider.cs

@ -97,6 +97,11 @@ namespace Fungus
return new Color32(235, 191, 217, 255); return new Color32(235, 191, 217, 255);
} }
public override bool IsReorderableArray(string propertyName)
{
return propertyName == "targetObjects";
}
#endregion #endregion
} }

16
Assets/Fungus/Scripts/Editor/BlockEditor.cs

@ -9,7 +9,6 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Rotorz.ReorderableList;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -150,20 +149,7 @@ namespace Fungus.EditorUtils
command.ParentBlock = block; command.ParentBlock = block;
} }
ReorderableListGUI.Title("Commands"); CommandListAdaptor.DrawCommandList(block, commandListProperty);
CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
adaptor.nodeRect = block._NodeRect;
ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;
if (block.CommandList.Count == 0)
{
EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info);
}
else
{
ReorderableListControl.DrawControlFromState(adaptor, null, flags);
}
// EventType.contextClick doesn't register since we moved the Block Editor to be inside // EventType.contextClick doesn't register since we moved the Block Editor to be inside
// a GUI Area, no idea why. As a workaround we just check for right click instead. // a GUI Area, no idea why. As a workaround we just check for right click instead.

4
Assets/Fungus/Scripts/Editor/CharacterEditor.cs

@ -3,7 +3,6 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using Rotorz.ReorderableList;
namespace Fungus.EditorUtils namespace Fungus.EditorUtils
{ {
@ -60,8 +59,7 @@ namespace Fungus.EditorUtils
GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect); GUI.DrawTexture(previewRect,characterTexture,ScaleMode.ScaleToFit,true,aspect);
} }
ReorderableListGUI.Title(new GUIContent("Portraits", "Character image sprites to display in the dialog")); EditorGUILayout.PropertyField(portraitsProp, new GUIContent("Portraits", "Character image sprites to display in the dialog"), true);
ReorderableListGUI.ListField(portraitsProp);
EditorGUILayout.HelpBox("All portrait images should use the exact same resolution to avoid positioning and tiling issues.", MessageType.Info); EditorGUILayout.HelpBox("All portrait images should use the exact same resolution to avoid positioning and tiling issues.", MessageType.Info);

33
Assets/Fungus/Scripts/Editor/CommandEditor.cs

@ -4,14 +4,14 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using Rotorz.ReorderableList; using UnityEditorInternal;
namespace Fungus.EditorUtils namespace Fungus.EditorUtils
{ {
[CustomEditor (typeof(Command), true)] [CustomEditor (typeof(Command), true)]
public class CommandEditor : Editor public class CommandEditor : Editor
{ {
#region statics
public static Command selectedCommand; public static Command selectedCommand;
public static CommandInfoAttribute GetCommandInfo(System.Type commandType) public static CommandInfoAttribute GetCommandInfo(System.Type commandType)
@ -34,6 +34,15 @@ namespace Fungus.EditorUtils
return retval; return retval;
} }
#endregion statics
private Dictionary<string, ReorderableList> reorderableLists;
public virtual void OnEnable()
{
reorderableLists = new Dictionary<string, ReorderableList>();
}
public virtual void DrawCommandInspectorGUI() public virtual void DrawCommandInspectorGUI()
{ {
Command t = target as Command; Command t = target as Command;
@ -148,8 +157,24 @@ namespace Fungus.EditorUtils
if (iterator.isArray && if (iterator.isArray &&
t.IsReorderableArray(iterator.name)) t.IsReorderableArray(iterator.name))
{ {
ReorderableListGUI.Title(new GUIContent(iterator.displayName, iterator.tooltip)); ReorderableList reordList = null;
ReorderableListGUI.ListField(iterator); reorderableLists.TryGetValue(iterator.displayName, out reordList);
if(reordList == null)
{
var locSerProp = iterator.Copy();
//create and insert
reordList = new ReorderableList(serializedObject, locSerProp, true, false, true, true)
{
drawHeaderCallback = (Rect rect) =>
{
EditorGUI.LabelField(rect, locSerProp.displayName);
}
};
reorderableLists.Add(iterator.displayName, reordList);
}
reordList.DoLayoutList();
} }
else else
{ {

18
Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs

@ -14,6 +14,24 @@ namespace Fungus.EditorUtils
{ {
public class CommandListAdaptor : IReorderableListAdaptor { public class CommandListAdaptor : IReorderableListAdaptor {
public static void DrawCommandList(Block block, SerializedProperty commandListProperty)
{
ReorderableListGUI.Title("Commands");
CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
adaptor.nodeRect = block._NodeRect;
ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;
if (block.CommandList.Count == 0)
{
EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info);
}
else
{
ReorderableListControl.DrawControlFromState(adaptor, null, flags);
}
}
protected SerializedProperty _arrayProperty; protected SerializedProperty _arrayProperty;
public float fixedItemHeight; public float fixedItemHeight;

13
Assets/Fungus/Scripts/Editor/FlowchartEditor.cs

@ -4,7 +4,6 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using Rotorz.ReorderableList;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -72,8 +71,9 @@ namespace Fungus.EditorUtils
EditorGUILayout.PropertyField(luaBindingNameProp); EditorGUILayout.PropertyField(luaBindingNameProp);
// Show list of commands to hide in Add Command menu // Show list of commands to hide in Add Command menu
ReorderableListGUI.Title(new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip)); //ReorderableListGUI.Title(new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip));
ReorderableListGUI.ListField(hideCommandsProp); //ReorderableListGUI.ListField(hideCommandsProp);
EditorGUILayout.PropertyField(hideCommandsProp, new GUIContent(hideCommandsProp.displayName, hideCommandsProp.tooltip), true);
GUILayout.BeginHorizontal(); GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
@ -134,12 +134,7 @@ namespace Fungus.EditorUtils
} }
} }
ReorderableListGUI.Title("Variables"); VariableListAdaptor.DrawVarList(w, variablesProp);
VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0, w == 0 ? VariableListAdaptor.DefaultWidth : w);
ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton;
ReorderableListControl.DrawControlFromState(adaptor, null, flags);
listRect = GUILayoutUtility.GetLastRect(); listRect = GUILayoutUtility.GetLastRect();

34
Assets/Fungus/Scripts/Editor/SaveDataEditor.cs

@ -1,34 +0,0 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
using UnityEngine;
using UnityEditor;
using Rotorz.ReorderableList;
namespace Fungus.EditorUtils
{
[CustomEditor (typeof(SaveData), true)]
public class SaveDataEditor : Editor
{
protected SerializedProperty flowchartsProp;
protected virtual void OnEnable()
{
flowchartsProp = serializedObject.FindProperty("flowcharts");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
ReorderableListGUI.Title("Flowcharts");
ReorderableListGUI.ListField(flowchartsProp);
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

12
Assets/Fungus/Scripts/Editor/SaveDataEditor.cs.meta

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 395934d0b0e6a48a396a25348aeaade5
timeCreated: 1484049679
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1
Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs

@ -5,7 +5,6 @@
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using Rotorz.ReorderableList;
namespace Fungus.EditorUtils namespace Fungus.EditorUtils
{ {

30
Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs

@ -1,30 +0,0 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
using UnityEngine;
using UnityEditor;
using Rotorz.ReorderableList;
namespace Fungus.EditorUtils
{
[CustomEditor (typeof(SavePointLoaded), true)]
public class SavePointLoadedEditor : EventHandlerEditor
{
protected SerializedProperty savePointKeysProp;
protected virtual void OnEnable()
{
savePointKeysProp = serializedObject.FindProperty("savePointKeys");
}
protected override void DrawProperties()
{
ReorderableListGUI.Title("Save Point Keys");
ReorderableListGUI.ListField(savePointKeysProp);
}
}
}
#endif

12
Assets/Fungus/Scripts/Editor/SavePointLoadedEditor.cs.meta

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 8514e225c506c4938a5da19210cc6217
timeCreated: 1484049679
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

40
Assets/Fungus/Scripts/Editor/SetColliderEditor.cs

@ -1,40 +0,0 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
using UnityEngine;
using Rotorz.ReorderableList;
namespace Fungus.EditorUtils
{
[CustomEditor (typeof(SetCollider))]
public class SetColliderEditor : CommandEditor
{
protected SerializedProperty targetObjectsProp;
protected SerializedProperty targetTagProp;
protected SerializedProperty activeStateProp;
protected virtual void OnEnable()
{
if (NullTargetCheck()) // Check for an orphaned editor instance
return;
targetObjectsProp = serializedObject.FindProperty("targetObjects");
targetTagProp = serializedObject.FindProperty("targetTag");
activeStateProp = serializedObject.FindProperty("activeState");
}
public override void DrawCommandGUI()
{
serializedObject.Update();
ReorderableListGUI.Title(new GUIContent("Target Objects", "Objects containing collider components (2D or 3D)"));
ReorderableListGUI.ListField(targetObjectsProp);
EditorGUILayout.PropertyField(targetTagProp);
EditorGUILayout.PropertyField(activeStateProp);
serializedObject.ApplyModifiedProperties();
}
}
}

12
Assets/Fungus/Scripts/Editor/SetColliderEditor.cs.meta

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 672281668cfa249738d9dbc91f96b88e
timeCreated: 1432222536
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

10
Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs

@ -25,6 +25,16 @@ namespace Fungus.EditorUtils
public int widthOfList; public int widthOfList;
static public void DrawVarList(int w, SerializedProperty variablesProp)
{
ReorderableListGUI.Title("Variables");
VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0, w == 0 ? VariableListAdaptor.DefaultWidth : w);
ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton;
ReorderableListControl.DrawControlFromState(adaptor, null, flags);
}
public SerializedProperty this[int index] public SerializedProperty this[int index]
{ {
get { return _arrayProperty.GetArrayElementAtIndex(index); } get { return _arrayProperty.GetArrayElementAtIndex(index); }

4
Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs

@ -3,7 +3,6 @@
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using Rotorz.ReorderableList;
namespace Fungus.EditorUtils namespace Fungus.EditorUtils
{ {
@ -41,8 +40,7 @@ namespace Fungus.EditorUtils
EditorGUILayout.PropertyField(audioModeProp); EditorGUILayout.PropertyField(audioModeProp);
if ((AudioMode)audioModeProp.enumValueIndex == AudioMode.Beeps) if ((AudioMode)audioModeProp.enumValueIndex == AudioMode.Beeps)
{ {
ReorderableListGUI.Title(new GUIContent("Beep Sounds", "A list of beep sounds to play at random")); EditorGUILayout.PropertyField(beepSoundsProp, new GUIContent("Beep Sounds", "A list of beep sounds to play at random"),true);
ReorderableListGUI.ListField(beepSoundsProp);
} }
else else
{ {

Loading…
Cancel
Save