Add Switch platform

This commit is contained in:
Wojtek Figat
2021-03-09 14:26:30 +01:00
parent 044234a55b
commit cc201e198d
40 changed files with 123 additions and 3 deletions

View File

@@ -58,6 +58,7 @@ public class Editor : EditorModule
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "PS4", "PLATFORM_TOOLS_PS4");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "XboxScarlett", "PLATFORM_TOOLS_XBOX_SCARLETT");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID");
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Switch", "PLATFORM_TOOLS_SWITCH");
// Visual Studio integration
if (options.Platform.Target == TargetPlatform.Windows)

View File

@@ -1326,9 +1326,9 @@ namespace FlaxEditor.Surface.Archetypes
Title = "Platform Switch",
Description = "Gets the input value based on the runtime-platform type",
Flags = NodeFlags.AllGraphs,
Size = new Vector2(220, 160),
Size = new Vector2(220, 180),
ConnectionsHints = ConnectionsHint.Value,
IndependentBoxes = new[] { 1, 2, 3, 4, 5, 6, 7, 8 },
IndependentBoxes = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 },
DependentBoxes = new[] { 0 },
Elements = new[]
{
@@ -1341,6 +1341,7 @@ namespace FlaxEditor.Surface.Archetypes
NodeElementArchetype.Factory.Input(5, "PlayStation 4", true, null, 6),
NodeElementArchetype.Factory.Input(6, "Xbox Scarlett", true, null, 7),
NodeElementArchetype.Factory.Input(7, "Android", true, null, 8),
NodeElementArchetype.Factory.Input(8, "Switch", true, null, 9),
}
},
new NodeArchetype

View File

@@ -46,6 +46,9 @@ public class Audio : EngineModule
case TargetPlatform.Android:
useOpenAL = true;
break;
case TargetPlatform.Switch:
useNone = true;
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}

View File

@@ -55,6 +55,8 @@ IMPLEMENT_SETTINGS_GETTER(PS4PlatformSettings, PS4Platform);
IMPLEMENT_SETTINGS_GETTER(XboxScarlettPlatformSettings, XboxScarlettPlatform);
#elif PLATFORM_ANDROID
IMPLEMENT_SETTINGS_GETTER(AndroidPlatformSettings, AndroidPlatform);
#elif PLATFORM_SWITCH
IMPLEMENT_SETTINGS_GETTER(SwitchPlatformSettings, SwitchPlatform);
#else
#error Unknown platform
#endif
@@ -199,6 +201,7 @@ void GameSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* mo
DESERIALIZE(PS4Platform);
DESERIALIZE(XboxScarlettPlatform);
DESERIALIZE(AndroidPlatform);
DESERIALIZE(SwitchPlatform);
}
void LayersAndTagsSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)

View File

@@ -11,6 +11,7 @@ namespace FlaxEditor.Content.Settings
{
internal const string PS4PlatformSettingsTypename = "FlaxEditor.Content.Settings.PS4PlatformSettings";
internal const string XboxScarlettPlatformSettingsTypename = "FlaxEditor.Content.Settings.XboxScarlettPlatformSettings";
internal const string SwitchPlatformSettingsTypename = "FlaxEditor.Content.Settings.SwitchPlatformSettings";
/// <summary>
/// The default application icon.
@@ -138,6 +139,14 @@ namespace FlaxEditor.Content.Settings
public JsonAsset AndroidPlatform;
#endif
#if FLAX_EDITOR || PLATFORM_SWITCH
/// <summary>
/// Reference to Switch Platform Settings asset. Used to apply configuration on Switch platform.
/// </summary>
[EditorOrder(2070), EditorDisplay("Platform Settings", "Switch"), AssetReference(SwitchPlatformSettingsTypename, true), Tooltip("Reference to Switch Platform Settings asset")]
public JsonAsset SwitchPlatform;
#endif
/// <summary>
/// Gets the absolute path to the game settings asset file.
/// </summary>
@@ -240,6 +249,10 @@ namespace FlaxEditor.Content.Settings
if (type == typeof(AndroidPlatformSettings))
return LoadAsset<AndroidPlatformSettings>(gameSettings.AndroidPlatform) as T;
#endif
#if FLAX_EDITOR || PLATFORM_SWITCH
if (type.FullName == SwitchPlatformSettingsTypename)
return LoadAsset(gameSettings.SwitchPlatform, SwitchPlatformSettingsTypename) as T;
#endif
if (gameSettings.CustomSettings != null)
{
@@ -324,6 +337,8 @@ namespace FlaxEditor.Content.Settings
return SaveAsset(gameSettings, ref gameSettings.XboxScarlettPlatform, obj);
if (type == typeof(AndroidPlatformSettings))
return SaveAsset(gameSettings, ref gameSettings.AndroidPlatform, obj);
if (type.FullName == SwitchPlatformSettingsTypename)
return SaveAsset(gameSettings, ref gameSettings.SwitchPlatform, obj);
if (type == typeof(AudioSettings))
return SaveAsset(gameSettings, ref gameSettings.Audio, obj);

View File

@@ -77,6 +77,7 @@ public:
Guid PS4Platform;
Guid XboxScarlettPlatform;
Guid AndroidPlatform;
Guid SwitchPlatform;
public:

View File

@@ -23,3 +23,6 @@
#if PLATFORM_ANDROID
#include "Engine/Platform/Android/AndroidPlatformSettings.h"
#endif
#if PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchPlatformSettings.h"
#endif

View File

@@ -42,6 +42,9 @@ public class Engine : EngineModule
case TargetPlatform.PS4:
options.SourcePaths.Add(Path.Combine(Globals.EngineRoot, "Source", "Platforms", "PS4", "Engine", "Engine"));
break;
case TargetPlatform.Switch:
options.SourcePaths.Add(Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Switch", "Engine", "Engine"));
break;
}
}
}

