Add support for cooking game for Switch

This commit is contained in:
Wojtek Figat
2021-03-15 14:32:10 +01:00
parent c7c339957b
commit c930d32b2b
11 changed files with 117 additions and 43 deletions

View File

@@ -92,6 +92,11 @@ namespace FlaxEditor.Content.Create
/// The Android settings
/// </summary>
AndroidPlatformSettings,
/// <summary>
/// The Switch settings
/// </summary>
SwitchPlatformSettings,
}
private static readonly Type[] _types =
@@ -111,6 +116,7 @@ namespace FlaxEditor.Content.Create
TypeUtils.GetManagedType(GameSettings.PS4PlatformSettingsTypename),
TypeUtils.GetManagedType(GameSettings.XboxScarlettPlatformSettingsTypename),
typeof(AndroidPlatformSettings),
TypeUtils.GetManagedType(GameSettings.SwitchPlatformSettingsTypename),
};
/// <summary>

View File

@@ -87,34 +87,14 @@ API_ENUM() enum class BuildPlatform
/// </summary>
API_ENUM(Attributes="EditorDisplay(null, \"Android ARM64 (arm64-v8a)\")")
AndroidARM64 = 9,
/// <summary>
/// Switch.
/// </summary>
Switch = 10,
};
inline const Char* ToString(const BuildPlatform platform)
{
switch (platform)
{
case BuildPlatform::Windows32:
return TEXT("Windows x86");
case BuildPlatform::Windows64:
return TEXT("Windows x64");
case BuildPlatform::UWPx86:
return TEXT("Windows Store x86");
case BuildPlatform::UWPx64:
return TEXT("Windows Store x64");
case BuildPlatform::XboxOne:
return TEXT("Xbox One");
case BuildPlatform::LinuxX64:
return TEXT("Linux x64");
case BuildPlatform::PS4:
return TEXT("PlayStation 4");
case BuildPlatform::XboxScarlett:
return TEXT("Xbox Scarlett");
case BuildPlatform::AndroidARM64:
return TEXT("Android ARM64");
default:
return TEXT("?");
}
}
extern FLAXENGINE_API const Char* ToString(const BuildPlatform platform);
/// <summary>
/// Game build configuration modes.
@@ -137,20 +117,7 @@ API_ENUM() enum class BuildConfiguration
Release = 2,
};
inline const Char* ToString(const BuildConfiguration configuration)
{
switch (configuration)
{
case BuildConfiguration::Debug:
return TEXT("Debug");
case BuildConfiguration::Development:
return TEXT("Development");
case BuildConfiguration::Release:
return TEXT("Release");
default:
return TEXT("?");
}
}
extern FLAXENGINE_API const Char* ToString(const BuildConfiguration configuration);
#define BUILD_STEP_CANCEL_CHECK if (GameCooker::IsCancelRequested()) return true

View File

@@ -39,7 +39,6 @@
#endif
#if PLATFORM_TOOLS_PS4
#include "Platforms/PS4/Editor/PlatformTools/PS4PlatformTools.h"
#include "Platforms/PS4/Engine/Platform/PS4PlatformSettings.h"
#endif
#if PLATFORM_TOOLS_XBOX_SCARLETT
#include "Platforms/XboxScarlett/Editor/PlatformTools/XboxScarlettPlatformTools.h"
@@ -47,6 +46,9 @@
#if PLATFORM_TOOLS_ANDROID
#include "Platform/Android/AndroidPlatformTools.h"
#endif
#if PLATFORM_TOOLS_SWITCH
#include "Platforms/Switch/Editor/PlatformTools/SwitchPlatformTools.h"
#endif
namespace GameCookerImpl
{
@@ -89,6 +91,50 @@ using namespace GameCookerImpl;
Delegate<GameCooker::EventType> GameCooker::OnEvent;
Delegate<const String&, float> GameCooker::OnProgress;
const Char* ToString(const BuildPlatform platform)
{
switch (platform)
{
case BuildPlatform::Windows32:
return TEXT("Windows x86");
case BuildPlatform::Windows64:
return TEXT("Windows x64");
case BuildPlatform::UWPx86:
return TEXT("Windows Store x86");
case BuildPlatform::UWPx64:
return TEXT("Windows Store x64");
case BuildPlatform::XboxOne:
return TEXT("Xbox One");
case BuildPlatform::LinuxX64:
return TEXT("Linux x64");
case BuildPlatform::PS4:
return TEXT("PlayStation 4");
case BuildPlatform::XboxScarlett:
return TEXT("Xbox Scarlett");
case BuildPlatform::AndroidARM64:
return TEXT("Android ARM64");
case BuildPlatform::Switch:
return TEXT("Switch");
default:
return TEXT("?");
}
}
const Char* ToString(const BuildConfiguration configuration)
{
switch (configuration)
{
case BuildConfiguration::Debug:
return TEXT("Debug");
case BuildConfiguration::Development:
return TEXT("Development");
case BuildConfiguration::Release:
return TEXT("Release");
default:
return TEXT("?");
}
}
bool CookingData::AssetTypeStatistics::operator<(const AssetTypeStatistics& other) const
{
if (ContentSize != other.ContentSize)
@@ -250,6 +296,11 @@ PlatformTools* GameCooker::GetTools(BuildPlatform platform)
case BuildPlatform::AndroidARM64:
result = New<AndroidPlatformTools>(ArchitectureType::ARM64);
break;
#endif
#if PLATFORM_TOOLS_SWITCH
case BuildPlatform::Switch:
result = New<SwitchPlatformTools>();
break;
#endif
}
Tools.Add(platform, result);

View File

@@ -180,7 +180,12 @@ bool CompileScriptsStep::Perform(CookingData& data)
platform = TEXT("Android");
architecture = TEXT("ARM64");
break;
case BuildPlatform::Switch:
platform = TEXT("Switch");
architecture = TEXT("ARM64");
break;
default:
LOG(Error, "Unknown or unsupported build platform.");
return true;
}
_extensionsToSkip.Clear();

