[HTML5] Better fullscreen, canvas resizing.

Three canvas resize policies:
- `None`: Godot window settings are ignored.
- `Project`: Godot handles the canvas like a native app (resizing it
  when setting the window size).
- `Adaptive`: Canvas size will always adapt to browser window size.

Use `None` if you want to control the canvas size with custom JavaScript
code.
This commit is contained in:
Fabio Alessandrelli 2021-01-30 11:35:03 +01:00
parent 1eef8a318b
commit 45a67fab35
7 changed files with 198 additions and 126 deletions

View file

@ -296,7 +296,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
args.push_back(flags[i]);
}
Dictionary config;
config["canvasResizePolicy"] = p_preset->get("html/full_window_size") ? 2 : 1;
config["canvasResizePolicy"] = p_preset->get("html/canvas_resize_policy");
config["gdnativeLibs"] = libs;
config["executable"] = p_name;
config["args"] = args;
@ -353,7 +353,7 @@ void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_op
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/full_window_size"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "html/canvas_resize_policy", PROPERTY_HINT_ENUM, "None,Project,Adaptive"), 2));
}
String EditorExportPlatformJavaScript::get_name() const {