summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/java/src/com/android/godot/GodotLib.java1
-rw-r--r--platform/android/java_glue.cpp20
-rw-r--r--platform/android/java_glue.h1
-rw-r--r--platform/iphone/app_delegate.mm2
-rw-r--r--platform/javascript/export/export.cpp164
-rw-r--r--platform/javascript/os_javascript.cpp2
-rw-r--r--platform/osx/os_osx.mm1
-rw-r--r--platform/windows/os_windows.cpp10
-rw-r--r--platform/x11/os_x11.cpp2
9 files changed, 73 insertions, 130 deletions
diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java
index 8d002c5ebc..f0ec3e97c6 100644
--- a/platform/android/java/src/com/android/godot/GodotLib.java
+++ b/platform/android/java/src/com/android/godot/GodotLib.java
@@ -59,5 +59,6 @@ public class GodotLib {
public static native void method(String p_sname,String p_name,String p_ret,String[] p_params);
public static native String getGlobal(String p_key);
public static native void callobject(int p_ID, String p_method, Object[] p_params);
+ public static native void calldeferred(int p_ID, String p_method, Object[] p_params);
}
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 9c5003cb17..cbe17f2f73 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -1146,6 +1146,26 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_callobject(JNIEnv * env,
// something
};
+JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_calldeferred(JNIEnv * env, jobject p_obj, jint ID, jstring method, jobjectArray params) {
+
+ String str_method = env->GetStringUTFChars( method, NULL );
+
+ Object* obj = ObjectDB::get_instance(ID);
+ ERR_FAIL_COND(!obj);
+
+ int count = env->GetArrayLength(params);
+ Variant args[VARIANT_ARG_MAX];
+
+ for (int i=0; i<MIN(count,VARIANT_ARG_MAX); i++) {
+
+ jobject obj = env->GetObjectArrayElement(params, i);
+ args[i] = _jobject_to_variant(env, obj);
+ };
+
+
+ obj->call_deferred(str_method, args[0],args[1],args[2],args[3],args[4]);
+ // something
+};
//Main::cleanup();
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index 7a0666f63d..4b3c14d0db 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -51,6 +51,7 @@ extern "C" {
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_method(JNIEnv * env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args);
JNIEXPORT jstring JNICALL Java_com_android_godot_GodotLib_getGlobal(JNIEnv * env, jobject obj, jstring path);
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_callobject(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params);
+ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_calldeferred(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params);
};
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index f80a855ef0..9677c18c17 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -165,7 +165,7 @@ static int frame_count = 0;
printf("**************** app delegate init\n");
CGRect rect = [[UIScreen mainScreen] bounds];
- application.statusBarHidden = YES;
+ [application setStatusBarHidden:YES animation:NO];
// disable idle timer
application.idleTimerDisabled = YES;
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index a81fabe085..50fa4f8815 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -60,8 +60,6 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
Ref<ImageTexture> logo;
- static Error save_pack_file_js(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
-
protected:
bool _set(const StringName& p_name, const Variant& p_value);
@@ -103,8 +101,6 @@ bool EditorExportPlatformJavaScript::_set(const StringName& p_name, const Varian
show_run=p_value;
else if (n=="options/memory_size")
max_memory=p_value;
- else if (n=="options/pack_mode")
- pack_mode=PackMode(int(p_value));
else
return false;
@@ -123,8 +119,6 @@ bool EditorExportPlatformJavaScript::_get(const StringName& p_name,Variant &r_re
r_ret=show_run;
else if (n=="options/memory_size")
r_ret=max_memory;
- else if (n=="options/pack_mode")
- r_ret=pack_mode;
else
return false;
@@ -134,7 +128,6 @@ void EditorExportPlatformJavaScript::_get_property_list( List<PropertyInfo> *p_l
p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_FILE,"zip"));
p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_FILE,"zip"));
- p_list->push_back( PropertyInfo( Variant::INT, "options/pack_mode",PROPERTY_HINT_ENUM,"Single File, Multiple Files"));
p_list->push_back( PropertyInfo( Variant::INT, "options/memory_size",PROPERTY_HINT_ENUM,"32mb,64mb,128mb,256mb,512mb,1024mb"));
p_list->push_back( PropertyInfo( Variant::BOOL, "browser/enable_run"));
@@ -143,32 +136,6 @@ void EditorExportPlatformJavaScript::_get_property_list( List<PropertyInfo> *p_l
}
-static const char* files_pre=""\
-"var Module;\n"\
-"if (typeof Module === 'undefined') Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');\n"\
-"if (!Module.expectedDataFileDownloads) {\n"\
-" Module.expectedDataFileDownloads = 0;\n"\
-" Module.finishedDataFileDownloads = 0;\n"\
-"}\n"\
-"Module.expectedDataFileDownloads++;\n"\
-"(function() {\n"\
-"\n"\
-" function runWithFS() {\n"\
-"function assert(check, msg) {\n"\
-" if (!check) throw msg + new Error().stack;\n"\
-"} \n";
-
-static const char* files_post=""\
-"}\n"\
-"if (Module['calledRun']) {\n"\
-" runWithFS();\n"\
-"} else {\n"\
-" if (!Module['preRun']) Module['preRun'] = [];\n"\
-" Module[\"preRun\"].push(runWithFS); // FS is not initialized yet, wait for it\n"\
-"}\n"\
-"})();";
-
-
static void _fix_html(Vector<uint8_t>& html,const String& name,int max_memory) {
@@ -178,7 +145,7 @@ static void _fix_html(Vector<uint8_t>& html,const String& name,int max_memory) {
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+"_files.js\"></script>\n";
+ 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];
@@ -195,65 +162,36 @@ static void _fix_html(Vector<uint8_t>& html,const String& name,int max_memory) {
}
}
+static void _fix_files(Vector<uint8_t>& html,uint64_t p_data_size) {
-struct JSExportData {
-
- EditorProgress *ep;
- FileAccess *f;
-
-};
-
-
-static void store_file_buffer(FileAccess*f,const String& p_path,const Vector<uint8_t>& p_data) {
-
-
- String pre = "Module['FS_createDataFile']('/', '"+p_path.replace("res://","")+"',[";
- CharString cs = pre.utf8();
- f->store_buffer((const uint8_t*)cs.ptr(),cs.length());
- for(int i=0;i<p_data.size();i++) {
-
-
- uint8_t c=',';
- if (i>0)
- f->store_buffer(&c,1);
-
- uint8_t str[4];
- uint8_t d = p_data[i];
- if (d<10) {
- str[0]='0'+d;
- str[1]=0;
- f->store_buffer(str,1);
- } else if (d<100) {
-
- str[0]='0'+d/10;
- str[1]='0'+d%10;
- str[2]=0;
- f->store_buffer(str,2);
+ String str;
+ String strnew;
+ 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("$DPLEN")!=-1) {
+ strnew+=lines[i].replace("$DPLEN",itos(p_data_size));
} else {
- str[0]='0'+d/100;
- str[1]='0'+(d/10)%10;
- str[2]='0'+d%10;
- str[3]=0;
- f->store_buffer(str,3);
+ strnew+=lines[i]+"\n";
}
}
- String post = "],true,true);\n";
- cs = post.utf8();
- f->store_buffer((const uint8_t*)cs.ptr(),cs.length());
+
+ CharString cs = strnew.utf8();
+ html.resize(cs.size());
+ for(int i=9;i<cs.size();i++) {
+ html[i]=cs[i];
+ }
}
+struct JSExportData {
-Error EditorExportPlatformJavaScript::save_pack_file_js(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) {
+ EditorProgress *ep;
+ FileAccess *f;
- JSExportData *ed=(JSExportData*)p_userdata;
+};
- FileAccess *f=(FileAccess *)p_userdata;
- store_file_buffer(ed->f,p_path,p_data);
- ed->ep->step("File: "+p_path,3+p_file*100/p_total);
- return OK;
-}
Error EditorExportPlatformJavaScript::export_project(const String& p_path,bool p_debug,const String& p_password) {
@@ -279,6 +217,20 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path,bool p
ep.step("Exporting to HTML5",0);
+ ep.step("Finding Files..",1);
+
+ FileAccess *f=FileAccess::open(p_path.get_base_dir()+"/data.pck",FileAccess::WRITE);
+ if (!f) {
+ EditorNode::add_io_error("Could not create file for writing:\n"+p_path.basename()+"_files.js");
+ return ERR_FILE_CANT_WRITE;
+ }
+ Error err = save_pack(f);
+ size_t len = f->get_len();
+ memdelete(f);
+ if (err)
+ return err;
+
+
unzFile pkg = unzOpen2(src_template.utf8().get_data(), &io);
if (!pkg) {
@@ -314,6 +266,11 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path,bool p
_fix_html(data,p_path.get_file().basename(),1<<(max_memory+5));
file=p_path.get_file();
}
+ if (file=="filesystem.js") {
+
+ _fix_files(data,len);
+ file=p_path.get_file().basename()+"_filesystem.js";
+ }
if (file=="godot.js") {
//_fix_godot(data);
@@ -335,49 +292,6 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path,bool p
}
- ep.step("Finding Files..",1);
-
- Vector<String> remaps;
-
- FileAccess *f=FileAccess::open(p_path.basename()+"_files.js",FileAccess::WRITE);
- if (!f) {
- EditorNode::add_io_error("Could not create file for writing:\n"+p_path.basename()+"_files.js");
- return ERR_FILE_CANT_WRITE;
- }
-
- f->store_buffer((const uint8_t*)files_pre,strlen(files_pre));
-
- if (pack_mode==PACK_SINGLE_FILE) {
-
- String ftmp = EditorSettings::get_singleton()->get_settings_path()+"/tmp/webpack.pck";
- FileAccess *f2 = FileAccess::open(ftmp,FileAccess::WRITE);
- if (!f2) {
- memdelete(f);
- return ERR_CANT_CREATE;
- }
- Error err = save_pack(f2,false);
- memdelete(f2);
- if (err) {
- memdelete(f);
- return ERR_CANT_CREATE;
- }
-
- Vector<uint8_t> data = FileAccess::get_file_as_array(ftmp);
- store_file_buffer(f,"data.pck",data);
-
-
- } else {
- JSExportData ed;
- ed.ep=&ep;
- ed.f=f;
-
- Error err =export_project_files(save_pack_file_js,&ed,false);
- if (err)
- return err;
- }
- f->store_buffer((const uint8_t*)files_post,strlen(files_post));
- memdelete(f);
-
return OK;
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index c131a7e84b..581df84925 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -511,7 +511,7 @@ void OS_JavaScript::process_accelerometer(const Vector3& p_accelerometer) {
bool OS_JavaScript::has_touchscreen_ui_hint() const {
- return true;
+ return false; //???
}
void OS_JavaScript::main_loop_request_quit() {
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 86d1dbb4c2..5be46e4843 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1277,6 +1277,7 @@ OS_OSX* OS_OSX::singleton=NULL;
OS_OSX::OS_OSX() {
+ main_loop=NULL;
singleton=this;
autoreleasePool = [[NSAutoreleasePool alloc] init];
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index efeb813a2d..eaf62a3e0a 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1534,7 +1534,9 @@ void OS_Windows::set_icon(const Image& p_icon) {
/* Create temporary bitmap buffer */
int icon_len = 40 + h * w * 4;
- BYTE *icon_bmp = (BYTE*)alloca(icon_len);
+ Vector<BYTE> v;
+ v.resize(icon_len);
+ BYTE *icon_bmp = &v[0];
encode_uint32(40,&icon_bmp[0]);
encode_uint32(w,&icon_bmp[4]);
@@ -1582,7 +1584,11 @@ bool OS_Windows::has_environment(const String& p_var) const {
String OS_Windows::get_environment(const String& p_var) const {
- return getenv(p_var.utf8().get_data());
+ char* val = getenv(p_var.utf8().get_data());
+ if (val)
+ return val;
+
+ return "";
};
String OS_Windows::get_stdin_string(bool p_block) {
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 79dd6f1234..95b30423f0 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -1232,7 +1232,7 @@ void OS_X11::set_icon(const Image& p_icon) {
DVector<uint8_t>::Read r = img.get_data().read();
- uint32_t *wr=(uint32_t*)&pd[2];
+ long *wr=(long*)&pd[2];
for(int i=0;i<w*h;i++) {