summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-05-24 01:35:47 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-05-24 01:35:47 -0300
commit1cad087969efefa401a11051343cd0689f660770 (patch)
tree1595dd049bdb7289752012dca4398b2251fb08fa /core
parentf9ff086235cd4ff406b136f62fff77b85c0873f9 (diff)
Making Godot Easier to Use..
-=-=-=-=-=-=-=-=-=-=-=-=-=-= -Auto indenter in code editor, this makes it much easier to paste external code. -Zoom in 2D viewport now uses the mouse pointer as reference. -Obscure hack to see where code/line of GDScript in C++ backtrace. -Fixed a bug where keys would get stuck on X11 if pressed simultaneously -Added Api on IP singleton to request local IPs. -Premultiplied alpha support when importing texture, editing PNGs and as a blend mode.
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/bind/core_bind.h10
-rw-r--r--core/image.cpp25
-rw-r--r--core/image.h1
-rw-r--r--core/io/file_access_encrypted.cpp5
-rw-r--r--core/io/ip.cpp13
-rw-r--r--core/io/ip.h3
-rw-r--r--core/os/file_access.cpp2
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/main_loop.cpp2
-rw-r--r--core/script_language.h1
11 files changed, 69 insertions, 2 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index ec159da00f..960cdbac20 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -98,6 +98,13 @@ void _ResourceSaver::_bind_methods() {
ObjectTypeDB::bind_method(_MD("save","path","resource:Resource"),&_ResourceSaver::save, DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_recognized_extensions","type"),&_ResourceSaver::get_recognized_extensions);
+
+ BIND_CONSTANT(FLAG_RELATIVE_PATHS);
+ BIND_CONSTANT(FLAG_BUNDLE_RESOURCES);
+ BIND_CONSTANT(FLAG_CHANGE_PATH);
+ BIND_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES);
+ BIND_CONSTANT(FLAG_SAVE_BIG_ENDIAN);
+ BIND_CONSTANT(FLAG_COMPRESS);
}
_ResourceSaver::_ResourceSaver() {
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 18eb594760..bb68bbaad8 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -39,6 +39,16 @@ protected:
static _ResourceSaver *singleton;
public:
+ enum SaverFlags {
+
+ FLAG_RELATIVE_PATHS=1,
+ FLAG_BUNDLE_RESOURCES=2,
+ FLAG_CHANGE_PATH=4,
+ FLAG_OMIT_EDITOR_PROPERTIES=8,
+ FLAG_SAVE_BIG_ENDIAN=16,
+ FLAG_COMPRESS=32,
+ };
+
static _ResourceSaver *get_singleton() { return singleton; }
Error save(const String &p_path,const RES& p_resource, uint32_t p_flags);
diff --git a/core/image.cpp b/core/image.cpp
index ccabd04d6f..db20862af5 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1660,6 +1660,31 @@ void Image::set_compress_bc_func(void (*p_compress_func)(Image *)) {
}
+
+void Image::premultiply_alpha() {
+
+ if (data.size()==0)
+ return;
+
+ if (format!=FORMAT_RGBA)
+ return; //not needed
+
+ DVector<uint8_t>::Write wp = data.write();
+ unsigned char *data_ptr=wp.ptr();
+
+
+ for(int i=0;i<height;i++) {
+ for(int j=0;j<width;j++) {
+
+ BColor bc = _get_pixel(j,i,data_ptr,0);
+ bc.r=(int(bc.r)*int(bc.a))>>8;
+ bc.g=(int(bc.g)*int(bc.a))>>8;
+ bc.b=(int(bc.b)*int(bc.a))>>8;
+ _put_pixel(j,i,bc,data_ptr);
+ }
+ }
+}
+
void Image::fix_alpha_edges() {
if (data.size()==0)
diff --git a/core/image.h b/core/image.h
index 186aceb1bf..99300fc3af 100644
--- a/core/image.h
+++ b/core/image.h
@@ -320,6 +320,7 @@ public:
void decompress();
void fix_alpha_edges();
+ void premultiply_alpha();
void blit_rect(const Image& p_src, const Rect2& p_src_rect,const Point2& p_dest);
void brush_transfer(const Image& p_src, const Image& p_brush, const Point2& p_dest);
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index bcd4197e11..29f27dcbda 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -25,6 +25,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base,const Vector<uint8_
} else if (p_mode==MODE_READ) {
+ writing=false;
key=p_key;
uint32_t magic = p_base->get_32();
print_line("MAGIC: "+itos(magic));
@@ -278,6 +279,10 @@ uint64_t FileAccessEncrypted::_get_modified_time(const String& p_file){
FileAccessEncrypted::FileAccessEncrypted() {
file=NULL;
+ pos=0;
+ eofed=false;
+ mode=MODE_MAX;
+ writing=false;
}
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 503a009444..d2a685f6b0 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -188,6 +188,18 @@ void IP::erase_resolve_item(ResolverID p_id) {
}
+Array IP::_get_local_addresses() const {
+
+ Array addresses;
+ List<IP_Address> ip_addresses;
+ get_local_addresses(&ip_addresses);
+ for(List<IP_Address>::Element *E=ip_addresses.front();E;E=E->next()) {
+ addresses.push_back(E->get());
+ }
+
+ return addresses;
+}
+
void IP::_bind_methods() {
ObjectTypeDB::bind_method(_MD("resolve_hostname","host"),&IP::resolve_hostname);
@@ -195,6 +207,7 @@ void IP::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_resolve_item_status","id"),&IP::get_resolve_item_status);
ObjectTypeDB::bind_method(_MD("get_resolve_item_address","id"),&IP::get_resolve_item_address);
ObjectTypeDB::bind_method(_MD("erase_resolve_item","id"),&IP::erase_resolve_item);
+ ObjectTypeDB::bind_method(_MD("get_local_addresses"),&IP::_get_local_addresses);
BIND_CONSTANT( RESOLVER_STATUS_NONE );
BIND_CONSTANT( RESOLVER_STATUS_WAITING );
diff --git a/core/io/ip.h b/core/io/ip.h
index f1ef5fe794..0181dc7d12 100644
--- a/core/io/ip.h
+++ b/core/io/ip.h
@@ -66,16 +66,19 @@ protected:
static void _bind_methods();
virtual IP_Address _resolve_hostname(const String& p_hostname)=0;
+ Array _get_local_addresses() const;
static IP* (*_create)();
public:
+
IP_Address resolve_hostname(const String& p_hostname);
// async resolver hostname
ResolverID resolve_hostname_queue_item(const String& p_hostname);
ResolverStatus get_resolve_item_status(ResolverID p_id) const;
IP_Address get_resolve_item_address(ResolverID p_id) const;
+ virtual void get_local_addresses(List<IP_Address> *r_addresses) const=0;
void erase_resolve_item(ResolverID p_id);
static IP* get_singleton();
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 31e7d19bae..ffa0cad8e4 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -100,7 +100,7 @@ FileAccess *FileAccess::open(const String& p_path, int p_mode_flags, Error *r_er
FileAccess *ret=NULL;
if (!(p_mode_flags&WRITE) && PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled()) {
ret = PackedData::get_singleton()->try_open_path(p_path);
- if (ret) {
+ if (ret) {
if (r_error)
*r_error=OK;
return ret;
diff --git a/core/os/input.cpp b/core/os/input.cpp
index d7c0d86d64..70733aadec 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -211,6 +211,8 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
if (p_event.key.scancode==0)
break;
+ // print_line(p_event);
+
if (p_event.key.pressed)
keys_pressed.insert(p_event.key.scancode);
else
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index a8e02526b9..d01331a256 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -37,7 +37,7 @@ void MainLoop::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT);
BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST);
BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST);
-
+ BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
};
diff --git a/core/script_language.h b/core/script_language.h
index 9731273610..560de520ca 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -141,6 +141,7 @@ public:
virtual int find_function(const String& p_function,const String& p_code) const=0;
virtual String make_function(const String& p_class,const String& p_name,const StringArray& p_args) const=0;
virtual Error complete_keyword(const String& p_code, int p_line, const String& p_base_path, const String& p_keyword, List<String>* r_options) { return ERR_UNAVAILABLE; }
+ virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0;
/* DEBUGGER FUNCTIONS */