summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/os/file_access.cpp2
-rw-r--r--core/os/file_access.h8
-rw-r--r--core/script_language.cpp12
-rw-r--r--core/script_language.h4
-rw-r--r--core/variant.cpp4
-rw-r--r--core/variant_parser.cpp40
6 files changed, 50 insertions, 20 deletions
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index a3ee9395de..1f23e8f33d 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -35,6 +35,8 @@
FileAccess::CreateFunc FileAccess::create_func[ACCESS_MAX]={0,0};
+FileAccess::FileCloseFailNotify FileAccess::close_fail_notify=NULL;
+
bool FileAccess::backup_save=false;
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 2c894c94eb..8d5823663e 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -47,6 +47,8 @@ public:
ACCESS_MAX
};
+ typedef void (*FileCloseFailNotify)(const String&);
+
typedef FileAccess*(*CreateFunc)();
bool endian_swap;
bool real_is_double;
@@ -56,7 +58,7 @@ protected:
virtual Error _open(const String& p_path, int p_mode_flags)=0; ///< open a file
virtual uint64_t _get_modified_time(const String& p_file)=0;
-
+ static FileCloseFailNotify close_fail_notify;
private:
static bool backup_save;
@@ -69,8 +71,12 @@ private:
return memnew( T );
}
+
+
public:
+ static void set_file_close_fail_notify_callback(FileCloseFailNotify p_cbk) { close_fail_notify=p_cbk; }
+
virtual void _set_access_type(AccessType p_access);
enum ModeFlags {
diff --git a/core/script_language.cpp b/core/script_language.cpp
index b3116a0297..68a694398a 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -32,7 +32,7 @@ ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
int ScriptServer::_language_count=0;
bool ScriptServer::scripting_enabled=true;
-
+bool ScriptServer::reload_scripts_on_save=false;
void Script::_notification( int p_what) {
@@ -92,6 +92,16 @@ void ScriptServer::init_languages() {
}
}
+void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
+
+ reload_scripts_on_save=p_enable;
+}
+
+bool ScriptServer::is_reload_scripts_on_save_enabled() {
+
+ return reload_scripts_on_save;
+}
+
void ScriptInstance::get_property_state(List<Pair<StringName, Variant> > &state) {
List<PropertyInfo> pinfo;
diff --git a/core/script_language.h b/core/script_language.h
index cbf6d8e116..478ebd88ed 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -47,6 +47,7 @@ class ScriptServer {
static ScriptLanguage *_languages[MAX_LANGUAGES];
static int _language_count;
static bool scripting_enabled;
+ static bool reload_scripts_on_save;
public:
static void set_scripting_enabled(bool p_enabled);
@@ -55,6 +56,9 @@ public:
static ScriptLanguage *get_language(int p_idx);
static void register_language(ScriptLanguage *p_language);
+ static void set_reload_scripts_on_save(bool p_enable);
+ static bool is_reload_scripts_on_save_enabled();
+
static void init_languages();
};
diff --git a/core/variant.cpp b/core/variant.cpp
index 38f5e69cc0..472d6cf568 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -3029,9 +3029,9 @@ String Variant::get_call_error_text(Object* p_base, const StringName& p_method,c
int errorarg=ce.argument;
err_text="Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(p_argptrs[errorarg]->get_type())+" to "+Variant::get_type_name(ce.expected)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
- err_text="Expected "+itos(ce.argument)+" arguments.";
+ err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
- err_text="Expected "+itos(ce.argument)+" arguments.";
+ err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) {
err_text="Method not found.";
} else if (ce.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index e2786b8099..875a144fef 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1789,6 +1789,14 @@ Error VariantParser::parse(Stream *p_stream, Variant& r_ret, String &r_err_str,
//////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
+static String rtosfix(double p_value) {
+
+
+ if (p_value==0.0)
+ return "0"; //avoid negative zero (-0) being written, which may annoy git, svn, etc. for changes when they don't exist.
+ else
+ return rtoss(p_value);
+}
Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud,EncodeResourceFunc p_encode_res_func,void* p_encode_res_ud) {
@@ -1807,7 +1815,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
} break;
case Variant::REAL: {
- String s = rtoss(p_variant.operator real_t());
+ String s = rtosfix(p_variant.operator real_t());
if (s.find(".")==-1 && s.find("e")==-1)
s+=".0";
p_store_string_func(p_store_string_ud, s );
@@ -1822,35 +1830,35 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
case Variant::VECTOR2: {
Vector2 v = p_variant;
- p_store_string_func(p_store_string_ud,"Vector2( "+rtoss(v.x) +", "+rtoss(v.y)+" )" );
+ p_store_string_func(p_store_string_ud,"Vector2( "+rtosfix(v.x) +", "+rtosfix(v.y)+" )" );
} break;
case Variant::RECT2: {
Rect2 aabb = p_variant;
- p_store_string_func(p_store_string_ud,"Rect2( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y)+" )" );
+ p_store_string_func(p_store_string_ud,"Rect2( "+rtosfix(aabb.pos.x) +", "+rtosfix(aabb.pos.y) +", "+rtosfix(aabb.size.x) +", "+rtosfix(aabb.size.y)+" )" );
} break;
case Variant::VECTOR3: {
Vector3 v = p_variant;
- p_store_string_func(p_store_string_ud,"Vector3( "+rtoss(v.x) +", "+rtoss(v.y)+", "+rtoss(v.z)+" )");
+ p_store_string_func(p_store_string_ud,"Vector3( "+rtosfix(v.x) +", "+rtosfix(v.y)+", "+rtosfix(v.z)+" )");
} break;
case Variant::PLANE: {
Plane p = p_variant;
- p_store_string_func(p_store_string_ud,"Plane( "+rtoss(p.normal.x) +", "+rtoss(p.normal.y)+", "+rtoss(p.normal.z)+", "+rtoss(p.d)+" )" );
+ p_store_string_func(p_store_string_ud,"Plane( "+rtosfix(p.normal.x) +", "+rtosfix(p.normal.y)+", "+rtosfix(p.normal.z)+", "+rtosfix(p.d)+" )" );
} break;
case Variant::_AABB: {
AABB aabb = p_variant;
- p_store_string_func(p_store_string_ud,"AABB( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.pos.z) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y) +", "+rtoss(aabb.size.z)+" )" );
+ p_store_string_func(p_store_string_ud,"AABB( "+rtosfix(aabb.pos.x) +", "+rtosfix(aabb.pos.y) +", "+rtosfix(aabb.pos.z) +", "+rtosfix(aabb.size.x) +", "+rtosfix(aabb.size.y) +", "+rtosfix(aabb.size.z)+" )" );
} break;
case Variant::QUAT: {
Quat quat = p_variant;
- p_store_string_func(p_store_string_ud,"Quat( "+rtoss(quat.x)+", "+rtoss(quat.y)+", "+rtoss(quat.z)+", "+rtoss(quat.w)+" )");
+ p_store_string_func(p_store_string_ud,"Quat( "+rtosfix(quat.x)+", "+rtosfix(quat.y)+", "+rtosfix(quat.z)+", "+rtosfix(quat.w)+" )");
} break;
case Variant::MATRIX32: {
@@ -1862,7 +1870,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i!=0 || j!=0)
s+=", ";
- s+=rtoss( m3.elements[i][j] );
+ s+=rtosfix( m3.elements[i][j] );
}
}
@@ -1878,7 +1886,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i!=0 || j!=0)
s+=", ";
- s+=rtoss( m3.elements[i][j] );
+ s+=rtosfix( m3.elements[i][j] );
}
}
@@ -1895,11 +1903,11 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i!=0 || j!=0)
s+=", ";
- s+=rtoss( m3.elements[i][j] );
+ s+=rtosfix( m3.elements[i][j] );
}
}
- s=s+", "+rtoss(t.origin.x) +", "+rtoss(t.origin.y)+", "+rtoss(t.origin.z);
+ s=s+", "+rtosfix(t.origin.x) +", "+rtosfix(t.origin.y)+", "+rtosfix(t.origin.z);
p_store_string_func(p_store_string_ud,s+" )");
} break;
@@ -1908,7 +1916,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
case Variant::COLOR: {
Color c = p_variant;
- p_store_string_func(p_store_string_ud,"Color( "+rtoss(c.r) +", "+rtoss(c.g)+", "+rtoss(c.b)+", "+rtoss(c.a)+" )");
+ p_store_string_func(p_store_string_ud,"Color( "+rtosfix(c.r) +", "+rtosfix(c.g)+", "+rtosfix(c.b)+", "+rtosfix(c.a)+" )");
} break;
case Variant::IMAGE: {
@@ -2143,7 +2151,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i]));
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i]));
}
p_store_string_func(p_store_string_ud," )");
@@ -2184,7 +2192,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y) );
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i].x)+", "+rtosfix(ptr[i].y) );
}
p_store_string_func(p_store_string_ud," )");
@@ -2202,7 +2210,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y)+", "+rtoss(ptr[i].z) );
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i].x)+", "+rtosfix(ptr[i].y)+", "+rtosfix(ptr[i].z) );
}
p_store_string_func(p_store_string_ud," )");
@@ -2222,7 +2230,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
if (i>0)
p_store_string_func(p_store_string_ud,", ");
- p_store_string_func(p_store_string_ud,rtoss(ptr[i].r)+", "+rtoss(ptr[i].g)+", "+rtoss(ptr[i].b)+", "+rtoss(ptr[i].a) );
+ p_store_string_func(p_store_string_ud,rtosfix(ptr[i].r)+", "+rtosfix(ptr[i].g)+", "+rtosfix(ptr[i].b)+", "+rtosfix(ptr[i].a) );
}
p_store_string_func(p_store_string_ud," )");