diff --git a/Scripts/CurrentSettings.cs b/Scripts/CurrentSettings.cs
index 2bce6d6a..e6be9877 100644
--- a/Scripts/CurrentSettings.cs
+++ b/Scripts/CurrentSettings.cs
@@ -372,6 +372,29 @@ public static bool AlwaysSnapToCurrentGrid {
PlayerPrefs.SetInt(KEY_PREFIX + "alwaysSnapToCurrentGrid", value ? 1 : 0);
}
}
+
+ // Experimental options
+
+ public static MainMode[] enabledModes {
+ get {
+ MainMode[] output = (MainMode[]) Enum.GetValues(typeof(MainMode));
+
+ if (!VertexPaintToolEnabled) {
+ output = Array.FindAll(output, e => { return e != MainMode.Paint; });
+ }
+
+ return output;
+ }
+ }
+
+ public static bool VertexPaintToolEnabled {
+ get {
+ return PlayerPrefs.GetInt(KEY_PREFIX + "VertexPaintToolEnabled") == 1;
+ }
+ set {
+ PlayerPrefs.SetInt(KEY_PREFIX + "VertexPaintToolEnabled", value ? 1 : 0);
+ }
+ }
}
}
diff --git a/Scripts/UI/SabreCSGPreferences.cs b/Scripts/UI/SabreCSGPreferences.cs
index 5018b461..225b1660 100644
--- a/Scripts/UI/SabreCSGPreferences.cs
+++ b/Scripts/UI/SabreCSGPreferences.cs
@@ -117,9 +117,17 @@ public static void PreferencesGUI()
}
EditorGUILayout.Space();
- EditorGUI.indentLevel = 1;
- EditorGUILayout.LabelField("Developer Options", EditorStyles.boldLabel);
- EditorGUI.indentLevel = 0;
+ using (new EditorGUI.IndentLevelScope()) {
+ EditorGUILayout.LabelField("Experimental Options", EditorStyles.boldLabel);
+ }
+ EditorGUILayout.Space();
+
+ CurrentSettings.VertexPaintToolEnabled = GUILayout.Toggle(CurrentSettings.VertexPaintToolEnabled, "Vertex paint tool");
+
+ EditorGUILayout.Space();
+ using (new EditorGUI.IndentLevelScope()) {
+ EditorGUILayout.LabelField("Developer Options", EditorStyles.boldLabel);
+ }
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
diff --git a/Scripts/UI/SabreGUILayout.cs b/Scripts/UI/SabreGUILayout.cs
index 11abf3b6..8de28a88 100644
--- a/Scripts/UI/SabreGUILayout.cs
+++ b/Scripts/UI/SabreGUILayout.cs
@@ -305,6 +305,11 @@ public static GUIStyle FormatStyle(Color textColor, int fontSize, FontStyle font
}
}
+ ///
+ /// Displays a list of enum buttons.
+ ///
+ /// The active value enum.
+ /// The enum selected when the user clicks one of the buttons.
public static T DrawEnumGrid(T value, params GUILayoutOption[] options) where T : struct, IConvertible
{
if (!typeof(T).IsEnum)
@@ -347,6 +352,60 @@ public static T DrawEnumGrid(T value, params GUILayoutOption[] options) where
return value;
}
+ ///
+ /// Displays a list of enum buttons, using only the provided enums.
+ ///
+ /// The active value enum.
+ /// The visible enum values.
+ /// The enum selected when the user clicks one of the buttons.
+ public static T DrawPartialEnumGrid(T value, T[] enabled, params GUILayoutOption[] options) where T : struct, IConvertible
+ {
+ if (!typeof(T).IsEnum)
+ {
+ throw new ArgumentException("DrawEnumGrid must be passed an enum");
+ }
+ GUILayout.BeginHorizontal();
+
+ T[] enabledList = enabled;
+ T[] baseList = (T[]) Enum.GetValues(value.GetType());
+
+ for (int i = 0; i < baseList.Length; i++)
+ {
+ if (Array.IndexOf(enabledList, baseList[i]) == -1) {
+ continue;
+ }
+
+ GUIStyle activeStyle;
+ if (baseList.Length == 1) // Only one button
+ {
+ activeStyle = EditorStyles.miniButton;
+ }
+ else if (i == 0) // Left-most button
+ {
+ activeStyle = EditorStyles.miniButtonLeft;
+ }
+ else if (i == baseList.Length - 1) // Right-most button
+ {
+ activeStyle = EditorStyles.miniButtonRight;
+ }
+ else // Normal mid button
+ {
+ activeStyle = EditorStyles.miniButtonMid;
+ }
+
+ bool isActive = (Convert.ToInt32(value) == i);
+ // string displayName = StringHelper.ParseDisplayString(names[i]);
+ string displayName = baseList[i].ToString();
+ if (GUILayout.Toggle(isActive, displayName, activeStyle, options))
+ {
+ value = (T)Enum.ToObject(typeof(T), i);
+ }
+ }
+
+ GUILayout.EndHorizontal();
+ return value;
+ }
+
public static bool DrawUVField(Rect rect, float? sourceFloat, ref string floatString, string controlName, GUIStyle style)
{
if (!sourceFloat.HasValue)
diff --git a/Scripts/UI/Toolbar.cs b/Scripts/UI/Toolbar.cs
index 3b578b0c..d5055f44 100644
--- a/Scripts/UI/Toolbar.cs
+++ b/Scripts/UI/Toolbar.cs
@@ -135,7 +135,7 @@ private static void OnTopToolbarGUI(int windowID)
{
currentMode = (MainMode)(-1);
}
- MainMode newMainMode = SabreGUILayout.DrawEnumGrid(currentMode, GUILayout.Width(50));
+ MainMode newMainMode = SabreGUILayout.DrawPartialEnumGrid(currentMode, CurrentSettings.enabledModes, GUILayout.Width(50));
if(newMainMode != currentMode)
{
csgModel.SetCurrentMode(newMainMode);