Merge remote-tracking branch 'origin/master' into gi
# Conflicts: # Source/Editor/Windows/Assets/VisualScriptWindow.cs
This commit is contained in:
@@ -175,37 +175,56 @@ namespace FlaxEditor.Windows.Assets
|
||||
// Parameter type editing
|
||||
var cmType = menu.AddChildMenu("Type");
|
||||
{
|
||||
var b = cmType.ContextMenu.AddButton(window.Surface.GetTypeName(param.Type) + "...", () =>
|
||||
var isArray = param.Type.IsArray;
|
||||
var isDictionary = !isArray && param.Type.IsDictionary;
|
||||
ScriptType singleValueType, arrayType, dictionaryType;
|
||||
ContextMenuButton b;
|
||||
if (isDictionary)
|
||||
{
|
||||
// Show context menu with list of parameter types to use
|
||||
var cm = new ItemsListContextMenu(180);
|
||||
var newParameterTypes = window.NewParameterTypes;
|
||||
foreach (var newParameterType in newParameterTypes)
|
||||
{
|
||||
var item = new TypeSearchPopup.TypeItemView(newParameterType);
|
||||
if (newParameterType.Type != null)
|
||||
item.Name = window.VisjectSurface.GetTypeName(newParameterType);
|
||||
cm.AddItem(item);
|
||||
}
|
||||
cm.ItemClicked += (ItemsListContextMenu.Item item) => window.SetParamType(index, (ScriptType)item.Tag);
|
||||
cm.SortItems();
|
||||
cm.Show(window, window.PointFromScreen(Input.MouseScreenPosition));
|
||||
});
|
||||
b.Enabled = window._canEdit;
|
||||
b.TooltipText = "Opens the type picker window to change the parameter type.";
|
||||
cmType.ContextMenu.AddSeparator();
|
||||
var args = param.Type.GetGenericArguments();
|
||||
singleValueType = new ScriptType(args[0]);
|
||||
arrayType = singleValueType.MakeArrayType();
|
||||
dictionaryType = param.Type;
|
||||
var keyName = window.Surface.GetTypeName(new ScriptType(args[0]));
|
||||
var valueName = window.Surface.GetTypeName(new ScriptType(args[1]));
|
||||
|
||||
ScriptType singleValueType, arrayType;
|
||||
if (param.Type.IsArray)
|
||||
{
|
||||
singleValueType = new ScriptType(param.Type.GetElementType());
|
||||
arrayType = param.Type;
|
||||
b = cmType.ContextMenu.AddButton($"Dictionary<{keyName}, {valueName}>");
|
||||
b.Enabled = false;
|
||||
|
||||
b = cmType.ContextMenu.AddButton($"Edit key type: {keyName}...", () => OnChangeType(item => window.SetParamType(index, ScriptType.MakeDictionaryType((ScriptType)item.Tag, new ScriptType(args[1])))));
|
||||
b.Enabled = window._canEdit;
|
||||
b.TooltipText = "Opens the type picker window to change the parameter type.";
|
||||
|
||||
b = cmType.ContextMenu.AddButton($"Edit value type: {valueName}...", () => OnChangeType(item => window.SetParamType(index, ScriptType.MakeDictionaryType(new ScriptType(args[0]), (ScriptType)item.Tag))));
|
||||
b.Enabled = window._canEdit;
|
||||
b.TooltipText = "Opens the type picker window to change the parameter type.";
|
||||
}
|
||||
else
|
||||
{
|
||||
singleValueType = param.Type;
|
||||
arrayType = param.Type.MakeArrayType();
|
||||
if (param.Type == ScriptType.Null)
|
||||
{
|
||||
b = cmType.ContextMenu.AddButton(window.Surface.GetTypeName(param.Type) + "...", () => OnChangeType(item => window.SetParamType(index, (ScriptType)item.Tag)));
|
||||
return;
|
||||
}
|
||||
else if (isArray)
|
||||
{
|
||||
singleValueType = param.Type.GetElementType();
|
||||
arrayType = param.Type;
|
||||
dictionaryType = ScriptType.MakeDictionaryType(new ScriptType(typeof(int)), singleValueType);
|
||||
b = cmType.ContextMenu.AddButton(window.Surface.GetTypeName(singleValueType) + "[]...", () => OnChangeType(item => window.SetParamType(index, ((ScriptType)item.Tag).MakeArrayType())));
|
||||
}
|
||||
else
|
||||
{
|
||||
singleValueType = param.Type;
|
||||
arrayType = param.Type.MakeArrayType();
|
||||
dictionaryType = ScriptType.MakeDictionaryType(new ScriptType(typeof(int)), singleValueType);
|
||||
b = cmType.ContextMenu.AddButton(window.Surface.GetTypeName(param.Type) + "...", () => OnChangeType(item => window.SetParamType(index, (ScriptType)item.Tag)));
|
||||
}
|
||||
b.Enabled = window._canEdit;
|
||||
b.TooltipText = "Opens the type picker window to change the parameter type.";
|
||||
}
|
||||
cmType.ContextMenu.AddSeparator();
|
||||
|
||||
b = cmType.ContextMenu.AddButton("Value", () => window.SetParamType(index, singleValueType));
|
||||
b.Checked = param.Type == singleValueType;
|
||||
b.Enabled = window._canEdit;
|
||||
@@ -214,8 +233,30 @@ namespace FlaxEditor.Windows.Assets
|
||||
b.Checked = param.Type == arrayType;
|
||||
b.Enabled = window._canEdit;
|
||||
b.TooltipText = "Changes parameter type to an array.";
|
||||
b = cmType.ContextMenu.AddButton("Dictionary", () => window.SetParamType(index, dictionaryType));
|
||||
b.Checked = param.Type == dictionaryType;
|
||||
b.Enabled = window._canEdit;
|
||||
b.TooltipText = "Changes parameter type to a dictionary.";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnChangeType(Action<ItemsListContextMenu.Item> itemClicked)
|
||||
{
|
||||
// Show context menu with list of parameter types to use
|
||||
var cm = new ItemsListContextMenu(180);
|
||||
var window = (VisualScriptWindow)Values[0];
|
||||
var newParameterTypes = window.NewParameterTypes;
|
||||
foreach (var newParameterType in newParameterTypes)
|
||||
{
|
||||
var item = new TypeSearchPopup.TypeItemView(newParameterType);
|
||||
if (newParameterType.Type != null)
|
||||
item.Name = window.VisjectSurface.GetTypeName(newParameterType);
|
||||
cm.AddItem(item);
|
||||
}
|
||||
cm.ItemClicked += itemClicked;
|
||||
cm.SortItems();
|
||||
cm.Show(window, window.PointFromScreen(Input.MouseScreenPosition));
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class PropertiesProxy
|
||||
@@ -366,7 +407,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
gridControl.Height = Button.DefaultHeight;
|
||||
gridControl.SlotsHorizontally = 2;
|
||||
gridControl.SlotsVertically = 1;
|
||||
|
||||
|
||||
var addOverride = grid.Button("Add Override");
|
||||
addOverride.Button.Clicked += OnOverrideMethodClicked;
|
||||
// TODO: Add sender arg to button clicked action?
|
||||
@@ -1198,6 +1239,22 @@ namespace FlaxEditor.Windows.Assets
|
||||
AfterType = type,
|
||||
AfterValue = TypeUtils.GetDefaultValue(type),
|
||||
};
|
||||
if (action.BeforeValue != null)
|
||||
{
|
||||
// Try to maintain existing value
|
||||
var beforeType = TypeUtils.GetObjectType(action.BeforeValue);
|
||||
if (type.IsArray && beforeType.IsArray && type.GetElementType().IsAssignableFrom(beforeType.GetElementType()))
|
||||
{
|
||||
var beforeArray = (Array)action.BeforeValue;
|
||||
var afterArray = TypeUtils.CreateArrayInstance(type.GetElementType(), beforeArray.Length);
|
||||
Array.Copy(beforeArray, afterArray, beforeArray.Length);
|
||||
action.AfterValue = afterArray;
|
||||
}
|
||||
else if (type.IsAssignableFrom(beforeType))
|
||||
{
|
||||
action.AfterValue = action.BeforeValue;
|
||||
}
|
||||
}
|
||||
_undo.AddAction(action);
|
||||
action.Do();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace FlaxEditor.Windows
|
||||
/// <summary>
|
||||
/// Proxy object for the Build tab.
|
||||
/// </summary>
|
||||
[HideInEditor]
|
||||
[CustomEditor(typeof(BuildTabProxy.Editor))]
|
||||
private class BuildTabProxy
|
||||
{
|
||||
@@ -65,6 +66,7 @@ namespace FlaxEditor.Windows
|
||||
PerPlatformOptions[PlatformType.Mac].Init("Output/Mac", "Mac");
|
||||
}
|
||||
|
||||
[HideInEditor]
|
||||
abstract class Platform
|
||||
{
|
||||
[HideInEditor]
|
||||
|
||||
Reference in New Issue
Block a user