summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-06-28 17:00:18 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-06-28 17:01:35 -0300
commitdb3b05d2893dcaddeb3bcb10b845ff150eb50895 (patch)
treee19d761357300ba03360593e3cbdda01e87f215e /scene/resources
parent9e54e1f34f7ee0b100b45fa2388f25096eb90670 (diff)
Reworked translation system
-Label and Button reload translation on the fly -Resources are loaded and reload depending on locale
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/audio_stream_sample.cpp5
-rw-r--r--scene/resources/audio_stream_sample.h1
-rw-r--r--scene/resources/curve.cpp2
-rw-r--r--scene/resources/material.cpp6
-rw-r--r--scene/resources/material.h6
-rw-r--r--scene/resources/scene_format_text.cpp10
-rw-r--r--scene/resources/scene_format_text.h3
-rw-r--r--scene/resources/texture.cpp19
8 files changed, 33 insertions, 19 deletions
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp
index 4f2ab18637..f12e231074 100644
--- a/scene/resources/audio_stream_sample.cpp
+++ b/scene/resources/audio_stream_sample.cpp
@@ -39,8 +39,6 @@ void AudioStreamPlaybackSample::start(float p_from_pos) {
ima_adpcm[i].last_nibble = -1;
ima_adpcm[i].loop_pos = 0x7FFFFFFF;
ima_adpcm[i].window_ofs = 0;
- ima_adpcm[i].ptr = (const uint8_t *)base->data;
- ima_adpcm[i].ptr += AudioStreamSample::DATA_PAD;
}
seek_pos(p_from_pos);
@@ -122,7 +120,8 @@ void AudioStreamPlaybackSample::do_resample(const Depth *p_src, AudioFrame *p_ds
int16_t nibble, diff, step;
ima_adpcm[i].last_nibble++;
- const uint8_t *src_ptr = ima_adpcm[i].ptr;
+ const uint8_t *src_ptr = (const uint8_t *)base->data;
+ src_ptr += AudioStreamSample::DATA_PAD;
uint8_t nbb = src_ptr[(ima_adpcm[i].last_nibble >> 1) * (is_stereo ? 2 : 1) + i];
nibble = (ima_adpcm[i].last_nibble & 1) ? (nbb >> 4) : (nbb & 0xF);
diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h
index cd02df512f..680f037f15 100644
--- a/scene/resources/audio_stream_sample.h
+++ b/scene/resources/audio_stream_sample.h
@@ -53,7 +53,6 @@ class AudioStreamPlaybackSample : public AudioStreamPlayback {
int32_t last_nibble;
int32_t loop_pos;
int32_t window_ofs;
- const uint8_t *ptr;
} ima_adpcm[2];
int64_t offset;
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index bc6d0230a0..338311b87b 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -730,7 +730,7 @@ void Curve::set_data(Array input) {
// Validate input
for (int i = 0; i < input.size(); i += ELEMS) {
ERR_FAIL_COND(input[i].get_type() != Variant::VECTOR2);
- ERR_FAIL_COND(input[i + 1].get_type() != Variant::REAL);
+ ERR_FAIL_COND(!input[i + 1].is_num());
ERR_FAIL_COND(input[i + 2].get_type() != Variant::REAL);
ERR_FAIL_COND(input[i + 3].get_type() != Variant::INT);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 0912c70144..3934467855 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -49,7 +49,7 @@ Material::~Material() {
bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
- if (p_name == SceneStringNames::get_singleton()->shader_shader) {
+ if (p_name == SceneStringNames::get_singleton()->shader) {
set_shader(p_value);
return true;
} else {
@@ -75,7 +75,7 @@ bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name == SceneStringNames::get_singleton()->shader_shader) {
+ if (p_name == SceneStringNames::get_singleton()->shader) {
r_ret = get_shader();
return true;
@@ -97,7 +97,7 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader,ShaderGraph"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader,ShaderGraph"));
if (!shader.is_null()) {
diff --git a/scene/resources/material.h b/scene/resources/material.h
index c043236489..fb6c5b81d9 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -42,9 +42,9 @@
class Material : public Resource {
- GDCLASS(Material, Resource);
- RES_BASE_EXTENSION("material");
- OBJ_SAVE_TYPE(Material);
+ GDCLASS(Material, Resource)
+ RES_BASE_EXTENSION("material")
+ OBJ_SAVE_TYPE(Material)
RID material;
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index f62fa93e04..8ad2970005 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -332,6 +332,7 @@ Error ResourceInteractiveLoaderText::poll() {
if (!ResourceCache::has(res_path)) {
resource->set_path(res_path);
}
+ resource->set_as_translation_remapped(translation_remapped);
}
return error;
}
@@ -606,6 +607,15 @@ int ResourceInteractiveLoaderText::get_stage_count() const {
return resources_total; //+ext_resources;
}
+void ResourceInteractiveLoaderText::set_translation_remapped(bool p_remapped) {
+
+ translation_remapped = p_remapped;
+}
+
+ResourceInteractiveLoaderText::ResourceInteractiveLoaderText() {
+ translation_remapped = false;
+}
+
ResourceInteractiveLoaderText::~ResourceInteractiveLoaderText() {
memdelete(f);
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index a7e78d62fe..1ea6465c21 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -38,6 +38,7 @@
class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
+ bool translation_remapped;
String local_path;
String res_path;
String error_text;
@@ -94,12 +95,14 @@ public:
virtual Error poll();
virtual int get_stage() const;
virtual int get_stage_count() const;
+ virtual void set_translation_remapped(bool p_remapped);
void open(FileAccess *p_f, bool p_skip_first_tag = false);
String recognize(FileAccess *p_f);
void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types);
Error rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map);
+ ResourceInteractiveLoaderText();
~ResourceInteractiveLoaderText();
};
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 6c7ae2445c..171826cb2f 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -91,7 +91,7 @@ Texture::Texture() {
void ImageTexture::reload_from_file() {
- String path = get_path();
+ String path = ResourceLoader::path_remap(get_path());
if (!path.is_resource_file())
return;
@@ -710,13 +710,16 @@ void StreamTexture::set_flags(uint32_t p_flags) {
void StreamTexture::reload_from_file() {
-#ifdef TOOLS_ENABLED
- String ipath = get_import_path();
- if (ipath.is_resource_file() && ipath != path_to_file) {
- path_to_file = ipath;
- }
-#endif
- load(path_to_file);
+ String path = get_path();
+ if (!path.is_resource_file())
+ return;
+
+ path = ResourceLoader::path_remap(path); //remap for translation
+ path = ResourceLoader::import_remap(path); //remap for import
+ if (!path.is_resource_file())
+ return;
+
+ load(path);
}
void StreamTexture::_bind_methods() {