diff --git a/Source/Editor/Cooker/Platform/Web/WebPlatformTools.cpp b/Source/Editor/Cooker/Platform/Web/WebPlatformTools.cpp index bd35fd61b..e8956cec1 100644 --- a/Source/Editor/Cooker/Platform/Web/WebPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/Web/WebPlatformTools.cpp @@ -205,7 +205,15 @@ bool WebPlatformTools::OnPostProcess(CookingData& data) FileSystem::CopyFile(dstIcon, platformDataPath / TEXT("favicon.ico")); } - // TODO: customizable HTML templates + // Copy custom HTMl template + auto customHtml = platformSettings->CustomHtml.TrimTrailing(); + if (customHtml.HasChars()) + { + FileSystem::CopyFile(data.OriginalOutputPath / TEXT("FlaxGame.html"), customHtml); + } + + // Rename game website main HTML file to match the most common name used by web servers (index.html) + FileSystem::MoveFile(data.OriginalOutputPath / TEXT("index.html"), data.OriginalOutputPath / TEXT("FlaxGame.html"), true); // Insert packaged file system with game data { @@ -254,8 +262,6 @@ bool WebPlatformTools::OnPostProcess(CookingData& data) return false; GameCooker::PackageFiles(); - // TODO: minify/compress output JS files (in Release builds) - LOG(Info, "Output website size: {0} MB", FileSystem::GetDirectorySize(data.OriginalOutputPath) / 1024 / 1024); return false; diff --git a/Source/Editor/CustomEditors/Editors/AssetRefEditor.cs b/Source/Editor/CustomEditors/Editors/AssetRefEditor.cs index b407d9a3c..42d9e4099 100644 --- a/Source/Editor/CustomEditors/Editors/AssetRefEditor.cs +++ b/Source/Editor/CustomEditors/Editors/AssetRefEditor.cs @@ -370,7 +370,7 @@ namespace FlaxEditor.CustomEditors.Editors SetValue(Editor.Instance.ContentDatabase.Find(Utilities.Utils.ToPathAbsolute(path))); else if (value is Asset) SetValue(FlaxEngine.Content.LoadAsync(path)); - else if (value is string) + else if (value is string || Values.Type == typeof(string)) SetValue(path); } diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp index 32f2f240c..9d46e45ac 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.cpp +++ b/Source/Engine/Platform/SDL/SDLWindow.cpp @@ -135,6 +135,11 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings) if (_settings.Parent != nullptr && (_settings.Type != WindowType::Tooltip && _settings.Type != WindowType::Popup)) _settings.Parent = nullptr; #endif +#if PLATFORM_WEB + // Control canvas size + // TODO: try using SDL_SetWindowFillDocument (min SDL 3.4) + flags |= SDL_WINDOW_RESIZABLE; +#endif // The window position needs to be relative to the parent window Int2 relativePosition(Math::TruncToInt(settings.Position.X), Math::TruncToInt(settings.Position.Y)); diff --git a/Source/Engine/Platform/Web/WebPlatformSettings.h b/Source/Engine/Platform/Web/WebPlatformSettings.h index 09b1a9ce4..27d29bd19 100644 --- a/Source/Engine/Platform/Web/WebPlatformSettings.h +++ b/Source/Engine/Platform/Web/WebPlatformSettings.h @@ -29,6 +29,12 @@ API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API Basis, }; + /// + /// The custom HTML template for the game page. + /// + API_FIELD(Attributes="EditorOrder(100), DefaultValue(\"\"), EditorDisplay(\"HTML\"), AssetReference(\".html\"), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.FilePathEditor\")") + String CustomHtml; + /// /// The output textures compression mode. /// diff --git a/Source/Platforms/Web/Binaries/Data/shell.html b/Source/Platforms/Web/Binaries/Data/shell.html new file mode 100644 index 000000000..d2fbcc1d3 --- /dev/null +++ b/Source/Platforms/Web/Binaries/Data/shell.html @@ -0,0 +1,127 @@ + + + + + + Flax Game + + + +
Flax Game
+
Loading...
+
+ +
+ + + + {{{ SCRIPT }}} +#if MODULARIZE && !EXPORT_ES6 + +#endif + + diff --git a/Source/Tools/Flax.Build/Platforms/Web/WebToolchain.cs b/Source/Tools/Flax.Build/Platforms/Web/WebToolchain.cs index c3e8f7749..f5e39999b 100644 --- a/Source/Tools/Flax.Build/Platforms/Web/WebToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/Web/WebToolchain.cs @@ -313,6 +313,10 @@ namespace Flax.Build.Platforms { args.Add("-sSIDE_MODULE"); } + + // Customize output HTML shell + if (options.LinkEnv.Output == LinkerOutput.Executable) + args.Add($"--shell-file \"{Globals.EngineRoot}/Source/Platforms/Web/Binaries/Data/shell.html\""); } args.Add("-Wl,--start-group");