summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/io/file_access_memory.cpp2
-rw-r--r--core/io/resource_loader.cpp1
-rw-r--r--core/io/translation_loader_po.cpp25
-rw-r--r--core/io/translation_loader_po.h4
-rw-r--r--core/object.cpp7
-rw-r--r--core/object.h3
-rw-r--r--core/os/main_loop.cpp10
-rw-r--r--core/os/main_loop.h2
-rw-r--r--core/os/memory.h9
-rw-r--r--core/resource.cpp27
-rw-r--r--core/resource.h4
-rw-r--r--core/translation.cpp6
12 files changed, 84 insertions, 16 deletions
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index 2cc52a9e2d..7db3499505 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -135,7 +135,7 @@ size_t FileAccessMemory::get_len() const {
bool FileAccessMemory::eof_reached() const {
- return pos >= length;
+ return pos > length;
}
uint8_t FileAccessMemory::get_8() const {
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index abb1082256..b547dc0e85 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -243,6 +243,7 @@ Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p
break;
}
+
return ret;
}
diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp
index fe101a8676..4ddb276a27 100644
--- a/core/io/translation_loader_po.cpp
+++ b/core/io/translation_loader_po.cpp
@@ -30,13 +30,8 @@
#include "os/file_access.h"
#include "translation.h"
-RES TranslationLoaderPO::load(const String &p_path, const String& p_original_path, Error *r_error) {
- if (r_error)
- *r_error=ERR_CANT_OPEN;
-
- FileAccess *f=FileAccess::open(p_path,FileAccess::READ);
- ERR_FAIL_COND_V(!f,RES());
+RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const String &p_path) {
String l = f->get_line();
@@ -52,6 +47,8 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat
String msg_id;
String msg_str;
String config;
+ int msg_line=0;
+
if (r_error)
*r_error=ERR_FILE_CORRUPT;
@@ -87,7 +84,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat
if (status==STATUS_READING_ID) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+" nexpected 'msgid', was expecting 'msgstr' while parsing: ");
+ ERR_EXPLAIN(p_path+":"+itos(line)+" Unexpected 'msgid', was expecting 'msgstr' while parsing: ");
ERR_FAIL_V(RES());
}
@@ -100,6 +97,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat
status=STATUS_READING_ID;
msg_id="";
msg_str="";
+ msg_line=line;
}
if (l.begins_with("msgstr")) {
@@ -113,6 +111,7 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat
l=l.substr(6,l.length()).strip_edges();
status=STATUS_READING_STRING;
+ msg_line=line;
}
if (l=="" || l.begins_with("#")) {
@@ -183,6 +182,18 @@ RES TranslationLoaderPO::load(const String &p_path, const String& p_original_pat
*r_error=OK;
return translation;
+}
+
+RES TranslationLoaderPO::load(const String &p_path, const String& p_original_path, Error *r_error) {
+
+ if (r_error)
+ *r_error=ERR_CANT_OPEN;
+
+ FileAccess *f=FileAccess::open(p_path,FileAccess::READ);
+ ERR_FAIL_COND_V(!f,RES());
+
+
+ return load_translation(f,r_error);
}
diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h
index a569674d80..b0c4e42682 100644
--- a/core/io/translation_loader_po.h
+++ b/core/io/translation_loader_po.h
@@ -30,10 +30,12 @@
#define TRANSLATION_LOADER_PO_H
#include "io/resource_loader.h"
-
+#include "translation.h"
+#include "os/file_access.h"
class TranslationLoaderPO : public ResourceFormatLoader {
public:
+ static RES load_translation(FileAccess *f, Error *r_error,const String& p_path=String());
virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String& p_type) const;
diff --git a/core/object.cpp b/core/object.cpp
index 3cfc0329bc..d7878fd623 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1756,6 +1756,7 @@ bool Object::is_queued_for_deletion() const {
void Object::set_edited(bool p_edited) {
_edited=p_edited;
+ _edited_version++;
}
bool Object::is_edited() const {
@@ -1763,6 +1764,11 @@ bool Object::is_edited() const {
return _edited;
}
+
+uint32_t Object::get_edited_version() const {
+
+ return _edited_version;
+}
#endif
Object::Object() {
@@ -1778,6 +1784,7 @@ Object::Object() {
#ifdef TOOLS_ENABLED
_edited=false;
+ _edited_version=0;
#endif
#ifdef DEBUG_ENABLED
diff --git a/core/object.h b/core/object.h
index 3945d1d0ba..f4a2472e88 100644
--- a/core/object.h
+++ b/core/object.h
@@ -85,6 +85,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_STORE_IF_NONZERO=512, //only store if nonzero
PROPERTY_USAGE_STORE_IF_NONONE=1024, //only store if false
PROPERTY_USAGE_NO_INSTANCE_STATE=2048,
+ PROPERTY_USAGE_RESTART_IF_CHANGED=4096,
PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED,
@@ -388,6 +389,7 @@ friend void postinitialize_handler(Object*);
bool _can_translate;
#ifdef TOOLS_ENABLED
bool _edited;
+ uint32_t _edited_version;
#endif
ScriptInstance *script_instance;
RefPtr script;
@@ -589,6 +591,7 @@ public:
#ifdef TOOLS_ENABLED
void set_edited(bool p_edited);
bool is_edited() const;
+ uint32_t get_edited_version() const; //this function is used to check when something changed beyond a point, it's used mainly for generating previews
#endif
void set_script_instance(ScriptInstance *p_instance);
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 310bbaa3b8..e5feebfbfc 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -43,6 +43,7 @@ void MainLoop::_bind_methods() {
BIND_VMETHOD( MethodInfo("_initialize") );
BIND_VMETHOD( MethodInfo("_iteration",PropertyInfo(Variant::REAL,"delta")) );
BIND_VMETHOD( MethodInfo("_idle",PropertyInfo(Variant::REAL,"delta")) );
+ BIND_VMETHOD( MethodInfo("_drop_files",PropertyInfo(Variant::STRING_ARRAY,"files"),PropertyInfo(Variant::INT,"screen")) );
BIND_VMETHOD( MethodInfo("_finalize") );
BIND_CONSTANT(NOTIFICATION_WM_MOUSE_ENTER);
@@ -108,6 +109,15 @@ bool MainLoop::idle(float p_time) {
return false;
}
+
+void MainLoop::drop_files(const Vector<String>& p_files,int p_from_screen) {
+
+
+ if (get_script_instance())
+ get_script_instance()->call("_drop_files",p_files,p_from_screen);
+
+}
+
void MainLoop::finish() {
if (get_script_instance()) {
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index a34014983e..57185d9d3d 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -64,6 +64,8 @@ public:
virtual bool idle(float p_time);
virtual void finish();
+ virtual void drop_files(const Vector<String>& p_files,int p_from_screen=0);
+
void set_init_script(const Ref<Script>& p_init_script);
MainLoop();
diff --git a/core/os/memory.h b/core/os/memory.h
index 8257e66851..5f4c6f929c 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -211,7 +211,7 @@ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_de
#ifdef DEBUG_MEMORY_ENABLED
-#define memalloc(m_size) Memory::alloc_static(m_size, __FILE__":"__STR(__LINE__)", memalloc.")
+#define memalloc(m_size) Memory::alloc_static(m_size, __FILE__ ":" __STR(__LINE__) ", memalloc.")
#define memrealloc(m_mem,m_size) Memory::realloc_static(m_mem,m_size)
#define memfree(m_size) Memory::free_static(m_size)
@@ -224,8 +224,7 @@ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_de
#endif
#ifdef DEBUG_MEMORY_ENABLED
-
-#define dynalloc(m_size) Memory::alloc_dynamic(m_size, __FILE__":"__STR(__LINE__)", type: DYNAMIC")
+#define dynalloc(m_size) Memory::alloc_dynamic(m_size, __FILE__ ":" __STR(__LINE__) ", type: DYNAMIC")
#define dynrealloc(m_mem,m_size) m_mem.resize(m_size)
#else
@@ -248,7 +247,7 @@ _ALWAYS_INLINE_ T *_post_initialize(T *p_obj) {
#ifdef DEBUG_MEMORY_ENABLED
-#define memnew(m_class) _post_initialize(new(__FILE__":"__STR(__LINE__)", memnew type: "__STR(m_class)) m_class)
+#define memnew(m_class) _post_initialize(new(__FILE__ ":" __STR(__LINE__) ", memnew type: " __STR(m_class)) m_class)
#else
@@ -291,7 +290,7 @@ void memdelete_allocator(T *p_class) {
#define memdelete_notnull(m_v) { if (m_v) memdelete(m_v); }
#ifdef DEBUG_MEMORY_ENABLED
-#define memnew_arr( m_class, m_count ) memnew_arr_template<m_class>(m_count,__FILE__":"__STR(__LINE__)", memnew_arr type: "_STR(m_class))
+#define memnew_arr( m_class, m_count ) memnew_arr_template<m_class>(m_count,__FILE__ ":" __STR(__LINE__) ", memnew_arr type: " _STR(m_class))
#else
diff --git a/core/resource.cpp b/core/resource.cpp
index 672e64b1bb..b7a5bad4b8 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -330,6 +330,31 @@ Ref<ResourceImportMetadata> Resource::get_import_metadata() const {
}
+#ifdef TOOLS_ENABLED
+
+uint32_t Resource::hash_edited_version() const {
+
+ uint32_t hash = hash_djb2_one_32(get_edited_version());
+
+ List<PropertyInfo> plist;
+ get_property_list(&plist);
+
+ for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
+
+ if (E->get().type==Variant::OBJECT && E->get().hint==PROPERTY_HINT_RESOURCE_TYPE) {
+ RES res = get(E->get().name);
+ if (res.is_valid()) {
+ hash = hash_djb2_one_32(res->hash_edited_version(),hash);
+ }
+ }
+ }
+
+ return hash;
+
+}
+
+#endif
+
Resource::Resource() {
@@ -341,6 +366,8 @@ Resource::Resource() {
}
+
+
Resource::~Resource() {
if (path_cache!="")
diff --git a/core/resource.h b/core/resource.h
index 8bcdd6b4b7..958414f62b 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -142,8 +142,12 @@ public:
Ref<ResourceImportMetadata> get_import_metadata() const;
+
+
#ifdef TOOLS_ENABLED
+ uint32_t hash_edited_version() const;
+
virtual void set_last_modified_time(uint64_t p_time) { last_modified_time=p_time; }
uint64_t get_last_modified_time() const { return last_modified_time; }
diff --git a/core/translation.cpp b/core/translation.cpp
index 85e207e08d..ee0ef2ea09 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -672,9 +672,11 @@ void TranslationServer::set_tool_translation(const Ref<Translation>& p_translati
StringName TranslationServer::tool_translate(const StringName& p_message) const {
if (tool_translation.is_valid()) {
- StringName r = tool_translation->tr(p_message);
- if (r)
+ StringName r = tool_translation->get_message(p_message);
+
+ if (r) {
return r;
+ }
}
return p_message;