Merge pull request #45706 from Faless/js/3.x_editor_preload

[3.2] [HTML5] Better editor persistent folders, automatically open zip import popup
This commit is contained in:
Rémi Verschelde 2021-02-04 14:54:04 +01:00 committed by GitHub
commit f9bf6fc3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -2326,6 +2326,11 @@ void ProjectManager::_install_project(const String &p_zip_path, const String &p_
} }
void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) { void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) {
if (p_files.size() == 1 && p_files[0].ends_with(".zip")) {
const String file = p_files[0].get_file();
_install_project(p_files[0], file.substr(0, file.length() - 4).capitalize());
return;
}
Set<String> folders_set; Set<String> folders_set;
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
for (int i = 0; i < p_files.size(); i++) { for (int i = 0; i < p_files.size(); i++) {

View File

@ -327,7 +327,7 @@
function startEditor(zip) { function startEditor(zip) {
const INDETERMINATE_STATUS_STEP_MS = 100; const INDETERMINATE_STATUS_STEP_MS = 100;
const persistentPaths = ['/home/web_user/.config', '/home/web_user/.cache', '/home/web_user/projects']; const persistentPaths = ['/home/web_user/'];
var editorCanvas = document.getElementById('editor-canvas'); var editorCanvas = document.getElementById('editor-canvas');
var gameCanvas = document.getElementById('game-canvas'); var gameCanvas = document.getElementById('game-canvas');
@ -498,11 +498,11 @@
engine.setUnloadAfterInit(false); // Don't want to reload when starting game. engine.setUnloadAfterInit(false); // Don't want to reload when starting game.
engine.init('godot.tools').then(function() { engine.init('godot.tools').then(function() {
if (zip) { if (zip) {
engine.copyToFS("/home/web_user/preload.zip", zip); engine.copyToFS("/tmp/preload.zip", zip);
} }
try { try {
// Avoid user creating project in the persistent root folder. // Avoid user creating project in the persistent root folder.
engine.copyToFS("/home/web_user/projects/keep", new Uint8Array()); engine.copyToFS("/home/web_user/keep", new Uint8Array());
} catch(e) { } catch(e) {
// File exists // File exists
} }

View File

@ -87,6 +87,13 @@ extern EMSCRIPTEN_KEEPALIVE int godot_js_main(int argc, char *argv[]) {
ResourceLoader::set_abort_on_missing_resources(false); ResourceLoader::set_abort_on_missing_resources(false);
Main::start(); Main::start();
os->get_main_loop()->init(); os->get_main_loop()->init();
#ifdef TOOLS_ENABLED
if (Main::is_project_manager() && FileAccess::exists("/tmp/preload.zip")) {
PoolStringArray ps;
ps.push_back("/tmp/preload.zip");
os->get_main_loop()->emit_signal("files_dropped", ps, -1);
}
#endif
emscripten_set_main_loop(main_loop_callback, -1, false); emscripten_set_main_loop(main_loop_callback, -1, false);
// Immediately run the first iteration. // Immediately run the first iteration.
// We are inside an animation frame, we want to immediately draw on the newly setup canvas. // We are inside an animation frame, we want to immediately draw on the newly setup canvas.