diff options
Diffstat (limited to 'platform/javascript/export')
-rw-r--r-- | platform/javascript/export/export.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 55b1ccbcaa..9e2595f4a1 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -77,11 +77,11 @@ public: virtual int get_device_count() const { return show_run?1:0; }; virtual String get_device_name(int p_device) const { return "Run in Browser"; } virtual String get_device_info(int p_device) const { return "Run exported HTML in the system's default browser."; } - virtual Error run(int p_device,bool p_dumb=false); + virtual Error run(int p_device,int p_flags=0); virtual bool requieres_password(bool p_debug) const { return false; } virtual String get_binary_extension() const { return "html"; } - virtual Error export_project(const String& p_path,bool p_debug,bool p_dumb=false); + virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0); virtual bool can_export(String *r_error=NULL) const; @@ -144,12 +144,16 @@ static void _fix_html(Vector<uint8_t>& html,const String& name,int max_memory) { str.parse_utf8((const char*)html.ptr(),html.size()); Vector<String> lines=str.split("\n"); for(int i=0;i<lines.size();i++) { - if (lines[i].find("godot.js")!=-1) { - strnew+="<script type=\"text/javascript\" src=\""+name+"_filesystem.js\"></script>\n"; - strnew+="<script async type=\"text/javascript\" src=\""+name+".js\"></script>\n"; - } else if (lines[i].find("var Module")!=-1) { - strnew+=lines[i]; - strnew+="TOTAL_MEMORY:"+itos(max_memory*1024*1024)+","; + + if (lines[i].find("$GODOTTMEM")!=-1) { + + strnew+=lines[i].replace("$GODOTTMEM",itos(max_memory*1024*1024))+"\n"; + } else if (lines[i].find("$GODOTFS")!=-1) { + strnew+=lines[i].replace("$GODOTFS",name+"fs.js")+"\n"; + } else if (lines[i].find("$GODOTMEM")!=-1) { + strnew+=lines[i].replace("$GODOTMEM",name+".mem")+"\n"; + } else if (lines[i].find("$GODOTJS")!=-1) { + strnew+=lines[i].replace("$GODOTJS",name+".js")+"\n"; } else { strnew+=lines[i]+"\n"; } @@ -194,7 +198,7 @@ struct JSExportData { -Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool p_debug, bool p_dumb) { +Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool p_debug, int p_flags) { String src_template; @@ -267,10 +271,10 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool _fix_html(data,p_path.get_file().basename(),1<<(max_memory+5)); file=p_path.get_file(); } - if (file=="filesystem.js") { + if (file=="godotfs.js") { _fix_files(data,len); - file=p_path.get_file().basename()+"_filesystem.js"; + file=p_path.get_file().basename()+"fs.js"; } if (file=="godot.js") { @@ -278,6 +282,12 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool file=p_path.get_file().basename()+".js"; } + if (file=="godot.mem") { + + //_fix_godot(data); + file=p_path.get_file().basename()+".mem"; + } + String dst = p_path.get_base_dir().plus_file(file); FileAccess *f=FileAccess::open(dst,FileAccess::WRITE); if (!f) { @@ -299,10 +309,10 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool } -Error EditorExportPlatformJavaScript::run(int p_device, bool p_dumb) { +Error EditorExportPlatformJavaScript::run(int p_device, int p_flags) { String path = EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp_export.html"; - Error err = export_project(path,true,""); + Error err = export_project(path,true,p_flags); if (err) return err; |