diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/array.cpp | 31 | ||||
-rw-r--r-- | core/array.h | 2 | ||||
-rw-r--r-- | core/bind/core_bind.cpp | 11 | ||||
-rw-r--r-- | core/bind/core_bind.h | 3 | ||||
-rw-r--r-- | core/input_map.cpp | 92 | ||||
-rw-r--r-- | core/input_map.h | 3 | ||||
-rw-r--r-- | core/io/http_client.cpp | 2 | ||||
-rw-r--r-- | core/io/http_client.h | 2 | ||||
-rw-r--r-- | core/object.cpp | 18 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | core/os/os.cpp | 17 | ||||
-rw-r--r-- | core/os/os.h | 4 | ||||
-rw-r--r-- | core/resource.cpp | 1 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 14 | ||||
-rw-r--r-- | core/script_debugger_remote.h | 2 | ||||
-rw-r--r-- | core/script_language.cpp | 2 | ||||
-rw-r--r-- | core/script_language.h | 7 | ||||
-rw-r--r-- | core/variant_call.cpp | 4 | ||||
-rw-r--r-- | core/variant_op.cpp | 10 | ||||
-rw-r--r-- | core/variant_parser.cpp | 39 |
20 files changed, 254 insertions, 11 deletions
diff --git a/core/array.cpp b/core/array.cpp index fef0fcbb40..1d283a14aa 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -155,6 +155,37 @@ int Array::find(const Variant& p_value) const { return _p->array.find(p_value); } +int Array::find_last(const Variant& p_value) const { + + if(_p->array.size() == 0) + return -1; + + for (int i=_p->array.size()-1; i>=0; i--) { + + if(_p->array[i] == p_value){ + return i; + }; + }; + + return -1; +} + +int Array::count(const Variant& p_value) const { + + if(_p->array.size() == 0) + return 0; + + int amount=0; + for (int i=0; i<_p->array.size(); i++) { + + if(_p->array[i] == p_value){ + amount++; + }; + }; + + return amount; +} + void Array::remove(int p_pos) { _p->array.remove(p_pos); diff --git a/core/array.h b/core/array.h index ecb91b69dc..9472a6dd21 100644 --- a/core/array.h +++ b/core/array.h @@ -72,6 +72,8 @@ public: void invert(); int find(const Variant& p_value) const; + int find_last(const Variant& p_value) const; + int count(const Variant& p_value) const; void erase(const Variant& p_value); diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index addc26525e..31c0c0e208 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -436,6 +436,15 @@ Error _OS::set_thread_name(const String& p_name) { return Thread::set_name(p_name); }; +void _OS::set_use_vsync(bool p_enable) { + OS::get_singleton()->set_use_vsync(p_enable); +} + +bool _OS::is_vsnc_enabled() const { + + return OS::get_singleton()->is_vsnc_enabled(); +} + /* enum Weekday { @@ -1110,6 +1119,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name); + ObjectTypeDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync); + ObjectTypeDB::bind_method(_MD("is_vsnc_enabled"),&_OS::is_vsnc_enabled); BIND_CONSTANT( DAY_SUNDAY ); BIND_CONSTANT( DAY_MONDAY ); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index af89536c45..441927940d 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -282,6 +282,9 @@ public: Error set_thread_name(const String& p_name); + void set_use_vsync(bool p_enable); + bool is_vsnc_enabled() const; + static _OS *get_singleton() { return singleton; } _OS(); diff --git a/core/input_map.cpp b/core/input_map.cpp index 17e98902a1..08ee8138a3 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -28,6 +28,7 @@ /*************************************************************************/ #include "input_map.h" #include "globals.h" +#include "os/keyboard.h" InputMap *InputMap::singleton=NULL; @@ -36,6 +37,7 @@ void InputMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_action","action"),&InputMap::has_action); ObjectTypeDB::bind_method(_MD("get_action_id","action"),&InputMap::get_action_id); ObjectTypeDB::bind_method(_MD("get_action_from_id","id"),&InputMap::get_action_from_id); + ObjectTypeDB::bind_method(_MD("get_actions"),&InputMap::_get_actions); ObjectTypeDB::bind_method(_MD("add_action","action"),&InputMap::add_action); ObjectTypeDB::bind_method(_MD("erase_action","action"),&InputMap::erase_action); @@ -75,6 +77,35 @@ StringName InputMap::get_action_from_id(int p_id) const { return input_id_map[p_id]; } +Array InputMap::_get_actions() { + + Array ret; + List<StringName> actions = get_actions(); + if(actions.empty()) + return ret; + + for(const List<StringName>::Element *E=actions.front();E;E=E->next()) { + + ret.push_back(E->get()); + } + + return ret; +} + +List<StringName> InputMap::get_actions() const { + + List<StringName> actions = List<StringName>(); + if(input_map.empty()){ + return actions; + } + + for (Map<StringName, Action>::Element *E=input_map.front();E;E=E->next()) { + actions.push_back(E->key()); + } + + return actions; +} + List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const { for (List<InputEvent>::Element *E=p_list.front();E;E=E->next()) { @@ -291,6 +322,67 @@ void InputMap::load_from_globals() { } +void InputMap::load_default() { + + InputEvent key; + key.type=InputEvent::KEY; + + add_action("ui_accept"); + key.key.scancode=KEY_RETURN; + action_add_event("ui_accept",key); + key.key.scancode=KEY_ENTER; + action_add_event("ui_accept",key); + key.key.scancode=KEY_SPACE; + action_add_event("ui_accept",key); + + add_action("ui_select"); + key.key.scancode=KEY_SPACE; + action_add_event("ui_select",key); + + add_action("ui_cancel"); + key.key.scancode=KEY_ESCAPE; + action_add_event("ui_cancel",key); + + add_action("ui_focus_next"); + key.key.scancode=KEY_TAB; + action_add_event("ui_focus_next",key); + + add_action("ui_focus_prev"); + key.key.scancode=KEY_TAB; + key.key.mod.shift=true; + action_add_event("ui_focus_prev",key); + key.key.mod.shift=false; + + add_action("ui_left"); + key.key.scancode=KEY_LEFT; + action_add_event("ui_left",key); + + add_action("ui_right"); + key.key.scancode=KEY_RIGHT; + action_add_event("ui_right",key); + + add_action("ui_up"); + key.key.scancode=KEY_UP; + action_add_event("ui_up",key); + + add_action("ui_down"); + key.key.scancode=KEY_DOWN; + action_add_event("ui_down",key); + + + add_action("ui_page_up"); + key.key.scancode=KEY_PAGEUP; + action_add_event("ui_page_up",key); + + add_action("ui_page_down"); + key.key.scancode=KEY_PAGEDOWN; + action_add_event("ui_page_down",key); + +// set("display/orientation", "landscape"); + + +} + InputMap::InputMap() { ERR_FAIL_COND(singleton); diff --git a/core/input_map.h b/core/input_map.h index 5cd1e41922..dc5a911963 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -47,6 +47,7 @@ class InputMap : public Object { List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const; Array _get_action_list(const StringName& p_action); + Array _get_actions(); protected: @@ -59,6 +60,7 @@ public: bool has_action(const StringName& p_action) const; int get_action_id(const StringName& p_action) const; StringName get_action_from_id(int p_id) const; + List<StringName> get_actions() const; void add_action(const StringName& p_action); void erase_action(const StringName& p_action); @@ -72,6 +74,7 @@ public: void load_from_globals(); + void load_default(); InputMap(); }; diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 11f9536243..3520680118 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -639,7 +639,7 @@ void HTTPClient::_bind_methods() { ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true)); ObjectTypeDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection); ObjectTypeDB::bind_method(_MD("get_connection:StreamPeer"),&HTTPClient::get_connection); - ObjectTypeDB::bind_method(_MD("request_raw","method","url","headers","body"),&HTTPClient::request_raw,DEFVAL(String())); + ObjectTypeDB::bind_method(_MD("request_raw","method","url","headers","body"),&HTTPClient::request_raw); ObjectTypeDB::bind_method(_MD("request","method","url","headers","body"),&HTTPClient::request,DEFVAL(String())); ObjectTypeDB::bind_method(_MD("send_body_text","body"),&HTTPClient::send_body_text); ObjectTypeDB::bind_method(_MD("send_body_data","body"),&HTTPClient::send_body_data); diff --git a/core/io/http_client.h b/core/io/http_client.h index a9cfb1ed73..ceb0273a7d 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -40,7 +40,7 @@ class HTTPClient : public Reference { OBJ_TYPE(HTTPClient,Reference); public: - enum RespondeCode { + enum ResponseCode { // 1xx informational RESPONSE_CONTINUE = 100, diff --git a/core/object.cpp b/core/object.cpp index d7878fd623..bedab63281 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1383,6 +1383,24 @@ void Object::get_signal_connection_list(const StringName& p_signal,List<Connecti } +bool Object::has_persistent_signal_connections() const { + + const StringName *S=NULL; + + while((S=signal_map.next(S))) { + + const Signal *s=&signal_map[*S]; + + for(int i=0;i<s->slot_map.size();i++) { + + if (s->slot_map.getv(i).conn.flags&CONNECT_PERSIST) + return true; + } + } + + return false; +} + Error Object::connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds,uint32_t p_flags) { diff --git a/core/object.h b/core/object.h index f4a2472e88..e886aa3459 100644 --- a/core/object.h +++ b/core/object.h @@ -604,6 +604,7 @@ public: void get_signal_list(List<MethodInfo> *p_signals ) const; void get_signal_connection_list(const StringName& p_signal,List<Connection> *p_connections) const; void get_all_signal_connections(List<Connection> *p_connections) const; + bool has_persistent_signal_connections() const; Error connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds=Vector<Variant>(),uint32_t p_flags=0); void disconnect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method); diff --git a/core/os/os.cpp b/core/os/os.cpp index 6910b368d3..e501bc2eb5 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -306,6 +306,15 @@ String OS::get_system_dir(SystemDir p_dir) const { return "."; } +String OS::get_safe_application_name() const { + String an = Globals::get_singleton()->get("application/name"); + Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" "); + for (int i=0;i<invalid_char.size();i++) { + an = an.replace(invalid_char[i],"-"); + } + return an; +} + String OS::get_data_dir() const { return "."; @@ -530,6 +539,14 @@ String OS::get_joy_guid(int p_device) const { void OS::set_context(int p_context) { } +void OS::set_use_vsync(bool p_enable) { + +} + +bool OS::is_vsnc_enabled() const{ + + return true; +} OS::OS() { last_error=NULL; diff --git a/core/os/os.h b/core/os/os.h index 76dd235d24..c291d09250 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -326,6 +326,7 @@ public: virtual String get_locale() const; + String get_safe_application_name() const; virtual String get_data_dir() const; virtual String get_resource_dir() const; @@ -419,6 +420,9 @@ public: virtual void set_context(int p_context); + virtual void set_use_vsync(bool p_enable); + virtual bool is_vsnc_enabled() const; + bool is_hidpi_allowed() const { return _allow_hidpi; } OS(); virtual ~OS(); diff --git a/core/resource.cpp b/core/resource.cpp index b7a5bad4b8..97dee3e1d7 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -133,6 +133,7 @@ void ResourceImportMetadata::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_source","path","md5"),&ResourceImportMetadata::add_source, ""); ObjectTypeDB::bind_method(_MD("get_source_path","idx"),&ResourceImportMetadata::get_source_path); ObjectTypeDB::bind_method(_MD("get_source_md5","idx"),&ResourceImportMetadata::get_source_md5); + ObjectTypeDB::bind_method(_MD("set_source_md5","idx", "md5"),&ResourceImportMetadata::set_source_md5); ObjectTypeDB::bind_method(_MD("remove_source","idx"),&ResourceImportMetadata::remove_source); ObjectTypeDB::bind_method(_MD("get_source_count"),&ResourceImportMetadata::get_source_count); ObjectTypeDB::bind_method(_MD("set_option","key","value"),&ResourceImportMetadata::set_option); diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 011b1f78a0..99d1e22c07 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -291,6 +291,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { _set_object_property(cmd[1],cmd[2],cmd[3]); + } else if (command=="reload_scripts") { + reload_all_scripts=true; } else if (command=="breakpoint") { bool set = cmd[3]; @@ -698,7 +700,8 @@ void ScriptDebuggerRemote::_poll_events() { profiling=false; _send_profiling_data(false); print_line("PROFILING END!"); - + } else if (command=="reload_scripts") { + reload_all_scripts=true; } else if (command=="breakpoint") { bool set = cmd[3]; @@ -863,6 +866,14 @@ void ScriptDebuggerRemote::idle_poll() { } } + if (reload_all_scripts) { + + for(int i=0;i<ScriptServer::get_language_count();i++) { + ScriptServer::get_language(i)->reload_all_scripts(); + } + reload_all_scripts=false; + } + _poll_events(); } @@ -1012,6 +1023,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() { profile_info_ptrs.resize(profile_info.size()); profiling=false; max_frame_functions=16; + reload_all_scripts=false; } diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 8fdab47013..c6a00e189f 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -60,6 +60,7 @@ class ScriptDebuggerRemote : public ScriptDebugger { bool profiling; int max_frame_functions; bool skip_profile_frame; + bool reload_all_scripts; Ref<StreamPeerTCP> tcp_client; @@ -168,6 +169,7 @@ public: virtual void profiling_end(); virtual void profiling_set_frame_times(float p_frame_time,float p_idle_time,float p_fixed_time,float p_fixed_frame_time); + ScriptDebuggerRemote(); ~ScriptDebuggerRemote(); }; diff --git a/core/script_language.cpp b/core/script_language.cpp index 1503418269..b3116a0297 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -51,7 +51,7 @@ void Script::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_source_code"),&Script::has_source_code); ObjectTypeDB::bind_method(_MD("get_source_code"),&Script::get_source_code); ObjectTypeDB::bind_method(_MD("set_source_code","source"),&Script::set_source_code); - ObjectTypeDB::bind_method(_MD("reload"),&Script::reload); + ObjectTypeDB::bind_method(_MD("reload","keep_state"),&Script::reload,DEFVAL(false)); } diff --git a/core/script_language.h b/core/script_language.h index bd76107acf..d8b4c61b6c 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -87,7 +87,7 @@ public: virtual bool has_source_code() const=0; virtual String get_source_code() const=0; virtual void set_source_code(const String& p_code)=0; - virtual Error reload()=0; + virtual Error reload(bool p_keep_state=false)=0; virtual bool is_tool() const=0; @@ -127,6 +127,8 @@ public: virtual Ref<Script> get_script() const=0; + virtual bool is_placeholder() const { return false; } + virtual ScriptLanguage *get_language()=0; virtual ~ScriptInstance(); }; @@ -189,6 +191,7 @@ public: virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); } + virtual void reload_all_scripts()=0; /* LOADER FUNCTIONS */ virtual void get_recognized_extensions(List<String> *p_extensions) const=0; @@ -248,6 +251,8 @@ public: void update(const List<PropertyInfo> &p_properties,const Map<StringName,Variant>& p_values); //likely changed in editor + virtual bool is_placeholder() const { return true; } + PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script,Object *p_owner); ~PlaceHolderScriptInstance(); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 4be763a511..f5dcd75691 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -463,6 +463,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM2(Array,insert); VCALL_LOCALMEM1(Array,remove); VCALL_LOCALMEM1R(Array,find); + VCALL_LOCALMEM1R(Array,find_last); + VCALL_LOCALMEM1R(Array,count); VCALL_LOCALMEM1(Array,erase); VCALL_LOCALMEM0(Array,sort); VCALL_LOCALMEM2(Array,sort_custom); @@ -1448,6 +1450,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray()); ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray()); ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray()); + ADDFUNC1(ARRAY,INT,Array,find_last,NIL,"value",varray()); + ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray()); ADDFUNC0(ARRAY,NIL,Array,pop_back,varray()); ADDFUNC0(ARRAY,NIL,Array,pop_front,varray()); ADDFUNC0(ARRAY,NIL,Array,sort,varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index a9cc37168d..6065094da7 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -1354,7 +1354,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) return; } else if (*str=="r8" ) { valid=true; - v->g=float(p_value)/255.0; + v->r=float(p_value)/255.0; return; } else if (*str=="g8" ) { valid=true; @@ -2213,16 +2213,16 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const { return v->get_v(); } else if (*str=="r8") { valid=true; - return v->r*255.0; + return (int)Math::round(v->r*255.0); } else if (*str=="g8" ) { valid=true; - return v->g*255.0; + return (int)Math::round(v->g*255.0); } else if (*str=="b8" ) { valid=true; - return v->b*255.0; + return (int)Math::round(v->b*255.0); } else if (*str=="a8" ) { valid=true; - return v->a*255.0; + return (int)Math::round(v->a*255.0); } } else if (p_index.get_type()==Variant::INT) { diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 8bd1fddfad..e2786b8099 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -2011,7 +2011,44 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str } break; case Variant::INPUT_EVENT: { - p_store_string_func(p_store_string_ud,"InputEvent()"); //will be added later + String str="InputEvent("; + + InputEvent ev=p_variant; + switch(ev.type) { + case InputEvent::KEY: { + + str+="KEY,"+itos(ev.key.scancode); + String mod; + if (ev.key.mod.alt) + mod+="A"; + if (ev.key.mod.shift) + mod+="S"; + if (ev.key.mod.control) + mod+="C"; + if (ev.key.mod.meta) + mod+="M"; + + if (mod!=String()) + str+=","+mod; + } break; + case InputEvent::MOUSE_BUTTON: { + + str+="MBUTTON,"+itos(ev.mouse_button.button_index); + } break; + case InputEvent::JOYSTICK_BUTTON: { + str+="JBUTTON,"+itos(ev.joy_button.button_index); + + } break; + case InputEvent::JOYSTICK_MOTION: { + str+="JAXIS,"+itos(ev.joy_motion.axis)+","+itos(ev.joy_motion.axis_value); + } break; + default: {} + } + + str+=")"; + + p_store_string_func(p_store_string_ud,str); //will be added later + } break; case Variant::DICTIONARY: { |