View File

@@ -16,6 +16,8 @@
#include "Platforms/XboxScarlett/Engine/Engine/XboxScarlettGame.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidGame.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Engine/SwitchGame.h"
#else
#error Missing Game implementation!
#endif

View File

@@ -75,6 +75,9 @@ public class Graphics : EngineModule
case TargetPlatform.Android:
options.PrivateDependencies.Add("GraphicsDeviceVulkan");
break;
case TargetPlatform.Switch:
options.PrivateDependencies.Add("GraphicsDeviceNull"); // TODO: use Vulkan on Switch
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}

View File

@@ -64,6 +64,9 @@ public class Main : EngineModule
case TargetPlatform.Android:
options.SourcePaths.Add(Path.Combine(FolderPath, "Android"));
break;
case TargetPlatform.Switch:
options.SourcePaths.Add(Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Switch", "Engine", "Main"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}
}

View File

@@ -534,6 +534,8 @@ const Char* ToString(PlatformType type)
return TEXT("Xbox Scarlett");
case PlatformType::Android:
return TEXT("Android");
case PlatformType::Switch:
return TEXT("Switch");
default:
return TEXT("");
}

View File

@@ -14,6 +14,8 @@
#include "Base/ClipboardBase.h"
#elif PLATFORM_ANDROID
#include "Base/ClipboardBase.h"
#elif PLATFORM_SWITCH
#include "Base/ClipboardBase.h"
#else
#error Missing Clipboard implementation!
#endif

View File

@@ -14,6 +14,8 @@
#include "Win32/Win32ConditionVariable.h"
#elif PLATFORM_ANDROID
#include "Unix/UnixConditionVariable.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchConditionVariable.h"
#else
#error Missing Condition Variable implementation!
#endif

View File

@@ -14,6 +14,8 @@
#include "Win32/Win32CriticalSection.h"
#elif PLATFORM_ANDROID
#include "Unix/UnixCriticalSection.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchCriticalSection.h"
#else
#error Missing Critical Section implementation!
#endif

View File

@@ -43,6 +43,11 @@ API_ENUM() enum class PlatformType
/// Running on Android.
/// </summary>
Android = 7,
/// <summary>
/// Running on Switch.
/// </summary>
Switch = 8,
};
/// <summary>
@@ -113,6 +118,9 @@ API_ENUM() enum class ArchitectureType
#if !defined(PLATFORM_IOS)
#define PLATFORM_IOS 0
#endif
#if !defined(PLATFORM_SWITCH)
#define PLATFORM_SWITCH 0
#endif
#if PLATFORM_WINDOWS
#include "Windows/WindowsDefines.h"
@@ -126,6 +134,8 @@ API_ENUM() enum class ArchitectureType
#include "Platforms/XboxScarlett/Engine/Platform/XboxScarlettDefines.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidDefines.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchDefines.h"
#else
#error Missing Defines implementation!
#endif

View File

@@ -14,6 +14,8 @@
#include "Win32/Win32File.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidFile.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchFile.h"
#else
#error Missing File implementation!
#endif

View File

@@ -14,6 +14,8 @@
#include "Platforms/XboxScarlett/Engine/Platform/XboxScarlettFileSystem.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidFileSystem.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchFileSystem.h"
#else
#error Missing File System implementation!
#endif

