Merge branch 'master' of https://github.com/okamstudio/godot
This commit is contained in:
commit
9962518ffd
131 changed files with 7749 additions and 967 deletions
|
|
@ -17,7 +17,7 @@ javascript_objects=[]
|
|||
for x in javascript_files:
|
||||
javascript_objects.append( env_javascript.Object( x ) )
|
||||
|
||||
env.Append(LINKFLAGS=["-s","EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function']\""])
|
||||
env.Append(LINKFLAGS=["-s","EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""])
|
||||
|
||||
prog = None
|
||||
|
||||
|
|
|
|||
|
|
@ -626,11 +626,14 @@ void AudioServerJavascript::finish(){
|
|||
}
|
||||
void AudioServerJavascript::update(){
|
||||
|
||||
for(List<Stream*>::Element *E=active_audio_streams.front();E;E=E->next()) {
|
||||
for(List<Stream*>::Element *E=active_audio_streams.front();E;) { //stream might be removed durnig this callback
|
||||
|
||||
if (E->get()->audio_stream ) {
|
||||
List<Stream*>::Element *N=E->next();
|
||||
|
||||
if (E->get()->audio_stream)
|
||||
E->get()->audio_stream->update();
|
||||
}
|
||||
|
||||
E=N;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -653,7 +656,7 @@ int AudioServerJavascript::get_default_mix_rate() const{
|
|||
|
||||
void AudioServerJavascript::set_stream_global_volume_scale(float p_volume){
|
||||
|
||||
|
||||
stream_volume_scale=p_volume;
|
||||
}
|
||||
void AudioServerJavascript::set_fx_global_volume_scale(float p_volume){
|
||||
|
||||
|
|
|
|||
|
|
@ -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,bool p_remote_debug=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,bool p_remote_debug=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;
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ struct JSExportData {
|
|||
|
||||
|
||||
|
||||
Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool p_debug, bool p_dumb, bool p_remote_debug) {
|
||||
Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool p_debug, int p_flags) {
|
||||
|
||||
|
||||
String src_template;
|
||||
|
|
@ -309,10 +309,10 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool
|
|||
}
|
||||
|
||||
|
||||
Error EditorExportPlatformJavaScript::run(int p_device, bool p_dumb, bool p_remote_debug) {
|
||||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
#include "main/main.h"
|
||||
#include "io/resource_loader.h"
|
||||
#include "os/keyboard.h"
|
||||
|
||||
#include "emscripten.h"
|
||||
#include <string.h>
|
||||
|
||||
OS_JavaScript *os=NULL;
|
||||
|
||||
|
|
@ -198,15 +199,39 @@ static void _gfx_idle() {
|
|||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
int start_step=0;
|
||||
|
||||
static void _godot_draw(void) {
|
||||
|
||||
os->main_loop_iterate();
|
||||
if (start_step==1) {
|
||||
start_step=2;
|
||||
Main::start();
|
||||
os->main_loop_begin();
|
||||
}
|
||||
|
||||
if (start_step==2) {
|
||||
os->main_loop_iterate();
|
||||
}
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/* Initialize the window */
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
void main_after_fs_sync(int value) {
|
||||
|
||||
start_step=1;
|
||||
printf("FS SYNCHED!\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
/* Initialize the window */
|
||||
printf("let it go!\n");
|
||||
glutInit(&argc, argv);
|
||||
os = new OS_JavaScript(_gfx_init,NULL,NULL,NULL,NULL);
|
||||
|
|
@ -220,7 +245,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
#endif
|
||||
ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility
|
||||
Main::start();
|
||||
|
||||
|
||||
glutSpecialUpFunc(_glut_skey_up);
|
||||
glutSpecialFunc(_glut_skey_down);
|
||||
|
|
@ -238,10 +263,32 @@ int main(int argc, char *argv[]) {
|
|||
// glutReshapeFunc(gears_reshape);
|
||||
glutDisplayFunc(_godot_draw);
|
||||
//glutSpecialFunc(gears_special);
|
||||
os->main_loop_begin();
|
||||
|
||||
|
||||
|
||||
//mount persistent filesystem
|
||||
EM_ASM(
|
||||
FS.mkdir('/userfs');
|
||||
FS.mount(IDBFS, {}, '/userfs');
|
||||
|
||||
|
||||
|
||||
// sync from persisted state into memory and then
|
||||
// run the 'test' function
|
||||
FS.syncfs(true, function (err) {
|
||||
assert(!err);
|
||||
console.log("done syncinc!");
|
||||
_after_sync_cb = Module.cwrap('main_after_fs_sync', 'void',['number']);
|
||||
_after_sync_cb(0);
|
||||
|
||||
});
|
||||
|
||||
);
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "main/main.h"
|
||||
|
||||
#include "core/globals.h"
|
||||
#include "emscripten.h"
|
||||
|
||||
int OS_JavaScript::get_video_driver_count() const {
|
||||
|
||||
|
|
@ -270,6 +271,32 @@ bool OS_JavaScript::main_loop_iterate() {
|
|||
|
||||
if (!main_loop)
|
||||
return false;
|
||||
|
||||
if (time_to_save_sync>=0) {
|
||||
int64_t newtime = get_ticks_msec();
|
||||
int64_t elapsed = newtime - last_sync_time;
|
||||
last_sync_time=newtime;
|
||||
|
||||
time_to_save_sync-=elapsed;
|
||||
|
||||
print_line("elapsed "+itos(elapsed)+" tts "+itos(time_to_save_sync));
|
||||
|
||||
if (time_to_save_sync<0) {
|
||||
//time to sync, for real
|
||||
// run 'success'
|
||||
print_line("DOING SYNCH!");
|
||||
EM_ASM(
|
||||
FS.syncfs(function (err) {
|
||||
assert(!err);
|
||||
console.log("Synched!");
|
||||
//ccall('success', 'v');
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return Main::iteration();
|
||||
}
|
||||
|
||||
|
|
@ -562,14 +589,21 @@ String OS_JavaScript::get_locale() const {
|
|||
|
||||
String OS_JavaScript::get_data_dir() const {
|
||||
|
||||
if (get_data_dir_func)
|
||||
return get_data_dir_func();
|
||||
return "/";
|
||||
//if (get_data_dir_func)
|
||||
// return get_data_dir_func();
|
||||
return "/userfs";
|
||||
//return Globals::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
|
||||
};
|
||||
|
||||
|
||||
void OS_JavaScript::_close_notification_funcs(const String& p_file,int p_flags) {
|
||||
|
||||
print_line("close "+p_file+" flags "+itos(p_flags));
|
||||
if (p_file.begins_with("/userfs") && p_flags&FileAccess::WRITE) {
|
||||
static_cast<OS_JavaScript*>(get_singleton())->last_sync_time=OS::get_singleton()->get_ticks_msec();
|
||||
static_cast<OS_JavaScript*>(get_singleton())->time_to_save_sync=5000; //five seconds since last save
|
||||
}
|
||||
}
|
||||
|
||||
OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func) {
|
||||
|
||||
|
|
@ -589,6 +623,9 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Ope
|
|||
open_uri_func=p_open_uri_func;
|
||||
get_data_dir_func=p_get_data_dir_func;
|
||||
get_locale_func=p_get_locale_func;
|
||||
FileAccessUnix::close_notification_func=_close_notification_funcs;
|
||||
|
||||
time_to_save_sync=-1;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ private:
|
|||
|
||||
bool use_gl2;
|
||||
|
||||
int64_t time_to_save_sync;
|
||||
int64_t last_sync_time;
|
||||
|
||||
Rasterizer *rasterizer;
|
||||
VisualServer *visual_server;
|
||||
AudioServerJavascript *audio_server;
|
||||
|
|
@ -85,6 +88,8 @@ private:
|
|||
GetDataDirFunc get_data_dir_func;
|
||||
GetLocaleFunc get_locale_func;
|
||||
|
||||
static void _close_notification_funcs(const String& p_file,int p_flags);
|
||||
|
||||
public:
|
||||
|
||||
// functions used by main to initialize/deintialize the OS
|
||||
|
|
@ -107,7 +112,7 @@ public:
|
|||
|
||||
typedef int64_t ProcessID;
|
||||
|
||||
static OS* get_singleton();
|
||||
//static OS* get_singleton();
|
||||
|
||||
virtual void vprint(const char* p_format, va_list p_list, bool p_stderr=false);
|
||||
virtual void print(const char *p_format, ... );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue