Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTML5] Better editor persistent folders, automatically open zip import popup #45705

Merged
merged 3 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/dummy/rasterizer_dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ class RasterizerStorageDummy : public RendererStorage {
AABB mesh_get_custom_aabb(RID p_mesh) const override { return AABB(); }

AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) override { return AABB(); }
void mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) override {}
void mesh_clear(RID p_mesh) override {}

/* MULTIMESH API */
Expand Down
5 changes: 5 additions & 0 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,11 @@ void ProjectManager::_install_project(const String &p_zip_path, const String &p_
}

void ProjectManager::_files_dropped(PackedStringArray 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;
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
for (int i = 0; i < p_files.size(); i++) {
Expand Down
6 changes: 3 additions & 3 deletions misc/dist/html/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@

function startEditor(zip) {
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 gameCanvas = document.getElementById('game-canvas');
Expand Down Expand Up @@ -493,11 +493,11 @@
engine.setUnloadAfterInit(false); // Don't want to reload when starting game.
engine.init('godot.tools').then(function() {
if (zip) {
engine.copyToFS("/home/web_user/preload.zip", zip);
engine.copyToFS("/tmp/preload.zip", zip);
}
try {
// 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) {
// File exists
}
Expand Down
7 changes: 7 additions & 0 deletions platform/javascript/javascript_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ extern EMSCRIPTEN_KEEPALIVE int godot_js_main(int argc, char *argv[]) {

Main::start();
os->get_main_loop()->initialize();
#ifdef TOOLS_ENABLED
if (Main::is_project_manager() && FileAccess::exists("/tmp/preload.zip")) {
PackedStringArray 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);
// Immediately run the first iteration.
// We are inside an animation frame, we want to immediately draw on the newly setup canvas.
Expand Down