View File

@@ -14,6 +14,8 @@
#include "Base/FileSystemWatcherBase.h"
#elif PLATFORM_ANDROID
#include "Base/FileSystemWatcherBase.h"
#elif PLATFORM_SWITCH
#include "Base/FileSystemWatcherBase.h"
#else
#error Missing File System Watcher implementation!
#endif

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
@@ -14,6 +14,8 @@
#include "Win32/Win32Network.h"
#elif PLATFORM_ANDROID
#include "Base/NetworkBase.h"
#elif PLATFORM_SWITCH
#include "Base/NetworkBase.h"
#else
#error Missing Network implementation!
#endif

View File

@@ -65,6 +65,9 @@ public class Platform : EngineModule
options.SourcePaths.Add(Path.Combine(FolderPath, "Unix"));
options.SourcePaths.Add(Path.Combine(FolderPath, "Android"));
break;
case TargetPlatform.Switch:
options.SourcePaths.Add(Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Switch", "Engine", "Platform"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}
if (options.Target.IsEditor)
@@ -76,6 +79,7 @@ public class Platform : EngineModule
options.SourceFiles.Add(Path.Combine(FolderPath, "Android", "AndroidPlatformSettings.h"));
AddSourceFileIfExists(options, Path.Combine(Globals.EngineRoot, "Source", "Platforms", "XboxScarlett", "Engine", "Platform", "XboxScarlettPlatformSettings.h"));
AddSourceFileIfExists(options, Path.Combine(Globals.EngineRoot, "Source", "Platforms", "PS4", "Engine", "Platform", "PS4PlatformSettings.h"));
AddSourceFileIfExists(options, Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Switch", "Engine", "Platform", "SwitchPlatformSettings.h"));
}
}
}

View File

@@ -20,6 +20,8 @@
#include "Platforms/XboxScarlett/Engine/Platform/XboxScarlettPlatform.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidPlatform.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchPlatform.h"
#else
#error Missing Platform implementation!
#endif

View File

@@ -14,6 +14,8 @@
#include "Win32/Win32Thread.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidThread.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchThread.h"
#else
#error Missing Thread implementation!
#endif

View File

@@ -140,6 +140,29 @@ typedef AndroidWindow Window;
class NetworkBase;
typedef NetworkBase Network;
#elif PLATFORM_SWITCH
class ClipboardBase;
typedef ClipboardBase Clipboard;
class SwitchCriticalSection;
typedef SwitchCriticalSection CriticalSection;
class SwitchConditionVariable;
typedef SwitchConditionVariable ConditionVariable;
class SwitchFileSystem;
typedef SwitchFileSystem FileSystem;
class FileSystemWatcherBase;
typedef FileSystemWatcherBase FileSystemWatcher;
class SwitchFile;
typedef SwitchFile File;
class SwitchPlatform;
typedef SwitchPlatform Platform;
class SwitchThread;
typedef SwitchThread Thread;
class SwitchWindow;
typedef SwitchWindow Window;
class NetworkBase;
typedef NetworkBase Network;
#else
#error Missing Types implementation!

View File

@@ -14,6 +14,8 @@
#include "Platforms/XboxScarlett/Engine/Platform/XboxScarlettWindow.h"
#elif PLATFORM_ANDROID
#include "Android/AndroidWindow.h"
#elif PLATFORM_SWITCH
#include "Platforms/Switch/Engine/Platform/SwitchWindow.h"
#else
#error Missing Window implementation!
#endif

View File

@@ -33,6 +33,7 @@ public class TextureTool : EngineModule
case TargetPlatform.Linux:
case TargetPlatform.PS4:
case TargetPlatform.Android:
case TargetPlatform.Switch:
useStb = true;
break;
default: throw new InvalidPlatformException(options.Platform.Target);

View File

@@ -767,6 +767,7 @@ void ShaderGenerator::ProcessGroupTools(Box* box, Node* node, Value& value)
PLATFORM_CASE(6, "PLATFORM_PS4");
PLATFORM_CASE(7, "PLATFORM_XBOX_SCARLETT");
PLATFORM_CASE(8, "PLATFORM_ANDROID");
PLATFORM_CASE(9, "PLATFORM_SWITCH");
#undef PLATFORM_CASE
break;
}

View File

@@ -714,6 +714,9 @@ void VisjectExecutor::ProcessGroupTools(Box* box, Node* node, Value& value)
case PlatformType::Android:
boxId = 8;
break;
case PlatformType::Switch:
boxId = 9;
break;
default: ;
}
value = tryGetValue(node->GetBox(node->GetBox(boxId)->HasConnection() ? boxId : 1), Value::Zero);

