Browse Source

Add Option to enable Searchable PopupMenus

master
desktop-maesty/steve 6 years ago
parent
commit
878ea043d9
  1. 10
      Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs
  2. 10
      Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs
  3. 4
      Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs
  4. 4
      Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs

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

@ -16,8 +16,11 @@ namespace Fungus
{
// Have we loaded the prefs yet
private static bool prefsLoaded = false;
const string HIDE_MUSH_KEY = "hideMushroomInHierarchy";
const string USE_EXP_MENUS = "useExperimentalMenus";
public static bool hideMushroomInHierarchy;
public static bool useExperimentalMenus;
static FungusEditorPreferences()
{
@ -36,17 +39,20 @@ namespace Fungus
// Preferences GUI
hideMushroomInHierarchy = EditorGUILayout.Toggle("Hide Mushroom Flowchart Icon", hideMushroomInHierarchy);
useExperimentalMenus = EditorGUILayout.Toggle(new GUIContent("Experimental Searchable Menus", "Experimental menus replace the Event, Add Variable and Add Command menus with a searchable menu more like the Unity AddComponent menu."), useExperimentalMenus);
// Save the preferences
if (GUI.changed)
{
EditorPrefs.SetBool("hideMushroomInHierarchy", hideMushroomInHierarchy);
EditorPrefs.SetBool(HIDE_MUSH_KEY, hideMushroomInHierarchy);
EditorPrefs.SetBool(USE_EXP_MENUS, useExperimentalMenus);
}
}
public static void LoadOnScriptLoad()
{
hideMushroomInHierarchy = EditorPrefs.GetBool("hideMushroomInHierarchy", false);
hideMushroomInHierarchy = EditorPrefs.GetBool(HIDE_MUSH_KEY, false);
useExperimentalMenus = EditorPrefs.GetBool(USE_EXP_MENUS, false);
prefsLoaded = true;
}
}

10
Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs

@ -61,10 +61,18 @@ namespace Fungus.EditorUtils
{
curBlock = block;
if (FungusEditorPreferences.useExperimentalMenus)
{
var win = new CommandSelectorPopupWindowContent(currentHandlerName,
width, (int)(height - EditorGUIUtility.singleLineHeight * 3));
PopupWindow.Show(position, win);
}
else
{
//need to ensure we have filtered data
filteredAttributes = GetFilteredSupportedCommands(curBlock.GetFlowchart());
}
//old method
DoOlderMenu();

4
Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs

@ -71,11 +71,13 @@ namespace Fungus.EditorUtils
static public void DoEventHandlerPopUp(Rect position, string currentHandlerName, Block block, int width, int height)
{
if (FungusEditorPreferences.useExperimentalMenus)
{
//new method
EventSelectorPopupWindowContent win = new EventSelectorPopupWindowContent(currentHandlerName, block, width, height);
PopupWindow.Show(position, win);
}
//old method
DoOlderMenu(block);
}

4
Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs

@ -56,10 +56,12 @@ namespace Fungus.EditorUtils
static public void DoAddVariable(Rect position, string currentHandlerName, Flowchart flowchart)
{
curFlowchart = flowchart;
if (FungusEditorPreferences.useExperimentalMenus)
{
//new method
VariableSelectPopupWindowContent win = new VariableSelectPopupWindowContent(currentHandlerName, POPUP_WIDTH, POPUP_HEIGHT);
PopupWindow.Show(position, win);
}
//old method
DoOlderMenu(flowchart);
}

Loading…
Cancel
Save