summaryrefslogtreecommitdiff
path: root/core/resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/resource.cpp')
-rw-r--r--core/resource.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/core/resource.cpp b/core/resource.cpp
index 97dee3e1d7..e8d4069779 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -30,7 +30,7 @@
#include "core_string_names.h"
#include <stdio.h>
#include "os/file_access.h"
-
+#include "io/resource_loader.h"
void ResourceImportMetadata::set_editor(const String& p_editor) {
@@ -95,10 +95,9 @@ bool ResourceImportMetadata::has_option(const String& p_key) const {
return options.has(p_key);
}
+
Variant ResourceImportMetadata::get_option(const String& p_key) const {
- if (!options.has(p_key))
- print_line(p_key);
ERR_FAIL_COND_V(!options.has(p_key),Variant());
return options[p_key];
@@ -218,14 +217,36 @@ String Resource::get_name() const {
return name;
}
-bool Resource::can_reload_from_file() {
+bool Resource::editor_can_reload_from_file() {
- return false;
+ return true; //by default yes
}
void Resource::reload_from_file() {
+ String path=get_path();
+ if (!path.is_resource_file())
+ return;
+
+ Ref<Resource> s = ResourceLoader::load(path,get_type(),true);
+
+ if (!s.is_valid())
+ return;
+
+ List<PropertyInfo> pi;
+ s->get_property_list(&pi);
+
+ for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
+
+ if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ continue;
+ if (E->get().name=="resource/path")
+ continue; //do not change path
+
+ set(E->get().name,s->get(E->get().name));
+
+ }
}
@@ -465,8 +486,6 @@ void ResourceCache::dump(const char* p_file,bool p_short) {
if (!p_short) {
if (f)
f->store_line(r->get_type()+": "+r->get_path());
- else
- print_line(r->get_type()+": "+r->get_path());
}
}
@@ -474,8 +493,6 @@ void ResourceCache::dump(const char* p_file,bool p_short) {
if (f)
f->store_line(E->key()+" count: "+itos(E->get()));
- else
- print_line(E->key()+" count: "+itos(E->get()));
}
if (f) {
f->close();