|
@@ -104,13 +104,12 @@ class LocalEntry extends FileEntry {
|
|
|
|
|
|
/*
|
|
|
When a resource is load, we add a watcher on it and wtih callback to call
|
|
|
- when this resource is modified. The problem is that in editor, several engine works
|
|
|
- in parallel, and if the same resource is load by different engine, we have
|
|
|
+ when this resource is modified. The problem is that in case several engine works
|
|
|
+ in parallel, and if the same resource is loaded by different engine, we have
|
|
|
to reload this resource for each engine when the file is modified (resulting
|
|
|
- in one file watcher with multiple callback). This problem occures only in editor (because
|
|
|
- games contains only one engine) so this feature is editor only.
|
|
|
+ in one file watcher with multiple callback).
|
|
|
*/
|
|
|
- #if editor var watchOnChangedHistory : Array<Null<Void -> Void>>; #end
|
|
|
+ #if multidriver var watchByEngine : Array<Null<Void -> Void>>; #end
|
|
|
|
|
|
#if (hl && (hl_ver >= version("1.12.0")) && !usesys)
|
|
|
var watchHandle : hl.uv.Fs;
|
|
@@ -163,7 +162,7 @@ class LocalEntry extends FileEntry {
|
|
|
#if nodejs
|
|
|
var cst = js.node.Fs.constants;
|
|
|
var path = w.file;
|
|
|
- #if editor
|
|
|
+ #if (multidriver && !macro) // Hide
|
|
|
// Fix searching path in hide/bin folder
|
|
|
path = hide.Ide.inst.getPath(path);
|
|
|
#end
|
|
@@ -187,7 +186,7 @@ class LocalEntry extends FileEntry {
|
|
|
if( watchCallback != null ) {
|
|
|
WATCH_LIST.remove(this);
|
|
|
watchCallback = null;
|
|
|
- #if editor watchOnChangedHistory = null; #end
|
|
|
+ #if multidriver watchByEngine = null; #end
|
|
|
#if (hl && (hl_ver >= version("1.12.0")) && !usesys)
|
|
|
watchHandle.close();
|
|
|
watchHandle = null;
|
|
@@ -215,9 +214,9 @@ class LocalEntry extends FileEntry {
|
|
|
w.watchCallback = null;
|
|
|
WATCH_LIST.remove(w);
|
|
|
|
|
|
- #if editor
|
|
|
- if (w.watchOnChangedHistory != null)
|
|
|
- this.watchOnChangedHistory = w.watchOnChangedHistory.copy();
|
|
|
+ #if multidriver
|
|
|
+ if (w.watchByEngine != null)
|
|
|
+ this.watchByEngine = w.watchByEngine.copy();
|
|
|
#end
|
|
|
}
|
|
|
WATCH_LIST.push(this);
|
|
@@ -244,35 +243,34 @@ class LocalEntry extends FileEntry {
|
|
|
watchTime = getModifTime();
|
|
|
#end
|
|
|
|
|
|
- #if editor
|
|
|
- if (watchOnChangedHistory == null)
|
|
|
- watchOnChangedHistory = [ onChanged ];
|
|
|
- else
|
|
|
- watchOnChangedHistory.push(onChanged);
|
|
|
+ #if multidriver
|
|
|
+ if (watchByEngine == null)
|
|
|
+ watchByEngine = [];
|
|
|
+ watchByEngine[h3d.Engine.getCurrent().id] = onChanged;
|
|
|
#end
|
|
|
|
|
|
watchCallback = function() {
|
|
|
- #if editor
|
|
|
+ #if (js && multidriver && !macro)
|
|
|
try {
|
|
|
- #end
|
|
|
fs.convert.run(this);
|
|
|
- #if editor
|
|
|
} catch ( e : Dynamic ) {
|
|
|
hide.Ide.inst.quickMessage('Failed convert for ${name}, trying again');
|
|
|
// Convert failed, let's mark this watch as not performed.
|
|
|
watchTime = -1;
|
|
|
return;
|
|
|
}
|
|
|
+ #else
|
|
|
+ fs.convert.run(this);
|
|
|
#end
|
|
|
|
|
|
- #if editor
|
|
|
- if (watchOnChangedHistory == null)
|
|
|
+ #if multidriver
|
|
|
+ if (watchByEngine == null)
|
|
|
return;
|
|
|
|
|
|
- var idx = watchOnChangedHistory.length - 1;
|
|
|
+ var idx = watchByEngine.length - 1;
|
|
|
while (idx >= 0) {
|
|
|
- if (watchOnChangedHistory[idx] != null)
|
|
|
- watchOnChangedHistory[idx]();
|
|
|
+ if (watchByEngine[idx] != null)
|
|
|
+ watchByEngine[idx]();
|
|
|
idx--;
|
|
|
}
|
|
|
#else
|
|
@@ -280,6 +278,21 @@ class LocalEntry extends FileEntry {
|
|
|
#end
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ #if multidriver
|
|
|
+ override function unwatch(id : Int) {
|
|
|
+ if ( watchByEngine == null || watchByEngine.length <= id )
|
|
|
+ return;
|
|
|
+ watchByEngine[id] = null;
|
|
|
+ var i = watchByEngine.length;
|
|
|
+ while ( i > 0 ) {
|
|
|
+ if ( watchByEngine[i-1] != null )
|
|
|
+ break;
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ watchByEngine.resize(i);
|
|
|
+ }
|
|
|
+ #end
|
|
|
}
|
|
|
|
|
|
class LocalFileSystem implements FileSystem {
|