|
|
@ -337,6 +337,27 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
// Build menu list |
|
|
|
// Build menu list |
|
|
|
List<System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); |
|
|
|
List<System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); |
|
|
|
|
|
|
|
List<KeyValuePair<System.Type, CommandInfoAttribute>> filteredAttributes = GetFilteredCommandInfoAttribute(menuTypes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(var keyPair in filteredAttributes) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetCommandOperation commandOperation = new SetCommandOperation(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandOperation.sequence = sequence; |
|
|
|
|
|
|
|
commandOperation.commandType = keyPair.Key; |
|
|
|
|
|
|
|
commandOperation.index = index; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandMenu.AddItem (new GUIContent (keyPair.Value.Category + "/" + keyPair.Value.CommandName), |
|
|
|
|
|
|
|
false, Callback, commandOperation); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandMenu.ShowAsContext(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<KeyValuePair<System.Type,CommandInfoAttribute>> GetFilteredCommandInfoAttribute(List<System.Type> menuTypes) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Dictionary<string, KeyValuePair<System.Type, CommandInfoAttribute>> filteredAttributes = new Dictionary<string, KeyValuePair<System.Type, CommandInfoAttribute>>(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (System.Type type in menuTypes) |
|
|
|
foreach (System.Type type in menuTypes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
object[] attributes = type.GetCustomAttributes(false); |
|
|
|
object[] attributes = type.GetCustomAttributes(false); |
|
|
@ -345,19 +366,23 @@ namespace Fungus |
|
|
|
CommandInfoAttribute infoAttr = obj as CommandInfoAttribute; |
|
|
|
CommandInfoAttribute infoAttr = obj as CommandInfoAttribute; |
|
|
|
if (infoAttr != null) |
|
|
|
if (infoAttr != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SetCommandOperation commandOperation = new SetCommandOperation(); |
|
|
|
string dictionaryName = string.Format("{0}/{1}", infoAttr.Category, infoAttr.CommandName); |
|
|
|
|
|
|
|
|
|
|
|
commandOperation.sequence = sequence; |
|
|
|
int existingItemPriority = -1; |
|
|
|
commandOperation.commandType = type; |
|
|
|
if (filteredAttributes.ContainsKey(dictionaryName)) |
|
|
|
commandOperation.index = index; |
|
|
|
{ |
|
|
|
|
|
|
|
existingItemPriority = filteredAttributes[dictionaryName].Value.Priority; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
commandMenu.AddItem (new GUIContent (infoAttr.Category + "/" + infoAttr.CommandName), |
|
|
|
if (infoAttr.Priority > existingItemPriority) |
|
|
|
false, Callback, commandOperation); |
|
|
|
{ |
|
|
|
|
|
|
|
KeyValuePair<System.Type, CommandInfoAttribute> keyValuePair = new KeyValuePair<System.Type, CommandInfoAttribute>(type, infoAttr); |
|
|
|
|
|
|
|
filteredAttributes[dictionaryName] = keyValuePair; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
commandMenu.ShowAsContext(); |
|
|
|
return filteredAttributes.Values.ToList<KeyValuePair<System.Type,CommandInfoAttribute>>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Callback(object obj) |
|
|
|
void Callback(object obj) |
|
|
|