Skip to content

Commit

Permalink
[HTML5] Make home path persistent in editor.
Browse files Browse the repository at this point in the history
We used to only persist specific sub-folder of /home/web_user/ when
running the Web Editor. This resulted in bad UX about default project
creation path etc.
This PR makes the whole folder persistent, move the zip preloading to a
different folder (to avoid persisting it), and automatically prompt the
user to import it if present.
  • Loading branch information
Faless committed Feb 3, 2021
1 parent 3629617 commit 2668ca7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions misc/dist/html/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,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 @@ -498,11 +498,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 @@ -87,6 +87,13 @@ extern EMSCRIPTEN_KEEPALIVE int godot_js_main(int argc, char *argv[]) {
ResourceLoader::set_abort_on_missing_resources(false);
Main::start();
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);
// Immediately run the first iteration.
// We are inside an animation frame, we want to immediately draw on the newly setup canvas.
Expand Down

0 comments on commit 2668ca7

Please sign in to comment.