diff options
47 files changed, 1492 insertions, 161 deletions
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<PropertyInfo> * 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<Script> s(script); if (!s.is_null() && s->can_instance() ) { - + OBJ_DEBUG_LOCK script_instance = s->instance_create(this); } @@ -1066,6 +1109,8 @@ void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { int ssize = slot_map.size(); + OBJ_DEBUG_LOCK + for(int i=0;i<ssize;i++) { const Connection &c = slot_map.getv(i).conn; @@ -1536,6 +1581,11 @@ Object::Object() { _edited=false; #endif +#ifdef DEBUG_ENABLED + _lock_index.init(1); +#endif + + } diff --git a/core/object.h b/core/object.h index 913d837172..6290f9d64b 100644 --- a/core/object.h +++ b/core/object.h @@ -331,7 +331,9 @@ public: Connection(const Variant& p_variant); }; private: - +#ifdef DEBUG_ENABLED +friend class _ObjectDebugLock; +#endif friend bool predelete_handler(Object*); friend void postinitialize_handler(Object*); @@ -365,7 +367,9 @@ friend void postinitialize_handler(Object*); HashMap< StringName, Signal, StringNameHasher> signal_map; List<Connection> connections; - +#ifdef DEBUG_ENABLED + SafeRefCount _lock_index; +#endif bool _block_signals; int _predelete_ok; Set<Object*> change_receptors; diff --git a/core/os/os.cpp b/core/os/os.cpp index f678d38f56..65d6ed50b2 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -124,6 +124,11 @@ String OS::get_executable_path() const { return _execpath; } +int OS::get_process_ID() const { + + return -1; +}; + uint64_t OS::get_frames_drawn() { return frames_drawn; diff --git a/core/os/os.h b/core/os/os.h index b41bf6ce73..e7fe0cb09e 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -162,6 +162,7 @@ public: virtual String get_executable_path() const; virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL)=0; virtual Error kill(const ProcessID& p_pid)=0; + virtual int get_process_ID() const; virtual Error shell_open(String p_uri); virtual Error set_cwd(const String& p_cwd); diff --git a/demos/2d/platformer/player.xml b/demos/2d/platformer/player.xml index 404032d352..c129d01f0d 100644 --- a/demos/2d/platformer/player.xml +++ b/demos/2d/platformer/player.xml @@ -1,15 +1,15 @@ <?xml version="1.0" encoding="UTF-8" ?> <resource_file type="PackedScene" subresource_count="24" version="1.0" version_name="Godot Engine v1.0.3917-beta1"> - <ext_resource path="res://robot_demo.*" type="Texture"></ext_resource> - <ext_resource path="res://osb_jump.*" type="Texture"></ext_resource> - <ext_resource path="res://player.*" type="Script"></ext_resource> - <ext_resource path="res://osb_right.*" type="Texture"></ext_resource> - <ext_resource path="res://sound_coin.*" type="Sample"></ext_resource> - <ext_resource path="res://sound_jump.*" type="Sample"></ext_resource> - <ext_resource path="res://sound_shoot.*" type="Sample"></ext_resource> - <ext_resource path="res://bullet.*" type="Texture"></ext_resource> - <ext_resource path="res://osb_fire.*" type="Texture"></ext_resource> - <ext_resource path="res://osb_left.*" type="Texture"></ext_resource> + <ext_resource path="res://osb_jump.png" type="Texture"></ext_resource> + <ext_resource path="res://bullet.png" type="Texture"></ext_resource> + <ext_resource path="res://osb_right.png" type="Texture"></ext_resource> + <ext_resource path="res://sound_coin.wav" type="Sample"></ext_resource> + <ext_resource path="res://sound_shoot.wav" type="Sample"></ext_resource> + <ext_resource path="res://osb_fire.png" type="Texture"></ext_resource> + <ext_resource path="res://robot_demo.png" type="Texture"></ext_resource> + <ext_resource path="res://osb_left.png" type="Texture"></ext_resource> + <ext_resource path="res://player.gd" type="Script"></ext_resource> + <ext_resource path="res://sound_jump.wav" type="Sample"></ext_resource> <resource type="RayShape2D" path="local://1"> <real name="custom_solver_bias"> 0.5 </real> <real name="length"> 20 </real> @@ -50,8 +50,8 @@ </resource> <resource type="Animation" path="local://4"> - <string name="resource/name"> "jumping" </string> - <real name="length"> 0.5 </real> + <string name="resource/name"> "run" </string> + <real name="length"> 1.25 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> <string name="tracks/0/type"> "value" </string> @@ -61,20 +61,23 @@ <string> "cont" </string> <bool> False </bool> <string> "transitions" </string> - <real_array len="3"> 1, 1, 1 </real_array> + <real_array len="6"> 1, 1, 1, 1, 1, 1 </real_array> <string> "values" </string> - <array len="3" shared="false"> - <int> 23 </int> - <int> 24 </int> - <int> 23 </int> + <array len="6" shared="false"> + <int> 0 </int> + <int> 1 </int> + <int> 2 </int> + <int> 3 </int> + <int> 4 </int> + <int> 0 </int> </array> <string> "times" </string> - <real_array len="3"> 0, 0.25, 0.5 </real_array> + <real_array len="6"> 0, 0.25, 0.5, 0.75, 1, 1.25 </real_array> </dictionary> </resource> <resource type="Animation" path="local://5"> - <string name="resource/name"> "run" </string> + <string name="resource/name"> "run_gun_fire" </string> <real name="length"> 1.25 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> @@ -88,12 +91,12 @@ <real_array len="6"> 1, 1, 1, 1, 1, 1 </real_array> <string> "values" </string> <array len="6" shared="false"> - <int> 0 </int> - <int> 1 </int> - <int> 2 </int> - <int> 3 </int> - <int> 4 </int> - <int> 0 </int> + <int> 10 </int> + <int> 11 </int> + <int> 12 </int> + <int> 13 </int> + <int> 14 </int> + <int> 5 </int> </array> <string> "times" </string> <real_array len="6"> 0, 0.25, 0.5, 0.75, 1, 1.25 </real_array> @@ -101,8 +104,8 @@ </resource> <resource type="Animation" path="local://6"> - <string name="resource/name"> "run_weapon" </string> - <real name="length"> 1.25 </real> + <string name="resource/name"> "jumping_weapon" </string> + <real name="length"> 0.5 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> <string name="tracks/0/type"> "value" </string> @@ -112,23 +115,18 @@ <string> "cont" </string> <bool> False </bool> <string> "transitions" </string> - <real_array len="6"> 1, 1, 1, 1, 1, 1 </real_array> + <real_array len="1"> 1 </real_array> <string> "values" </string> - <array len="6" shared="false"> - <int> 5 </int> - <int> 6 </int> - <int> 7 </int> - <int> 8 </int> - <int> 9 </int> - <int> 5 </int> + <array len="1" shared="false"> + <int> 26 </int> </array> <string> "times" </string> - <real_array len="6"> 0, 0.25, 0.5, 0.75, 1, 1.25 </real_array> + <real_array len="1"> 0 </real_array> </dictionary> </resource> <resource type="Animation" path="local://7"> - <string name="resource/name"> "falling" </string> + <string name="resource/name"> "crouch" </string> <real name="length"> 0.01 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> @@ -142,7 +140,7 @@ <real_array len="1"> 1 </real_array> <string> "values" </string> <array len="1" shared="false"> - <int> 21 </int> + <int> 22 </int> </array> <string> "times" </string> <real_array len="1"> 0 </real_array> @@ -150,7 +148,7 @@ </resource> <resource type="Animation" path="local://8"> - <string name="resource/name"> "falling_weapon" </string> + <string name="resource/name"> "jumping" </string> <real name="length"> 0.5 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> @@ -161,19 +159,21 @@ <string> "cont" </string> <bool> False </bool> <string> "transitions" </string> - <real_array len="1"> 1 </real_array> + <real_array len="3"> 1, 1, 1 </real_array> <string> "values" </string> - <array len="1" shared="false"> - <int> 26 </int> + <array len="3" shared="false"> + <int> 23 </int> + <int> 24 </int> + <int> 23 </int> </array> <string> "times" </string> - <real_array len="1"> 0 </real_array> + <real_array len="3"> 0, 0.25, 0.5 </real_array> </dictionary> </resource> <resource type="Animation" path="local://9"> - <string name="resource/name"> "idle_weapon" </string> - <real name="length"> 0.5 </real> + <string name="resource/name"> "run_weapon" </string> + <real name="length"> 1.25 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> <string name="tracks/0/type"> "value" </string> @@ -183,18 +183,23 @@ <string> "cont" </string> <bool> False </bool> <string> "transitions" </string> - <real_array len="1"> 1 </real_array> + <real_array len="6"> 1, 1, 1, 1, 1, 1 </real_array> <string> "values" </string> - <array len="1" shared="false"> - <int> 25 </int> + <array len="6" shared="false"> + <int> 5 </int> + <int> 6 </int> + <int> 7 </int> + <int> 8 </int> + <int> 9 </int> + <int> 5 </int> </array> <string> "times" </string> - <real_array len="1"> 0 </real_array> + <real_array len="6"> 0, 0.25, 0.5, 0.75, 1, 1.25 </real_array> </dictionary> </resource> <resource type="Animation" path="local://10"> - <string name="resource/name"> "jumping_weapon" </string> + <string name="resource/name"> "idle_weapon" </string> <real name="length"> 0.5 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> @@ -208,7 +213,7 @@ <real_array len="1"> 1 </real_array> <string> "values" </string> <array len="1" shared="false"> - <int> 26 </int> + <int> 25 </int> </array> <string> "times" </string> <real_array len="1"> 0 </real_array> @@ -216,8 +221,8 @@ </resource> <resource type="Animation" path="local://11"> - <string name="resource/name"> "crouch" </string> - <real name="length"> 0.01 </real> + <string name="resource/name"> "falling_weapon" </string> + <real name="length"> 0.5 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> <string name="tracks/0/type"> "value" </string> @@ -230,7 +235,7 @@ <real_array len="1"> 1 </real_array> <string> "values" </string> <array len="1" shared="false"> - <int> 22 </int> + <int> 26 </int> </array> <string> "times" </string> <real_array len="1"> 0 </real_array> @@ -238,8 +243,8 @@ </resource> <resource type="Animation" path="local://12"> - <string name="resource/name"> "run_gun_fire" </string> - <real name="length"> 1.25 </real> + <string name="resource/name"> "falling" </string> + <real name="length"> 0.01 </real> <bool name="loop"> True </bool> <real name="step"> 0.25 </real> <string name="tracks/0/type"> "value" </string> @@ -249,18 +254,13 @@ <string> "cont" </string> <bool> False </bool> <string> "transitions" </string> - <real_array len="6"> 1, 1, 1, 1, 1, 1 </real_array> + <real_array len="1"> 1 </real_array> <string> "values" </string> - <array len="6" shared="false"> - <int> 10 </int> - <int> 11 </int> - <int> 12 </int> - <int> 13 </int> - <int> 14 </int> - <int> 5 </int> + <array len="1" shared="false"> + <int> 21 </int> </array> <string> "times" </string> - <real_array len="6"> 0, 0.25, 0.5, 0.75, 1, 1.25 </real_array> + <real_array len="1"> 0 </real_array> </dictionary> </resource> @@ -271,7 +271,7 @@ <string> "pitch" </string> <real> 1 </real> <string> "sample" </string> - <resource resource_type="Sample" path="res://sound_jump.*"> </resource> + <resource resource_type="Sample" path="res://sound_jump.wav"> </resource> </dictionary> <dictionary name="samples/shoot" shared="false"> <string> "db" </string> @@ -279,7 +279,7 @@ <string> "pitch" </string> <real> 1 </real> <string> "sample" </string> - <resource resource_type="Sample" path="res://sound_shoot.*"> </resource> + <resource resource_type="Sample" path="res://sound_shoot.wav"> </resource> </dictionary> <dictionary name="samples/coin" shared="false"> <string> "db" </string> @@ -287,7 +287,7 @@ <string> "pitch" </string> <real> 1 </real> <string> "sample" </string> - <resource resource_type="Sample" path="res://sound_coin.*"> </resource> + <resource resource_type="Sample" path="res://sound_coin.wav"> </resource> </dictionary> </resource> @@ -300,7 +300,7 @@ <string> "visibility/visible" </string> <string> "visibility/opacity" </string> <string> "visibility/self_opacity" </string> - <string> "visibility/on_top" </string> + <string> "visibility/behind_parent" </string> <string> "transform/pos" </string> <string> "transform/rot" </string> <string> "transform/scale" </string> @@ -396,15 +396,15 @@ <string> "playback/default_blend_time" </string> <string> "root/root" </string> <string> "anims/idle" </string> - <string> "anims/jumping" </string> <string> "anims/run" </string> - <string> "anims/run_weapon" </string> - <string> "anims/falling" </string> - <string> "anims/falling_weapon" </string> - <string> "anims/idle_weapon" </string> + <string> "anims/standing_weapon_ready" </string> <string> "anims/jumping_weapon" </string> <string> "anims/crouch" </string> - <string> "anims/standing_weapon_ready" </string> + <string> "anims/jumping" </string> + <string> "anims/run_weapon" </string> + <string> "anims/idle_weapon" </string> + <string> "anims/falling_weapon" </string> + <string> "anims/falling" </string> <string> "playback/active" </string> <string> "playback/speed" </string> <string> "blend_times" </string> @@ -476,18 +476,19 @@ <array len="71" shared="false"> <bool> True </bool> <real> 1 </real> + <bool> False </bool> <vector2> 0, 0 </vector2> <real> 0 </real> <vector2> 1, 1 </vector2> <int> 2 </int> <resource resource_type="Shape2D" path="local://1"> </resource> <matrix32> 1, -0, 0, 1.76469, 0.291992, -12.1587 </matrix32> - <bool> False </bool> <resource resource_type="Shape2D" path="local://2"> </resource> <matrix32> 1, -0, 0, 1, 0, 0 </matrix32> <real> 3 </real> + <int> 0 </int> <int> 3 </int> - <resource resource_type="Script" path="res://player.*"> </resource> + <resource resource_type="Script" path="res://player.gd"> </resource> <dictionary shared="false"> <string> "__editor_plugin_states__" </string> <dictionary shared="false"> @@ -507,7 +508,7 @@ <string> "zoom" </string> <real> 2.272073 </real> <string> "ofs" </string> - <vector2> -125.17, -137.776 </vector2> + <vector2> -181.946, -86.2812 </vector2> </dictionary> <string> "3D" </string> <dictionary shared="false"> @@ -594,20 +595,20 @@ <int> 0 </int> </dictionary> <string> "__editor_plugin_screen__" </string> - <string> "2D" </string> + <string> "3D" </string> </dictionary> - <resource resource_type="Texture" path="res://robot_demo.*"> </resource> + <resource resource_type="Texture" path="res://robot_demo.png"> </resource> <int> 16 </int> - <int> 1 </int> <color> 1, 1, 1, 1 </color> <rect2> 0, 0, 0, 0 </rect2> <real> 0.363636 </real> + <int> 1 </int> <vector2> 20.7312, 3.21187 </vector2> <real> 83.450417 </real> <int> 4 </int> <real> 0.3 </real> <real> 0.1 </real> - <resource resource_type="Texture" path="res://bullet.*"> </resource> + <resource resource_type="Texture" path="res://bullet.png"> </resource> <real> 180 </real> <real> 20 </real> <real> 9.8 </real> @@ -630,7 +631,6 @@ <array len="0" shared="false"> </array> <string> "" </string> - <int> 0 </int> <int> 10000000 </int> <real> 0.2 </real> <vector2> 31.2428, 4.08784 </vector2> @@ -641,20 +641,20 @@ <vector2_array len="3"> -0.138023, 16.5036, -19.902, -24.8691, 19.3625, -24.6056 </vector2_array> <vector2> 27.7593, 360.87 </vector2> <vector2> 1.49157, 1.46265 </vector2> - <resource resource_type="Texture" path="res://osb_left.*"> </resource> + <resource resource_type="Texture" path="res://osb_left.png"> </resource> <resource name=""></resource> <string> "move_left" </string> <vector2> 121.542, 361.415 </vector2> - <resource resource_type="Texture" path="res://osb_right.*"> </resource> + <resource resource_type="Texture" path="res://osb_right.png"> </resource> <string> "move_right" </string> <vector2> 666.224, 359.02 </vector2> - <resource resource_type="Texture" path="res://osb_jump.*"> </resource> + <resource resource_type="Texture" path="res://osb_jump.png"> </resource> <string> "jump" </string> <vector2> 668.073, 262.788 </vector2> - <resource resource_type="Texture" path="res://osb_fire.*"> </resource> + <resource resource_type="Texture" path="res://osb_fire.png"> </resource> <string> "shoot" </string> </array> <string> "nodes" </string> - <int_array len="572"> -1, -1, 1, 0, -1, 28, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10, 15, 8, 16, 5, 17, 11, 18, 3, 19, 3, 20, 0, 21, 8, 22, 12, 23, 8, 24, 0, 25, 0, 26, 2, 27, 3, 28, 13, 29, 14, 0, 0, 0, 31, 30, -1, 18, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 32, 15, 33, 0, 34, 2, 35, 8, 36, 8, 37, 5, 38, 16, 39, 17, 40, 18, 41, 8, 42, 19, 0, 1, 0, 44, 43, -1, 57, 2, 0, 3, 1, 4, 20, 5, 0, 45, 17, 6, 21, 7, 22, 8, 4, 46, 23, 47, 24, 48, 1, 49, 3, 50, 24, 51, 8, 52, 2, 53, 2, 54, 8, 55, 25, 56, 8, 57, 8, 58, 26, 59, 3, 60, 27, 61, 28, 62, 1, 63, 3, 64, 3, 65, 29, 66, 3, 67, 3, 68, 3, 69, 30, 70, 30, 71, 3, 72, 3, 73, 3, 74, 3, 75, 30, 76, 3, 77, 3, 78, 3, 79, 3, 80, 3, 81, 3, 82, 3, 83, 3, 84, 3, 85, 5, 86, 3, 87, 18, 88, 1, 89, 31, 90, 1, 91, 32, 92, 1, 93, 33, 94, 34, 0, 0, 0, 96, 95, -1, 17, 97, 17, 98, 3, 99, 35, 100, 36, 101, 37, 102, 38, 103, 39, 104, 40, 105, 41, 106, 42, 107, 43, 108, 44, 109, 45, 110, 0, 111, 30, 112, 46, 113, 47, 0, 0, 0, 115, 114, -1, 22, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 33, 0, 116, 8, 117, 0, 118, 3, 119, 4, 120, 48, 121, 48, 122, 49, 123, 49, 124, 0, 125, 0, 126, 50, 127, 50, 128, 50, 129, 50, 0, 0, 0, 131, 130, -1, 7, 2, 0, 3, 1, 4, 1, 5, 0, 6, 51, 7, 3, 8, 4, 0, 0, 0, 132, 132, -1, 9, 2, 0, 3, 1, 4, 1, 5, 0, 6, 52, 7, 3, 8, 53, 133, 6, 134, 8, 0, 0, 0, 136, 135, -1, 14, 137, 12, 138, 54, 139, 3, 140, 1, 141, 3, 142, 3, 143, 3, 144, 55, 145, 55, 146, 55, 147, 55, 148, 5, 149, 3, 150, 3, 0, 0, 0, 151, 151, -1, 9, 2, 0, 3, 1, 4, 1, 5, 0, 6, 2, 7, 3, 8, 4, 152, 48, 153, 56, 0, 0, 0, 155, 154, -1, 4, 156, 48, 34, 2, 157, 3, 158, 4, 0, 9, 0, 160, 159, -1, 13, 2, 0, 3, 1, 4, 1, 5, 0, 6, 57, 7, 3, 8, 58, 161, 59, 162, 60, 163, 60, 164, 0, 165, 61, 166, 17, 0, 9, 0, 160, 167, -1, 13, 2, 0, 3, 1, 4, 1, 5, 0, 6, 62, 7, 3, 8, 58, 161, 63, 162, 60, 163, 60, 164, 0, 165, 64, 166, 17, 0, 9, 0, 160, 168, -1, 13, 2, 0, 3, 1, 4, 1, 5, 0, 6, 65, 7, 3, 8, 58, 161, 66, 162, 60, 163, 60, 164, 8, 165, 67, 166, 17, 0, 9, 0, 160, 169, -1, 13, 2, 0, 3, 1, 4, 1, 5, 0, 6, 68, 7, 3, 8, 58, 161, 69, 162, 60, 163, 60, 164, 8, 165, 70, 166, 17, 0 </int_array> + <int_array len="572"> -1, -1, 1, 0, -1, 28, 2, 0, 3, 1, 4, 1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 2, 13, 9, 14, 10, 15, 2, 16, 6, 17, 11, 18, 4, 19, 4, 20, 0, 21, 12, 22, 13, 23, 2, 24, 0, 25, 0, 26, 3, 27, 4, 28, 14, 29, 15, 0, 0, 0, 31, 30, -1, 18, 2, 0, 3, 1, 4, 1, 5, 2, 6, 3, 7, 4, 8, 5, 32, 16, 33, 0, 34, 3, 35, 2, 36, 2, 37, 6, 38, 17, 39, 12, 40, 18, 41, 2, 42, 19, 0, 1, 0, 44, 43, -1, 57, 2, 0, 3, 1, 4, 20, 5, 2, 45, 21, 6, 22, 7, 23, 8, 5, 46, 24, 47, 25, 48, 1, 49, 4, 50, 25, 51, 2, 52, 3, 53, 3, 54, 2, 55, 26, 56, 2, 57, 2, 58, 27, 59, 4, 60, 28, 61, 29, 62, 1, 63, 4, 64, 4, 65, 30, 66, 4, 67, 4, 68, 4, 69, 31, 70, 31, 71, 4, 72, 4, 73, 4, 74, 4, 75, 31, 76, 4, 77, 4, 78, 4, 79, 4, 80, 4, 81, 4, 82, 4, 83, 4, 84, 4, 85, 6, 86, 4, 87, 18, 88, 1, 89, 32, 90, 1, 91, 33, 92, 1, 93, 34, 94, 35, 0, 0, 0, 96, 95, -1, 17, 97, 21, 98, 4, 99, 36, 100, 37, 101, 38, 102, 39, 103, 40, 104, 41, 105, 42, 106, 43, 107, 44, 108, 45, 109, 46, 110, 0, 111, 31, 112, 47, 113, 48, 0, 0, 0, 115, 114, -1, 22, 2, 0, 3, 1, 4, 1, 5, 2, 6, 3, 7, 4, 8, 5, 33, 0, 116, 2, 117, 0, 118, 4, 119, 5, 120, 12, 121, 12, 122, 49, 123, 49, 124, 0, 125, 0, 126, 50, 127, 50, 128, 50, 129, 50, 0, 0, 0, 131, 130, -1, 7, 2, 0, 3, 1, 4, 1, 5, 2, 6, 51, 7, 4, 8, 5, 0, 0, 0, 132, 132, -1, 9, 2, 0, 3, 1, 4, 1, 5, 2, 6, 52, 7, 4, 8, 53, 133, 7, 134, 2, 0, 0, 0, 136, 135, -1, 14, 137, 13, 138, 54, 139, 4, 140, 1, 141, 4, 142, 4, 143, 4, 144, 55, 145, 55, 146, 55, 147, 55, 148, 6, 149, 4, 150, 4, 0, 0, 0, 151, 151, -1, 9, 2, 0, 3, 1, 4, 1, 5, 2, 6, 3, 7, 4, 8, 5, 152, 12, 153, 56, 0, 0, 0, 155, 154, -1, 4, 156, 12, 34, 3, 157, 4, 158, 5, 0, 9, 0, 160, 159, -1, 13, 2, 0, 3, 1, 4, 1, 5, 2, 6, 57, 7, 4, 8, 58, 161, 59, 162, 60, 163, 60, 164, 0, 165, 61, 166, 21, 0, 9, 0, 160, 167, -1, 13, 2, 0, 3, 1, 4, 1, 5, 2, 6, 62, 7, 4, 8, 58, 161, 63, 162, 60, 163, 60, 164, 0, 165, 64, 166, 21, 0, 9, 0, 160, 168, -1, 13, 2, 0, 3, 1, 4, 1, 5, 2, 6, 65, 7, 4, 8, 58, 161, 66, 162, 60, 163, 60, 164, 2, 165, 67, 166, 21, 0, 9, 0, 160, 169, -1, 13, 2, 0, 3, 1, 4, 1, 5, 2, 6, 68, 7, 4, 8, 58, 161, 69, 162, 60, 163, 60, 164, 2, 165, 70, 166, 21, 0 </int_array> <string> "conns" </string> <int_array len="0"> </int_array> </dictionary> diff --git a/demos/2d/platformer/stage.xml b/demos/2d/platformer/stage.xml index 4f9cd899e5..cf9a5ff44a 100644 --- a/demos/2d/platformer/stage.xml +++ b/demos/2d/platformer/stage.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> <resource_file type="PackedScene" subresource_count="9" version="1.0" version_name="Godot Engine v1.0.3917-beta1"> - <ext_resource path="res://music.*" type="AudioStream"></ext_resource> - <ext_resource path="res://tileset.*" type="TileSet"></ext_resource> - <ext_resource path="res://coin.*" type="PackedScene"></ext_resource> - <ext_resource path="res://player.*" type="PackedScene"></ext_resource> - <ext_resource path="res://moving_platform.*" type="PackedScene"></ext_resource> - <ext_resource path="res://enemy.*" type="PackedScene"></ext_resource> - <ext_resource path="res://seesaw.*" type="PackedScene"></ext_resource> - <ext_resource path="res://parallax_bg.*" type="PackedScene"></ext_resource> + <ext_resource path="res://music.ogg" type="AudioStream"></ext_resource> + <ext_resource path="res://tileset.xml" type="TileSet"></ext_resource> + <ext_resource path="res://coin.xml" type="PackedScene"></ext_resource> + <ext_resource path="res://player.xml" type="PackedScene"></ext_resource> + <ext_resource path="res://enemy.xml" type="PackedScene"></ext_resource> + <ext_resource path="res://moving_platform.xml" type="PackedScene"></ext_resource> + <ext_resource path="res://seesaw.xml" type="PackedScene"></ext_resource> + <ext_resource path="res://parallax_bg.xml" type="PackedScene"></ext_resource> <main_resource> <dictionary name="_bundled" shared="false"> <string> "names" </string> @@ -20,7 +20,7 @@ <string> "visibility/visible" </string> <string> "visibility/opacity" </string> <string> "visibility/self_opacity" </string> - <string> "visibility/on_top" </string> + <string> "visibility/behind_parent" </string> <string> "transform/pos" </string> <string> "transform/rot" </string> <string> "transform/scale" </string> @@ -159,9 +159,9 @@ <string> "pixel_snap" </string> <bool> False </bool> <string> "zoom" </string> - <real> 1.108033 </real> + <real> 0.735092 </real> <string> "ofs" </string> - <vector2> -19.8136, -223.194 </vector2> + <vector2> 55.9232, 767.661 </vector2> </dictionary> <string> "3D" </string> <dictionary shared="false"> @@ -252,12 +252,13 @@ </dictionary> <bool> True </bool> <real> 1 </real> + <bool> False </bool> <vector2> 0, 0 </vector2> <real> 0 </real> <vector2> 1, 1 </vector2> <int> 64 </int> <int> 16 </int> - <resource resource_type="TileSet" path="res://tileset.*"> </resource> + <resource resource_type="TileSet" path="res://tileset.xml"> </resource> <int_array len="1998"> 0, 2, 70, 536870914, 71, 10, 72, 10, 73, 10, 74, 10, 75, 10, 76, 10, 77, 10, 78, 10, 65536, 2, 65606, 536870914, 65607, 10, 65608, 10, 65609, 10, 65610, 10, 65611, 10, 65612, 10, 65613, 10, 65614, 10, 131072, 2, 131142, 536870914, 131143, 10, 131144, 10, 131145, 10, 131146, 10, 131147, 10, 131148, 10, 131149, 10, 131150, 10, 196608, 2, 196626, 9, 196678, 536870914, 196679, 10, 196680, 10, 196681, 10, 196682, 10, 196683, 10, 196684, 10, 196685, 10, 196686, 10, 262144, 2, 262162, 8, 262214, 536870914, 262215, 10, 262216, 10, 262217, 10, 262218, 10, 262219, 10, 262220, 10, 262221, 10, 262222, 10, 327680, 2, 327697, 536870921, 327698, 7, 327733, 9, 327750, 536870914, 327751, 10, 327752, 10, 327753, 10, 327754, 10, 327755, 10, 327756, 10, 327757, 10, 327758, 10, 393216, 2, 393233, 536870920, 393234, 7, 393257, 9, 393269, 7, 393286, 536870914, 393287, 10, 393288, 10, 393289, 10, 393290, 10, 393291, 10, 393292, 10, 393293, 10, 393294, 10, 458752, 2, 458769, 7, 458770, 8, 458790, 9, 458793, 8, 458805, 8, 458822, 536870914, 458823, 10, 458824, 10, 458825, 10, 458826, 10, 458827, 10, 458828, 10, 458829, 10, 458830, 10, 524288, 4, 524289, 1, 524304, 536870913, 524305, 536870918, 524306, 6, 524307, 5, 524308, 1, 524326, 8, 524329, 7, 524341, 7, 524358, 536870914, 524359, 10, 524360, 10, 524361, 10, 524362, 10, 524363, 10, 524364, 10, 524365, 10, 524366, 10, 589824, 10, 589825, 13, 589840, 536870914, 589841, 10, 589842, 10, 589843, 10, 589844, 2, 589862, 7, 589865, 7, 589876, 536870913, 589877, 6, 589878, 1, 589894, 536870914, 589895, 10, 589896, 10, 589897, 10, 589898, 10, 589899, 10, 589900, 10, 589901, 10, 589902, 10, 655360, 2, 655376, 536870914, 655377, 10, 655378, 10, 655379, 10, 655380, 2, 655398, 7, 655401, 8, 655412, 536870925, 655413, 11, 655414, 13, 655430, 536870914, 655431, 10, 655432, 10, 655433, 10, 655434, 10, 655435, 10, 655436, 10, 655437, 10, 655438, 10, 720896, 2, 720912, 536870914, 720913, 10, 720914, 10, 720915, 10, 720916, 2, 720934, 8, 720937, 7, 720958, 536870913, 720959, 5, 720960, 536870917, 720961, 5, 720962, 5, 720963, 536870917, 720964, 5, 720965, 0, 720966, 536870916, 720967, 10, 720968, 10, 720969, 10, 720970, 10, 720971, 10, 720972, 10, 720973, 10, 720974, 10, 786432, 2, 786437, 9, 786448, 536870914, 786449, 10, 786450, 10, 786451, 10, 786452, 2, 786464, 536870913, 786465, 1, 786470, 7, 786473, 7, 786474, 536870924, 786475, 1, 786494, 536870914, 786495, 10, 786496, 10, 786497, 10, 786498, 10, 786499, 10, 786500, 10, 786501, 10, 786502, 10, 786503, 10, 786504, 10, 786505, 10, 786506, 10, 786507, 10, 786508, 10, 786509, 10, 851968, 2, 851973, 7, 851984, 536870914, 851985, 10, 851986, 10, 851987, 10, 851988, 2, 851996, 536870913, 851997, 1, 852000, 536870914, 852001, 3, 852006, 7, 852009, 536870913, 852011, 2, 852030, 536870914, 852031, 10, 852032, 10, 852033, 10, 852034, 10, 852035, 10, 852036, 10, 852037, 10, 852038, 10, 852039, 10, 852040, 10, 852041, 10, 852042, 10, 852043, 10, 852044, 10, 852045, 10, 917504, 2, 917506, 9, 917509, 7, 917512, 536870921, 917520, 536870925, 917521, 11, 917522, 11, 917523, 11, 917524, 13, 917532, 536870925, 917533, 13, 917536, 536870914, 917537, 4, 917538, 1, 917540, 536870913, 917541, 0, 917542, 1, 917545, 536870914, 917546, 10, 917547, 4, 917548, 1, 917566, 536870914, 917567, 10, 917568, 10, 917569, 10, 917570, 10, 917571, 10, 917572, 10, 917573, 10, 917574, 10, 917575, 10, 917576, 10, 917577, 10, 917578, 10, 917579, 10, 917580, 10, 917581, 10, 983040, 2, 983042, 7, 983045, 7, 983048, 536870920, 983050, 536870913, 983051, 1, 983064, 536870913, 983065, 1, 983072, 536870914, 983073, 10, 983074, 4, 983075, 0, 983076, 536870916, 983077, 10, 983078, 4, 983079, 536870912, 983080, 536870912, 983081, 536870916, 983082, 10, 983083, 10, 983084, 2, 983095, 9, 983102, 536870914, 983103, 10, 983104, 10, 983105, 10, 983106, 10, 983107, 10, 983108, 10, 983109, 10, 983110, 10, 983111, 10, 983112, 10, 983113, 10, 983114, 10, 983115, 10, 983116, 10, 983117, 10, 1048576, 2, 1048578, 8, 1048581, 8, 1048584, 536870919, 1048586, 536870925, 1048587, 13, 1048600, 536870925, 1048601, 13, 1048604, 9, 1048608, 536870925, 1048609, 536870923, 1048610, 536870923, 1048611, 536870923, 1048612, 10, 1048613, 10, 1048614, 10, 1048615, 10, 1048616, 10, 1048617, 10, 1048618, 10, 1048619, 10, 1048620, 4, 1048621, 1, 1048630, 536870921, 1048631, 8, 1048638, 536870914, 1048639, 10, 1048640, 10, 1048641, 10, 1048642, 10, 1048643, 10, 1048644, 10, 1048645, 10, 1048646, 10, 1048647, 10, 1048648, 10, 1048649, 10, 1048650, 10, 1048651, 10, 1048652, 10, 1048653, 10, 1114112, 4, 1114113, 0, 1114114, 6, 1114115, 0, 1114116, 0, 1114117, 6, 1114118, 1, 1114120, 536870920, 1114128, 536870913, 1114129, 5, 1114130, 536870917, 1114131, 5, 1114132, 0, 1114133, 1, 1114140, 7, 1114141, 536870921, 1114148, 536870914, 1114149, 10, 1114150, 10, 1114151, 10, 1114152, 10, 1114153, 10, 1114154, 10, 1114155, 10, 1114156, 10, 1114157, 2, 1114166, 536870920, 1114167, 8, 1114174, 536870914, 1114175, 10, 1114176, 10, 1114177, 10, 1114178, 10, 1114179, 10, 1114180, 10, 1114181, 10, 1114182, 10, 1114183, 10, 1114184, 10, 1114185, 10, 1114186, 10, 1114187, 10, 1114188, 10, 1179648, 10, 1179649, 10, 1179650, 10, 1179651, 10, 1179652, 10, 1179653, 10, 1179654, 2, 1179656, 536870919, 1179663, 536870915, 1179665, 10, 1179666, 10, 1179667, 10, 1179668, 10, 1179669, 4, 1179670, 12, 1179675, 9, 1179676, 8, 1179677, 8, 1179684, 536870914, 1179685, 10, 1179686, 10, 1179687, 10, 1179688, 10, 1179689, 10, 1179690, 10, 1179691, 10, 1179692, 10, 1179693, 4, 1179694, 1, 1179701, 9, 1179702, 536870919, 1179703, 7, 1179710, 536870914, 1179711, 10, 1179712, 10, 1179713, 10, 1179714, 10, 1179715, 10, 1179716, 10, 1179717, 10, 1179718, 10, 1179719, 10, 1179720, 10, 1179721, 10, 1179722, 10, 1245184, 10, 1245185, 10, 1245186, 10, 1245187, 10, 1245188, 10, 1245189, 10, 1245190, 2, 1245192, 536870919, 1245199, 536870913, 1245200, 536870916, 1245201, 10, 1245202, 10, 1245203, 10, 1245204, 10, 1245205, 10, 1245207, 1, 1245211, 7, 1245212, 7, 1245213, 536870920, 1245220, 536870914, 1245221, 10, 1245222, 10, 1245223, 10, 1245224, 10, 1245225, 10, 1245226, 10, 1245227, 10, 1245228, 10, 1245229, 10, 1245230, 2, 1245237, 8, 1245238, 536870919, 1245239, 8, 1245240, 536870921, 1245246, 536870914, 1245247, 10, 1245248, 10, 1245249, 10, 1245250, 10, 1245251, 10, 1245252, 10, 1245253, 10, 1245254, 10, 1245255, 10, 1245256, 10, 1245257, 10, 1245258, 10, 1310720, 10, 1310721, 10, 1310722, 10, 1310723, 10, 1310724, 10, 1310725, 10, 1310726, 2, 1310728, 536870920, 1310730, 536870913, 1310731, 1, 1310734, 536870913, 1310735, 536870916, 1310736, 10, 1310737, 10, 1310738, 10, 1310739, 10, 1310740, 10, 1310741, 10, 1310742, 10, 1310743, 4, 1310744, 1, 1310747, 8, 1310748, 7, 1310749, 536870919, 1310756, 536870914, 1310757, 10, 1310758, 10, 1310759, 10, 1310760, 10, 1310761, 10, 1310762, 10, 1310763, 10, 1310764, 10, 1310765, 10, 1310766, 4, 1310767, 5, 1310768, 12, 1310773, 7, 1310774, 536870919, 1310775, 7, 1310776, 536870919, 1310782, 536870914, 1310783, 10, 1310784, 10, 1310785, 10, 1310786, 10, 1310787, 10, 1310788, 10, 1310789, 10, 1310790, 10, 1310791, 10, 1310792, 10, 1310793, 10, 1376256, 10, 1376257, 10, 1376258, 10, 1376259, 10, 1376260, 10, 1376261, 10, 1376262, 4, 1376263, 0, 1376264, 536870918, 1376265, 0, 1376266, 536870916, 1376267, 4, 1376268, 0, 1376269, 0, 1376270, 536870916, 1376271, 10, 1376272, 10, 1376273, 10, 1376274, 10, 1376275, 10, 1376276, 10, 1376277, 10, 1376278, 10, 1376279, 10, 1376280, 4, 1376281, 12, 1376283, 8, 1376284, 8, 1376285, 536870920, 1376287, 536870924, 1376288, 0, 1376289, 5, 1376290, 536870917, 1376291, 0, 1376292, 536870916, 1376293, 10, 1376294, 10, 1376295, 10, 1376296, 10, 1376297, 10, 1376298, 10, 1376299, 10, 1376300, 10, 1376301, 10, 1376302, 10, 1376303, 10, 1376305, 12, 1376309, 7, 1376310, 536870920, 1376311, 7, 1376312, 536870920, 1376318, 536870914, 1376319, 10, 1376320, 10, 1376321, 10, 1376322, 10, 1376323, 10, 1376324, 10, 1376325, 10, 1376326, 10, 1376327, 10, 1376328, 10, 1441792, 10, 1441793, 10, 1441794, 10, 1441795, 10, 1441796, 10, 1441797, 10, 1441798, 10, 1441799, 10, 1441800, 10, 1441801, 10, 1441802, 10, 1441803, 10, 1441804, 10, 1441805, 10, 1441806, 10, 1441807, 10, 1441808, 10, 1441809, 10, 1441810, 10, 1441811, 10, 1441812, 10, 1441813, 10, 1441814, 10, 1441815, 10, 1441816, 10, 1441818, 0, 1441819, 6, 1441820, 6, 1441821, 536870918, 1441822, 5, 1441824, 10, 1441825, 10, 1441826, 10, 1441827, 10, 1441828, 10, 1441829, 10, 1441830, 10, 1441831, 10, 1441832, 10, 1441833, 10, 1441834, 10, 1441835, 10, 1441836, 10, 1441837, 10, 1441838, 10, 1441839, 10, 1441840, 10, 1441842, 0, 1441843, 0, 1441844, 0, 1441845, 6, 1441846, 536870918, 1441847, 6, 1441848, 536870918, 1441849, 0, 1441850, 5, 1441851, 536870917, 1441852, 5, 1441853, 0, 1441854, 536870916, 1441855, 10, 1441856, 10, 1441857, 10, 1441858, 10, 1441859, 10, 1441860, 10, 1441861, 10, 1441862, 10, 1441863, 10, 1507328, 10, 1507329, 10, 1507330, 10, 1507331, 10, 1507332, 10, 1507333, 10, 1507334, 10, 1507335, 10, 1507336, 10, 1507337, 10, 1507338, 10, 1507339, 10, 1507340, 10, 1507341, 10, 1507342, 10, 1507343, 10, 1507344, 10, 1507345, 10, 1507346, 10, 1507347, 10, 1507348, 10, 1507349, 10, 1507350, 10, 1507351, 10, 1507352, 10, 1507353, 10, 1507354, 10, 1507355, 10, 1507356, 10, 1507357, 10, 1507358, 10, 1507359, 10, 1507360, 10, 1507361, 10, 1507362, 10, 1507363, 10, 1507364, 10, 1507365, 10, 1507366, 10, 1507367, 10, 1507368, 10, 1507369, 10, 1507370, 10, 1507371, 10, 1507372, 10, 1507373, 10, 1507374, 10, 1507375, 10, 1507376, 10, 1507377, 10, 1507378, 10, 1507379, 10, 1507380, 10, 1507381, 10, 1507382, 10, 1507383, 10, 1507384, 10, 1507385, 10, 1507386, 10, 1507387, 10, 1507388, 10, 1507389, 10, 1507390, 10, 1507391, 10, 1507392, 10, 1507393, 10, 1507394, 10, 1507395, 10, 1507396, 10, 1507397, 10, 1507398, 10, 1507399, 10, 1572864, 10, 1572865, 10, 1572866, 10, 1572867, 10, 1572868, 10, 1572869, 10, 1572870, 10, 1572871, 10, 1572872, 10, 1572873, 10, 1572874, 10, 1572875, 10, 1572876, 10, 1572877, 10, 1572878, 10, 1572879, 10, 1572880, 10, 1572881, 10, 1572882, 10, 1572883, 10, 1572884, 10, 1572885, 10, 1572886, 10, 1572887, 10, 1572888, 10, 1572889, 10, 1572890, 10, 1572891, 10, 1572892, 10, 1572893, 10, 1572894, 10, 1572895, 10, 1572896, 10, 1572897, 10, 1572898, 10, 1572899, 10, 1572900, 10, 1572901, 10, 1572902, 10, 1572903, 10, 1572904, 10, 1572905, 10, 1572906, 10, 1572907, 10, 1572908, 10, 1572909, 10, 1572910, 10, 1572911, 10, 1572912, 10, 1572913, 10, 1572914, 10, 1572915, 10, 1572916, 10, 1572917, 10, 1572918, 10, 1572919, 10, 1572920, 10, 1572921, 10, 1572922, 10, 1572923, 10, 1572924, 10, 1572925, 10, 1572926, 10, 1572927, 10, 1572928, 10, 1572929, 10, 1572930, 10, 1572931, 10, 1572932, 10, 1572933, 10, 1572934, 10, 1572935, 10, 1638400, 10, 1638401, 10, 1638402, 10, 1638403, 10, 1638404, 10, 1638405, 10, 1638406, 10, 1638407, 10, 1638408, 10, 1638409, 10, 1638410, 10, 1638411, 10, 1638412, 10, 1638413, 10, 1638414, 10, 1638415, 10, 1638416, 10, 1638417, 10, 1638418, 10, 1638419, 10, 1638420, 10, 1638421, 10, 1638422, 10, 1638423, 10, 1638424, 10, 1638425, 10, 1638426, 10, 1638427, 10, 1638428, 10, 1638429, 10, 1638430, 10, 1638431, 10, 1638432, 10, 1638433, 10, 1638434, 10, 1638435, 10, 1638436, 10, 1638437, 10, 1638438, 10, 1638439, 10, 1638440, 10, 1638441, 10, 1638442, 10, 1638443, 10, 1638444, 10, 1638445, 10, 1638446, 10, 1638447, 10, 1638448, 10, 1638449, 10, 1638450, 10, 1638451, 10, 1638452, 10, 1638453, 10, 1638454, 10, 1638455, 10, 1638456, 10, 1638457, 10, 1638458, 10, 1638459, 10, 1638460, 10, 1638461, 10, 1638462, 10, 1638463, 10, 1638464, 10, 1638465, 10, 1638466, 10, 1638467, 10, 1638468, 10, 1638469, 10, 1638470, 10, 1638471, 10, 1703952, 10, 1703953, 10, 1703954, 10, 1703955, 10, 1703956, 10, 1703957, 10, 1703958, 10, 1703959, 10, 1703960, 10, 1703961, 10, 1703962, 10, 1703963, 10, 1703964, 10, 1703965, 10, 1703966, 10, 1703967, 10, 1703968, 10, 1703969, 10, 1703970, 10, 1703971, 10, 1703972, 10, 1703973, 10, 1703974, 10, 1703975, 10, 1703976, 10, 1703977, 10, 1703978, 10, 1703979, 10, 1703980, 10, 1703981, 10, 1703982, 10, 1703983, 10, 1703984, 10, 1703985, 10, 1703986, 10, 1703987, 10, 1703988, 10, 1703989, 10, 1703990, 10, 1703991, 10, 1703992, 10, 1703993, 10, 1703994, 10, 1703995, 10, 1703996, 10, 1703997, 10, 1703998, 10, 1703999, 10, 1704000, 10, 1704001, 10, 1704002, 10, 1704003, 10, 1704004, 10, 1704005, 10, 1704006, 10, 1704007, 10, 1769488, 10, 1769489, 10, 1769490, 10, 1769491, 10, 1769492, 10, 1769493, 10, 1769494, 10, 1769495, 10, 1769496, 10, 1769497, 10, 1769498, 10, 1769499, 10, 1769500, 10, 1769501, 10, 1769502, 10, 1769503, 10, 1769504, 10, 1769505, 10, 1769506, 10, 1769507, 10, 1769508, 10, 1769509, 10, 1769510, 10, 1769511, 10, 1769512, 10, 1769513, 10, 1769514, 10, 1769515, 10, 1769516, 10, 1769517, 10, 1769518, 10, 1769519, 10, 1769520, 10, 1769521, 10, 1769522, 10, 1769523, 10, 1769524, 10, 1769525, 10, 1769526, 10, 1769527, 10, 1769528, 10, 1769529, 10, 1769530, 10, 1769531, 10, 1769532, 10, 1769533, 10, 1769534, 10, 1769535, 10, 1769536, 10, 1769537, 10, 1769538, 10, 1769539, 10, 1769540, 10, 1769541, 10 </int_array> <dictionary shared="false"> <string> "_edit_lock_" </string> @@ -267,7 +268,7 @@ <string> "_editor_collapsed" </string> <bool> True </bool> </dictionary> - <resource resource_type="PackedScene" path="res://coin.*"> </resource> + <resource resource_type="PackedScene" path="res://coin.xml"> </resource> <vector2> 672, 1120 </vector2> <vector2> 704, 1120 </vector2> <vector2> 736, 1120 </vector2> @@ -310,9 +311,9 @@ <vector2> 4300.75, 541.058 </vector2> <vector2> 4236.75, 541.058 </vector2> <vector2> 4172.75, 541.058 </vector2> - <resource resource_type="PackedScene" path="res://player.*"> </resource> + <resource resource_type="PackedScene" path="res://player.xml"> </resource> <vector2> 236.879, 1051.15 </vector2> - <resource resource_type="PackedScene" path="res://moving_platform.*"> </resource> + <resource resource_type="PackedScene" path="res://moving_platform.xml"> </resource> <vector2> 1451.86, 742.969 </vector2> <vector2> 0, 140 </vector2> <real> 5 </real> @@ -321,12 +322,11 @@ <real> 10 </real> <vector2> 3419.86, 739.662 </vector2> <vector2> 450, 0 </vector2> - <resource resource_type="PackedScene" path="res://seesaw.*"> </resource> + <resource resource_type="PackedScene" path="res://seesaw.xml"> </resource> <vector2> 2402.79, 849.52 </vector2> - <resource resource_type="AudioStream" path="res://music.*"> </resource> - <bool> False </bool> + <resource resource_type="AudioStream" path="res://music.ogg"> </resource> <real> 2 </real> - <resource resource_type="PackedScene" path="res://enemy.*"> </resource> + <resource resource_type="PackedScene" path="res://enemy.xml"> </resource> <vector2> 834.664, 1309.6 </vector2> <vector2> 707.665, 1225.05 </vector2> <vector2> 1125.21, 1053.06 </vector2> @@ -338,7 +338,7 @@ <vector2> 3429.73, 540.865 </vector2> <vector2> 3546.2, 1356.19 </vector2> <vector2> 2406.63, 815.115 </vector2> - <resource resource_type="PackedScene" path="res://parallax_bg.*"> </resource> + <resource resource_type="PackedScene" path="res://parallax_bg.xml"> </resource> <real> 12 </real> <real> -202 </real> <real> 358 </real> @@ -352,7 +352,7 @@ <real> -1 </real> </array> <string> "nodes" </string> - <int_array len="688"> -1, -1, 1, 0, -1, 1, 2, 0, 0, 0, 0, 4, 3, -1, 12, 5, 1, 6, 2, 7, 2, 8, 1, 9, 3, 10, 4, 11, 5, 12, 6, 13, 7, 14, 8, 15, 9, 2, 10, 0, 0, 0, 1, 16, -1, 1, 2, 11, 0, 2, 0, 18, 17, 12, 1, 9, 13, 0, 2, 0, 18, 19, 12, 1, 9, 14, 0, 2, 0, 18, 20, 12, 1, 9, 15, 0, 2, 0, 18, 21, 12, 1, 9, 16, 0, 2, 0, 18, 22, 12, 1, 9, 17, 0, 2, 0, 18, 23, 12, 1, 9, 18, 0, 2, 0, 18, 24, 12, 1, 9, 19, 0, 2, 0, 18, 25, 12, 1, 9, 20, 0, 2, 0, 18, 26, 12, 1, 9, 21, 0, 2, 0, 18, 27, 12, 1, 9, 22, 0, 2, 0, 18, 28, 12, 1, 9, 23, 0, 2, 0, 18, 29, 12, 1, 9, 24, 0, 2, 0, 18, 30, 12, 1, 9, 25, 0, 2, 0, 18, 31, 12, 1, 9, 26, 0, 2, 0, 18, 32, 12, 1, 9, 27, 0, 2, 0, 18, 33, 12, 1, 9, 28, 0, 2, 0, 18, 34, 12, 1, 9, 29, 0, 2, 0, 18, 35, 12, 1, 9, 30, 0, 2, 0, 18, 36, 12, 1, 9, 31, 0, 2, 0, 18, 37, 12, 1, 9, 32, 0, 2, 0, 18, 38, 12, 1, 9, 33, 0, 2, 0, 18, 39, 12, 1, 9, 34, 0, 2, 0, 18, 40, 12, 1, 9, 35, 0, 2, 0, 18, 41, 12, 1, 9, 36, 0, 2, 0, 18, 42, 12, 1, 9, 37, 0, 2, 0, 18, 43, 12, 1, 9, 38, 0, 2, 0, 18, 44, 12, 1, 9, 39, 0, 2, 0, 18, 45, 12, 1, 9, 40, 0, 2, 0, 18, 46, 12, 1, 9, 41, 0, 2, 0, 18, 47, 12, 1, 9, 42, 0, 2, 0, 18, 48, 12, 1, 9, 43, 0, 2, 0, 18, 49, 12, 1, 9, 44, 0, 2, 0, 18, 50, 12, 1, 9, 45, 0, 2, 0, 18, 51, 12, 1, 9, 46, 0, 2, 0, 18, 52, 12, 1, 9, 47, 0, 2, 0, 18, 53, 12, 1, 9, 48, 0, 2, 0, 18, 54, 12, 1, 9, 49, 0, 2, 0, 18, 55, 12, 1, 9, 50, 0, 2, 0, 18, 56, 12, 1, 9, 51, 0, 2, 0, 18, 57, 12, 1, 9, 52, 0, 2, 0, 18, 58, 12, 1, 9, 53, 0, 2, 0, 18, 59, 12, 1, 9, 54, 0, 0, 0, 61, 60, 55, 1, 9, 56, 0, 0, 0, 1, 62, -1, 0, 0, 46, 0, 64, 63, 57, 3, 9, 58, 65, 59, 66, 60, 0, 46, 0, 64, 67, 57, 3, 9, 61, 65, 62, 66, 63, 0, 46, 0, 64, 68, 57, 3, 9, 64, 65, 65, 66, 63, 0, 46, 0, 64, 69, 66, 1, 9, 67, 0, 0, 0, 71, 70, -1, 6, 72, 68, 73, 69, 74, 1, 75, 70, 76, 1, 77, 69, 0, 0, 0, 1, 78, -1, 0, 0, 52, 0, 61, 79, 71, 1, 9, 72, 0, 52, 0, 61, 80, 71, 1, 9, 73, 0, 52, 0, 61, 81, 71, 1, 9, 74, 0, 52, 0, 61, 82, 71, 1, 9, 75, 0, 52, 0, 61, 83, 71, 1, 9, 76, 0, 52, 0, 61, 84, 71, 1, 9, 77, 0, 52, 0, 61, 85, 71, 1, 9, 78, 0, 52, 0, 61, 86, 71, 1, 9, 79, 0, 52, 0, 61, 87, 71, 1, 9, 80, 0, 52, 0, 61, 88, 71, 1, 9, 81, 0, 52, 0, 61, 89, 71, 1, 9, 82, 0, 0, 0, 91, 90, 83, 0, 0, 0, 0, 92, 92, -1, 29, 5, 1, 6, 2, 7, 2, 8, 1, 93, 84, 94, 85, 95, 86, 96, 87, 97, 88, 98, 88, 99, 88, 100, 88, 101, 1, 102, 1, 103, 89, 104, 2, 105, 4, 106, 90, 107, 2, 108, 91, 109, 4, 110, 69, 111, 69, 112, 92, 113, 93, 114, 93, 115, 1, 116, 69, 117, 94, 0 </int_array> + <int_array len="688"> -1, -1, 1, 0, -1, 1, 2, 0, 0, 0, 0, 4, 3, -1, 12, 5, 1, 6, 2, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 9, 15, 10, 2, 11, 0, 0, 0, 1, 16, -1, 1, 2, 12, 0, 2, 0, 18, 17, 13, 1, 9, 14, 0, 2, 0, 18, 19, 13, 1, 9, 15, 0, 2, 0, 18, 20, 13, 1, 9, 16, 0, 2, 0, 18, 21, 13, 1, 9, 17, 0, 2, 0, 18, 22, 13, 1, 9, 18, 0, 2, 0, 18, 23, 13, 1, 9, 19, 0, 2, 0, 18, 24, 13, 1, 9, 20, 0, 2, 0, 18, 25, 13, 1, 9, 21, 0, 2, 0, 18, 26, 13, 1, 9, 22, 0, 2, 0, 18, 27, 13, 1, 9, 23, 0, 2, 0, 18, 28, 13, 1, 9, 24, 0, 2, 0, 18, 29, 13, 1, 9, 25, 0, 2, 0, 18, 30, 13, 1, 9, 26, 0, 2, 0, 18, 31, 13, 1, 9, 27, 0, 2, 0, 18, 32, 13, 1, 9, 28, 0, 2, 0, 18, 33, 13, 1, 9, 29, 0, 2, 0, 18, 34, 13, 1, 9, 30, 0, 2, 0, 18, 35, 13, 1, 9, 31, 0, 2, 0, 18, 36, 13, 1, 9, 32, 0, 2, 0, 18, 37, 13, 1, 9, 33, 0, 2, 0, 18, 38, 13, 1, 9, 34, 0, 2, 0, 18, 39, 13, 1, 9, 35, 0, 2, 0, 18, 40, 13, 1, 9, 36, 0, 2, 0, 18, 41, 13, 1, 9, 37, 0, 2, 0, 18, 42, 13, 1, 9, 38, 0, 2, 0, 18, 43, 13, 1, 9, 39, 0, 2, 0, 18, 44, 13, 1, 9, 40, 0, 2, 0, 18, 45, 13, 1, 9, 41, 0, 2, 0, 18, 46, 13, 1, 9, 42, 0, 2, 0, 18, 47, 13, 1, 9, 43, 0, 2, 0, 18, 48, 13, 1, 9, 44, 0, 2, 0, 18, 49, 13, 1, 9, 45, 0, 2, 0, 18, 50, 13, 1, 9, 46, 0, 2, 0, 18, 51, 13, 1, 9, 47, 0, 2, 0, 18, 52, 13, 1, 9, 48, 0, 2, 0, 18, 53, 13, 1, 9, 49, 0, 2, 0, 18, 54, 13, 1, 9, 50, 0, 2, 0, 18, 55, 13, 1, 9, 51, 0, 2, 0, 18, 56, 13, 1, 9, 52, 0, 2, 0, 18, 57, 13, 1, 9, 53, 0, 2, 0, 18, 58, 13, 1, 9, 54, 0, 2, 0, 18, 59, 13, 1, 9, 55, 0, 0, 0, 61, 60, 56, 1, 9, 57, 0, 0, 0, 1, 62, -1, 0, 0, 46, 0, 64, 63, 58, 3, 9, 59, 65, 60, 66, 61, 0, 46, 0, 64, 67, 58, 3, 9, 62, 65, 63, 66, 64, 0, 46, 0, 64, 68, 58, 3, 9, 65, 65, 66, 66, 64, 0, 46, 0, 64, 69, 67, 1, 9, 68, 0, 0, 0, 71, 70, -1, 6, 72, 69, 73, 3, 74, 1, 75, 70, 76, 1, 77, 3, 0, 0, 0, 1, 78, -1, 0, 0, 52, 0, 61, 79, 71, 1, 9, 72, 0, 52, 0, 61, 80, 71, 1, 9, 73, 0, 52, 0, 61, 81, 71, 1, 9, 74, 0, 52, 0, 61, 82, 71, 1, 9, 75, 0, 52, 0, 61, 83, 71, 1, 9, 76, 0, 52, 0, 61, 84, 71, 1, 9, 77, 0, 52, 0, 61, 85, 71, 1, 9, 78, 0, 52, 0, 61, 86, 71, 1, 9, 79, 0, 52, 0, 61, 87, 71, 1, 9, 80, 0, 52, 0, 61, 88, 71, 1, 9, 81, 0, 52, 0, 61, 89, 71, 1, 9, 82, 0, 0, 0, 91, 90, 83, 0, 0, 0, 0, 92, 92, -1, 29, 5, 1, 6, 2, 7, 2, 8, 3, 93, 84, 94, 85, 95, 86, 96, 87, 97, 88, 98, 88, 99, 88, 100, 88, 101, 1, 102, 1, 103, 89, 104, 2, 105, 5, 106, 90, 107, 2, 108, 91, 109, 5, 110, 3, 111, 3, 112, 92, 113, 93, 114, 93, 115, 1, 116, 3, 117, 94, 0 </int_array> <string> "conns" </string> <int_array len="0"> </int_array> </dictionary> diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 399d0247fc..1af37e2a60 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -333,6 +333,12 @@ Error OS_Unix::kill(const ProcessID& p_pid) { return ret?ERR_INVALID_PARAMETER:OK; } +int OS_Unix::get_process_ID() const { + + return getpid(); +}; + + bool OS_Unix::has_environment(const String& p_var) const { return getenv(p_var.utf8().get_data())!=NULL; diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 72943ac25b..1dcf0bd2fd 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -98,6 +98,7 @@ public: virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL); virtual Error kill(const ProcessID& p_pid); + virtual int get_process_ID() const; virtual bool has_environment(const String& p_var) const; virtual String get_environment(const String& p_var) const; diff --git a/modules/SCsub b/modules/SCsub index 2cd2eeae83..9b42a14e31 100644 --- a/modules/SCsub +++ b/modules/SCsub @@ -10,7 +10,6 @@ env.modules_sources=[ #env.add_source_files(env.modules_sources,"*.cpp")
Export('env')
-
for x in env.module_list:
if (x in env.disabled_modules):
continue
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index c099c3f33c..f789493ae8 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -1095,7 +1095,7 @@ MethodInfo GDFunctions::get_info(Function p_func) { return mi; } break; case MATH_RAND: { - MethodInfo mi("rand"); + MethodInfo mi("randi"); mi.return_val.type=Variant::INT; return mi; } break; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 29857e6be6..75bb47ceab 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -635,6 +635,19 @@ Variant GDFunction::call(GDInstance *p_instance,const Variant **p_args, int p_ar err.argument-=1; } } + } if (methodstr=="free") { + + if (err.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) { + + if (base->is_ref()) { + err_text="Attempted to free a reference."; + break; + } else if (base->get_type()==Variant::OBJECT) { + + err_text="Attempted to free a locked object (calling or emitting)."; + break; + } + } } err_text=_get_call_error(err,"function '"+methodstr+"' in base '"+basestr+"'",(const Variant**)argptrs); break; diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template index 41be3e9d80..99c3650efa 100644 --- a/platform/android/AndroidManifest.xml.template +++ b/platform/android/AndroidManifest.xml.template @@ -11,7 +11,7 @@ android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTask" android:screenOrientation="landscape" - android:configChanges="orientation|keyboardHidden"> + android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> diff --git a/platform/android/java/ant.properties b/platform/android/java/ant.properties index dc3868516d..b0971e891e 100644 --- a/platform/android/java/ant.properties +++ b/platform/android/java/ant.properties @@ -15,8 +15,3 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. -key.store=/home/luis/Downloads/carnavalguachin.keystore -key.alias=momoselacome - -key.store.password=12345678 -key.alias.password=12345678 diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index 276ba63b29..ddb2dcfa75 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -135,7 +135,7 @@ public class Godot extends Activity implements SensorEventListener }; public ResultCallback result_callback; - private PaymentsManager mPaymentsManager; + private PaymentsManager mPaymentsManager = null; @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) { if(requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE){ @@ -168,6 +168,7 @@ public class Godot extends Activity implements SensorEventListener @Override protected void onCreate(Bundle icicle) { + System.out.printf("** GODOT ACTIVITY CREATED HERE ***\n"); super.onCreate(icicle); _self = this; diff --git a/platform/android/java/src/com/android/godot/GodotPaymentV3.java b/platform/android/java/src/com/android/godot/GodotPaymentV3.java new file mode 100644 index 0000000000..9d2893cde6 --- /dev/null +++ b/platform/android/java/src/com/android/godot/GodotPaymentV3.java @@ -0,0 +1,83 @@ +package com.android.godot; + + +import android.app.Activity; + + +public class GodotPaymentV3 extends Godot.SingletonBase { + + private Godot activity; + + private Integer purchaseCallbackId = 0; + + private String accessToken; + + private String purchaseValidationUrlPrefix; + + public void purchase( String _sku) { + final String sku = _sku; + activity.getPaymentsManager().setBaseSingleton(this); + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + activity.getPaymentsManager().requestPurchase(sku); + } + }); + }; + + + static public Godot.SingletonBase initialize(Activity p_activity) { + + return new GodotPaymentV3(p_activity); + } + + + public GodotPaymentV3(Activity p_activity) { + + registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix"}); + activity=(Godot) p_activity; + } + + + + public void callbackSuccess(){ + GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{}); + } + + public void callbackFail(){ + GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{}); + } + + public void callbackCancel(){ + GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{}); + } + + public int getPurchaseCallbackId() { + return purchaseCallbackId; + } + + public void setPurchaseCallbackId(int purchaseCallbackId) { + this.purchaseCallbackId = purchaseCallbackId; + } + + + + public String getPurchaseValidationUrlPrefix(){ + return this.purchaseValidationUrlPrefix ; + } + + public void setPurchaseValidationUrlPrefix(String url){ + this.purchaseValidationUrlPrefix = url; + } + + + public String getAccessToken() { + return accessToken; + } + + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + +} diff --git a/platform/android/java/src/com/android/godot/payments/ConsumeTask.java b/platform/android/java/src/com/android/godot/payments/ConsumeTask.java new file mode 100644 index 0000000000..62b33c002a --- /dev/null +++ b/platform/android/java/src/com/android/godot/payments/ConsumeTask.java @@ -0,0 +1,71 @@ +package com.android.godot.payments; + +import com.android.vending.billing.IInAppBillingService; + +import android.content.Context; +import android.os.AsyncTask; +import android.os.RemoteException; +import android.util.Log; + +abstract public class ConsumeTask { + + private Context context; + + private IInAppBillingService mService; + public ConsumeTask(IInAppBillingService mService, Context context ){ + this.context = context; + this.mService = mService; + } + + + public void consume(final String sku){ +// Log.d("XXX", "Consuming product " + sku); + PaymentsCache pc = new PaymentsCache(context); + Boolean isBlocked = pc.getConsumableFlag("block", sku); + String _token = pc.getConsumableValue("token", sku); +// Log.d("XXX", "token " + _token); + if(!isBlocked && _token == null){ +// _token = "inapp:"+context.getPackageName()+":android.test.purchased"; +// Log.d("XXX", "Consuming product " + sku + " with token " + _token); + }else if(!isBlocked){ +// Log.d("XXX", "It is not blocked ¿?"); + return; + }else if(_token == null){ +// Log.d("XXX", "No token available"); + this.error("No token for sku:" + sku); + return; + } + final String token = _token; + new AsyncTask<String, String, String>(){ + + @Override + protected String doInBackground(String... params) { + try { +// Log.d("XXX", "Requesting to release item."); + int response = mService.consumePurchase(3, context.getPackageName(), token); +// Log.d("XXX", "release response code: " + response); + if(response == 0 || response == 8){ + return null; + } + } catch (RemoteException e) { + return e.getMessage(); + + } + return "Some error"; + } + + protected void onPostExecute(String param){ + if(param == null){ + success(); + }else{ + error(param); + } + } + + }.execute(); + } + + abstract protected void success(); + abstract protected void error(String message); + +} diff --git a/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java new file mode 100644 index 0000000000..08fc405183 --- /dev/null +++ b/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java @@ -0,0 +1,79 @@ +package com.android.godot.payments; + +import org.json.JSONException; +import org.json.JSONObject; + +import com.android.godot.GodotLib; +import com.android.godot.utils.Crypt; +import com.android.vending.billing.IInAppBillingService; + +import android.app.Activity; +import android.app.PendingIntent; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.IntentSender.SendIntentException; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.RemoteException; +import android.util.Log; + +abstract public class HandlePurchaseTask { + + private Activity context; + + public HandlePurchaseTask(Activity context ){ + this.context = context; + } + + + public void handlePurchaseRequest(int resultCode, Intent data){ +// Log.d("XXX", "Handling purchase response"); +// int responseCode = data.getIntExtra("RESPONSE_CODE", 0); + PaymentsCache pc = new PaymentsCache(context); + + String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); +// String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); + + if (resultCode == Activity.RESULT_OK) { + + try { + Log.d("SARLANGA", purchaseData); + + + JSONObject jo = new JSONObject(purchaseData); +// String sku = jo.getString("productId"); +// alert("You have bought the " + sku + ". Excellent choice, aventurer!"); +// String orderId = jo.getString("orderId"); +// String packageName = jo.getString("packageName"); + String productId = jo.getString("productId"); +// Long purchaseTime = jo.getLong("purchaseTime"); +// Integer state = jo.getInt("purchaseState"); + String developerPayload = jo.getString("developerPayload"); + String purchaseToken = jo.getString("purchaseToken"); + + if(! pc.getConsumableValue("validation_hash", productId).equals(developerPayload) ) { + error("Untrusted callback"); + return; + } + + pc.setConsumableValue("ticket", productId, purchaseData); + pc.setConsumableFlag("block", productId, true); + pc.setConsumableValue("token", productId, purchaseToken); + + success(purchaseToken, productId); + return; + } catch (JSONException e) { + error(e.getMessage()); + } + }else if( resultCode == Activity.RESULT_CANCELED){ + canceled(); + } + } + + abstract protected void success(String purchaseToken, String sku); + abstract protected void error(String message); + abstract protected void canceled(); + + +} diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsCache.java b/platform/android/java/src/com/android/godot/payments/PaymentsCache.java new file mode 100644 index 0000000000..ba84097732 --- /dev/null +++ b/platform/android/java/src/com/android/godot/payments/PaymentsCache.java @@ -0,0 +1,42 @@ +package com.android.godot.payments; + +import android.content.Context; +import android.content.SharedPreferences; + +public class PaymentsCache { + + public Context context; + + public PaymentsCache(Context context){ + this.context = context; + } + + + public void setConsumableFlag(String set, String sku, Boolean flag){ + SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPref.edit(); + editor.putBoolean(sku, flag); + editor.commit(); +} + + public boolean getConsumableFlag(String set, String sku){ + SharedPreferences sharedPref = context.getSharedPreferences( + "consumables_" + set, Context.MODE_PRIVATE); + return sharedPref.getBoolean(sku, false); + } + + + public void setConsumableValue(String set, String sku, String value){ + SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPref.edit(); + editor.putString(sku, value); + editor.commit(); + } + + public String getConsumableValue(String set, String sku){ + SharedPreferences sharedPref = context.getSharedPreferences( + "consumables_" + set, Context.MODE_PRIVATE); + return sharedPref.getString(sku, null); + } + +} diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java new file mode 100644 index 0000000000..325e3a0751 --- /dev/null +++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java @@ -0,0 +1,151 @@ +package com.android.godot.payments; + +import android.app.Activity; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.IBinder; + +import com.android.godot.Godot; +import com.android.godot.GodotPaymentV3; +import com.android.vending.billing.IInAppBillingService; + +public class PaymentsManager { + + public static final int BILLING_RESPONSE_RESULT_OK = 0; + + + public static final int REQUEST_CODE_FOR_PURCHASE = 0x1001; + + + private Activity activity; + IInAppBillingService mService; + + + public void setActivity(Activity activity){ + this.activity = activity; + } + + public static PaymentsManager createManager(Activity activity){ + PaymentsManager manager = new PaymentsManager(activity); + return manager; + } + + private PaymentsManager(Activity activity){ + this.activity = activity; + } + + public PaymentsManager initService(){ + activity.bindService( + new Intent("com.android.vending.billing.InAppBillingService.BIND"), + mServiceConn, + Context.BIND_AUTO_CREATE); + return this; + } + + public void destroy(){ + if (mService != null) { + activity.unbindService(mServiceConn); + } + } + + ServiceConnection mServiceConn = new ServiceConnection() { + @Override + public void onServiceDisconnected(ComponentName name) { + mService = null; + } + + @Override + public void onServiceConnected(ComponentName name, + IBinder service) { + mService = IInAppBillingService.Stub.asInterface(service); + } + }; + + public void requestPurchase(String sku){ + new PurchaseTask(mService, Godot.getInstance()) { + + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); + + } + + @Override + protected void canceled() { + godotPaymentV3.callbackCancel(); + } + }.purchase(sku); + + } + + public void processPurchaseResponse(int resultCode, Intent data) { + new HandlePurchaseTask(activity){ + + @Override + protected void success(String purchaseToken, String sku) { + validatePurchase(purchaseToken, sku); + } + + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); + + } + + @Override + protected void canceled() { + godotPaymentV3.callbackCancel(); + + }}.handlePurchaseRequest(resultCode, data); + } + + public void validatePurchase(String purchaseToken, final String sku){ + + new ValidateTask(activity, godotPaymentV3){ + + @Override + protected void success() { + + new ConsumeTask(mService, activity) { + + @Override + protected void success() { + godotPaymentV3.callbackSuccess(); + + } + + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); + + } + }.consume(sku); + + } + + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); + + } + + @Override + protected void canceled() { + godotPaymentV3.callbackCancel(); + + } + }.validatePurchase(sku); + } + + private GodotPaymentV3 godotPaymentV3; + + public void setBaseSingleton(GodotPaymentV3 godotPaymentV3) { + this.godotPaymentV3 = godotPaymentV3; + + } + + +} + diff --git a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java new file mode 100644 index 0000000000..3b2cb78d27 --- /dev/null +++ b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java @@ -0,0 +1,121 @@ +package com.android.godot.payments; + +import org.json.JSONException; +import org.json.JSONObject; + +import com.android.godot.GodotLib; +import com.android.godot.utils.Crypt; +import com.android.vending.billing.IInAppBillingService; + +import android.app.Activity; +import android.app.PendingIntent; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.IntentSender.SendIntentException; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.RemoteException; +import android.util.Log; + +abstract public class PurchaseTask { + + private Activity context; + + private IInAppBillingService mService; + public PurchaseTask(IInAppBillingService mService, Activity context ){ + this.context = context; + this.mService = mService; + } + + + private boolean isLooping = false; + + public void purchase(final String sku){ +// Log.d("XXX", "Starting purchase"); + PaymentsCache pc = new PaymentsCache(context); + Boolean isBlocked = pc.getConsumableFlag("block", sku); +// if(isBlocked){ +// Log.d("XXX", "Is awaiting payment confirmation"); +// error("Awaiting payment confirmation"); +// return; +// } + final String hash = Crypt.createRandomHash() + Crypt.createRandomHash(); + + Bundle buyIntentBundle; + try { + buyIntentBundle = mService.getBuyIntent(3, context.getApplicationContext().getPackageName(), sku, "inapp", hash ); + } catch (RemoteException e) { +// Log.d("XXX", "Error: " + e.getMessage()); + error(e.getMessage()); + return; + } + Object rc = buyIntentBundle.get("RESPONSE_CODE"); + int responseCode = 0; + if(rc == null){ + responseCode = PaymentsManager.BILLING_RESPONSE_RESULT_OK; + }else if( rc instanceof Integer){ + responseCode = ((Integer)rc).intValue(); + }else if( rc instanceof Long){ + responseCode = (int)((Long)rc).longValue(); + } +// Log.d("XXX", "Buy intent response code: " + responseCode); + if(responseCode == 1 || responseCode == 3 || responseCode == 4){ + canceled(); + return ; + } + if(responseCode == 7){ + new ConsumeTask(mService, context) { + + @Override + protected void success() { +// Log.d("XXX", "Product was erroniously purchased!"); + if(isLooping){ +// Log.d("XXX", "It is looping"); + error("Error while purchasing product"); + return; + } + isLooping=true; + PurchaseTask.this.purchase(sku); + + } + + @Override + protected void error(String message) { + PurchaseTask.this.error(message); + + } + }.consume(sku); + return; + } + + + PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); + pc.setConsumableValue("validation_hash", sku, hash); + try { + if(context == null){ +// Log.d("XXX", "No context!"); + } + if(pendingIntent == null){ +// Log.d("XXX", "No pending intent"); + } +// Log.d("XXX", "Starting activity for purchase!"); + context.startIntentSenderForResult( + pendingIntent.getIntentSender(), + PaymentsManager.REQUEST_CODE_FOR_PURCHASE, + new Intent(), + Integer.valueOf(0), Integer.valueOf(0), + Integer.valueOf(0)); + } catch (SendIntentException e) { + error(e.getMessage()); + } + + + + } + + abstract protected void error(String message); + abstract protected void canceled(); + + +} diff --git a/platform/android/java/src/com/android/godot/payments/ValidateTask.java b/platform/android/java/src/com/android/godot/payments/ValidateTask.java new file mode 100644 index 0000000000..6ea415e8a9 --- /dev/null +++ b/platform/android/java/src/com/android/godot/payments/ValidateTask.java @@ -0,0 +1,97 @@ +package com.android.godot.payments; + +import org.json.JSONException; +import org.json.JSONObject; + +import com.android.godot.Godot; +import com.android.godot.GodotLib; +import com.android.godot.GodotPaymentV3; +import com.android.godot.utils.Crypt; +import com.android.godot.utils.HttpRequester; +import com.android.godot.utils.RequestParams; +import com.android.vending.billing.IInAppBillingService; + +import android.app.Activity; +import android.app.PendingIntent; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.IntentSender.SendIntentException; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.RemoteException; +import android.util.Log; + +abstract public class ValidateTask { + + private Activity context; + private GodotPaymentV3 godotPaymentsV3; + public ValidateTask(Activity context, GodotPaymentV3 godotPaymentsV3){ + this.context = context; + this.godotPaymentsV3 = godotPaymentsV3; + } + + public void validatePurchase(final String sku){ + new AsyncTask<String, String, String>(){ + + + private ProgressDialog dialog; + + @Override + protected void onPreExecute(){ + dialog = ProgressDialog.show(context, null, "Please wait..."); + } + + @Override + protected String doInBackground(String... params) { + PaymentsCache pc = new PaymentsCache(context); + String url = godotPaymentsV3.getPurchaseValidationUrlPrefix(); + RequestParams param = new RequestParams(); + param.setUrl(url); + param.put("ticket", pc.getConsumableValue("ticket", sku)); + param.put("purchaseToken", pc.getConsumableValue("token", sku)); + param.put("sku", sku); +// Log.d("XXX", "Haciendo request a " + url); +// Log.d("XXX", "ticket: " + pc.getConsumableValue("ticket", sku)); +// Log.d("XXX", "purchaseToken: " + pc.getConsumableValue("token", sku)); +// Log.d("XXX", "sku: " + sku); + param.put("package", context.getApplicationContext().getPackageName()); + HttpRequester requester = new HttpRequester(); + String jsonResponse = requester.post(param); +// Log.d("XXX", "Validation response:\n"+jsonResponse); + return jsonResponse; + } + + @Override + protected void onPostExecute(String response){ + if(dialog != null){ + dialog.dismiss(); + } + JSONObject j; + try { + j = new JSONObject(response); + if(j.getString("status").equals("OK")){ + success(); + return; + }else if(j.getString("status") != null){ + error(j.getString("message")); + }else{ + error("Connection error"); + } + } catch (JSONException e) { + error(e.getMessage()); + }catch (Exception e){ + error(e.getMessage()); + } + + + } + + }.execute(); + } + abstract protected void success(); + abstract protected void error(String message); + abstract protected void canceled(); + + +} diff --git a/platform/android/java/src/com/android/godot/utils/Crypt.java b/platform/android/java/src/com/android/godot/utils/Crypt.java new file mode 100644 index 0000000000..7801f474b9 --- /dev/null +++ b/platform/android/java/src/com/android/godot/utils/Crypt.java @@ -0,0 +1,39 @@ +package com.android.godot.utils; + +import java.security.MessageDigest; +import java.util.Random; + +public class Crypt { + + public static String md5(String input){ + try { + // Create MD5 Hash + MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); + digest.update(input.getBytes()); + byte messageDigest[] = digest.digest(); + + // Create Hex String + StringBuffer hexString = new StringBuffer(); + for (int i=0; i<messageDigest.length; i++) + hexString.append(Integer.toHexString(0xFF & messageDigest[i])); + return hexString.toString(); + + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + + public static String createRandomHash(){ + return md5(Long.toString(createRandomLong())); + } + + public static long createAbsRandomLong(){ + return Math.abs(createRandomLong()); + } + + public static long createRandomLong(){ + Random r = new Random(); + return r.nextLong(); + } +} diff --git a/platform/android/java/src/com/android/godot/utils/CustomSSLSocketFactory.java b/platform/android/java/src/com/android/godot/utils/CustomSSLSocketFactory.java new file mode 100644 index 0000000000..5f2b44fc8c --- /dev/null +++ b/platform/android/java/src/com/android/godot/utils/CustomSSLSocketFactory.java @@ -0,0 +1,54 @@ +package com.android.godot.utils; +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import org.apache.http.conn.ssl.SSLSocketFactory; + + +/** + * + * @author Luis Linietsky <luis.linietsky@gmail.com> + */ +public class CustomSSLSocketFactory extends SSLSocketFactory { + SSLContext sslContext = SSLContext.getInstance("TLS"); + + public CustomSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { + super(truststore); + + TrustManager tm = new X509TrustManager() { + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + } + + public X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + + sslContext.init(null, new TrustManager[] { tm }, null); + } + + @Override + public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { + return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); + } + + @Override + public Socket createSocket() throws IOException { + return sslContext.getSocketFactory().createSocket(); + } +}
\ No newline at end of file diff --git a/platform/android/java/src/com/android/godot/utils/HttpRequester.java b/platform/android/java/src/com/android/godot/utils/HttpRequester.java new file mode 100644 index 0000000000..7de77881d0 --- /dev/null +++ b/platform/android/java/src/com/android/godot/utils/HttpRequester.java @@ -0,0 +1,206 @@ +package com.android.godot.utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.security.KeyStore; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpVersion; +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.PlainSocketFactory; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.apache.http.params.HttpProtocolParams; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; + + +import android.content.Context; +import android.content.SharedPreferences; +import android.util.Log; + +/** + * + * @author Luis Linietsky <luis.linietsky@gmail.com> + */ +public class HttpRequester { + + private Context context; + private static final int TTL = 600000; // 10 minutos + private long cttl=0; + + public HttpRequester(){ +// Log.d("XXX", "Creando http request sin contexto"); + } + + public HttpRequester(Context context){ + this.context=context; +// Log.d("XXX", "Creando http request con contexto"); + } + + public String post(RequestParams params){ + HttpPost httppost = new HttpPost(params.getUrl()); + try { + httppost.setEntity(new UrlEncodedFormEntity(params.toPairsList())); + return request(httppost); + } catch (UnsupportedEncodingException e) { + return null; + } + } + + public String get(RequestParams params){ + String response = getResponseFromCache(params.getUrl()); + if(response == null){ +// Log.d("XXX", "Cache miss!"); + HttpGet httpget = new HttpGet(params.getUrl()); + long timeInit = new Date().getTime(); + response = request(httpget); + long delay = new Date().getTime() - timeInit; + Log.d("com.app11tt.android.utils.HttpRequest::get(url)", "Url: " + params.getUrl() + " downloaded in " + String.format("%.03f", delay/1000.0f) + " seconds"); + if(response == null || response.length() == 0){ + response = ""; + }else{ + saveResponseIntoCache(params.getUrl(), response); + } + } + Log.d("XXX", "Req: " + params.getUrl()); + Log.d("XXX", "Resp: " + response); + return response; + } + + private String request(HttpUriRequest request){ +// Log.d("XXX", "Haciendo request a: " + request.getURI() ); + Log.d("PPP", "Haciendo request a: " + request.getURI() ); + long init = new Date().getTime(); + HttpClient httpclient = getNewHttpClient(); + HttpParams httpParameters = httpclient.getParams(); + HttpConnectionParams.setConnectionTimeout(httpParameters, 0); + HttpConnectionParams.setSoTimeout(httpParameters, 0); + HttpConnectionParams.setTcpNoDelay(httpParameters, true); + try { + HttpResponse response = httpclient.execute(request); + Log.d("PPP", "Fin de request (" + (new Date().getTime() - init) + ") a: " + request.getURI() ); +// Log.d("XXX1", "Status:" + response.getStatusLine().toString()); + if(response.getStatusLine().getStatusCode() == 200){ + String strResponse = EntityUtils.toString(response.getEntity()); +// Log.d("XXX2", strResponse); + return strResponse; + }else{ + Log.d("XXX3", "Response status code:" + response.getStatusLine().getStatusCode() + "\n" + EntityUtils.toString(response.getEntity())); + return null; + } + + } catch (ClientProtocolException e) { + Log.d("XXX3", e.getMessage()); + } catch (IOException e) { + Log.d("XXX4", e.getMessage()); + } + return null; + } + + private HttpClient getNewHttpClient() { + try { + KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); + trustStore.load(null, null); + + SSLSocketFactory sf = new CustomSSLSocketFactory(trustStore); + sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + + HttpParams params = new BasicHttpParams(); + HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); + HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); + + SchemeRegistry registry = new SchemeRegistry(); + registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); + registry.register(new Scheme("https", sf, 443)); + + ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); + + return new DefaultHttpClient(ccm, params); + } catch (Exception e) { + return new DefaultHttpClient(); + } + } + + private static String convertStreamToString(InputStream is) { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder sb = new StringBuilder(); + String line = null; + try { + while ((line = reader.readLine()) != null) { + sb.append((line + "\n")); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return sb.toString(); + } + + public void saveResponseIntoCache(String request, String response){ + if(context == null){ +// Log.d("XXX", "No context, cache failed!"); + return; + } + SharedPreferences sharedPref = context.getSharedPreferences("http_get_cache", Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sharedPref.edit(); + editor.putString("request_" + Crypt.md5(request), response); + editor.putLong("request_" + Crypt.md5(request) + "_ttl", new Date().getTime() + getTtl()); + editor.commit(); + } + + + public String getResponseFromCache(String request){ + if(context == null){ + Log.d("XXX", "No context, cache miss"); + return null; + } + SharedPreferences sharedPref = context.getSharedPreferences( "http_get_cache", Context.MODE_PRIVATE); + long ttl = getResponseTtl(request); + if(ttl == 0l || (new Date().getTime() - ttl) > 0l){ + Log.d("XXX", "Cache invalid ttl:" + ttl + " vs now:" + new Date().getTime()); + return null; + } + return sharedPref.getString("request_" + Crypt.md5(request), null); + } + + public long getResponseTtl(String request){ + SharedPreferences sharedPref = context.getSharedPreferences( + "http_get_cache", Context.MODE_PRIVATE); + return sharedPref.getLong("request_" + Crypt.md5(request) + "_ttl", 0l); + } + + public long getTtl() { + return cttl > 0 ? cttl : TTL; + } + + public void setTtl(long ttl) { + this.cttl = (ttl*1000) + new Date().getTime(); + } + +} diff --git a/platform/android/java/src/com/android/godot/utils/RequestParams.java b/platform/android/java/src/com/android/godot/utils/RequestParams.java new file mode 100644 index 0000000000..31bf1940ad --- /dev/null +++ b/platform/android/java/src/com/android/godot/utils/RequestParams.java @@ -0,0 +1,58 @@ +package com.android.godot.utils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; + +/** + * + * @author Luis Linietsky <luis.linietsky@gmail.com> + */ +public class RequestParams { + + private HashMap<String,String> params; + private String url; + + public RequestParams(){ + params = new HashMap<String,String>(); + } + + public void put(String key, String value){ + params.put(key, value); + } + + public String get(String key){ + return params.get(key); + } + + public void remove(Object key){ + params.remove(key); + } + + public boolean has(String key){ + return params.containsKey(key); + } + + public List<NameValuePair> toPairsList(){ + List<NameValuePair> fields = new ArrayList<NameValuePair>(); + + for(String key : params.keySet()){ + fields.add(new BasicNameValuePair(key, this.get(key))); + } + return fields; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + +} diff --git a/platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl b/platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl new file mode 100644 index 0000000000..2a492f7845 --- /dev/null +++ b/platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.vending.billing; + +import android.os.Bundle; + +/** + * InAppBillingService is the service that provides in-app billing version 3 and beyond. + * This service provides the following features: + * 1. Provides a new API to get details of in-app items published for the app including + * price, type, title and description. + * 2. The purchase flow is synchronous and purchase information is available immediately + * after it completes. + * 3. Purchase information of in-app purchases is maintained within the Google Play system + * till the purchase is consumed. + * 4. An API to consume a purchase of an inapp item. All purchases of one-time + * in-app items are consumable and thereafter can be purchased again. + * 5. An API to get current purchases of the user immediately. This will not contain any + * consumed purchases. + * + * All calls will give a response code with the following possible values + * RESULT_OK = 0 - success + * RESULT_USER_CANCELED = 1 - user pressed back or canceled a dialog + * RESULT_BILLING_UNAVAILABLE = 3 - this billing API version is not supported for the type requested + * RESULT_ITEM_UNAVAILABLE = 4 - requested SKU is not available for purchase + * RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API + * RESULT_ERROR = 6 - Fatal error during the API action + * RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned + * RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned + */ +interface IInAppBillingService { + /** + * Checks support for the requested billing API version, package and in-app type. + * Minimum API version supported by this interface is 3. + * @param apiVersion the billing version which the app is using + * @param packageName the package name of the calling app + * @param type type of the in-app item being purchased "inapp" for one-time purchases + * and "subs" for subscription. + * @return RESULT_OK(0) on success, corresponding result code on failures + */ + int isBillingSupported(int apiVersion, String packageName, String type); + + /** + * Provides details of a list of SKUs + * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle + * with a list JSON strings containing the productId, price, title and description. + * This API can be called with a maximum of 20 SKUs. + * @param apiVersion billing API version that the Third-party is using + * @param packageName the package name of the calling app + * @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST" + * @return Bundle containing the following key-value pairs + * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on + * failure as listed above. + * "DETAILS_LIST" with a StringArrayList containing purchase information + * in JSON format similar to: + * '{ "productId" : "exampleSku", "type" : "inapp", "price" : "$5.00", + * "title : "Example Title", "description" : "This is an example description" }' + */ + Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle); + + /** + * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU, + * the type, a unique purchase token and an optional developer payload. + * @param apiVersion billing API version that the app is using + * @param packageName package name of the calling app + * @param sku the SKU of the in-app item as published in the developer console + * @param type the type of the in-app item ("inapp" for one-time purchases + * and "subs" for subscription). + * @param developerPayload optional argument to be sent back with the purchase information + * @return Bundle containing the following key-value pairs + * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on + * failure as listed above. + * "BUY_INTENT" - PendingIntent to start the purchase flow + * + * The Pending intent should be launched with startIntentSenderForResult. When purchase flow + * has completed, the onActivityResult() will give a resultCode of OK or CANCELED. + * If the purchase is successful, the result data will contain the following key-value pairs + * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on + * failure as listed above. + * "INAPP_PURCHASE_DATA" - String in JSON format similar to + * '{"orderId":"12999763169054705758.1371079406387615", + * "packageName":"com.example.app", + * "productId":"exampleSku", + * "purchaseTime":1345678900000, + * "purchaseToken" : "122333444455555", + * "developerPayload":"example developer payload" }' + * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that + * was signed with the private key of the developer + * TODO: change this to app-specific keys. + */ + Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type, + String developerPayload); + + /** + * Returns the current SKUs owned by the user of the type and package name specified along with + * purchase information and a signature of the data to be validated. + * This will return all SKUs that have been purchased in V3 and managed items purchased using + * V1 and V2 that have not been consumed. + * @param apiVersion billing API version that the app is using + * @param packageName package name of the calling app + * @param type the type of the in-app items being requested + * ("inapp" for one-time purchases and "subs" for subscription). + * @param continuationToken to be set as null for the first call, if the number of owned + * skus are too many, a continuationToken is returned in the response bundle. + * This method can be called again with the continuation token to get the next set of + * owned skus. + * @return Bundle containing the following key-value pairs + * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on + * failure as listed above. + * "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs + * "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information + * "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures + * of the purchase information + * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the + * next set of in-app purchases. Only set if the + * user has more owned skus than the current list. + */ + Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken); + + /** + * Consume the last purchase of the given SKU. This will result in this item being removed + * from all subsequent responses to getPurchases() and allow re-purchase of this item. + * @param apiVersion billing API version that the app is using + * @param packageName package name of the calling app + * @param purchaseToken token in the purchase information JSON that identifies the purchase + * to be consumed + * @return 0 if consumption succeeded. Appropriate error values for failures. + */ + int consumePurchase(int apiVersion, String packageName, String purchaseToken); +} diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index f50a36c259..201f08c35a 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -440,7 +440,8 @@ public: case Variant::STRING: { jobject o = env->CallObjectMethodA(instance,E->get().method,v); - String singname = env->GetStringUTFChars((jstring)o, NULL ); + String str = env->GetStringUTFChars((jstring)o, NULL ); + ret=str; } break; case Variant::STRING_ARRAY: { @@ -665,11 +666,12 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, initialized=true; - _godot_instance=activity; JavaVM *jvm; env->GetJavaVM(&jvm); + _godot_instance=env->NewGlobalRef(activity); +// _godot_instance=activity; __android_log_print(ANDROID_LOG_INFO,"godot","***************** HELLO FROM JNI!!!!!!!!"); @@ -816,8 +818,10 @@ static void _initialize_java_modules() { jmethodID getClassLoader = env->GetMethodID(activityClass,"getClassLoader", "()Ljava/lang/ClassLoader;"); jobject cls = env->CallObjectMethod(_godot_instance, getClassLoader); + //cls=env->NewGlobalRef(cls); jclass classLoader = env->FindClass("java/lang/ClassLoader"); + //classLoader=(jclass)env->NewGlobalRef(classLoader); jmethodID findClass = env->GetMethodID(classLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); @@ -835,6 +839,7 @@ static void _initialize_java_modules() { ERR_EXPLAIN("Couldn't find singleton for class: "+m); ERR_CONTINUE(!singletonClass); } + //singletonClass=(jclass)env->NewGlobalRef(singletonClass); __android_log_print(ANDROID_LOG_INFO,"godot","****^*^*?^*^*class data %x",singletonClass); jmethodID initialize = env->GetStaticMethodID(singletonClass, "initialize", "(Landroid/app/Activity;)Lcom/android/godot/Godot$SingletonBase;"); diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index c5889174cd..93b9563988 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -108,8 +108,15 @@ static int frame_count = 0; if ([[UIDevice currentDevice]respondsToSelector:@selector(identifierForVendor)]) { uuid = [UIDevice currentDevice].identifierForVendor.UUIDString; }else{ - // return [UIDevice currentDevice]. uniqueIdentifier - uuid = [[UIDevice currentDevice] performSelector:@selector(uniqueIdentifier)]; + + // before iOS 6, so just generate an identifier and store it + uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"identiferForVendor"]; + if( !uuid ) { + CFUUIDRef cfuuid = CFUUIDCreate(NULL); + uuid = (__bridge_transfer NSString*)CFUUIDCreateString(NULL, cfuuid); + CFRelease(cfuuid); + [[NSUserDefaults standardUserDefaults] setObject:uuid forKey:@"identifierForVendor"]; + } } OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String])); diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 61ec87ccc1..4b95ef2bea 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -37,7 +37,6 @@ def get_flags(): ('tools', 'yes'), ('nedmalloc', 'no'), ('webp', 'yes'), - ('module_FacebookScorer_ios_enabled', 'no'), ] diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index a603e8dbf3..4570342613 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -64,25 +64,22 @@ bool _play_video(String p_path) { p_path = Globals::get_singleton()->globalize_path(p_path); - // NSString *file_path = [NSString stringWithCString:p_path.utf8().get_data() encoding:NSASCIIStringEncoding]; NSString* file_path = [[[NSString alloc] initWithUTF8String:p_path.utf8().get_data()] autorelease]; NSURL *file_url = [NSURL fileURLWithPath:file_path]; _instance.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:file_url]; _instance.moviePlayerController.controlStyle = MPMovieControlStyleNone; - [_instance.moviePlayerController setScalingMode:MPMovieScalingModeAspectFit]; - // [_instance.moviePlayerController setScalingMode:MPMovieScalingModeAspectFill]; + // [_instance.moviePlayerController setScalingMode:MPMovieScalingModeAspectFit]; + [_instance.moviePlayerController setScalingMode:MPMovieScalingModeAspectFill]; [[NSNotificationCenter defaultCenter] addObserver:_instance selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:_instance.moviePlayerController]; - - [[_instance window] makeKeyAndVisible]; - _instance.backgroundWindow = [[UIApplication sharedApplication] keyWindow]; - [_instance.moviePlayerController.view setFrame:_instance.backgroundWindow.frame]; + + [_instance.moviePlayerController.view setFrame:_instance.bounds]; _instance.moviePlayerController.view.userInteractionEnabled = NO; - [_instance.backgroundWindow addSubview:_instance.moviePlayerController.view]; + [_instance addSubview:_instance.moviePlayerController.view]; [_instance.moviePlayerController play]; return true; @@ -484,6 +481,14 @@ static void clear_touches() { return self; } +// -(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers { +// return YES; +// } + +// - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ +// return YES; +// } + // Stop animating and release resources when they are no longer needed. - (void)dealloc { @@ -510,8 +515,4 @@ static void clear_touches() { _stop_video(); } -- (void)handleTap:(UITapGestureRecognizer *)gesture { - NSLog(@"Gesture\n"); -} - @end diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index 316e619e11..71e95666af 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -167,6 +167,31 @@ Error InAppStore::request_product_info(Variant p_params) { ret["type"] = "purchase"; ret["result"] = "ok"; ret["product_id"] = pid; + + if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){ + + NSURL *receiptFileURL = nil; + NSBundle *bundle = [NSBundle mainBundle]; + if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) { + + // Get the transaction receipt file path location in the app bundle. + receiptFileURL = [bundle appStoreReceiptURL]; + + // Read in the contents of the transaction file. + ret["receipt"] = receiptFileURL; + + } else { + // Fall back to deprecated transaction receipt, + // which is still available in iOS 7. + + // Use SKPaymentTransaction's transactionReceipt. + ret["receipt"] = transaction.transactionReceipt; + } + + }else{ + ret["receipt"] = transaction.transactionReceipt; + } + InAppStore::get_singleton()->_post_event(ret); [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; } break; diff --git a/platform/isim/detect.py b/platform/isim/detect.py index 48f71bbef5..c89ca81167 100644 --- a/platform/isim/detect.py +++ b/platform/isim/detect.py @@ -38,7 +38,6 @@ def get_flags(): ('tools', 'yes'), ('nedmalloc', 'no'), ('webp', 'yes'), - ('module_FacebookScorer_ios_enabled', 'no'), ] diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 8a461c76fc..0f87d52d63 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -715,17 +715,18 @@ bool CanvasItem::is_block_transform_notify_enabled() const { return block_transform_notify; } -void CanvasItem::set_on_top(bool p_on_top) { +void CanvasItem::set_draw_behind_parent(bool p_enable) { - if (on_top==p_on_top) + if (behind==p_enable) return; - on_top=p_on_top; - VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,on_top); + behind=p_enable; + VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,!behind); + } -bool CanvasItem::is_on_top() const { +bool CanvasItem::is_draw_behind_parent_enabled() const{ - return on_top; + return behind; } @@ -764,8 +765,11 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity); ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity); - ObjectTypeDB::bind_method(_MD("set_on_top","on_top"),&CanvasItem::set_on_top); - ObjectTypeDB::bind_method(_MD("is_on_top"),&CanvasItem::is_on_top); + ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enabe"),&CanvasItem::set_draw_behind_parent); + ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled); + + ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top); + ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top); //ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform); @@ -796,7 +800,8 @@ void CanvasItem::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") ); ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") ); ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top"), _SCS("set_on_top"),_SCS("is_on_top") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), _SCS("set_blend_mode"),_SCS("get_blend_mode") ); //exporting these two things doesn't really make much sense i think @@ -859,7 +864,7 @@ CanvasItem::CanvasItem() : xform_change(this) { first_draw=false; blend_mode=BLEND_MODE_MIX; drawing=false; - on_top=true; + behind=false; block_transform_notify=false; viewport=NULL; canvas_layer=NULL; diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 0da4aa3086..5489e105d9 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -77,7 +77,7 @@ private: bool pending_children_sort; bool drawing; bool block_transform_notify; - bool on_top; + bool behind; mutable Matrix32 global_transform; mutable bool global_invalid; @@ -102,6 +102,9 @@ private: void _notify_transform(CanvasItem *p_node); + void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); } + bool _is_on_top() const { return !is_draw_behind_parent_enabled(); } + protected: @@ -175,8 +178,8 @@ public: void set_as_toplevel(bool p_toplevel); bool is_set_as_toplevel() const; - void set_on_top(bool p_on_top); - bool is_on_top() const; + void set_draw_behind_parent(bool p_enable); + bool is_draw_behind_parent_enabled() const; CanvasItem *get_parent_item() const; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 53d36e64ea..83c0397554 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -351,11 +351,13 @@ void Control::_notification(int p_notification) { window->tooltip_timer = memnew( Timer ); add_child(window->tooltip_timer); + window->tooltip_timer->force_parent_owned(); window->tooltip_timer->set_wait_time( GLOBAL_DEF("display/tooltip_delay",0.7)); window->tooltip_timer->connect("timeout",this,"_window_show_tooltip"); window->tooltip=NULL; window->tooltip_popup = memnew( TooltipPanel ); add_child(window->tooltip_popup); + window->tooltip_popup->force_parent_owned(); window->tooltip_label = memnew( TooltipLabel ); window->tooltip_popup->add_child(window->tooltip_label); window->tooltip_popup->set_as_toplevel(true); diff --git a/scene/main/node.h b/scene/main/node.h index ec03fb19e8..828acb8de7 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -264,6 +264,8 @@ public: static void set_human_readable_collision_renaming(bool p_enabled); static void init_node_hrcr(); + void force_parent_owned() { data.parent_owned=true; } //hack to avoid duplicate nodes + /* CANVAS */ Node(); diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 931125a1c0..669240b8da 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -375,6 +375,18 @@ bool BodyPair2DSW::setup(float p_step) { } #endif + + + c.bounce=MAX(A->get_bounce(),B->get_bounce()); + if (c.bounce) { + + Vector2 crA( -A->get_angular_velocity() * c.rA.y, A->get_angular_velocity() * c.rA.x ); + Vector2 crB( -B->get_angular_velocity() * c.rB.y, B->get_angular_velocity() * c.rB.x ); + Vector2 dv = B->get_linear_velocity() + crB - A->get_linear_velocity() - crA; + c.bounce = c.bounce * dv.dot(c.normal); + } + + } return true; @@ -420,8 +432,7 @@ void BodyPair2DSW::solve(float p_step) { A->apply_bias_impulse(c.rA,-jb); B->apply_bias_impulse(c.rB, jb); - real_t bounce=MAX(A->get_bounce(),B->get_bounce()); - real_t jn = -(bounce + vn)*c.mass_normal; + real_t jn = -(c.bounce + vn)*c.mass_normal; real_t jnOld = c.acc_normal_impulse; c.acc_normal_impulse = MAX(jnOld + jn, 0.0f); diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h index ebe26776ed..15d7e62d3a 100644 --- a/servers/physics_2d/body_pair_2d_sw.h +++ b/servers/physics_2d/body_pair_2d_sw.h @@ -66,6 +66,8 @@ class BodyPair2DSW : public Constraint2DSW { bool active; Vector2 rA,rB; bool reused; + float bounce; + }; Vector2 offset_B; //use local A coordinates to avoid numerical issues on collision detection diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index ca1e769ffa..ea87ac625b 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -510,6 +510,20 @@ void CodeTextEditor::set_error(const String& p_error) { } +void CodeTextEditor::_update_font() { + + String editor_font = EditorSettings::get_singleton()->get("text_editor/font"); + if (editor_font!="") { + Ref<Font> fnt = ResourceLoader::load(editor_font); + if (fnt.is_valid()) { + text_editor->add_font_override("font",fnt); + return; + } + } + + text_editor->add_font_override("font",get_font("source","Fonts")); +} + void CodeTextEditor::_text_changed_idle_timeout() { @@ -527,8 +541,9 @@ void CodeTextEditor::_bind_methods() { ObjectTypeDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed); ObjectTypeDB::bind_method("_text_changed",&CodeTextEditor::_text_changed); + ObjectTypeDB::bind_method("_update_font",&CodeTextEditor::_update_font); ObjectTypeDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout); - ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request); + ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request); } CodeTextEditor::CodeTextEditor() { @@ -571,4 +586,5 @@ CodeTextEditor::CodeTextEditor() { text_editor->set_completion(true,cs); idle->connect("timeout", this,"_text_changed_idle_timeout"); + EditorSettings::get_singleton()->connect("settings_changed",this,"_update_font"); } diff --git a/tools/editor/code_editor.h b/tools/editor/code_editor.h index fc8285d161..5a588d2ccb 100644 --- a/tools/editor/code_editor.h +++ b/tools/editor/code_editor.h @@ -131,7 +131,9 @@ class CodeTextEditor : public Control { Label *error; - void _complete_request(const String& p_request,int p_line); + void _update_font(); + + void _complete_request(const String& p_request,int p_line); protected: void set_error(const String& p_error); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index af61022af2..efb0f72239 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3263,6 +3263,14 @@ EditorNode::EditorNode() { editor_register_icons(theme); editor_register_fonts(theme); + String global_font = EditorSettings::get_singleton()->get("global/font"); + if (global_font!="") { + Ref<Font> fnt = ResourceLoader::load(global_font); + if (fnt.is_valid()) { + theme->set_default_theme_font(fnt); + } + } + Ref<StyleBoxTexture> focus_sbt=memnew( StyleBoxTexture ); focus_sbt->set_texture(theme->get_icon("EditorFocus","EditorIcons")); for(int i=0;i<4;i++) { diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 6f4db7412b..6d3384d0f7 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -384,6 +384,9 @@ void EditorSettings::_load_defaults() { _THREAD_SAFE_METHOD_ + set("global/font",""); + hints["global/font"]=PropertyInfo(Variant::STRING,"global/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt"); + set("text_editor/background_color",Color::html("3b000000")); set("text_editor/text_color",Color::html("aaaaaa")); set("text_editor/text_selected_color",Color::html("000000")); @@ -398,6 +401,9 @@ void EditorSettings::_load_defaults() { set("text_editor/idle_parse_delay",2); set("text_editor/create_signal_callbacks",true); set("text_editor/autosave_interval_seconds",60); + set("text_editor/font",""); + hints["text_editor/font"]=PropertyInfo(Variant::STRING,"text_editor/font",PROPERTY_HINT_GLOBAL_FILE,"*.fnt"); + set("3d_editor/default_fov",45.0); set("3d_editor/default_z_near",0.1); @@ -429,9 +435,9 @@ void EditorSettings::_load_defaults() { set("import/pvrtc_texture_tool",""); #ifdef WINDOWS_ENABLED - hints["import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_FILE,"*.exe"); + hints["import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_GLOBAL_FILE,"*.exe"); #else - hints["import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_FILE,""); + hints["import/pvrtc_texture_tool"]=PropertyInfo(Variant::STRING,"import/pvrtc_texture_tool",PROPERTY_HINT_GLOBAL_FILE,""); #endif set("PVRTC/fast_conversion",false); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 1cce161d08..c2243bcc03 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -909,7 +909,14 @@ void CustomPropertyEditor::_action_pressed(int p_which) { Vector<String> extensions=hint_text.split(","); for(int i=0;i<extensions.size();i++) { - file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper() ); + String filter = extensions[i]; + if (filter.begins_with(".")) + filter="*"+extensions[i]; + else if (!filter.begins_with("*")) + filter="*."+extensions[i]; + + + file->add_filter(filter+" ; "+extensions[i].to_upper() ); } } |