From 31ce3c5fd0300aac1e86bced1efc5f9ec94bdb6b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 13 Mar 2014 22:57:24 -0300 Subject: -fix bug in cache for atlas import/export -fix some menus -fixed bug in out transition curves -detect and remove file:/// in collada -remove multiscript for now -remove dependencies on mouse in OS, moved to Input -avoid fscache from screwing up (fix might make it slower, but it works) -funcref was missing, it's there now --- .../android/java/src/com/android/godot/Godot.java | 44 ++++++++++++++++++---- .../java/src/com/android/godot/GodotIO.java | 42 ++++++++++++++++++++- .../java/src/com/android/godot/GodotLib.java | 6 +-- 3 files changed, 80 insertions(+), 12 deletions(-) (limited to 'platform/android/java/src') diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index cf1545df82..9868e62957 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -49,15 +49,19 @@ import android.media.*; import android.hardware.*; import android.content.*; +import android.net.Uri; +import android.media.MediaPlayer; + import java.lang.reflect.Method; import java.util.List; import java.util.ArrayList; +import com.android.godot.payments.PaymentsManager; +import java.io.IOException; import android.provider.Settings.Secure; public class Godot extends Activity implements SensorEventListener -{ - +{ static public class SingletonBase { protected void registerClass(String p_name, String[] p_methods) { @@ -131,8 +135,12 @@ public class Godot extends Activity implements SensorEventListener }; public ResultCallback result_callback; + private PaymentsManager mPaymentsManager; + @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) { - if (result_callback != null) { + if(requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE){ + mPaymentsManager.processPurchaseResponse(resultCode, data); + }else if (result_callback != null) { result_callback.callback(requestCode, resultCode, data); result_callback = null; }; @@ -152,13 +160,17 @@ public class Godot extends Activity implements SensorEventListener } + private static Godot _self; + + public static Godot getInstance(){ + return Godot._self; + } + @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); - - - + _self = this; Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -172,12 +184,20 @@ public class Godot extends Activity implements SensorEventListener mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); result_callback = null; - + + mPaymentsManager = PaymentsManager.createManager(this).initService(); + // instanceSingleton( new GodotFacebook(this) ); } + @Override protected void onDestroy(){ + + if(mPaymentsManager != null ) mPaymentsManager.destroy(); + super.onDestroy(); + } + @Override protected void onPause() { super.onPause(); mView.onPause(); @@ -291,7 +311,15 @@ public class Godot extends Activity implements SensorEventListener @Override public boolean onKeyDown(int keyCode, KeyEvent event) { GodotLib.key(event.getUnicodeChar(0), true); return super.onKeyDown(keyCode, event); - }; + } + + public PaymentsManager getPaymentsManager() { + return mPaymentsManager; + } + +// public void setPaymentsManager(PaymentsManager mPaymentsManager) { +// this.mPaymentsManager = mPaymentsManager; +// }; // Audio diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index 1f3967cb8f..4b6a44335c 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -57,6 +57,9 @@ public class GodotIO { AssetManager am; Activity activity; + Context applicationContext; + MediaPlayer mediaPlayer; + final int SCREEN_LANDSCAPE=0; final int SCREEN_PORTRAIT=1; final int SCREEN_REVERSE_LANDSCAPE=2; @@ -326,7 +329,7 @@ public class GodotIO { activity=p_activity; streams=new HashMap(); dirs=new HashMap(); - + applicationContext = activity.getApplicationContext(); } @@ -502,6 +505,43 @@ public class GodotIO { } }; + public void playVideo(String p_path) + { + Uri filePath = Uri.parse(p_path); + mediaPlayer = new MediaPlayer(); + + try { + mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + mediaPlayer.setDataSource(applicationContext, filePath); + mediaPlayer.prepare(); + mediaPlayer.start(); + } + catch(IOException e) + { + System.out.println("IOError while playing video"); + } + } + + public boolean isVideoPlaying() { + if (mediaPlayer != null) { + return mediaPlayer.isPlaying(); + } + return false; + } + + public void pauseVideo() { + if (mediaPlayer != null) { + mediaPlayer.pause(); + } + } + + public void stopVideo() { + if (mediaPlayer != null) { + mediaPlayer.release(); + mediaPlayer = null; + } + } + protected static final String PREFS_FILE = "device_id.xml"; protected static final String PREFS_DEVICE_ID = "device_id"; diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index f0ec3e97c6..ffa3f306f1 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -51,14 +51,14 @@ public class GodotLib { public static native void step(); public static native void touch(int what,int pointer,int howmany, int[] arr); public static native void accelerometer(float x, float y, float z); - public static native void key(int p_unicode_char, boolean p_pressed); + public static native void key(int p_unicode_char, boolean p_pressed); public static native void focusin(); public static native void focusout(); public static native void audio(); public static native void singleton(String p_name,Object p_object); 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); + 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); } -- cgit v1.2.3 From bdb5d68e77a0b2d8b06c469ee91d0d09cd4fb8db Mon Sep 17 00:00:00 2001 From: reduz Date: Thu, 13 Mar 2014 20:26:38 -0700 Subject: Update GodotLib.java --- platform/android/java/src/com/android/godot/GodotLib.java | 4 ---- 1 file changed, 4 deletions(-) (limited to 'platform/android/java/src') diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index e496d81356..459c6c1222 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -51,11 +51,7 @@ public class GodotLib { public static native void step(); public static native void touch(int what,int pointer,int howmany, int[] arr); public static native void accelerometer(float x, float y, float z); -<<<<<<< HEAD - public static native void key(int p_unicode_char, boolean p_pressed); -======= public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed); ->>>>>>> 81757d2e977d959e6b0bc26f9fa990417ca91de9 public static native void focusin(); public static native void focusout(); public static native void audio(); -- cgit v1.2.3 From 9f33134c93ecbadda70e8eefc50563e29b2eb7f2 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 5 Apr 2014 12:39:30 -0300 Subject: -Support for changing fonts -Detect when free() might crash the project and throw error -fixed 2D Bounce in physics (3d still broken) -renamed “on_top” property to “behind_parent”, which makes more sense, old on_top remains there for compatibility but is invisible. -large amount of fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bind/core_bind.cpp | 7 + core/bind/core_bind.h | 2 + core/io/resource_format_binary.cpp | 1 + core/message_queue.cpp | 3 +- core/object.cpp | 54 +++++- core/object.h | 8 +- core/os/os.cpp | 5 + core/os/os.h | 1 + demos/2d/platformer/player.xml | 176 +++++++++--------- demos/2d/platformer/stage.xml | 42 ++--- drivers/unix/os_unix.cpp | 6 + drivers/unix/os_unix.h | 1 + modules/SCsub | 1 - modules/gdscript/gd_functions.cpp | 2 +- modules/gdscript/gd_script.cpp | 13 ++ platform/android/AndroidManifest.xml.template | 2 +- platform/android/java/ant.properties | 5 - .../android/java/src/com/android/godot/Godot.java | 3 +- .../java/src/com/android/godot/GodotPaymentV3.java | 83 +++++++++ .../com/android/godot/payments/ConsumeTask.java | 71 +++++++ .../android/godot/payments/HandlePurchaseTask.java | 79 ++++++++ .../com/android/godot/payments/PaymentsCache.java | 42 +++++ .../android/godot/payments/PaymentsManager.java | 151 +++++++++++++++ .../com/android/godot/payments/PurchaseTask.java | 121 ++++++++++++ .../com/android/godot/payments/ValidateTask.java | 97 ++++++++++ .../java/src/com/android/godot/utils/Crypt.java | 39 ++++ .../godot/utils/CustomSSLSocketFactory.java | 54 ++++++ .../src/com/android/godot/utils/HttpRequester.java | 206 +++++++++++++++++++++ .../src/com/android/godot/utils/RequestParams.java | 58 ++++++ .../vending/billing/IInAppBillingService.aidl | 144 ++++++++++++++ platform/android/java_glue.cpp | 9 +- platform/iphone/app_delegate.mm | 11 +- platform/iphone/detect.py | 1 - platform/iphone/gl_view.mm | 25 +-- platform/iphone/in_app_store.mm | 25 +++ platform/isim/detect.py | 1 - scene/2d/canvas_item.cpp | 25 ++- scene/2d/canvas_item.h | 9 +- scene/gui/control.cpp | 2 + scene/main/node.h | 2 + servers/physics_2d/body_pair_2d_sw.cpp | 15 +- servers/physics_2d/body_pair_2d_sw.h | 2 + tools/editor/code_editor.cpp | 18 +- tools/editor/code_editor.h | 4 +- tools/editor/editor_node.cpp | 8 + tools/editor/editor_settings.cpp | 10 +- tools/editor/property_editor.cpp | 9 +- 47 files changed, 1492 insertions(+), 161 deletions(-) create mode 100644 platform/android/java/src/com/android/godot/GodotPaymentV3.java create mode 100644 platform/android/java/src/com/android/godot/payments/ConsumeTask.java create mode 100644 platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java create mode 100644 platform/android/java/src/com/android/godot/payments/PaymentsCache.java create mode 100644 platform/android/java/src/com/android/godot/payments/PaymentsManager.java create mode 100644 platform/android/java/src/com/android/godot/payments/PurchaseTask.java create mode 100644 platform/android/java/src/com/android/godot/payments/ValidateTask.java create mode 100644 platform/android/java/src/com/android/godot/utils/Crypt.java create mode 100644 platform/android/java/src/com/android/godot/utils/CustomSSLSocketFactory.java create mode 100644 platform/android/java/src/com/android/godot/utils/HttpRequester.java create mode 100644 platform/android/java/src/com/android/godot/utils/RequestParams.java create mode 100644 platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl (limited to 'platform/android/java/src') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 1b4ca8151b..e3360a23d2 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -246,6 +246,12 @@ Error _OS::kill(int p_pid) { return OS::get_singleton()->kill(p_pid); } +int _OS::get_process_ID() const { + + return OS::get_singleton()->get_process_ID(); +}; + + bool _OS::has_environment(const String& p_var) const { return OS::get_singleton()->has_environment(p_var); @@ -561,6 +567,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("execute","path","arguments","blocking"),&_OS::execute); ObjectTypeDB::bind_method(_MD("kill","pid"),&_OS::kill); ObjectTypeDB::bind_method(_MD("shell_open","uri"),&_OS::shell_open); + ObjectTypeDB::bind_method(_MD("get_process_ID"),&_OS::get_process_ID); ObjectTypeDB::bind_method(_MD("get_environment","environment"),&_OS::get_environment); ObjectTypeDB::bind_method(_MD("has_environment","environment"),&_OS::has_environment); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 3d03247c07..0084726547 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -117,6 +117,8 @@ public: Error kill(int p_pid); Error shell_open(String p_uri); + int get_process_ID() const; + bool has_environment(const String& p_var) const; String get_environment(const String& p_var) const; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 47f278596b..33f4cafedd 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -949,6 +949,7 @@ String ResourceInteractiveLoaderBinary::recognize(FileAccess *p_f) { } else if (header[0]!='R' || header[1]!='S' || header[2]!='R' || header[3]!='C') { //not normal + error=ERR_FILE_UNRECOGNIZED; return ""; } diff --git a/core/message_queue.cpp b/core/message_queue.cpp index a9c49fbef2..dbf6217dc2 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -378,11 +378,12 @@ void MessageQueue::flush() { } } - message->~Message(); read_pos+=sizeof(Message); if (message->type!=TYPE_NOTIFICATION) read_pos+=sizeof(Variant)*message->args; + message->~Message(); + _THREAD_SAFE_UNLOCK_ } diff --git a/core/object.cpp b/core/object.cpp index 692010b1b7..b40f4ec151 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -33,6 +33,30 @@ #include "message_queue.h" #include "core_string_names.h" #include "translation.h" + +#ifdef DEBUG_ENABLED + +struct _ObjectDebugLock { + + Object *obj; + + _ObjectDebugLock(Object *p_obj) { + obj=p_obj; + obj->_lock_index.ref(); + } + ~_ObjectDebugLock() { + obj->_lock_index.unref(); + } +}; + +#define OBJ_DEBUG_LOCK _ObjectDebugLock _debug_lock(this); + +#else + +#define OBJ_DEBUG_LOCK + +#endif + Array convert_property_list(const List * p_list) { Array va; @@ -562,13 +586,22 @@ void Object::call_multilevel(const StringName& p_method,const Variant** p_args,i ERR_FAIL(); return; } + + + if (_lock_index.get()>1) { + ERR_EXPLAIN("Object is locked and can't be freed."); + ERR_FAIL(); + return; + } #endif + //must be here, must be before everything, memdelete(this); return; } //Variant ret; + OBJ_DEBUG_LOCK Variant::CallError error; @@ -594,6 +627,7 @@ void Object::call_multilevel_reversed(const StringName& p_method,const Variant** MethodBind *method=ObjectTypeDB::get_method(get_type_name(),p_method); Variant::CallError error; + OBJ_DEBUG_LOCK if (method) { @@ -813,6 +847,15 @@ Variant Object::call(const StringName& p_method,const Variant** p_args,int p_arg ERR_EXPLAIN("Can't 'free' a reference."); ERR_FAIL_V(Variant()); } + + if (_lock_index.get()>1) { + r_error.argument=0; + r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; + ERR_EXPLAIN("Object is locked and can't be freed."); + ERR_FAIL_V(Variant()); + + } + #endif //must be here, must be before everything, memdelete(this); @@ -821,7 +864,7 @@ Variant Object::call(const StringName& p_method,const Variant** p_args,int p_arg } Variant ret; - + OBJ_DEBUG_LOCK if (script_instance) { ret = script_instance->call(p_method,p_args,p_argcount,r_error); //force jumptable @@ -902,7 +945,7 @@ void Object::set_script(const RefPtr& p_script) { Ref