diff options
80 files changed, 427 insertions, 239 deletions
diff --git a/.gitignore b/.gitignore index f24d91a7ee..d947306558 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ core/method_bind.inc core/method_bind_ext.inc core/script_encryption_key.cpp core/global_defaults.cpp +drivers/unix/os_unix_global_settings_path.cpp tools/editor/register_exporters.cpp tools/editor/doc_data_compressed.h tools/editor/editor_icons.cpp diff --git a/SConstruct b/SConstruct index f16f4f6d65..95ad0010a2 100644 --- a/SConstruct +++ b/SConstruct @@ -127,6 +127,7 @@ opts.Add("CXX", "Compiler"); opts.Add("CCFLAGS", "Custom flags for the C++ compiler"); opts.Add("CFLAGS", "Custom flags for the C compiler"); opts.Add("LINKFLAGS", "Custom flags for the linker"); +opts.Add('unix_global_settings_path', 'unix-specific path to system-wide settings. Currently only used by templates.','') opts.Add('disable_3d', 'Disable 3D nodes for smaller executable (yes/no)', "no") opts.Add('disable_advanced_gui', 'Disable advance 3D gui nodes and behaviors (yes/no)', "no") opts.Add('colored', 'Enable colored output for the compilation (yes/no)', 'no') diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 1a0552e8d1..4cd3cd595f 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -905,7 +905,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) { error=ERR_FILE_UNRECOGNIZED; ERR_EXPLAIN("Unrecognized binary resource file: "+local_path); - ERR_FAIL_V(); + ERR_FAIL(); } bool big_endian = f->get_32(); diff --git a/core/os/os.h b/core/os/os.h index e5338b4a02..e908177df7 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -184,6 +184,7 @@ public: virtual void set_low_processor_usage_mode(bool p_enabled); virtual bool is_in_low_processor_usage_mode() const; + virtual String get_installed_templates_path() const { return ""; }; virtual String get_executable_path() const; virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL)=0; virtual Error kill(const ProcessID& p_pid)=0; diff --git a/core/vector.h b/core/vector.h index d103400622..78dff5eadb 100644 --- a/core/vector.h +++ b/core/vector.h @@ -42,7 +42,7 @@ template<class T> class Vector { - mutable void* _ptr; + mutable T* _ptr; // internal helpers @@ -51,21 +51,21 @@ class Vector { if (!_ptr) return NULL; - return reinterpret_cast<SafeRefCount*>(_ptr); + return reinterpret_cast<SafeRefCount*>((uint8_t*)_ptr-sizeof(int)-sizeof(SafeRefCount)); } _FORCE_INLINE_ int* _get_size() const { if (!_ptr) return NULL; - return reinterpret_cast<int*>(((uint8_t*)(_ptr))+sizeof(SafeRefCount)); + return reinterpret_cast<int*>((uint8_t*)_ptr-sizeof(int)); } _FORCE_INLINE_ T* _get_data() const { if (!_ptr) return NULL; - return reinterpret_cast<T*>(((uint8_t*)(_ptr))+sizeof(SafeRefCount)+sizeof(int)); + return reinterpret_cast<T*>(_ptr); } @@ -88,11 +88,11 @@ public: _FORCE_INLINE_ void clear() { resize(0); } _FORCE_INLINE_ int size() const { - - if (!_ptr) - return 0; + int* size = _get_size(); + if (size) + return *size; else - return *reinterpret_cast<int*>(((uint8_t*)(_ptr))+sizeof(SafeRefCount)); + return 0; } _FORCE_INLINE_ bool empty() const { return _ptr == 0; } Error resize(int p_size); @@ -174,7 +174,7 @@ void Vector<T>::_unref(void *p_data) { if (!p_data) return; - SafeRefCount *src = reinterpret_cast<SafeRefCount*>(p_data); + SafeRefCount *src = reinterpret_cast<SafeRefCount*>((uint8_t*)p_data-sizeof(int)-sizeof(SafeRefCount)); if (!src->unref()) return; // still in use @@ -189,7 +189,7 @@ void Vector<T>::_unref(void *p_data) { } // free mem - memfree(p_data); + memfree((uint8_t*)p_data-sizeof(int)-sizeof(SafeRefCount)); } @@ -201,7 +201,8 @@ void Vector<T>::_copy_on_write() { if (_get_refcount()->get() > 1 ) { /* in use by more than me */ - SafeRefCount *src_new=(SafeRefCount *)memalloc(_get_alloc_size(*_get_size())); + void* mem_new = memalloc(_get_alloc_size(*_get_size())); + SafeRefCount *src_new=(SafeRefCount *)mem_new; src_new->init(); int * _size = (int*)(src_new+1); *_size=*_get_size(); @@ -215,7 +216,7 @@ void Vector<T>::_copy_on_write() { } _unref(_ptr); - _ptr=src_new; + _ptr=_data; } } @@ -260,16 +261,17 @@ Error Vector<T>::resize(int p_size) { if (size()==0) { // alloc from scratch - _ptr = (T*)memalloc(_get_alloc_size(p_size)); - ERR_FAIL_COND_V( !_ptr ,ERR_OUT_OF_MEMORY); + void* ptr=memalloc(_get_alloc_size(p_size)); + ERR_FAIL_COND_V( !ptr ,ERR_OUT_OF_MEMORY); + _ptr=(T*)((uint8_t*)ptr+sizeof(int)+sizeof(SafeRefCount)); _get_refcount()->init(); // init refcount *_get_size()=0; // init size (currently, none) } else { - void *_ptrnew = (T*)memrealloc(_ptr,_get_alloc_size(p_size)); + void *_ptrnew = (T*)memrealloc((uint8_t*)_ptr-sizeof(int)-sizeof(SafeRefCount),_get_alloc_size(p_size)); ERR_FAIL_COND_V( !_ptrnew ,ERR_OUT_OF_MEMORY); - _ptr=_ptrnew; + _ptr=(T*)((uint8_t*)_ptrnew+sizeof(int)+sizeof(SafeRefCount)); } // construct the newly created elements @@ -291,10 +293,10 @@ Error Vector<T>::resize(int p_size) { t->~T(); } - void *_ptrnew = (T*)memrealloc(_ptr,_get_alloc_size(p_size)); + void *_ptrnew = (T*)memrealloc((uint8_t*)_ptr-sizeof(int)-sizeof(SafeRefCount),_get_alloc_size(p_size)); ERR_FAIL_COND_V( !_ptrnew ,ERR_OUT_OF_MEMORY); - _ptr=_ptrnew; + _ptr=(T*)((uint8_t*)_ptrnew+sizeof(int)+sizeof(SafeRefCount)); *_get_size()=p_size; diff --git a/demos/gui/input_mapping/controls.scn b/demos/gui/input_mapping/controls.scn Binary files differindex 276712ba22..03567fb691 100644 --- a/demos/gui/input_mapping/controls.scn +++ b/demos/gui/input_mapping/controls.scn diff --git a/doc/base/classes.xml b/doc/base/classes.xml index ab1320908e..15804b24cc 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -26960,7 +26960,7 @@ This method controls whether the position between two cached points is interpola Lazy (non-greedy) quantifiers [code]*?[/code] Begining [code]^[/code] and end [code]$[/code] anchors Alternation [code]|[/code] - Backreferences [code]\1[/code] to [code]\9[/code] + Backreferences [code]\1[/code] and [code]\g{1}[/code] POSIX character classes [code][[:alnum:]][/code] Lookahead [code](?=)[/code], [code](?!)[/code] and lookbehind [code](?<=)[/code], [code](?<!)[/code] ASCII [code]\xFF[/code] and Unicode [code]\uFFFF[/code] code points (in a style similar to Python) @@ -26972,9 +26972,10 @@ This method controls whether the position between two cached points is interpola </return> <argument index="0" name="pattern" type="String"> </argument> - <argument index="1" name="expanded" type="bool" default="true"> + <argument index="1" name="capture" type="int" default="9"> </argument> <description> + Compiles and assign the regular expression pattern to use. The limit on the number of capturing groups can be specified or made unlimited if negative. </description> </method> <method name="find" qualifiers="const"> diff --git a/drivers/nrex/README.md b/drivers/nrex/README.md index 951b301c1e..9ff67992dc 100644 --- a/drivers/nrex/README.md +++ b/drivers/nrex/README.md @@ -1,5 +1,7 @@ # NREX: Node RegEx +Version 0.1 + Small node-based regular expression library. It only does text pattern matchhing, not replacement. To use add the files `nrex.hpp`, `nrex.cpp` and `nrex_config.h` to your project and follow the example: @@ -32,7 +34,7 @@ Currently supported features: * Unicode `\uFFFF` code points * Positive `(?=)` and negative `(?!)` lookahead * Positive `(?<=)` and negative `(?<!)` lookbehind (fixed length and no alternations) - * Backreferences `\1` to `\9` (with option to expand to `\99`) + * Backreferences `\1` and `\g{1}` (limited by default to 9 - can be unlimited) ## License diff --git a/drivers/nrex/nrex.cpp b/drivers/nrex/nrex.cpp index 104e07f887..1eb9ec38c8 100644 --- a/drivers/nrex/nrex.cpp +++ b/drivers/nrex/nrex.cpp @@ -1,4 +1,5 @@ // NREX: Node RegEx +// Version 0.1 // // Copyright (c) 2015, Zher Huei Lee // All rights reserved. @@ -299,6 +300,10 @@ struct nrex_node_group : public nrex_node { length = 1; } + if (mode == LookAhead || mode == LookBehind) + { + quantifiable = false; + } } virtual ~nrex_node_group() @@ -322,6 +327,10 @@ struct nrex_node_group : public nrex_node int offset = 0; if (mode == LookBehind) { + if (pos < length) + { + return -1; + } offset = length; } int res = childset[i]->test(s, pos - offset); @@ -450,7 +459,7 @@ struct nrex_node_char : public nrex_node int test(nrex_search* s, int pos) const { - if (s->end == pos || s->at(pos) != ch) + if (s->end <= pos || 0 > pos || s->at(pos) != ch) { return -1; } @@ -473,7 +482,7 @@ struct nrex_node_range : public nrex_node int test(nrex_search* s, int pos) const { - if (s->end == pos) + if (s->end <= pos || 0 > pos) { return -1; } @@ -555,7 +564,7 @@ struct nrex_node_class : public nrex_node int test(nrex_search* s, int pos) const { - if (s->end == pos) + if (s->end <= pos || 0 > pos) { return -1; } @@ -727,7 +736,7 @@ struct nrex_node_shorthand : public nrex_node int test(nrex_search* s, int pos) const { - if (s->end == pos) + if (s->end <= pos || 0 > pos) { return -1; } @@ -811,16 +820,12 @@ struct nrex_node_quantifier : public nrex_node int test(nrex_search* s, int pos) const { - return test_step(s, pos, 1); + return test_step(s, pos, 0, pos); } - int test_step(nrex_search* s, int pos, int level) const + int test_step(nrex_search* s, int pos, int level, int start) const { - if (max == 0) - { - return pos; - } - if ((max >= 1 && level > max) || pos > s->end) + if (pos > s->end) { return -1; } @@ -840,14 +845,26 @@ struct nrex_node_quantifier : public nrex_node return res; } } - int res = child->test(s, pos); - if (s->complete) + if (max >= 0 && level > max) { - return res; + return -1; + } + if (level > 1 && level > min + 1 && pos == start) + { + return -1; + } + int res = pos; + if (level >= 1) + { + res = child->test(s, pos); + if (s->complete) + { + return res; + } } if (res >= 0) { - int res_step = test_step(s, res, level + 1); + int res_step = test_step(s, res, level + 1, start); if (res_step >= 0) { return res_step; @@ -983,6 +1000,13 @@ nrex::nrex() { } +nrex::nrex(const nrex_char* pattern, int captures) + : _capturing(0) + , _root(NULL) +{ + compile(pattern, captures); +} + nrex::~nrex() { if (_root) @@ -1008,10 +1032,14 @@ void nrex::reset() int nrex::capture_size() const { - return _capturing + 1; + if (_root) + { + return _capturing + 1; + } + return 0; } -bool nrex::compile(const nrex_char* pattern, bool extended) +bool nrex::compile(const nrex_char* pattern, int captures) { reset(); nrex_node_group* root = NREX_NEW(nrex_node_group(_capturing)); @@ -1053,7 +1081,7 @@ bool nrex::compile(const nrex_char* pattern, bool extended) NREX_COMPILE_ERROR("unrecognised qualifier for group"); } } - else if ((!extended && _capturing < 9) || (extended && _capturing < 99)) + else if (captures >= 0 && _capturing < captures) { nrex_node_group* group = NREX_NEW(nrex_node_group(++_capturing)); stack.top()->add_child(group); @@ -1190,15 +1218,6 @@ bool nrex::compile(const nrex_char* pattern, bool extended) } else if (nrex_is_quantifier(c[0])) { - if (stack.top()->back == NULL || !stack.top()->back->quantifiable) - { - if (c[0] == '{') - { - stack.top()->add_child(NREX_NEW(nrex_node_char('{'))); - continue; - } - NREX_COMPILE_ERROR("element not quantifiable"); - } int min = 0; int max = -1; bool valid_quantifier = true; @@ -1270,6 +1289,10 @@ bool nrex::compile(const nrex_char* pattern, bool extended) } if (valid_quantifier) { + if (stack.top()->back == NULL || !stack.top()->back->quantifiable) + { + NREX_COMPILE_ERROR("element not quantifiable"); + } nrex_node_quantifier* quant = NREX_NEW(nrex_node_quantifier(min, max)); if (min == max) { @@ -1323,20 +1346,26 @@ bool nrex::compile(const nrex_char* pattern, bool extended) stack.top()->add_child(NREX_NEW(nrex_node_shorthand(c[1]))); ++c; } - else if ('1' <= c[1] && c[1] <= '9') + else if (('1' <= c[1] && c[1] <= '9') || (c[1] == 'g' && c[2] == '{')) { int ref = 0; - if (extended && '0' <= c[2] && c[2] <= '9') + bool unclosed = false; + if (c[1] == 'g') { - ref = int(c[1] - '0') * 10 + int(c[2] - '0'); + unclosed = true; c = &c[2]; } - else + while ('0' <= c[1] && c[1] <= '9') { - ref = int(c[1] - '0'); + ref = ref * 10 + int(c[1] - '0'); ++c; } - if (ref > _capturing) + if (c[1] == '}') + { + unclosed = false; + ++c; + } + if (ref > _capturing || ref <= 0 || unclosed) { NREX_COMPILE_ERROR("backreference to non-existent capture"); } @@ -1377,6 +1406,10 @@ bool nrex::compile(const nrex_char* pattern, bool extended) bool nrex::match(const nrex_char* str, nrex_result* captures, int offset, int end) const { + if (!_root) + { + return false; + } nrex_search s(str, captures); if (end >= offset) { @@ -1386,7 +1419,7 @@ bool nrex::match(const nrex_char* str, nrex_result* captures, int offset, int en { s.end = NREX_STRLEN(str); } - for (int i = offset; i < s.end; ++i) + for (int i = offset; i <= s.end; ++i) { for (int c = 0; c <= _capturing; ++c) { diff --git a/drivers/nrex/nrex.hpp b/drivers/nrex/nrex.hpp index e26a61c39a..44e950c517 100644 --- a/drivers/nrex/nrex.hpp +++ b/drivers/nrex/nrex.hpp @@ -1,4 +1,5 @@ // NREX: Node RegEx +// Version 0.1 // // Copyright (c) 2015, Zher Huei Lee // All rights reserved. @@ -59,7 +60,32 @@ class nrex int _capturing; nrex_node* _root; public: + + /*! + * \brief Initialises an empty regex container + */ nrex(); + + /*! + * \brief Initialises and compiles the regex pattern + * + * This calls nrex::compile() with the same arguments. To check whether + * the compilation was successfull, use nrex::valid(). + * + * If the NREX_THROW_ERROR was defined it would automatically throw a + * runtime error nrex_compile_error if it encounters a problem when + * parsing the pattern. + * + * \param pattern The regex pattern + * \param captures The maximum number of capture groups to allow. Any + * extra would be converted to non-capturing groups. + * If negative, no limit would be imposed. Defaults + * to 9. + * + * \see nrex::compile() + */ + nrex(const nrex_char* pattern, int captures = 9); + ~nrex(); /*! @@ -78,9 +104,9 @@ class nrex * * This is used to provide the array size of the captures needed for * nrex::match() to work. The size is actually the number of capture - * groups + one for the matching of the entire pattern. The result is - * always capped at 10 or 100, depending on the extend option given in - * nrex::compile() (default 10). + * groups + one for the matching of the entire pattern. This can be + * capped using the extra argument given in nrex::compile() + * (default 10). * * \return The number of captures */ @@ -97,12 +123,13 @@ class nrex * parsing the pattern. * * \param pattern The regex pattern - * \param extended If true, raises the limit on number of capture - * groups and back-references to 99. Otherwise limited - * to 9. Defaults to false. + * \param captures The maximum number of capture groups to allow. Any + * extra would be converted to non-capturing groups. + * If negative, no limit would be imposed. Defaults + * to 9. * \return True if the pattern was succesfully compiled */ - bool compile(const nrex_char* pattern, bool extended = false); + bool compile(const nrex_char* pattern, int captures = 9); /*! * \brief Uses the pattern to search through the provided string diff --git a/drivers/nrex/regex.cpp b/drivers/nrex/regex.cpp index 246384b10a..e8578221a9 100644 --- a/drivers/nrex/regex.cpp +++ b/drivers/nrex/regex.cpp @@ -15,7 +15,7 @@ void RegEx::_bind_methods() { - ObjectTypeDB::bind_method(_MD("compile","pattern", "expanded"),&RegEx::compile, DEFVAL(true)); + ObjectTypeDB::bind_method(_MD("compile","pattern", "capture"),&RegEx::compile, DEFVAL(9)); ObjectTypeDB::bind_method(_MD("find","text","start","end"),&RegEx::find, DEFVAL(0), DEFVAL(-1)); ObjectTypeDB::bind_method(_MD("clear"),&RegEx::clear); ObjectTypeDB::bind_method(_MD("is_valid"),&RegEx::is_valid); @@ -68,11 +68,11 @@ String RegEx::get_capture(int capture) const { } -Error RegEx::compile(const String& p_pattern, bool expanded) { +Error RegEx::compile(const String& p_pattern, int capture) { clear(); - exp.compile(p_pattern.c_str(), expanded); + exp.compile(p_pattern.c_str(), capture); ERR_FAIL_COND_V( !exp.valid(), FAILED ); diff --git a/drivers/nrex/regex.h b/drivers/nrex/regex.h index be52da8149..76aab2aea6 100644 --- a/drivers/nrex/regex.h +++ b/drivers/nrex/regex.h @@ -36,7 +36,7 @@ public: bool is_valid() const; int get_capture_count() const; String get_capture(int capture) const; - Error compile(const String& p_pattern, bool expanded = false); + Error compile(const String& p_pattern, int capture = 9); int find(const String& p_text, int p_start = 0, int p_end = -1) const; RegEx(); diff --git a/drivers/theora/video_stream_theora.cpp b/drivers/theora/video_stream_theora.cpp index 01b6f4d35e..fe248bc911 100644 --- a/drivers/theora/video_stream_theora.cpp +++ b/drivers/theora/video_stream_theora.cpp @@ -411,6 +411,7 @@ void VideoStreamPlaybackTheora::set_file(const String& p_file) { th_decode_ctl(td,TH_DECCTL_GET_PPLEVEL_MAX,&pp_level_max, sizeof(pp_level_max)); pp_level=pp_level_max; + pp_level=0; th_decode_ctl(td,TH_DECCTL_SET_PPLEVEL,&pp_level,sizeof(pp_level)); pp_inc=0; @@ -620,7 +621,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) { if(videobuf_time>=get_time()) { frame_done=true; - } else{ /*If we are too slow, reduce the pp level.*/ pp_inc=pp_level>0?-1:0; diff --git a/drivers/theora/video_stream_theora.h b/drivers/theora/video_stream_theora.h index 3d88ba4e4b..c15ef31cfc 100644 --- a/drivers/theora/video_stream_theora.h +++ b/drivers/theora/video_stream_theora.h @@ -138,20 +138,20 @@ class VideoStreamTheora : public VideoStream { OBJ_TYPE(VideoStreamTheora,VideoStream); String file; - int audio_track; + int audio_track; public: Ref<VideoStreamPlayback> instance_playback() { Ref<VideoStreamPlaybackTheora> pb = memnew( VideoStreamPlaybackTheora ); - pb->set_audio_track(audio_track); + pb->set_audio_track(audio_track); pb->set_file(file); return pb; } void set_file(const String& p_file) { file=p_file; } - void set_audio_track(int p_track) { audio_track=p_track; } + void set_audio_track(int p_track) { audio_track=p_track; } VideoStreamTheora() { audio_track=0; } diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index 9fbb467baa..e8b3cadfc7 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -1,5 +1,13 @@ Import('env') +ed_gl_set='#include "os_unix.h"\n' +ed_gl_set+='String OS_Unix::get_global_settings_path() const {\n' +ed_gl_set+='\treturn "' + env["unix_global_settings_path"]+'";\n' +ed_gl_set+='}\n' +f = open("os_unix_global_settings_path.cpp","wb") +f.write(ed_gl_set) +f.close() + env.add_source_files(env.drivers_sources,"*.cpp") Export('env') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index fd8c26f6d9..94a7b03f45 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -477,6 +477,14 @@ String OS_Unix::get_data_dir() const { } +String OS_Unix::get_installed_templates_path() const { + String p=get_global_settings_path(); + if (p!="") + return p+"/templates/"; + else + return ""; +} + String OS_Unix::get_executable_path() const { #ifdef __linux__ diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 2ee6102164..9ac18c9055 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -64,6 +64,8 @@ protected: String stdin_buf; + String get_global_settings_path() const; + public: @@ -111,6 +113,7 @@ public: virtual void debug_break(); + virtual String get_installed_templates_path() const; virtual String get_executable_path() const; virtual String get_data_dir() const; diff --git a/drivers/webp/dec/alpha.c b/drivers/webp/dec/alpha.c index 52216fc4d6..1d029b0e6a 100644 --- a/drivers/webp/dec/alpha.c +++ b/drivers/webp/dec/alpha.c @@ -18,7 +18,7 @@ #include "../dsp/dsp.h" #include "../utils/quant_levels_dec.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "webp/format_constants.h" //------------------------------------------------------------------------------ // ALPHDecoder object. diff --git a/drivers/webp/dec/decode_vp8.h b/drivers/webp/dec/decode_vp8.h index b9337bbec0..2bf1bdbbf5 100644 --- a/drivers/webp/dec/decode_vp8.h +++ b/drivers/webp/dec/decode_vp8.h @@ -14,7 +14,7 @@ #ifndef WEBP_WEBP_DECODE_VP8_H_ #define WEBP_WEBP_DECODE_VP8_H_ -#include "../webp/decode.h" +#include "webp/decode.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/dec/webp.c b/drivers/webp/dec/webp.c index 952178fa89..93a113a48d 100644 --- a/drivers/webp/dec/webp.c +++ b/drivers/webp/dec/webp.c @@ -17,7 +17,7 @@ #include "./vp8li.h" #include "./webpi.h" #include "../utils/utils.h" -#include "../webp/mux_types.h" // ALPHA_FLAG +#include "webp/mux_types.h" // ALPHA_FLAG //------------------------------------------------------------------------------ // RIFF layout is: diff --git a/drivers/webp/demux/anim_decode.c b/drivers/webp/demux/anim_decode.c index adf84cd193..c81cedfba0 100644 --- a/drivers/webp/demux/anim_decode.c +++ b/drivers/webp/demux/anim_decode.c @@ -11,15 +11,15 @@ // #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif #include <assert.h> #include <string.h> #include "../utils/utils.h" -#include "../webp/decode.h" -#include "../webp/demux.h" +#include "webp/decode.h" +#include "webp/demux.h" #define NUM_CHANNELS 4 diff --git a/drivers/webp/demux/demux.c b/drivers/webp/demux/demux.c index e8e5418efe..3717e21165 100644 --- a/drivers/webp/demux/demux.c +++ b/drivers/webp/demux/demux.c @@ -11,7 +11,7 @@ // #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif #include <assert.h> @@ -19,9 +19,9 @@ #include <string.h> #include "../utils/utils.h" -#include "../webp/decode.h" // WebPGetFeatures -#include "../webp/demux.h" -#include "../webp/format_constants.h" +#include "webp/decode.h" // WebPGetFeatures +#include "webp/demux.h" +#include "webp/format_constants.h" #define DMUX_MAJ_VERSION 0 #define DMUX_MIN_VERSION 2 diff --git a/drivers/webp/dsp/dsp.h b/drivers/webp/dsp/dsp.h index 8395df40e4..4613d9c3ff 100644 --- a/drivers/webp/dsp/dsp.h +++ b/drivers/webp/dsp/dsp.h @@ -15,10 +15,10 @@ #define WEBP_DSP_DSP_H_ #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/dsp/lossless.h b/drivers/webp/dsp/lossless.h index ee6771333f..149c6a01d3 100644 --- a/drivers/webp/dsp/lossless.h +++ b/drivers/webp/dsp/lossless.h @@ -15,8 +15,8 @@ #ifndef WEBP_DSP_LOSSLESS_H_ #define WEBP_DSP_LOSSLESS_H_ -#include "../webp/types.h" -#include "../webp/decode.h" +#include "webp/types.h" +#include "webp/decode.h" #include "../enc/histogram.h" #include "../utils/utils.h" diff --git a/drivers/webp/enc/alpha.c b/drivers/webp/enc/alpha.c index fad6346e43..1842b36401 100644 --- a/drivers/webp/enc/alpha.c +++ b/drivers/webp/enc/alpha.c @@ -19,7 +19,7 @@ #include "../utils/filters.h" #include "../utils/quant_levels.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "webp/format_constants.h" // ----------------------------------------------------------------------------- // Encodes the given alpha data via specified compression method 'method'. diff --git a/drivers/webp/enc/backward_references.h b/drivers/webp/enc/backward_references.h index daa084d846..e410b06f7d 100644 --- a/drivers/webp/enc/backward_references.h +++ b/drivers/webp/enc/backward_references.h @@ -15,8 +15,8 @@ #include <assert.h> #include <stdlib.h> -#include "../webp/types.h" -#include "../webp/format_constants.h" +#include "webp/types.h" +#include "webp/format_constants.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/enc/config.c b/drivers/webp/enc/config.c index f9f7961d58..8fd2276cb5 100644 --- a/drivers/webp/enc/config.c +++ b/drivers/webp/enc/config.c @@ -11,7 +11,7 @@ // // Author: Skal (pascal.massimino@gmail.com) -#include "../webp/encode.h" +#include "webp/encode.h" //------------------------------------------------------------------------------ // WebPConfig diff --git a/drivers/webp/enc/delta_palettization.c b/drivers/webp/enc/delta_palettization.c index 062e588d79..8bd3a3d233 100644 --- a/drivers/webp/enc/delta_palettization.c +++ b/drivers/webp/enc/delta_palettization.c @@ -13,7 +13,7 @@ #include "./delta_palettization.h" #ifdef WEBP_EXPERIMENTAL_FEATURES -#include "../webp/types.h" +#include "webp/types.h" #include "../dsp/lossless.h" #define MK_COL(r, g, b) (((r) << 16) + ((g) << 8) + (b)) diff --git a/drivers/webp/enc/delta_palettization.h b/drivers/webp/enc/delta_palettization.h index e41c0c5ab5..54195d452c 100644 --- a/drivers/webp/enc/delta_palettization.h +++ b/drivers/webp/enc/delta_palettization.h @@ -13,7 +13,7 @@ #ifndef WEBP_ENC_DELTA_PALETTIZATION_H_ #define WEBP_ENC_DELTA_PALETTIZATION_H_ -#include "../webp/encode.h" +#include "webp/encode.h" #include "../enc/vp8li.h" // Replaces enc->argb_[] input by a palettizable approximation of it, diff --git a/drivers/webp/enc/frame.c b/drivers/webp/enc/frame.c index 5b7a40b9ad..65a98ada4d 100644 --- a/drivers/webp/enc/frame.c +++ b/drivers/webp/enc/frame.c @@ -17,7 +17,7 @@ #include "./cost.h" #include "./vp8enci.h" #include "../dsp/dsp.h" -#include "../webp/format_constants.h" // RIFF constants +#include "webp/format_constants.h" // RIFF constants #define SEGMENT_VISU 0 #define DEBUG_SEARCH 0 // useful to track search convergence diff --git a/drivers/webp/enc/histogram.c b/drivers/webp/enc/histogram.c index 62c320d809..68c27fb1db 100644 --- a/drivers/webp/enc/histogram.c +++ b/drivers/webp/enc/histogram.c @@ -10,7 +10,7 @@ // Author: Jyrki Alakuijala (jyrki@google.com) // #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif #include <math.h> diff --git a/drivers/webp/enc/histogram.h b/drivers/webp/enc/histogram.h index adb16c01ca..72f045793a 100644 --- a/drivers/webp/enc/histogram.h +++ b/drivers/webp/enc/histogram.h @@ -17,8 +17,8 @@ #include <string.h> #include "./backward_references.h" -#include "../webp/format_constants.h" -#include "../webp/types.h" +#include "webp/format_constants.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/enc/syntax.c b/drivers/webp/enc/syntax.c index a0e79ef404..2b65f15ca1 100644 --- a/drivers/webp/enc/syntax.c +++ b/drivers/webp/enc/syntax.c @@ -14,8 +14,8 @@ #include <assert.h> #include "../utils/utils.h" -#include "../webp/format_constants.h" // RIFF constants -#include "../webp/mux_types.h" // ALPHA_FLAG +#include "webp/format_constants.h" // RIFF constants +#include "webp/mux_types.h" // ALPHA_FLAG #include "./vp8enci.h" //------------------------------------------------------------------------------ diff --git a/drivers/webp/enc/vp8enci.h b/drivers/webp/enc/vp8enci.h index 1a7ebe5703..0cb2ccc353 100644 --- a/drivers/webp/enc/vp8enci.h +++ b/drivers/webp/enc/vp8enci.h @@ -20,7 +20,7 @@ #include "../utils/bit_writer.h" #include "../utils/thread.h" #include "../utils/utils.h" -#include "../webp/encode.h" +#include "webp/encode.h" #ifdef WEBP_EXPERIMENTAL_FEATURES #include "./vp8li.h" diff --git a/drivers/webp/enc/vp8l.c b/drivers/webp/enc/vp8l.c index 047c9032ac..284995e830 100644 --- a/drivers/webp/enc/vp8l.c +++ b/drivers/webp/enc/vp8l.c @@ -22,7 +22,7 @@ #include "../utils/bit_writer.h" #include "../utils/huffman_encode.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "webp/format_constants.h" #include "./delta_palettization.h" diff --git a/drivers/webp/enc/vp8li.h b/drivers/webp/enc/vp8li.h index 6b6db127db..4543c3b260 100644 --- a/drivers/webp/enc/vp8li.h +++ b/drivers/webp/enc/vp8li.h @@ -17,8 +17,8 @@ #include "./backward_references.h" #include "./histogram.h" #include "../utils/bit_writer.h" -#include "../webp/encode.h" -#include "../webp/format_constants.h" +#include "webp/encode.h" +#include "webp/format_constants.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/mux/anim_encode.c b/drivers/webp/mux/anim_encode.c index fa86eaac94..bb7c0f50b9 100644 --- a/drivers/webp/mux/anim_encode.c +++ b/drivers/webp/mux/anim_encode.c @@ -15,10 +15,10 @@ #include <stdio.h> #include "../utils/utils.h" -#include "../webp/decode.h" -#include "../webp/encode.h" -#include "../webp/format_constants.h" -#include "../webp/mux.h" +#include "webp/decode.h" +#include "webp/encode.h" +#include "webp/format_constants.h" +#include "webp/mux.h" #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf diff --git a/drivers/webp/mux/muxi.h b/drivers/webp/mux/muxi.h index 718b2f5d58..8bd5291661 100644 --- a/drivers/webp/mux/muxi.h +++ b/drivers/webp/mux/muxi.h @@ -17,7 +17,7 @@ #include <stdlib.h> #include "../dec/vp8i.h" #include "../dec/vp8li.h" -#include "../webp/mux.h" +#include "webp/mux.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/bit_reader.c b/drivers/webp/utils/bit_reader.c index cd265321bb..5081d5cd4d 100644 --- a/drivers/webp/utils/bit_reader.c +++ b/drivers/webp/utils/bit_reader.c @@ -12,7 +12,7 @@ // Author: Skal (pascal.massimino@gmail.com) #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif #include "./bit_reader_inl.h" diff --git a/drivers/webp/utils/bit_reader.h b/drivers/webp/utils/bit_reader.h index 0fc62d33b7..7e09653ebc 100644 --- a/drivers/webp/utils/bit_reader.h +++ b/drivers/webp/utils/bit_reader.h @@ -19,7 +19,7 @@ #ifdef _MSC_VER #include <stdlib.h> // _byteswap_ulong #endif -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/bit_reader_inl.h b/drivers/webp/utils/bit_reader_inl.h index 37215702d4..20ce5f3cc7 100644 --- a/drivers/webp/utils/bit_reader_inl.h +++ b/drivers/webp/utils/bit_reader_inl.h @@ -17,7 +17,7 @@ #define WEBP_UTILS_BIT_READER_INL_H_ #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif #ifdef WEBP_FORCE_ALIGNED diff --git a/drivers/webp/utils/bit_writer.h b/drivers/webp/utils/bit_writer.h index ef360d1dc6..867a5ee055 100644 --- a/drivers/webp/utils/bit_writer.h +++ b/drivers/webp/utils/bit_writer.h @@ -14,7 +14,7 @@ #ifndef WEBP_UTILS_BIT_WRITER_H_ #define WEBP_UTILS_BIT_WRITER_H_ -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/color_cache.h b/drivers/webp/utils/color_cache.h index a9a9f64270..34299e4c4e 100644 --- a/drivers/webp/utils/color_cache.h +++ b/drivers/webp/utils/color_cache.h @@ -15,7 +15,7 @@ #ifndef WEBP_UTILS_COLOR_CACHE_H_ #define WEBP_UTILS_COLOR_CACHE_H_ -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/endian_inl.h b/drivers/webp/utils/endian_inl.h index e11260ff7d..253b7be8ee 100644 --- a/drivers/webp/utils/endian_inl.h +++ b/drivers/webp/utils/endian_inl.h @@ -13,11 +13,11 @@ #define WEBP_UTILS_ENDIAN_INL_H_ #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif #include "../dsp/dsp.h" -#include "../webp/types.h" +#include "webp/types.h" // some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__) #if !defined(WORDS_BIGENDIAN) && \ diff --git a/drivers/webp/utils/filters.h b/drivers/webp/utils/filters.h index 088b132fc5..4aba3fd3b7 100644 --- a/drivers/webp/utils/filters.h +++ b/drivers/webp/utils/filters.h @@ -14,7 +14,7 @@ #ifndef WEBP_UTILS_FILTERS_H_ #define WEBP_UTILS_FILTERS_H_ -#include "../webp/types.h" +#include "webp/types.h" #include "../dsp/dsp.h" #ifdef __cplusplus diff --git a/drivers/webp/utils/huffman.c b/drivers/webp/utils/huffman.c index d57376aa6b..e6f482a6a8 100644 --- a/drivers/webp/utils/huffman.c +++ b/drivers/webp/utils/huffman.c @@ -16,7 +16,7 @@ #include <string.h> #include "./huffman.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "webp/format_constants.h" // Huffman data read via DecodeImageStream is represented in two (red and green) // bytes. diff --git a/drivers/webp/utils/huffman.h b/drivers/webp/utils/huffman.h index c6dd6aaa45..a8cc0da1c3 100644 --- a/drivers/webp/utils/huffman.h +++ b/drivers/webp/utils/huffman.h @@ -15,8 +15,8 @@ #define WEBP_UTILS_HUFFMAN_H_ #include <assert.h> -#include "../webp/format_constants.h" -#include "../webp/types.h" +#include "webp/format_constants.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/huffman_encode.c b/drivers/webp/utils/huffman_encode.c index 6421c2beed..d7aad6f56d 100644 --- a/drivers/webp/utils/huffman_encode.c +++ b/drivers/webp/utils/huffman_encode.c @@ -16,7 +16,7 @@ #include <string.h> #include "./huffman_encode.h" #include "../utils/utils.h" -#include "../webp/format_constants.h" +#include "webp/format_constants.h" // ----------------------------------------------------------------------------- // Util function to optimize the symbol map for RLE coding diff --git a/drivers/webp/utils/huffman_encode.h b/drivers/webp/utils/huffman_encode.h index a157165148..93610066f3 100644 --- a/drivers/webp/utils/huffman_encode.h +++ b/drivers/webp/utils/huffman_encode.h @@ -14,7 +14,7 @@ #ifndef WEBP_UTILS_HUFFMAN_ENCODE_H_ #define WEBP_UTILS_HUFFMAN_ENCODE_H_ -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/quant_levels.h b/drivers/webp/utils/quant_levels.h index 1cb5a32cae..3916b977ab 100644 --- a/drivers/webp/utils/quant_levels.h +++ b/drivers/webp/utils/quant_levels.h @@ -16,7 +16,7 @@ #include <stdlib.h> -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/quant_levels_dec.h b/drivers/webp/utils/quant_levels_dec.h index 9aab068076..29c7e6e205 100644 --- a/drivers/webp/utils/quant_levels_dec.h +++ b/drivers/webp/utils/quant_levels_dec.h @@ -14,7 +14,7 @@ #ifndef WEBP_UTILS_QUANT_LEVELS_DEC_H_ #define WEBP_UTILS_QUANT_LEVELS_DEC_H_ -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/random.h b/drivers/webp/utils/random.h index c392a615ca..745f3e2e87 100644 --- a/drivers/webp/utils/random.h +++ b/drivers/webp/utils/random.h @@ -15,7 +15,7 @@ #define WEBP_UTILS_RANDOM_H_ #include <assert.h> -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/rescaler.h b/drivers/webp/utils/rescaler.h index 98b01a76d0..868467b4d7 100644 --- a/drivers/webp/utils/rescaler.h +++ b/drivers/webp/utils/rescaler.h @@ -18,7 +18,7 @@ extern "C" { #endif -#include "../webp/types.h" +#include "webp/types.h" #define WEBP_RESCALER_RFIX 32 // fixed-point precision for multiplies #define WEBP_RESCALER_ONE (1ull << WEBP_RESCALER_RFIX) diff --git a/drivers/webp/utils/thread.h b/drivers/webp/utils/thread.h index 8408311855..6008bb7c01 100644 --- a/drivers/webp/utils/thread.h +++ b/drivers/webp/utils/thread.h @@ -15,10 +15,10 @@ #define WEBP_UTILS_THREAD_H_ #ifdef HAVE_CONFIG_H -#include "../webp/config.h" +#include "webp/config.h" #endif -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/drivers/webp/utils/utils.c b/drivers/webp/utils/utils.c index d8e30930af..35aeae6ab8 100644 --- a/drivers/webp/utils/utils.c +++ b/drivers/webp/utils/utils.c @@ -13,8 +13,8 @@ #include <stdlib.h> #include <string.h> // for memcpy() -#include "../webp/decode.h" -#include "../webp/encode.h" +#include "webp/decode.h" +#include "webp/encode.h" #include "./utils.h" // If PRINT_MEM_INFO is defined, extra info (like total memory used, number of diff --git a/drivers/webp/utils/utils.h b/drivers/webp/utils/utils.h index fcdb7e139b..d0e1cb250a 100644 --- a/drivers/webp/utils/utils.h +++ b/drivers/webp/utils/utils.h @@ -17,7 +17,7 @@ #include <assert.h> -#include "../webp/types.h" +#include "webp/types.h" #ifdef __cplusplus extern "C" { diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 1deeb3457a..7d550f4fa0 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1020,18 +1020,24 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d EditorProgress ep("export","Exporting for Android",104); - String apk_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - if (p_debug) { - - src_apk=custom_debug_package!=""?custom_debug_package:apk_path+"android_debug.apk"; - } else { - - src_apk=custom_release_package!=""?custom_release_package:apk_path+"android_release.apk"; + if (p_debug) + src_apk=custom_debug_package; + else + src_apk=custom_release_package; + if (src_apk=="") { + String err; + if (p_debug) { + src_apk=find_export_template("android_debug.apk", &err); + } else { + src_apk=find_export_template("android_release.apk", &err); + } + if (src_apk=="") { + EditorNode::add_io_error(err); + return ERR_FILE_NOT_FOUND; + } } - FileAccess *src_f=NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); @@ -1659,10 +1665,7 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const { err+="Debug Keystore not configured in editor settings.\n"; } - - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - if (!FileAccess::exists(exe_path+"android_debug.apk") || !FileAccess::exists(exe_path+"android_release.apk")) { + if (!exists_export_template("android_debug.apk") || !exists_export_template("android_release.apk")) { valid=false; err+="No export templates found.\nDownload and install export templates.\n"; } diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp index 434aaff414..2acd920f31 100644 --- a/platform/bb10/export/export.cpp +++ b/platform/bb10/export/export.cpp @@ -275,10 +275,16 @@ Error EditorExportPlatformBB10::export_project(const String& p_path, bool p_debu EditorProgress ep("export","Exporting for BlackBerry 10",104); - String template_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - String src_template=custom_package!=""?custom_package:template_path.plus_file("bb10.zip"); - + String src_template=custom_package; + + if (src_template=="") { + String err; + src_template = find_export_template("bb10.zip", &err); + if (src_template=="") { + EditorNode::add_io_error(err); + return ERR_FILE_NOT_FOUND; + } + } FileAccess *src_f=NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); @@ -733,9 +739,7 @@ bool EditorExportPlatformBB10::can_export(String *r_error) const { err+="Blackberry host tools not configured in editor settings.\n"; } - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - if (!FileAccess::exists(exe_path+"bb10.zip")) { + if (!exists_export_template("bb10.zip")) { valid=false; err+="No export template found.\nDownload and install export templates.\n"; } diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 9e2595f4a1..acbcbb4652 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -205,18 +205,24 @@ Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool EditorProgress ep("export","Exporting for javascript",104); - String template_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - if (p_debug) { - - src_template=custom_debug_package!=""?custom_debug_package:template_path+"javascript_debug.zip"; - } else { - - src_template=custom_release_package!=""?custom_release_package:template_path+"javascript_release.zip"; + if (p_debug) + src_template=custom_debug_package; + else + src_template=custom_release_package; + if (src_template=="") { + String err; + if (p_debug) { + src_template=find_export_template("javascript_debug.zip", &err); + } else { + src_template=find_export_template("javascript_release.zip", &err); + } + if (src_template=="") { + EditorNode::add_io_error(err); + return ERR_FILE_NOT_FOUND; + } } - FileAccess *src_f=NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); @@ -337,9 +343,8 @@ bool EditorExportPlatformJavaScript::can_export(String *r_error) const { bool valid=true; String err; - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - if (!FileAccess::exists(exe_path+"javascript_debug.zip") || !FileAccess::exists(exe_path+"javascript_release.zip")) { + if (!exists_export_template("javascript_debug.zip") || !exists_export_template("javascript_release.zip")) { valid=false; err+="No export templates found.\nDownload and install export templates.\n"; } diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 79ee91bc61..0bece6ec76 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -251,15 +251,19 @@ Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug EditorProgress ep("export","Exporting for OSX",104); - String pkg_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/osx.zip"; - - if (p_debug) { - - src_pkg=custom_debug_package!=""?custom_debug_package:pkg_path; - } else { - - src_pkg=custom_release_package!=""?custom_release_package:pkg_path; + if (p_debug) + src_pkg=custom_debug_package; + else + src_pkg=custom_release_package; + + if (src_pkg=="") { + String err; + src_pkg=find_export_template("osx.zip", &err); + if (src_pkg=="") { + EditorNode::add_io_error(err); + return ERR_FILE_NOT_FOUND; + } } @@ -464,9 +468,8 @@ bool EditorExportPlatformOSX::can_export(String *r_error) const { bool valid=true; String err; - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - if (!FileAccess::exists(exe_path+"osx.zip")) { + if (!exists_export_template("osx.zip")) { valid=false; err+="No export templates found.\nDownload and install export templates.\n"; } diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 4ec4b054db..3193a2acbb 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -170,7 +170,6 @@ def get_flags(): return [ ('freetype','builtin'), #use builtin freetype ('openssl','builtin'), #use builtin openssl - ('theora','no'), ] def build_res_file( target, source, env ): diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 357aaa225b..abd532c156 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -309,6 +309,15 @@ void CanvasItem::hide() { _change_notify("visibility/visible"); } +void CanvasItem::set_hidden(bool p_hidden) { + + if (hidden == p_hidden) { + return; + } + + _set_visible_(!p_hidden); +} + Variant CanvasItem::edit_get_state() const { @@ -1043,6 +1052,7 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden); ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show); ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide); + ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden); ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 4885256c64..667fedc956 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -190,6 +190,7 @@ public: bool is_hidden() const; void show(); void hide(); + void set_hidden(bool p_hidden); void update(); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index a65f68ed2c..7d48420a83 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -594,6 +594,15 @@ bool Spatial::is_hidden() const{ return !data.visible; } +void Spatial::set_hidden(bool p_hidden) { + + if (data.visible != p_hidden) { + return; + } + + _set_visible_(!p_hidden); +} + void Spatial::_set_visible_(bool p_visible) { if (p_visible) @@ -742,6 +751,7 @@ void Spatial::_bind_methods() { ObjectTypeDB::bind_method(_MD("hide"), &Spatial::hide); ObjectTypeDB::bind_method(_MD("is_visible"), &Spatial::is_visible); ObjectTypeDB::bind_method(_MD("is_hidden"), &Spatial::is_hidden); + ObjectTypeDB::bind_method(_MD("set_hidden","hidden"), &Spatial::set_hidden); ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_); ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 7fa6099d7a..b1e3a82868 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -191,6 +191,7 @@ public: void hide(); bool is_visible() const; bool is_hidden() const; + void set_hidden(bool p_hidden); #ifdef TOOLS_ENABLED void set_import_transform(const Transform& p_transform) ; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 75a1cb92ee..22e3a81e52 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -623,7 +623,7 @@ void FileDialog::_update_drives() { } } -bool FileDialog::default_show_hidden_files=true; +bool FileDialog::default_show_hidden_files=false; void FileDialog::_bind_methods() { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 18de8ed568..10ba20a833 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -568,7 +568,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { int char_w = 0; if (font != NULL) { - int char_w = font->get_char_size(text[ofs]).width; + char_w = font->get_char_size(text[ofs]).width; } pixel_ofs+=char_w; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 97c36ff71b..a832162994 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -628,11 +628,11 @@ String Node::validate_child_name(const String& p_name) const { } -void Node::_validate_child_name(Node *p_child) { +void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) { /* Make sure the name is unique */ - if (node_hrcr) { + if (node_hrcr || p_force_human_readable) { //this approach to autoset node names is human readable but very slow //it's turned on while running in the editor @@ -700,11 +700,7 @@ void Node::_validate_child_name(Node *p_child) { if (!unique) { node_hrcr_count.ref(); -#ifdef DEBUG_ENABLED - String name = "@"+String(p_child->get_type_name())+itos(node_hrcr_count.get()); -#else - String name = "@"+itos(node_hrcr_count.get()); -#endif + String name = "@"+String(p_child->get_name())+"@"+itos(node_hrcr_count.get()); p_child->data.name=name; } } @@ -732,24 +728,27 @@ void Node::_add_child_nocheck(Node* p_child,const StringName& p_name) { } -void Node::add_child(Node *p_child) { +void Node::add_child(Node *p_child, bool p_legible_unique_name) { ERR_FAIL_NULL(p_child); /* Fail if node has a parent */ - ERR_EXPLAIN("Can't add child "+p_child->get_name()+" to itself.") - ERR_FAIL_COND( p_child==this ); // adding to itself! + if (p_child==this) { + ERR_EXPLAIN("Can't add child "+p_child->get_name()+" to itself.") + ERR_FAIL_COND( p_child==this ); // adding to itself! + } ERR_EXPLAIN("Can't add child, already has a parent"); ERR_FAIL_COND( p_child->data.parent ); ERR_EXPLAIN("Can't add child while a notification is happening"); ERR_FAIL_COND( data.blocked > 0 ); /* Validate name */ - _validate_child_name(p_child); + _validate_child_name(p_child,p_legible_unique_name); _add_child_nocheck(p_child,p_child->data.name); } + void Node::_propagate_validate_owner() { if (data.owner) { @@ -1984,7 +1983,7 @@ void Node::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_name","name"),&Node::set_name); ObjectTypeDB::bind_method(_MD("get_name"),&Node::get_name); - ObjectTypeDB::bind_method(_MD("add_child","node:Node"),&Node::add_child); + ObjectTypeDB::bind_method(_MD("add_child","node:Node","legible_unique_name"),&Node::add_child,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("remove_child","node:Node"),&Node::remove_child); //ObjectTypeDB::bind_method(_MD("remove_and_delete_child","node:Node"),&Node::remove_and_delete_child); ObjectTypeDB::bind_method(_MD("get_child_count"),&Node::get_child_count); diff --git a/scene/main/node.h b/scene/main/node.h index 87fa4dd6ca..196c4a06eb 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -122,7 +122,7 @@ private: - void _validate_child_name(Node *p_name); + void _validate_child_name(Node *p_name, bool p_force_human_readable=false); void _propagate_reverse_notification(int p_notification); void _propagate_deferred_notification(int p_notification, bool p_reverse); @@ -187,7 +187,7 @@ public: StringName get_name() const; void set_name(const String& p_name); - void add_child(Node *p_child); + void add_child(Node *p_child,bool p_legible_unique_name=false); void remove_child(Node *p_child); int get_child_count() const; diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 8edbaf0b89..c66e73b430 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -382,7 +382,7 @@ void BodySW::set_space(SpaceSW *p_space){ } -void BodySW::_compute_area_gravity(const AreaSW *p_area) { +void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) { if (p_area->is_gravity_point()) { if(p_area->get_gravity_distance_scale() > 0) { @@ -394,6 +394,9 @@ void BodySW::_compute_area_gravity(const AreaSW *p_area) { } else { gravity += p_area->get_gravity_vector() * p_area->get_gravity(); } + + area_linear_damp += p_area->get_linear_damp(); + area_angular_damp += p_area->get_angular_damp(); } void BodySW::integrate_forces(real_t p_step) { @@ -409,13 +412,15 @@ void BodySW::integrate_forces(real_t p_step) { int ac = areas.size(); bool replace = false; - gravity=Vector3(0,0,0); + gravity = Vector3(0,0,0); + area_linear_damp = 0; + area_angular_damp = 0; if (ac) { areas.sort(); const AreaCMP *aa = &areas[0]; damp_area = aa[ac-1].area; for(int i=ac-1;i>=0;i--) { - _compute_area_gravity(aa[i].area); + _compute_area_gravity_and_dampenings(aa[i].area); if (aa[i].area->get_space_override_mode() == PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE) { replace = true; break; @@ -424,20 +429,21 @@ void BodySW::integrate_forces(real_t p_step) { } if( !replace ) { - _compute_area_gravity(def_area); + _compute_area_gravity_and_dampenings(def_area); } gravity*=gravity_scale; + // If less than 0, override dampenings with that of the Body if (angular_damp>=0) area_angular_damp=angular_damp; - else - area_angular_damp=damp_area->get_angular_damp(); + //else + // area_angular_damp=damp_area->get_angular_damp(); if (linear_damp>=0) area_linear_damp=linear_damp; - else - area_linear_damp=damp_area->get_linear_damp(); + //else + // area_linear_damp=damp_area->get_linear_damp(); Vector3 motion; diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index 66d814bfd1..4c4c7818c5 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -130,7 +130,7 @@ class BodySW : public CollisionObjectSW { BodySW *island_next; BodySW *island_list_next; - _FORCE_INLINE_ void _compute_area_gravity(const AreaSW *p_area); + _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const AreaSW *p_area); _FORCE_INLINE_ void _update_inertia_tensor(); diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 3afbbe5455..d0c5cbc77b 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -380,7 +380,7 @@ void Body2DSW::set_space(Space2DSW *p_space){ } -void Body2DSW::_compute_area_gravity(const Area2DSW *p_area) { +void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) { if (p_area->is_gravity_point()) { if(p_area->get_gravity_distance_scale() > 0) { @@ -393,6 +393,8 @@ void Body2DSW::_compute_area_gravity(const Area2DSW *p_area) { gravity += p_area->get_gravity_vector() * p_area->get_gravity(); } + area_linear_damp += p_area->get_linear_damp(); + area_angular_damp += p_area->get_angular_damp(); } void Body2DSW::integrate_forces(real_t p_step) { @@ -406,13 +408,15 @@ void Body2DSW::integrate_forces(real_t p_step) { int ac = areas.size(); bool replace = false; - gravity=Vector2(0,0); + gravity = Vector2(0,0); + area_angular_damp = 0; + area_linear_damp = 0; if (ac) { areas.sort(); const AreaCMP *aa = &areas[0]; damp_area = aa[ac-1].area; for(int i=ac-1;i>=0;i--) { - _compute_area_gravity(aa[i].area); + _compute_area_gravity_and_dampenings(aa[i].area); if (aa[i].area->get_space_override_mode() == Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE) { replace = true; break; @@ -420,19 +424,20 @@ void Body2DSW::integrate_forces(real_t p_step) { } } if( !replace ) { - _compute_area_gravity(def_area); + _compute_area_gravity_and_dampenings(def_area); } gravity*=gravity_scale; + // If less than 0, override dampenings with that of the Body2D if (angular_damp>=0) - area_angular_damp=angular_damp; - else - area_angular_damp=damp_area->get_angular_damp(); + area_angular_damp = angular_damp; + //else + // area_angular_damp=damp_area->get_angular_damp(); if (linear_damp>=0) - area_linear_damp=linear_damp; - else - area_linear_damp=damp_area->get_linear_damp(); + area_linear_damp = linear_damp; + //else + // area_linear_damp=damp_area->get_linear_damp(); Vector2 motion; bool do_motion=false; diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index 2fbfcaca60..8418c5dcd7 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -132,7 +132,7 @@ class Body2DSW : public CollisionObject2DSW { Body2DSW *island_next; Body2DSW *island_list_next; - _FORCE_INLINE_ void _compute_area_gravity(const Area2DSW *p_area); + _FORCE_INLINE_ void _compute_area_gravity_and_dampenings(const Area2DSW *p_area); friend class Physics2DDirectBodyStateSW; // i give up, too many functions to expose diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 4ccb612a39..b8aa5874d1 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -961,7 +961,7 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) { Object *obj=NULL; RES res; - Node *node = root->get_node_and_resource(animation->track_get_path(i),res); + Node *node = root->get_node_and_resource(p_animation->track_get_path(i),res); if (res.is_valid()) { obj=res.ptr(); @@ -969,32 +969,32 @@ void AnimationKeyEditor::_cleanup_animation(Ref<Animation> p_animation) { obj=node; } - if (obj && animation->track_get_type(i)==Animation::TYPE_VALUE) { - valid_type=obj->get_static_property_type(animation->track_get_path(i).get_property(),&prop_exists); + if (obj && p_animation->track_get_type(i)==Animation::TYPE_VALUE) { + valid_type=obj->get_static_property_type(p_animation->track_get_path(i).get_property(),&prop_exists); } if (!obj && cleanup_tracks->is_pressed()) { - animation->remove_track(i); + p_animation->remove_track(i); i--; continue; } - if (!prop_exists || animation->track_get_type(i)!=Animation::TYPE_VALUE || cleanup_keys->is_pressed()==false) + if (!prop_exists || p_animation->track_get_type(i)!=Animation::TYPE_VALUE || cleanup_keys->is_pressed()==false) continue; - for(int j=0;j<animation->track_get_key_count(i);j++) { + for(int j=0;j<p_animation->track_get_key_count(i);j++) { - Variant v = animation->track_get_key_value(i,j); + Variant v = p_animation->track_get_key_value(i,j); if (!Variant::can_convert(v.get_type(),valid_type)) { - animation->track_remove_key(i,j); + p_animation->track_remove_key(i,j); j--; } } - if (animation->track_get_key_count(i)==0 && cleanup_tracks->is_pressed()) { - animation->remove_track(i); + if (p_animation->track_get_key_count(i)==0 && cleanup_tracks->is_pressed()) { + p_animation->remove_track(i); i--; } } diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index 66b38e2f0c..104539c308 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -34,8 +34,7 @@ void EditorFileDialog::_notification(int p_what) { fav_down->set_icon(get_icon("MoveDown","EditorIcons")); fav_rm->set_icon(get_icon("RemoveSmall","EditorIcons")); - } - if (p_what==NOTIFICATION_PROCESS) { + } else if (p_what==NOTIFICATION_PROCESS) { if (preview_waiting) { preview_wheel_timeout-=get_process_delta_time(); @@ -48,12 +47,17 @@ void EditorFileDialog::_notification(int p_what) { preview_wheel_timeout=0.1; } } - } - - if (p_what==NOTIFICATION_DRAW) { + } else if (p_what==NOTIFICATION_DRAW) { //RID ci = get_canvas_item(); //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); + } else if (p_what==EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { + + bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"); + + if (show_hidden != show_hidden_files) { + set_show_hidden_files(show_hidden); + } } } @@ -1013,7 +1017,7 @@ void EditorFileDialog::_go_forward(){ } -bool EditorFileDialog::default_show_hidden_files=true; +bool EditorFileDialog::default_show_hidden_files=false; void EditorFileDialog::set_display_mode(DisplayMode p_mode) { @@ -1142,7 +1146,7 @@ void EditorFileDialog::_save_to_recent() { EditorFileDialog::EditorFileDialog() { - show_hidden_files=true; + show_hidden_files=default_show_hidden_files; display_mode=DISPLAY_THUMBNAILS; local_history_pos=0; diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index a4906c1b3a..cd455406b7 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -399,6 +399,40 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const } +String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { + String user_file = EditorSettings::get_singleton()->get_settings_path() + +"/templates/"+template_file_name; + String system_file=OS::get_singleton()->get_installed_templates_path(); + bool has_system_path=(system_file!=""); + system_file+=template_file_name; + + // Prefer user file + if (FileAccess::exists(user_file)) { + return user_file; + } + + // Now check system file + if (has_system_path) { + if (FileAccess::exists(system_file)) { + return system_file; + } + } + + // Not found + if (err) { + *err+="No export template found at \""+user_file+"\""; + if (has_system_path) + *err+="\n or \""+system_file+"\"."; + else + *err+="."; + } + return ""; +} + +bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const { + return find_export_template(template_file_name,err)!=""; +} + /////////////////////////////////////// @@ -1131,19 +1165,32 @@ Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug, ep.step("Setting Up..",0); - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - if (use64) { - if (p_debug) - exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary64; - else - exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary64; - } else { + String exe_path=""; - if (p_debug) - exe_path=custom_debug_binary!=""?custom_debug_binary:exe_path+debug_binary32; - else - exe_path=custom_release_binary!=""?custom_release_binary:exe_path+release_binary32; + if (p_debug) + exe_path=custom_debug_binary; + else + exe_path=custom_release_binary; + if (exe_path=="") { + String fname; + if (use64) { + if (p_debug) + fname=debug_binary64; + else + fname=release_binary64; + } else { + if (p_debug) + fname=debug_binary32; + else + fname=release_binary32; + } + String err=""; + exe_path=find_export_template(fname,&err); + if (exe_path=="") { + EditorNode::add_io_error(err); + return ERR_FILE_CANT_READ; + } } FileAccess *src_exe=FileAccess::open(exe_path,FileAccess::READ); @@ -1207,14 +1254,12 @@ bool EditorExportPlatformPC::can_export(String *r_error) const { String err; bool valid=true; - String exe_path = EditorSettings::get_singleton()->get_settings_path()+"/templates/"; - - if (use64 && (!FileAccess::exists(exe_path+debug_binary64) || !FileAccess::exists(exe_path+release_binary64))) { + if (use64 && (!exists_export_template(debug_binary64)) || !exists_export_template(release_binary64)) { valid=false; err="No 64 bits export templates found.\nDownload and install export templates.\n"; } - if (!use64 && (!FileAccess::exists(exe_path+debug_binary32) || !FileAccess::exists(exe_path+release_binary32))) { + if (!use64 && (!exists_export_template(debug_binary32) || !exists_export_template(release_binary32))) { valid=false; err="No 32 bits export templates found.\nDownload and install export templates.\n"; } diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index e3ef3a592c..93086f7ad4 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -86,6 +86,8 @@ protected: Vector<uint8_t> get_exported_file_default(String& p_fname) const; virtual Vector<uint8_t> get_exported_file(String& p_fname) const; virtual Vector<StringName> get_dependencies(bool p_bundles) const; + virtual String find_export_template(String template_file_name, String *err=NULL) const; + virtual bool exists_export_template(String template_file_name, String *err=NULL) const; struct TempData { diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 8b04e4f77e..8e39ce36f8 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -4594,6 +4594,7 @@ EditorNode::EditorNode() { ResourceLoader::set_abort_on_missing_resources(false); FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); + EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); ResourceLoader::set_error_notify_func(this,_load_error_notify); ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report); diff --git a/tools/editor/editor_settings.h b/tools/editor/editor_settings.h index 4ba940cd1c..bdfa5160d6 100644 --- a/tools/editor/editor_settings.h +++ b/tools/editor/editor_settings.h @@ -107,6 +107,7 @@ public: static EditorSettings *get_singleton(); void erase(String p_var); String get_settings_path() const; + String get_global_settings_path() const; String get_project_settings_path() const; const Map<String,Plugin>& get_plugins() const { return plugins; } diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 956e7a98a2..4e394f9e3f 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1137,12 +1137,14 @@ void ScriptEditor::_menu_option(int p_option) { return; int line = tx->cursor_get_line(); int next_line = line + 1; + int column = tx->cursor_get_column(); - if (line == tx->get_line_count() - 1 || next_line >= tx->get_line_count()) + if (line >= tx->get_line_count() - 1) tx->set_line(line, tx->get_line(line) + "\n"); String line_clone = tx->get_line(line); tx->insert_at(line_clone, next_line); + tx->cursor_set_column(column); tx->update(); } break; |