Move to custom tool method within platform
This commit is contained in:
@@ -197,6 +197,12 @@ namespace FlaxEditor.Windows
|
||||
label.Label.AutoHeight = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to add platform specific tools if available.
|
||||
/// </summary>
|
||||
/// <param name="layout">The layout to start the tools at.</param>
|
||||
public virtual void OnCustomToolsLayout(LayoutElementsContainer layout) { }
|
||||
|
||||
public virtual void Build()
|
||||
{
|
||||
var output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(Output));
|
||||
@@ -237,120 +243,13 @@ namespace FlaxEditor.Windows
|
||||
class Android : Platform
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.AndroidARM64;
|
||||
}
|
||||
|
||||
class Switch : Platform
|
||||
/// <inheritdoc />
|
||||
public override void OnCustomToolsLayout(LayoutElementsContainer layout)
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.Switch;
|
||||
}
|
||||
|
||||
class PS5 : Platform
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.PS5;
|
||||
}
|
||||
|
||||
class Mac : Platform
|
||||
{
|
||||
public enum Archs
|
||||
{
|
||||
[EditorDisplay(null, "arm64")]
|
||||
ARM64,
|
||||
|
||||
[EditorDisplay(null, "x64")]
|
||||
x64,
|
||||
}
|
||||
|
||||
public Archs CPU = Archs.ARM64;
|
||||
|
||||
protected override BuildPlatform BuildPlatform => CPU == Archs.ARM64 ? BuildPlatform.MacOSARM64 : BuildPlatform.MacOSx64;
|
||||
}
|
||||
|
||||
class iOS : Platform
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.iOSARM64;
|
||||
}
|
||||
|
||||
class Editor : CustomEditor
|
||||
{
|
||||
private PlatformType _platform;
|
||||
private Button _buildButton;
|
||||
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
var proxy = (BuildTabProxy)Values[0];
|
||||
_platform = proxy.Selector.Selected;
|
||||
var platformObj = proxy.PerPlatformOptions[_platform];
|
||||
|
||||
if (!platformObj.IsSupported)
|
||||
{
|
||||
layout.Label("This platform is not supported on this system.", TextAlignment.Center);
|
||||
}
|
||||
else if (platformObj.IsAvailable)
|
||||
{
|
||||
string name;
|
||||
switch (_platform)
|
||||
{
|
||||
case PlatformType.Windows:
|
||||
name = "Windows";
|
||||
break;
|
||||
case PlatformType.XboxOne:
|
||||
name = "Xbox One";
|
||||
break;
|
||||
case PlatformType.UWP:
|
||||
name = "Windows Store";
|
||||
layout.Label("UWP (Windows Store) platform has been deprecated and is no longer supported", TextAlignment.Center).Label.TextColor = Color.Red;
|
||||
break;
|
||||
case PlatformType.Linux:
|
||||
name = "Linux";
|
||||
break;
|
||||
case PlatformType.PS4:
|
||||
name = "PlayStation 4";
|
||||
break;
|
||||
case PlatformType.XboxScarlett:
|
||||
name = "Xbox Scarlett";
|
||||
break;
|
||||
case PlatformType.Android:
|
||||
name = "Android";
|
||||
break;
|
||||
case PlatformType.Switch:
|
||||
name = "Switch";
|
||||
break;
|
||||
case PlatformType.PS5:
|
||||
name = "PlayStation 5";
|
||||
break;
|
||||
case PlatformType.Mac:
|
||||
name = "Mac";
|
||||
break;
|
||||
case PlatformType.iOS:
|
||||
name = "iOS";
|
||||
break;
|
||||
default:
|
||||
name = Utilities.Utils.GetPropertyNameUI(_platform.ToString());
|
||||
break;
|
||||
}
|
||||
var group = layout.Group(name);
|
||||
|
||||
group.Object(new ReadOnlyValueContainer(platformObj));
|
||||
|
||||
layout.Space(2);
|
||||
var openOutputButton = layout.Button("Open output folder").Button;
|
||||
openOutputButton.TooltipText = "Opens the defined out folder if the path exists.";
|
||||
openOutputButton.Clicked += () =>
|
||||
{
|
||||
string output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(proxy.PerPlatformOptions[_platform].Output));
|
||||
if (Directory.Exists(output))
|
||||
FlaxEngine.FileSystem.ShowFileExplorer(output);
|
||||
else
|
||||
FlaxEditor.Editor.LogWarning($"Can not open path: {output} because it does not exist.");
|
||||
};
|
||||
layout.Space(2);
|
||||
|
||||
_buildButton = layout.Button("Build").Button;
|
||||
_buildButton.Clicked += OnBuildClicked;
|
||||
base.OnCustomToolsLayout(layout);
|
||||
|
||||
// Add emulation options to android tab.
|
||||
if (_platform == PlatformType.Android)
|
||||
{
|
||||
layout.Space(5);
|
||||
var emulatorGroup = layout.Group("Tools");
|
||||
var sdkPath = Environment.GetEnvironmentVariable("ANDROID_HOME");
|
||||
@@ -533,7 +432,7 @@ namespace FlaxEditor.Windows
|
||||
return;
|
||||
|
||||
// Get built APK at output path
|
||||
string output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(proxy.PerPlatformOptions[_platform].Output));
|
||||
string output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(Output));
|
||||
if (!Directory.Exists(output))
|
||||
{
|
||||
FlaxEditor.Editor.LogWarning("Can not copy APK because output folder does not exist.");
|
||||
@@ -611,6 +510,117 @@ namespace FlaxEditor.Windows
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Switch : Platform
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.Switch;
|
||||
}
|
||||
|
||||
class PS5 : Platform
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.PS5;
|
||||
}
|
||||
|
||||
class Mac : Platform
|
||||
{
|
||||
public enum Archs
|
||||
{
|
||||
[EditorDisplay(null, "arm64")]
|
||||
ARM64,
|
||||
|
||||
[EditorDisplay(null, "x64")]
|
||||
x64,
|
||||
}
|
||||
|
||||
public Archs CPU = Archs.ARM64;
|
||||
|
||||
protected override BuildPlatform BuildPlatform => CPU == Archs.ARM64 ? BuildPlatform.MacOSARM64 : BuildPlatform.MacOSx64;
|
||||
}
|
||||
|
||||
class iOS : Platform
|
||||
{
|
||||
protected override BuildPlatform BuildPlatform => BuildPlatform.iOSARM64;
|
||||
}
|
||||
|
||||
class Editor : CustomEditor
|
||||
{
|
||||
private PlatformType _platform;
|
||||
private Button _buildButton;
|
||||
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
var proxy = (BuildTabProxy)Values[0];
|
||||
_platform = proxy.Selector.Selected;
|
||||
var platformObj = proxy.PerPlatformOptions[_platform];
|
||||
|
||||
if (!platformObj.IsSupported)
|
||||
{
|
||||
layout.Label("This platform is not supported on this system.", TextAlignment.Center);
|
||||
}
|
||||
else if (platformObj.IsAvailable)
|
||||
{
|
||||
string name;
|
||||
switch (_platform)
|
||||
{
|
||||
case PlatformType.Windows:
|
||||
name = "Windows";
|
||||
break;
|
||||
case PlatformType.XboxOne:
|
||||
name = "Xbox One";
|
||||
break;
|
||||
case PlatformType.UWP:
|
||||
name = "Windows Store";
|
||||
layout.Label("UWP (Windows Store) platform has been deprecated and is no longer supported", TextAlignment.Center).Label.TextColor = Color.Red;
|
||||
break;
|
||||
case PlatformType.Linux:
|
||||
name = "Linux";
|
||||
break;
|
||||
case PlatformType.PS4:
|
||||
name = "PlayStation 4";
|
||||
break;
|
||||
case PlatformType.XboxScarlett:
|
||||
name = "Xbox Scarlett";
|
||||
break;
|
||||
case PlatformType.Android:
|
||||
name = "Android";
|
||||
break;
|
||||
case PlatformType.Switch:
|
||||
name = "Switch";
|
||||
break;
|
||||
case PlatformType.PS5:
|
||||
name = "PlayStation 5";
|
||||
break;
|
||||
case PlatformType.Mac:
|
||||
name = "Mac";
|
||||
break;
|
||||
case PlatformType.iOS:
|
||||
name = "iOS";
|
||||
break;
|
||||
default:
|
||||
name = Utilities.Utils.GetPropertyNameUI(_platform.ToString());
|
||||
break;
|
||||
}
|
||||
var group = layout.Group(name);
|
||||
|
||||
group.Object(new ReadOnlyValueContainer(platformObj));
|
||||
|
||||
layout.Space(2);
|
||||
var openOutputButton = layout.Button("Open output folder").Button;
|
||||
openOutputButton.TooltipText = "Opens the defined out folder if the path exists.";
|
||||
openOutputButton.Clicked += () =>
|
||||
{
|
||||
string output = StringUtils.ConvertRelativePathToAbsolute(Globals.ProjectFolder, StringUtils.NormalizePath(proxy.PerPlatformOptions[_platform].Output));
|
||||
if (Directory.Exists(output))
|
||||
FlaxEngine.FileSystem.ShowFileExplorer(output);
|
||||
else
|
||||
FlaxEditor.Editor.LogWarning($"Can not open path: {output} because it does not exist.");
|
||||
};
|
||||
layout.Space(2);
|
||||
|
||||
_buildButton = layout.Button("Build").Button;
|
||||
_buildButton.Clicked += OnBuildClicked;
|
||||
platformObj.OnCustomToolsLayout(layout);
|
||||
}
|
||||
else
|
||||
{
|
||||
platformObj.OnNotAvailableLayout(layout);
|
||||
|
||||
Reference in New Issue
Block a user