View File

@@ -453,6 +453,14 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
COMPILE_PROFILE(Vulkan_SM5, SHADER_FILE_CHUNK_INTERNAL_VULKAN_SM5_CACHE);
break;
}
#endif
#if PLATFORM_TOOLS_SWITCH
case BuildPlatform::Switch:
{
const char* platformDefineName = "PLATFORM_SWITCH";
COMPILE_PROFILE(Vulkan_SM5, SHADER_FILE_CHUNK_INTERNAL_VULKAN_SM5_CACHE);
break;
}
#endif
default:
{

View File

@@ -89,6 +89,7 @@ namespace FlaxEditor.GUI
new PlatformData(PlatformType.PS4, icons.PS4, "PlayStation 4"),
new PlatformData(PlatformType.XboxScarlett, icons.XboxSeriesX, "Xbox Scarlett"),
new PlatformData(PlatformType.Android, icons.Android, "Android"),
new PlatformData(PlatformType.Switch, icons.ColorWheel, "Switch"),
};
const float IconSize = 48.0f;

View File

@@ -945,6 +945,9 @@ namespace FlaxEditor.Modules
if (typeXboxScarlettPlatformSettings != null)
Proxy.Add(new SettingsProxy(typeXboxScarlettPlatformSettings));
Proxy.Add(new SettingsProxy(typeof(AndroidPlatformSettings)));
var typeSwitchPlatformSettings = TypeUtils.GetManagedType(GameSettings.SwitchPlatformSettingsTypename);
if (typeSwitchPlatformSettings != null)
Proxy.Add(new SettingsProxy(typeSwitchPlatformSettings));
Proxy.Add(new SettingsProxy(typeof(AudioSettings)));
// Last add generic json (won't override other json proxies)

View File

@@ -43,6 +43,7 @@ namespace FlaxEditor.Windows
{ PlatformType.PS4, new PS4() },
{ PlatformType.XboxScarlett, new XboxScarlett() },
{ PlatformType.Android, new Android() },
{ PlatformType.Switch, new Switch() },
};
public BuildTabProxy(GameCookerWindow win, PlatformSelector platformSelector)
@@ -57,6 +58,7 @@ namespace FlaxEditor.Windows
PerPlatformOptions[PlatformType.PS4].Init("Output/PS4", "PS4");
PerPlatformOptions[PlatformType.XboxScarlett].Init("Output/XboxScarlett", "XboxScarlett");
PerPlatformOptions[PlatformType.Android].Init("Output/Android", "Android");
PerPlatformOptions[PlatformType.Switch].Init("Output/Switch", "Switch");
}
public abstract class Platform
@@ -188,6 +190,11 @@ namespace FlaxEditor.Windows
protected override BuildPlatform BuildPlatform => BuildPlatform.AndroidARM64;
}
public class Switch : Platform
{
protected override BuildPlatform BuildPlatform => BuildPlatform.Switch;
}
public class Editor : CustomEditor
{
private PlatformType _platform;
@@ -229,6 +236,9 @@ namespace FlaxEditor.Windows
case PlatformType.Android:
name = "Android";
break;
case PlatformType.Switch:
name = "Switch";
break;
default:
name = CustomEditorsUtil.GetPropertyNameUI(_platform.ToString());
break;

View File

@@ -510,7 +510,7 @@ bool MCore::LoadEngine()
// Info
char* buildInfo = mono_get_runtime_build_info();
LOG(Info, "Mono version: {0}", String(buildInfo));
mono_free(buildInfo);
mono_free(buildInfo);
return false;
}

View File

@@ -4799,6 +4799,16 @@ namespace pugi
return xml_node();
}
PUGI__FN xml_node xml_node::child_or_append(const char_t* name_)
{
if (!_root) return xml_node();
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
if (i->name && impl::strequal(name_, i->name)) return xml_node(i);
return append_child(name_);
}
PUGI__FN xml_attribute xml_node::attribute(const char_t* name_) const
{
if (!_root) return xml_attribute();
@@ -4869,7 +4879,18 @@ namespace pugi
return PUGIXML_TEXT("");
}
PUGI__FN const char_t* xml_node::child_value(const char_t* name_) const
PUGI__FN bool xml_node::set_child_value(const char_t* rhs)
{
if (!_root) return false;
for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
if (i->value && impl::is_text_node(i))
return xml_node(i).set_value(rhs);
return append_child(node_pcdata).set_value(rhs);
}
PUGI__FN const char_t* xml_node::child_value(const char_t* name_) const
{
return child(name_).child_value();
}

View File

@@ -452,12 +452,14 @@ namespace pugi
// Get child, attribute or next/previous sibling with the specified name
xml_node child(const char_t* name) const;
xml_node child_or_append(const char_t* name);
xml_attribute attribute(const char_t* name) const;
xml_node next_sibling(const char_t* name) const;
xml_node previous_sibling(const char_t* name) const;
// Get child value of current node; that is, value of the first child node of type PCDATA/CDATA
const char_t* child_value() const;
bool set_child_value(const char_t* rhs);
// Get child value of child with specified name. Equivalent to child(name).child_value().
const char_t* child_value(const char_t* name) const;