View File

@@ -40,6 +40,7 @@ public class freetype : DepsModule
case TargetPlatform.Linux:
case TargetPlatform.PS4:
case TargetPlatform.Android:
case TargetPlatform.Switch:
options.OutputFiles.Add(Path.Combine(depsRoot, "libfreetype.a"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);

View File

@@ -88,6 +88,9 @@ public class mono : DepsModule
options.DependencyFiles.Add(Path.Combine(depsRoot, "libmonosgen-2.0.so"));
options.Libraries.Add(Path.Combine(depsRoot, "libmonosgen-2.0.so"));
break;
case TargetPlatform.Switch:
// TODO: mono for Switch
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}

View File

@@ -39,6 +39,7 @@ public class ogg : DepsModule
case TargetPlatform.Linux:
case TargetPlatform.PS4:
case TargetPlatform.Android:
case TargetPlatform.Switch:
options.OutputFiles.Add(Path.Combine(depsRoot, "libogg.a"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);

View File

@@ -45,6 +45,7 @@ public class vorbis : DepsModule
options.OutputFiles.Add(Path.Combine(depsRoot, "libvorbisfile.a"));
break;
case TargetPlatform.PS4:
case TargetPlatform.Switch:
options.OutputFiles.Add(Path.Combine(depsRoot, "libvorbis.a"));
break;
default: throw new InvalidPlatformException(options.Platform.Target);

View File

@@ -31,6 +31,7 @@ namespace Flax.Build
case TargetPlatform.Linux:
case TargetPlatform.PS4:
case TargetPlatform.Android:
case TargetPlatform.Switch:
options.OutputFiles.Add(Path.Combine(path, string.Format("lib{0}.a", name)));
break;
default: throw new InvalidPlatformException(options.Platform.Target);

View File

@@ -90,6 +90,7 @@ namespace Flax.Build
case TargetPlatform.PS4: return "PLATFORM_PS4";
case TargetPlatform.XboxScarlett: return "PLATFORM_XBOX_SCARLETT";
case TargetPlatform.Android: return "PLATFORM_ANDROID";
case TargetPlatform.Switch: return "PLATFORM_SWITCH";
default: throw new InvalidPlatformException(platform);
}
}

View File

@@ -230,6 +230,7 @@ namespace Flax.Build
case TargetPlatform.Linux: return targetArchitecture == TargetArchitecture.x64;
case TargetPlatform.PS4: return targetArchitecture == TargetArchitecture.x64;
case TargetPlatform.Android: return targetArchitecture == TargetArchitecture.ARM64;
case TargetPlatform.Switch: return targetArchitecture == TargetArchitecture.ARM64;
default: return false;
}
}

View File

@@ -41,6 +41,11 @@ namespace Flax.Build
/// Running on Android.
/// </summary>
Android = 7,
/// <summary>
/// Running on Switch.
/// </summary>
Switch = 8,
}
/// <summary>

View File

@@ -237,6 +237,7 @@ namespace Flax.Deps
}
case TargetPlatform.Linux:
case TargetPlatform.PS4:
case TargetPlatform.Switch:
{
cmdLine = "CMakeLists.txt";
break;

View File

@@ -143,6 +143,7 @@
<Compile Include="Platforms\Windows\*.cs" />
<Compile Include="Platforms\XboxOne\*.cs" />
<Compile Include="..\..\Platforms\XboxScarlett\Flax.Build\*.cs" />
<Compile Include="..\..\Platforms\Switch\Flax.Build\*.cs" />
<Compile Include="Projects\IProjectCustomizer.cs" />
<Compile Include="Projects\Project.cs" />
<Compile Include="Projects\ProjectFormat.cs" />

View File

@@ -34,6 +34,7 @@ namespace Flax.Build
TargetPlatform.PS4,
TargetPlatform.XboxScarlett,
TargetPlatform.Android,
TargetPlatform.Switch,
};
/// <summary>

View File

@@ -61,6 +61,7 @@ namespace Flax.Build.Platforms
case TargetPlatform.PS4: return Sdk.HasValid("PS4Sdk");
case TargetPlatform.XboxScarlett: return GetSDKs().ContainsKey(WindowsPlatformSDK.v10_0_19041_0) && Sdk.HasValid("GDK");
case TargetPlatform.Android: return AndroidSdk.Instance.IsValid && AndroidNdk.Instance.IsValid;
case TargetPlatform.Switch: return Sdk.HasValid("SwitchSdk");
default: return false;
}
}