summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp10
-rw-r--r--core/dictionary.cpp10
-rw-r--r--core/dictionary.h2
-rw-r--r--core/global_constants.cpp1
-rw-r--r--core/globals.cpp4
-rw-r--r--core/helper/value_evaluator.h43
-rw-r--r--core/image.cpp60
-rw-r--r--core/image.h1
-rw-r--r--core/input_map.cpp2
-rw-r--r--core/io/config_file.cpp2
-rw-r--r--core/io/http_client.cpp64
-rw-r--r--core/io/http_client.h2
-rw-r--r--core/io/marshalls.cpp6
-rw-r--r--core/make_binders.py48
-rw-r--r--core/math/math_funcs.cpp4
-rw-r--r--core/os/file_access.cpp4
-rw-r--r--core/translation.cpp16
-rw-r--r--core/translation.h4
-rw-r--r--core/typedefs.h4
-rw-r--r--core/ustring.cpp48
-rw-r--r--core/ustring.h4
-rw-r--r--core/variant.cpp12
-rw-r--r--core/variant_call.cpp10
-rw-r--r--core/vector.h5
24 files changed, 307 insertions, 59 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1eb7f790a3..45d089599b 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1893,15 +1893,15 @@ void _Directory::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_drive","idx"),&_Directory::get_drive);
ObjectTypeDB::bind_method(_MD("change_dir:Error","todir"),&_Directory::change_dir);
ObjectTypeDB::bind_method(_MD("get_current_dir"),&_Directory::get_current_dir);
- ObjectTypeDB::bind_method(_MD("make_dir:Error","name"),&_Directory::make_dir);
- ObjectTypeDB::bind_method(_MD("make_dir_recursive:Error","name"),&_Directory::make_dir_recursive);
- ObjectTypeDB::bind_method(_MD("file_exists","name"),&_Directory::file_exists);
- ObjectTypeDB::bind_method(_MD("dir_exists","name"),&_Directory::dir_exists);
+ ObjectTypeDB::bind_method(_MD("make_dir:Error","path"),&_Directory::make_dir);
+ ObjectTypeDB::bind_method(_MD("make_dir_recursive:Error","path"),&_Directory::make_dir_recursive);
+ ObjectTypeDB::bind_method(_MD("file_exists","path"),&_Directory::file_exists);
+ ObjectTypeDB::bind_method(_MD("dir_exists","path"),&_Directory::dir_exists);
// ObjectTypeDB::bind_method(_MD("get_modified_time","file"),&_Directory::get_modified_time);
ObjectTypeDB::bind_method(_MD("get_space_left"),&_Directory::get_space_left);
ObjectTypeDB::bind_method(_MD("copy:Error","from","to"),&_Directory::copy);
ObjectTypeDB::bind_method(_MD("rename:Error","from","to"),&_Directory::rename);
- ObjectTypeDB::bind_method(_MD("remove:Error","file"),&_Directory::remove);
+ ObjectTypeDB::bind_method(_MD("remove:Error","path"),&_Directory::remove);
}
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index a013c21b29..75c8531251 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -110,6 +110,16 @@ bool Dictionary::has(const Variant& p_key) const {
return _p->variant_map.has(p_key);
}
+
+bool Dictionary::has_all(const Array& p_keys) const {
+ for (int i=0;i<p_keys.size();i++) {
+ if( !has(p_keys[i]) ) {
+ return false;
+ }
+ }
+ return true;
+}
+
void Dictionary::erase(const Variant& p_key) {
_copy_on_write();
_p->variant_map.erase(p_key);
diff --git a/core/dictionary.h b/core/dictionary.h
index 145e7e5c84..c854e95ee6 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -69,6 +69,8 @@ public:
bool is_shared() const;
bool has(const Variant& p_key) const;
+ bool has_all(const Array& p_keys) const;
+
void erase(const Variant& p_key);
bool operator==(const Dictionary& p_dictionary) const;
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 130fca1b2a..3cf4ff8f83 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -476,7 +476,6 @@ static _GlobalConstant _global_constants[]={
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ),
- BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ),
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_EDITOR ),
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_NETWORK ),
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_DEFAULT ),
diff --git a/core/globals.cpp b/core/globals.cpp
index c0c1171ae6..020e05fb8f 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -54,7 +54,7 @@ String Globals::localize_path(const String& p_path) const {
if (resource_path=="")
return p_path; //not initialied yet
- if (p_path.find(":/") != -1)
+ if (p_path.begins_with("res://") || p_path.begins_with("user://"))
return p_path.simplify_path();
@@ -82,6 +82,8 @@ String Globals::localize_path(const String& p_path) const {
if (sep == -1) {
return "res://"+path;
};
+
+
String parent = path.substr(0, sep);
String plocal = localize_path(parent);
diff --git a/core/helper/value_evaluator.h b/core/helper/value_evaluator.h
new file mode 100644
index 0000000000..a03602bc61
--- /dev/null
+++ b/core/helper/value_evaluator.h
@@ -0,0 +1,43 @@
+/*************************************************************************/
+/* value_evaluator.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef VALUE_EVALUATOR_H
+#define VALUE_EVALUATOR_H
+
+#include "core/object.h"
+
+class ValueEvaluator : public Object {
+
+ OBJ_TYPE(ValueEvaluator, Object);
+public:
+ virtual double eval(const String& p_text) {
+ return p_text.to_double();
+ }
+};
+
+#endif // VALUE_EVALUATOR_H
diff --git a/core/image.cpp b/core/image.cpp
index 52946bbb85..8635aa1b29 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -901,6 +901,66 @@ static void _generate_po2_mipmap(const uint8_t* p_src, uint8_t* p_dst, uint32_t
}
+void Image::shrink_x2() {
+
+ ERR_FAIL_COND(format==FORMAT_INDEXED || format==FORMAT_INDEXED_ALPHA);
+ ERR_FAIL_COND( data.size()==0 );
+
+
+
+ if (mipmaps) {
+
+ //just use the lower mipmap as base and copy all
+ DVector<uint8_t> new_img;
+
+ int ofs = get_mipmap_offset(1);
+
+ int new_size = data.size()-ofs;
+ new_img.resize(new_size);
+
+
+ {
+ DVector<uint8_t>::Write w=new_img.write();
+ DVector<uint8_t>::Read r=data.read();
+
+ copymem(w.ptr(),&r[ofs],new_size);
+ }
+
+ mipmaps--;
+ width/=2;
+ height/=2;
+ data=new_img;
+
+ } else {
+
+ DVector<uint8_t> new_img;
+
+ ERR_FAIL_COND( format>=FORMAT_INDEXED );
+ int ps = get_format_pixel_size(format);
+ new_img.resize((width/2)*(height/2)*ps);
+
+ {
+ DVector<uint8_t>::Write w=new_img.write();
+ DVector<uint8_t>::Read r=data.read();
+
+ switch(format) {
+
+ case FORMAT_GRAYSCALE:
+ case FORMAT_INTENSITY: _generate_po2_mipmap<1>(r.ptr(), w.ptr(), width,height); break;
+ case FORMAT_GRAYSCALE_ALPHA: _generate_po2_mipmap<2>(r.ptr(), w.ptr(), width,height); break;
+ case FORMAT_RGB: _generate_po2_mipmap<3>(r.ptr(), w.ptr(), width,height); break;
+ case FORMAT_RGBA: _generate_po2_mipmap<4>(r.ptr(), w.ptr(), width,height); break;
+ default: {}
+ }
+ }
+
+ width/=2;
+ height/=2;
+ data=new_img;
+
+ }
+}
+
Error Image::generate_mipmaps(int p_mipmaps,bool p_keep_existing) {
if (!_can_modify(format)) {
diff --git a/core/image.h b/core/image.h
index fe1822f661..35bbd1a684 100644
--- a/core/image.h
+++ b/core/image.h
@@ -249,6 +249,7 @@ public:
void resize_to_po2(bool p_square=false);
void resize( int p_width, int p_height, Interpolation p_interpolation=INTERPOLATE_BILINEAR );
Image resized( int p_width, int p_height, int p_interpolation=INTERPOLATE_BILINEAR );
+ void shrink_x2();
/**
* Crop the image to a specific size, if larger, then the image is filled by black
*/
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 5a9b035771..17e98902a1 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -106,7 +106,7 @@ List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const
} break;
case InputEvent::JOYSTICK_MOTION: {
- same=(e.joy_motion.axis==p_event.joy_motion.axis);
+ same=(e.joy_motion.axis==p_event.joy_motion.axis && (e.joy_motion.axis_value < 0) == (p_event.joy_motion.axis_value < 0));
} break;
}
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index fd20ec9404..e0dc7ef9fa 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -207,7 +207,7 @@ Error ConfigFile::load(const String& p_path) {
void ConfigFile::_bind_methods(){
ObjectTypeDB::bind_method(_MD("set_value","section","key","value"),&ConfigFile::set_value);
- ObjectTypeDB::bind_method(_MD("get_value","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("get_value:Variant","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant()));
ObjectTypeDB::bind_method(_MD("has_section","section"),&ConfigFile::has_section);
ObjectTypeDB::bind_method(_MD("has_section_key","section","key"),&ConfigFile::has_section_key);
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index e0c01c9422..680e0ef7f9 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -72,7 +72,6 @@ Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_ve
return OK;
}
-
void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){
close();
@@ -80,6 +79,65 @@ void HTTPClient::set_connection(const Ref<StreamPeer>& p_connection){
}
+Ref<StreamPeer> HTTPClient::get_connection() const {
+
+ return connection;
+}
+
+Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const DVector<uint8_t>& p_body) {
+
+ ERR_FAIL_INDEX_V(p_method,METHOD_MAX,ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(status!=STATUS_CONNECTED,ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(connection.is_null(),ERR_INVALID_DATA);
+
+
+ static const char* _methods[METHOD_MAX]={
+ "GET",
+ "HEAD",
+ "POST",
+ "PUT",
+ "DELETE",
+ "OPTIONS",
+ "TRACE",
+ "CONNECT"};
+
+ String request=String(_methods[p_method])+" "+p_url+" HTTP/1.1\r\n";
+ request+="Host: "+conn_host+":"+itos(conn_port)+"\r\n";
+ bool add_clen=p_body.size()>0;
+ for(int i=0;i<p_headers.size();i++) {
+ request+=p_headers[i]+"\r\n";
+ if (add_clen && p_headers[i].find("Content-Length:")==0) {
+ add_clen=false;
+ }
+ }
+ if (add_clen) {
+ request+="Content-Length: "+itos(p_body.size())+"\r\n";
+ //should it add utf8 encoding? not sure
+ }
+ request+="\r\n";
+ CharString cs=request.utf8();
+
+ DVector<uint8_t> data;
+
+ //Maybe this goes faster somehow?
+ for(int i=0;i<cs.length();i++) {
+ data.append( cs[i] );
+ }
+ data.append_array( p_body );
+
+ DVector<uint8_t>::Read r = data.read();
+ Error err = connection->put_data(&r[0], data.size());
+
+ if (err) {
+ close();
+ status=STATUS_CONNECTION_ERROR;
+ return err;
+ }
+
+ status=STATUS_REQUESTING;
+
+ return OK;
+}
Error HTTPClient::request( Method p_method, const String& p_url, const Vector<String>& p_headers,const String& p_body) {
@@ -151,6 +209,7 @@ int HTTPClient::get_response_code() const {
return response_num;
}
+
Error HTTPClient::get_response_headers(List<String> *r_response) {
if (!response_headers.size())
@@ -297,6 +356,7 @@ Error HTTPClient::poll(){
chunked=false;
body_left=0;
chunk_left=0;
+ response_str.clear();
response_headers.clear();
response_num = RESPONSE_OK;
@@ -578,6 +638,8 @@ void HTTPClient::_bind_methods() {
ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true));
ObjectTypeDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection);
+ ObjectTypeDB::bind_method(_MD("get_connection:StreamPeer"),&HTTPClient::get_connection);
+ ObjectTypeDB::bind_method(_MD("request_raw","method","url","headers","body"),&HTTPClient::request_raw,DEFVAL(String()));
ObjectTypeDB::bind_method(_MD("request","method","url","headers","body"),&HTTPClient::request,DEFVAL(String()));
ObjectTypeDB::bind_method(_MD("send_body_text","body"),&HTTPClient::send_body_text);
ObjectTypeDB::bind_method(_MD("send_body_data","body"),&HTTPClient::send_body_data);
diff --git a/core/io/http_client.h b/core/io/http_client.h
index e795646c70..a9cfb1ed73 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -168,7 +168,9 @@ public:
Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true);
void set_connection(const Ref<StreamPeer>& p_connection);
+ Ref<StreamPeer> get_connection() const;
+ Error request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const DVector<uint8_t>& p_body);
Error request( Method p_method, const String& p_url, const Vector<String>& p_headers,const String& p_body=String());
Error send_body_text(const String& p_body);
Error send_body_data(const ByteArray& p_body);
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 1733aecd46..60617e1237 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -438,8 +438,9 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
case InputEvent::JOYSTICK_MOTION: {
ie.joy_motion.axis=decode_uint32(&buf[12]);
+ ie.joy_motion.axis_value=decode_float(&buf[16]);
if (r_len)
- (*r_len)+=4;
+ (*r_len)+=8;
} break;
}
@@ -1154,8 +1155,9 @@ Error encode_variant(const Variant& p_variant, uint8_t *r_buffer, int &r_len) {
int axis = ie.joy_motion.axis;
encode_uint32(axis,&buf[llen]);
+ encode_float(ie.joy_motion.axis_value, &buf[llen+4]);
}
- llen+=4;
+ llen+=8;
} break;
}
diff --git a/core/make_binders.py b/core/make_binders.py
index ebd48777b6..93371dc0a3 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -6,7 +6,7 @@ template_typed="""
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
public:
-
+
$ifret R$ $ifnoret void$ (T::*method)($arg, P@$) $ifconst const$;
#ifdef DEBUG_METHODS_ENABLED
virtual Variant::Type _gen_argument_type(int p_arg) const { return _get_argument_type(p_arg); }
@@ -16,13 +16,13 @@ public:
$
return Variant::NIL;
}
-#endif
+#endif
virtual String get_instance_type() const {
return T::get_type_static();
}
virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) {
-
+
T *instance=p_object->cast_to<T>();
r_error.error=Variant::CallError::CALL_OK;
#ifdef DEBUG_METHODS_ENABLED
@@ -47,7 +47,7 @@ public:
$ifret return Variant(ret);$
$ifnoret return Variant();$
}
-
+
MethodBind$argc$$ifret R$$ifconst C$ () {
#ifdef DEBUG_METHODS_ENABLED
@@ -55,14 +55,14 @@ public:
_generate_argument_types($argc$);
#else
set_argument_count($argc$);
-#endif
+#endif
};
};
template<class T $ifret ,class R$ $ifargs ,$ $arg, class P@$>
MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$) $ifconst const$ ) {
- MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$> * a = memnew( (MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$>) );
+ MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$> * a = memnew( (MethodBind$argc$$ifret R$$ifconst C$<T $ifret ,R$ $ifargs ,$ $arg, P@$>) );
a->method=p_method;
return a;
}
@@ -88,7 +88,7 @@ public:
$
return Variant::NIL;
}
-#endif
+#endif
virtual String get_instance_type() const {
return type_name;
}
@@ -105,15 +105,15 @@ public:
r_error.error=Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS;
r_error.argument=get_argument_count();
return Variant();
- }
-
+ }
+
if (p_arg_count<(get_argument_count()-get_default_argument_count())) {
r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument=get_argument_count()-get_default_argument_count();
return Variant();
}
-
+
$arg CHECK_ARG(@);
$
#endif
@@ -128,7 +128,7 @@ public:
_generate_argument_types($argc$);
#else
set_argument_count($argc$);
-#endif
+#endif
};
};
@@ -151,12 +151,12 @@ MethodBind* create_method_bind($ifret R$ $ifnoret void$ (T::*p_method)($arg, P@$
def make_version(template,nargs,argmax,const,ret):
-
+
intext=template
from_pos=0
outtext=""
-
- while(True):
+
+ while(True):
to_pos=intext.find("$",from_pos)
if (to_pos==-1):
outtext+=intext[from_pos:]
@@ -169,13 +169,13 @@ def make_version(template,nargs,argmax,const,ret):
macro=intext[to_pos+1:end]
cmd=""
data=""
-
+
if (macro.find(" ")!=-1):
cmd=macro[0:macro.find(" ")]
data=macro[macro.find(" ")+1:]
else:
cmd=macro
-
+
if (cmd=="argc"):
outtext+=str(nargs)
if (cmd=="ifret" and ret):
@@ -206,11 +206,11 @@ def make_version(template,nargs,argmax,const,ret):
elif (cmd=="noarg"):
for i in range(nargs+1,argmax+1):
outtext+=data.replace("@",str(i))
-
+
from_pos=end+1
-
+
return outtext
-
+
def run(target, source, env):
@@ -244,9 +244,9 @@ def run(target, source, env):
f.write(text_ext)
f.close()
-
-
-
-
-
+
+
+
+
+
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 07f114725d..0fbd031214 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -135,18 +135,20 @@ double Math::rad2deg(double p_y) {
double Math::round(double p_val) {
- if (p_val>0) {
+ if (p_val>=0) {
return ::floor(p_val+0.5);
} else {
p_val=-p_val;
return -::floor(p_val+0.5);
}
}
+
double Math::asin(double p_x) {
return ::asin(p_x);
}
+
double Math::acos(double p_x) {
return ::acos(p_x);
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 0846ef3eb0..a3ee9395de 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -284,7 +284,7 @@ Vector<String> FileAccess::get_csv_line(String delim) const {
String l;
int qc=0;
do {
- l+=get_line();
+ l+=get_line()+"\n";
qc=0;
for(int i=0;i<l.length();i++) {
@@ -295,6 +295,8 @@ Vector<String> FileAccess::get_csv_line(String delim) const {
} while (qc%2);
+ l=l.substr(0, l.length()-1);
+
Vector<String> strings;
bool in_quote=false;
diff --git a/core/translation.cpp b/core/translation.cpp
index e4dad8d8de..85e207e08d 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -665,6 +665,22 @@ void TranslationServer::setup() {
}
+void TranslationServer::set_tool_translation(const Ref<Translation>& p_translation) {
+ tool_translation=p_translation;
+}
+
+StringName TranslationServer::tool_translate(const StringName& p_message) const {
+
+ if (tool_translation.is_valid()) {
+ StringName r = tool_translation->tr(p_message);
+ if (r)
+ return r;
+ }
+
+ return p_message;
+}
+
+
void TranslationServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_locale","locale"),&TranslationServer::set_locale);
diff --git a/core/translation.h b/core/translation.h
index 5be6b8913a..cdb22bfeca 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -75,6 +75,7 @@ class TranslationServer : public Object {
Set< Ref<Translation> > translations;
+ Ref<Translation> tool_translation;
bool enabled;
@@ -102,6 +103,9 @@ public:
static Vector<String> get_all_locales();
static Vector<String> get_all_locale_names();
+ void set_tool_translation(const Ref<Translation>& p_translation);
+ StringName tool_translate(const StringName& p_message) const;
+
void setup();
void clear();
diff --git a/core/typedefs.h b/core/typedefs.h
index 5047644692..6f9bb58958 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -41,7 +41,11 @@
#define _MKSTR(m_x) _STR(m_x)
#endif
// have to include version.h for this to work, include it in the .cpp not the .h
+#ifdef VERSION_PATCH
+#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_PATCH)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION)
+#else
#define VERSION_MKSTRING _MKSTR(VERSION_MAJOR)"." _MKSTR(VERSION_MINOR)"." _MKSTR(VERSION_STATUS)"." _MKSTR(VERSION_REVISION)
+#endif // VERSION_PATCH
#define VERSION_FULL_NAME _MKSTR(VERSION_NAME)" v" VERSION_MKSTRING
diff --git a/core/ustring.cpp b/core/ustring.cpp
index a9d0012ebe..1f0eadc03f 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2867,25 +2867,29 @@ CharType String::ord_at(int p_idx) const {
return operator[](p_idx);
}
-String String::strip_edges() const {
+String String::strip_edges(bool left, bool right) const {
int len=length();
int beg=0,end=len;
- for (int i=0;i<length();i++) {
+ if(left) {
+ for (int i=0;i<len;i++) {
- if (operator[](i)<=32)
- beg++;
- else
- break;
+ if (operator[](i)<=32)
+ beg++;
+ else
+ break;
+ }
}
- for (int i=(int)(length()-1);i>=0;i--) {
+ if(right) {
+ for (int i=(int)(len-1);i>=0;i--) {
- if (operator[](i)<=32)
- end--;
- else
- break;
+ if (operator[](i)<=32)
+ end--;
+ else
+ break;
+ }
}
if (beg==0 && end==len)
@@ -3629,13 +3633,14 @@ String String::percent_decode() const {
CharString pe;
- for(int i=0;i<length();i++) {
-
- uint8_t c=operator[](i);
+ CharString cs = utf8();
+ for(int i=0;i<cs.length();i++) {
+
+ uint8_t c = cs[i];
if (c=='%' && i<length()-2) {
- uint8_t a = LOWERCASE(operator[](i+1));
- uint8_t b = LOWERCASE(operator[](i+2));
+ uint8_t a = LOWERCASE(cs[i+1]);
+ uint8_t b = LOWERCASE(cs[i+2]);
c=0;
if (a>='0' && a<='9')
@@ -3955,3 +3960,14 @@ String String::sprintf(const Array& values, bool* error) const {
*error = false;
return formatted;
}
+
+#include "translation.h"
+
+String TTR(const String& p_text) {
+
+ if (TranslationServer::get_singleton()) {
+ return TranslationServer::get_singleton()->translate(p_text);
+ }
+
+ return p_text;
+}
diff --git a/core/ustring.h b/core/ustring.h
index 6310d0a854..78c041fb92 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -169,7 +169,7 @@ public:
String left(int p_pos) const;
String right(int p_pos) const;
- String strip_edges() const;
+ String strip_edges(bool left = true, bool right = true) const;
String strip_escapes() const;
String extension() const;
String basename() const;
@@ -256,5 +256,7 @@ struct NoCaseComparator {
/* end of namespace */
+//tool translate
+String TTR(const String&);
#endif
diff --git a/core/variant.cpp b/core/variant.cpp
index 527a0d238f..ea5a378ad0 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1556,6 +1556,18 @@ Variant::operator String() const {
return str;
} break;
+ case VECTOR2_ARRAY: {
+
+ DVector<Vector2> vec = operator DVector<Vector2>();
+ String str;
+ for(int i=0;i<vec.size();i++) {
+
+ if (i>0)
+ str+=", ";
+ str=str+Variant( vec[i] );
+ }
+ return str;
+ } break;
case VECTOR3_ARRAY: {
DVector<Vector3> vec = operator DVector<Vector3>();
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 78814c83e2..4be763a511 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -246,6 +246,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(String,match);
VCALL_LOCALMEM1R(String,matchn);
VCALL_LOCALMEM1R(String,begins_with);
+ VCALL_LOCALMEM1R(String,ends_with);
VCALL_LOCALMEM2R(String,replace);
VCALL_LOCALMEM2R(String,replacen);
VCALL_LOCALMEM2R(String,insert);
@@ -256,7 +257,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(String,to_lower);
VCALL_LOCALMEM1R(String,left);
VCALL_LOCALMEM1R(String,right);
- VCALL_LOCALMEM0R(String,strip_edges);
+ VCALL_LOCALMEM2R(String,strip_edges);
VCALL_LOCALMEM0R(String,extension);
VCALL_LOCALMEM0R(String,basename);
VCALL_LOCALMEM1R(String,plus_file);
@@ -440,6 +441,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Dictionary,empty);
VCALL_LOCALMEM0(Dictionary,clear);
VCALL_LOCALMEM1R(Dictionary,has);
+ VCALL_LOCALMEM1R(Dictionary,has_all);
VCALL_LOCALMEM1(Dictionary,erase);
VCALL_LOCALMEM0R(Dictionary,hash);
VCALL_LOCALMEM0R(Dictionary,keys);
@@ -593,6 +595,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_PTR0R(Image, get_data);
VCALL_PTR3(Image, blit_rect);
VCALL_PTR1R(Image, converted);
+ VCALL_PTR0(Image, fix_alpha_edges);
VCALL_PTR0R( AABB, get_area );
VCALL_PTR0R( AABB, has_no_area );
@@ -1260,6 +1263,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(STRING,BOOL,String,match,STRING,"expr",varray());
ADDFUNC1(STRING,BOOL,String,matchn,STRING,"expr",varray());
ADDFUNC1(STRING,BOOL,String,begins_with,STRING,"text",varray());
+ ADDFUNC1(STRING,BOOL,String,ends_with,STRING,"text",varray());
ADDFUNC2(STRING,STRING,String,replace,STRING,"what",STRING,"forwhat",varray());
ADDFUNC2(STRING,STRING,String,replacen,STRING,"what",STRING,"forwhat",varray());
@@ -1273,7 +1277,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(STRING,STRING,String,left,INT,"pos",varray());
ADDFUNC1(STRING,STRING,String,right,INT,"pos",varray());
- ADDFUNC0(STRING,STRING,String,strip_edges,varray());
+ ADDFUNC2(STRING,STRING,String,strip_edges,BOOL,"left",BOOL,"right",varray(true,true));
ADDFUNC0(STRING,STRING,String,extension,varray());
ADDFUNC0(STRING,STRING,String,basename,varray());
ADDFUNC1(STRING,STRING,String,plus_file,STRING,"file",varray());
@@ -1408,6 +1412,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(IMAGE, RAW_ARRAY, Image, get_data, varray());
ADDFUNC3(IMAGE, NIL, Image, blit_rect, IMAGE, "src", RECT2, "src_rect", VECTOR2, "dest", varray(0));
ADDFUNC1(IMAGE, IMAGE, Image, converted, INT, "format", varray(0));
+ ADDFUNC0(IMAGE, NIL, Image, fix_alpha_edges, varray());
ADDFUNC0(_RID,INT,RID,get_id,varray());
@@ -1423,6 +1428,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(DICTIONARY,BOOL,Dictionary,empty,varray());
ADDFUNC0(DICTIONARY,NIL,Dictionary,clear,varray());
ADDFUNC1(DICTIONARY,BOOL,Dictionary,has,NIL,"value",varray());
+ ADDFUNC1(DICTIONARY,BOOL,Dictionary,has_all,ARRAY,"values",varray());
ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray());
ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray());
ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray());
diff --git a/core/vector.h b/core/vector.h
index 16a09c1ddd..87248ccf68 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -70,7 +70,8 @@ class Vector {
}
_FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const {
- return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
+ //return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
+ return nearest_power_of_2(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
}
_FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const {
@@ -79,7 +80,7 @@ class Vector {
size_t p;
if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
if (_add_overflow(o, sizeof(SafeRefCount)+sizeof(int), &p)) return false;
- *out = nearest_power_of_2_templated(p);
+ *out = nearest_power_of_2(p);
return true;
#else
// Speed is more important than correctness here, do the operations unchecked