Merge pull request #46930 from Faless/js/4.x_project_manager_drop_hack
[HTML5] Drag and drop zip in project manager.
This commit is contained in:
commit
a1eccd9eb8
|
@ -502,7 +502,7 @@
|
||||||
showTab('loader');
|
showTab('loader');
|
||||||
setLoaderEnabled(true);
|
setLoaderEnabled(true);
|
||||||
};
|
};
|
||||||
editor.start({'args': args});
|
editor.start({'args': args, 'persistentDrops': is_project_manager});
|
||||||
});
|
});
|
||||||
}, 0);
|
}, 0);
|
||||||
OnEditorExit = null;
|
OnEditorExit = null;
|
||||||
|
@ -563,7 +563,7 @@
|
||||||
//selectVideoMode();
|
//selectVideoMode();
|
||||||
showTab('editor');
|
showTab('editor');
|
||||||
setLoaderEnabled(false);
|
setLoaderEnabled(false);
|
||||||
editor.start({'args': ['--video-driver', video_driver]}).then(function() {
|
editor.start({'args': ['--project-manager', '--video-driver', video_driver], 'persistentDrops': true}).then(function() {
|
||||||
setStatusMode('hidden');
|
setStatusMode('hidden');
|
||||||
initializing = false;
|
initializing = false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -103,6 +103,11 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
persistentPaths: ['/userfs'],
|
persistentPaths: ['/userfs'],
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
persistentDrops: false,
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
* @type {Array.<string>}
|
* @type {Array.<string>}
|
||||||
|
@ -231,6 +236,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||||
this.locale = parse('locale', this.locale);
|
this.locale = parse('locale', this.locale);
|
||||||
this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy);
|
this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy);
|
||||||
this.persistentPaths = parse('persistentPaths', this.persistentPaths);
|
this.persistentPaths = parse('persistentPaths', this.persistentPaths);
|
||||||
|
this.persistentDrops = parse('persistentDrops', this.persistentDrops);
|
||||||
this.experimentalVK = parse('experimentalVK', this.experimentalVK);
|
this.experimentalVK = parse('experimentalVK', this.experimentalVK);
|
||||||
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs);
|
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs);
|
||||||
this.fileSizes = parse('fileSizes', this.fileSizes);
|
this.fileSizes = parse('fileSizes', this.fileSizes);
|
||||||
|
@ -316,6 +322,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
|
||||||
'canvas': this.canvas,
|
'canvas': this.canvas,
|
||||||
'canvasResizePolicy': this.canvasResizePolicy,
|
'canvasResizePolicy': this.canvasResizePolicy,
|
||||||
'locale': locale,
|
'locale': locale,
|
||||||
|
'persistentDrops': this.persistentDrops,
|
||||||
'virtualKeyboard': this.experimentalVK,
|
'virtualKeyboard': this.experimentalVK,
|
||||||
'onExecute': this.onExecute,
|
'onExecute': this.onExecute,
|
||||||
'onExit': function (p_code) {
|
'onExit': function (p_code) {
|
||||||
|
|
|
@ -192,33 +192,45 @@ const GodotDisplayDragDrop = {
|
||||||
GodotDisplayDragDrop.promises = [];
|
GodotDisplayDragDrop.promises = [];
|
||||||
GodotDisplayDragDrop.pending_files = [];
|
GodotDisplayDragDrop.pending_files = [];
|
||||||
callback(drops);
|
callback(drops);
|
||||||
const dirs = [DROP.substr(0, DROP.length - 1)];
|
if (GodotConfig.persistent_drops) {
|
||||||
// Remove temporary files
|
// Delay removal at exit.
|
||||||
files.forEach(function (file) {
|
GodotOS.atexit(function (resolve, reject) {
|
||||||
FS.unlink(file);
|
GodotDisplayDragDrop.remove_drop(files, DROP);
|
||||||
let dir = file.replace(DROP, '');
|
resolve();
|
||||||
let idx = dir.lastIndexOf('/');
|
});
|
||||||
while (idx > 0) {
|
} else {
|
||||||
dir = dir.substr(0, idx);
|
GodotDisplayDragDrop.remove_drop(files, DROP);
|
||||||
if (dirs.indexOf(DROP + dir) === -1) {
|
}
|
||||||
dirs.push(DROP + dir);
|
});
|
||||||
}
|
},
|
||||||
idx = dir.lastIndexOf('/');
|
|
||||||
|
remove_drop: function (files, drop_path) {
|
||||||
|
const dirs = [drop_path.substr(0, drop_path.length - 1)];
|
||||||
|
// Remove temporary files
|
||||||
|
files.forEach(function (file) {
|
||||||
|
FS.unlink(file);
|
||||||
|
let dir = file.replace(drop_path, '');
|
||||||
|
let idx = dir.lastIndexOf('/');
|
||||||
|
while (idx > 0) {
|
||||||
|
dir = dir.substr(0, idx);
|
||||||
|
if (dirs.indexOf(drop_path + dir) === -1) {
|
||||||
|
dirs.push(drop_path + dir);
|
||||||
}
|
}
|
||||||
});
|
idx = dir.lastIndexOf('/');
|
||||||
// Remove dirs.
|
}
|
||||||
dirs.sort(function (a, b) {
|
});
|
||||||
const al = (a.match(/\//g) || []).length;
|
// Remove dirs.
|
||||||
const bl = (b.match(/\//g) || []).length;
|
dirs.sort(function (a, b) {
|
||||||
if (al > bl) {
|
const al = (a.match(/\//g) || []).length;
|
||||||
return -1;
|
const bl = (b.match(/\//g) || []).length;
|
||||||
} else if (al < bl) {
|
if (al > bl) {
|
||||||
return 1;
|
return -1;
|
||||||
}
|
} else if (al < bl) {
|
||||||
return 0;
|
return 1;
|
||||||
}).forEach(function (dir) {
|
}
|
||||||
FS.rmdir(dir);
|
return 0;
|
||||||
});
|
}).forEach(function (dir) {
|
||||||
|
FS.rmdir(dir);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ const GodotConfig = {
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
canvas_resize_policy: 2, // Adaptive
|
canvas_resize_policy: 2, // Adaptive
|
||||||
virtual_keyboard: false,
|
virtual_keyboard: false,
|
||||||
|
persistent_drops: false,
|
||||||
on_execute: null,
|
on_execute: null,
|
||||||
on_exit: null,
|
on_exit: null,
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ const GodotConfig = {
|
||||||
GodotConfig.canvas = p_opts['canvas'];
|
GodotConfig.canvas = p_opts['canvas'];
|
||||||
GodotConfig.locale = p_opts['locale'] || GodotConfig.locale;
|
GodotConfig.locale = p_opts['locale'] || GodotConfig.locale;
|
||||||
GodotConfig.virtual_keyboard = p_opts['virtualKeyboard'];
|
GodotConfig.virtual_keyboard = p_opts['virtualKeyboard'];
|
||||||
|
GodotConfig.persistent_drops = !!p_opts['persistentDrops'];
|
||||||
GodotConfig.on_execute = p_opts['onExecute'];
|
GodotConfig.on_execute = p_opts['onExecute'];
|
||||||
GodotConfig.on_exit = p_opts['onExit'];
|
GodotConfig.on_exit = p_opts['onExit'];
|
||||||
},
|
},
|
||||||
|
@ -80,6 +82,7 @@ const GodotConfig = {
|
||||||
GodotConfig.locale = 'en';
|
GodotConfig.locale = 'en';
|
||||||
GodotConfig.canvas_resize_policy = 2;
|
GodotConfig.canvas_resize_policy = 2;
|
||||||
GodotConfig.virtual_keyboard = false;
|
GodotConfig.virtual_keyboard = false;
|
||||||
|
GodotConfig.persistent_drops = false;
|
||||||
GodotConfig.on_execute = null;
|
GodotConfig.on_execute = null;
|
||||||
GodotConfig.on_exit = null;
|
GodotConfig.on_exit = null;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue