summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--core/bind/core_bind.cpp7
-rw-r--r--core/bind/core_bind.h4
-rw-r--r--core/os/os.h4
-rw-r--r--doc/base/classes.xml36
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp18
-rw-r--r--drivers/gles2/shaders/material.glsl10
-rw-r--r--drivers/unix/os_unix.cpp3
-rw-r--r--platform/nacl/os_nacl.cpp6
-rw-r--r--scene/gui/file_dialog.cpp14
-rw-r--r--scene/gui/file_dialog.h3
-rw-r--r--scene/gui/item_list.cpp56
-rw-r--r--scene/gui/item_list.h7
-rw-r--r--scene/gui/line_edit.cpp5
-rw-r--r--scene/gui/text_edit.cpp163
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--scene/resources/baked_light.cpp46
-rw-r--r--scene/resources/baked_light.h9
-rw-r--r--scene/resources/shader_graph.cpp18
-rw-r--r--servers/visual/rasterizer.h4
-rw-r--r--servers/visual/visual_server_raster.cpp60
-rw-r--r--servers/visual/visual_server_raster.h9
-rw-r--r--servers/visual/visual_server_wrap_mt.h8
-rw-r--r--servers/visual_server.h9
-rw-r--r--tools/editor/editor_file_dialog.cpp12
-rw-r--r--tools/editor/editor_file_dialog.h3
-rw-r--r--tools/editor/editor_settings.cpp3
-rw-r--r--tools/editor/editor_sub_scene.cpp2
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.cpp28
-rw-r--r--tools/editor/plugins/particles_2d_editor_plugin.h6
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp1243
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.h105
-rw-r--r--tools/export/blender25/io_scene_dae/export_dae.py2
34 files changed, 1300 insertions, 611 deletions
diff --git a/.gitignore b/.gitignore
index bf5be79d55..15ca139916 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,9 @@ platform/android/libs/play_licensing/gen/*
.deps/*
.dirstamp
+# Vim temp files
+*.swo
+*.swp
# QT project files
*.config
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index bf611f89c9..915cbc0578 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -508,11 +508,11 @@ Dictionary _OS::get_time(bool utc) const {
}
/**
- * Get a dictionary of time values when given epoc time
+ * Get a dictionary of time values when given epoch time
*
* Dictionary Time values will be a union if values from #get_time
* and #get_date dictionaries (with the exception of dst =
- * day light standard time, as it cannot be determined from epoc)
+ * day light standard time, as it cannot be determined from epoch)
*/
Dictionary _OS::get_time_from_unix_time( uint64_t unix_time_val) const {
@@ -552,7 +552,8 @@ Dictionary _OS::get_time_from_unix_time( uint64_t unix_time_val) const {
imonth++;
}
- date.month = static_cast<OS::Month>(imonth);
+ /// Add 1 to month to make sure months are indexed starting at 1
+ date.month = static_cast<OS::Month>(imonth+1);
date.day = dayno + 1;
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index ab11c4804c..db5ff42cfe 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -81,7 +81,9 @@ public:
};
enum Month {
- MONTH_JANUARY,
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
diff --git a/core/os/os.h b/core/os/os.h
index 73726feb37..160c0495bb 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -224,7 +224,9 @@ public:
};
enum Month {
- MONTH_JANUARY,
+ /// Start at 1 to follow Windows SYSTEMTIME structure
+ /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 04e08f166e..bc8bec4bbf 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -20639,6 +20639,18 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
<description>
</description>
</method>
+ <method name="get_time_from_unix_time" qualifiers="const">
+ <return type="Dictionary">
+ </return>
+ <argument index="0" name="unix_time_val" type="int">
+ </argument>
+ <description>
+ Get a dictionary of time values when given epoch time.
+ Dictionary Time values will be a union of values from [method get_time]
+ and [method get_date] dictionaries (with the exception of dst =
+ day light standard time, as it cannot be determined from epoc)
+ </description>
+ </method>
<method name="get_time_zone_info" qualifiers="const">
<return type="Dictionary">
</return>
@@ -20922,29 +20934,29 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
</constant>
<constant name="DAY_SATURDAY" value="6">
</constant>
- <constant name="MONTH_JANUARY" value="0">
+ <constant name="MONTH_JANUARY" value="1">
</constant>
- <constant name="MONTH_FEBRUARY" value="1">
+ <constant name="MONTH_FEBRUARY" value="2">
</constant>
- <constant name="MONTH_MARCH" value="2">
+ <constant name="MONTH_MARCH" value="3">
</constant>
- <constant name="MONTH_APRIL" value="3">
+ <constant name="MONTH_APRIL" value="4">
</constant>
- <constant name="MONTH_MAY" value="4">
+ <constant name="MONTH_MAY" value="5">
</constant>
- <constant name="MONTH_JUNE" value="5">
+ <constant name="MONTH_JUNE" value="6">
</constant>
- <constant name="MONTH_JULY" value="6">
+ <constant name="MONTH_JULY" value="7">
</constant>
- <constant name="MONTH_AUGUST" value="7">
+ <constant name="MONTH_AUGUST" value="8">
</constant>
- <constant name="MONTH_SEPTEMBER" value="8">
+ <constant name="MONTH_SEPTEMBER" value="9">
</constant>
- <constant name="MONTH_OCTOBER" value="9">
+ <constant name="MONTH_OCTOBER" value="10">
</constant>
- <constant name="MONTH_NOVEMBER" value="10">
+ <constant name="MONTH_NOVEMBER" value="11">
</constant>
- <constant name="MONTH_DECEMBER" value="11">
+ <constant name="MONTH_DECEMBER" value="12">
</constant>
<constant name="SCREEN_ORIENTATION_LANDSCAPE" value="0">
</constant>
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index e43487d719..1568d93af7 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -6561,8 +6561,19 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP,false);
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER,false);
+ material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_COLOR, false);
+
+
if (material->flags[VS::MATERIAL_FLAG_UNSHADED] == false && current_debug != VS::SCENARIO_DEBUG_SHADELESS) {
+ if (baked_light != NULL) {
+ if (baked_light->realtime_color_enabled) {
+ float realtime_energy = baked_light->realtime_energy;
+ material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_COLOR, true);
+ material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_COLOR, Vector3(baked_light->realtime_color.r*realtime_energy, baked_light->realtime_color.g*realtime_energy, baked_light->realtime_color.b*realtime_energy));
+ }
+ }
+
if (e->instance->sampled_light.is_valid()) {
SampledLight *sl = sampled_light_owner.get(e->instance->sampled_light);
@@ -10769,9 +10780,16 @@ bool RasterizerGLES2::_test_depth_shadow_buffer() {
void RasterizerGLES2::init() {
+ if (OS::get_singleton()->is_stdout_verbose()) {
+ print_line("Using GLES2 video driver");
+ }
+
#ifdef GLEW_ENABLED
GLuint res = glewInit();
ERR_FAIL_COND(res!=GLEW_OK);
+ if (OS::get_singleton()->is_stdout_verbose()) {
+ print_line(String("GLES2: Using GLEW ") + (const char*) glewGetString(GLEW_VERSION));
+ }
#endif
diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl
index ccd80bf2f0..e68949b056 100644
--- a/drivers/gles2/shaders/material.glsl
+++ b/drivers/gles2/shaders/material.glsl
@@ -618,6 +618,12 @@ uniform float ambient_dp_sampler_multiplier;
#endif
+#ifdef ENABLE_AMBIENT_COLOR
+
+uniform vec3 ambient_color;
+
+#endif
+
FRAGMENT_SHADER_GLOBALS
@@ -1262,7 +1268,9 @@ LIGHT_SHADER_CODE
#if defined(ENABLE_AMBIENT_OCTREE) || defined(ENABLE_AMBIENT_LIGHTMAP) || defined(ENABLE_AMBIENT_DP_SAMPLER)
-
+#if defined(ENABLE_AMBIENT_COLOR)
+ ambientmap_color*=ambient_color;
+#endif
diffuse.rgb+=ambientmap_color;
#endif
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index a004a116e0..84b6dc24dc 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -251,6 +251,9 @@ OS::Date OS_Unix::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=1900+lt->tm_year;
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
ret.month=(Month)(lt->tm_mon + 1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
diff --git a/platform/nacl/os_nacl.cpp b/platform/nacl/os_nacl.cpp
index de6a15525b..e2a92ee8c7 100644
--- a/platform/nacl/os_nacl.cpp
+++ b/platform/nacl/os_nacl.cpp
@@ -249,7 +249,11 @@ OS::Date OSNacl::get_date(bool utc) const {
lt=localtime(&t);
Date ret;
ret.year=lt->tm_year;
- ret.month=(Month)lt->tm_mon;
+
+ // Index starting at 1 to match OS_Unix::get_date
+ // and Windows SYSTEMTIME and tm_mon follows the typical structure
+ // of 0-11, noted here: http://www.cplusplus.com/reference/ctime/tm/
+ ret.month=(Month)(lt->tm_mon+1);
ret.day=lt->tm_mday;
ret.weekday=(Weekday)lt->tm_wday;
ret.dst=lt->tm_isdst;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index b8b8c99c39..64fdfdfefe 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -181,12 +181,10 @@ void FileDialog::_action_pressed() {
String f=dir_access->get_current_dir().plus_file(file->get_text());
- if (mode==MODE_OPEN_FILE && dir_access->file_exists(f)) {
+ if ((mode==MODE_OPEN_ANY || mode==MODE_OPEN_FILE) && dir_access->file_exists(f)) {
emit_signal("file_selected",f);
hide();
- }
-
- if (mode==MODE_OPEN_DIR) {
+ }else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
String path=dir_access->get_current_dir();
@@ -304,7 +302,7 @@ void FileDialog::_tree_dc_selected() {
if (d["dir"]) {
dir_access->change_dir(d["name"]);
- if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR)
+ if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR || mode==MODE_OPEN_ANY)
file->set_text("");
call_deferred("_update_file_list");
call_deferred("_update_dir");
@@ -552,8 +550,9 @@ void FileDialog::set_mode(Mode p_mode) {
case MODE_OPEN_FILE: get_ok()->set_text("Open"); set_title("Open a File"); makedir->hide(); break;
case MODE_OPEN_FILES: get_ok()->set_text("Open"); set_title("Open File(s)"); makedir->hide(); break;
- case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break;
case MODE_OPEN_DIR: get_ok()->set_text("Open"); set_title("Open a Directory"); makedir->show(); break;
+ case MODE_OPEN_ANY: get_ok()->set_text("Open"); set_title("Open a File or Directory"); makedir->show(); break;
+ case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break;
}
if (mode==MODE_OPEN_FILES) {
@@ -710,6 +709,8 @@ void FileDialog::_bind_methods() {
BIND_CONSTANT( MODE_OPEN_FILE );
BIND_CONSTANT( MODE_OPEN_FILES );
BIND_CONSTANT( MODE_OPEN_DIR );
+ BIND_CONSTANT( MODE_OPEN_ANY );
+
BIND_CONSTANT( MODE_SAVE_FILE );
BIND_CONSTANT( ACCESS_RESOURCES );
@@ -877,3 +878,4 @@ LineEditFileChooser::LineEditFileChooser() {
dialog->connect("files_selected",this,"_chosen");
}
+
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 2042adbc20..1fcf8387ce 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -57,7 +57,8 @@ public:
MODE_OPEN_FILE,
MODE_OPEN_FILES,
MODE_OPEN_DIR,
- MODE_SAVE_FILE,
+ MODE_OPEN_ANY,
+ MODE_SAVE_FILE
};
typedef Ref<Texture> (*GetIconFunc)(const String&);
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 2d2cabfc01..171dd94bfa 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -7,6 +7,7 @@ void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool
Item item;
item.icon=p_texture;
+ item.icon_region=Rect2i();
item.text=p_item;
item.selectable=p_selectable;
item.selected=false;
@@ -23,6 +24,7 @@ void ItemList::add_icon_item(const Ref<Texture>& p_item,bool p_selectable){
Item item;
item.icon=p_item;
+ item.icon_region=Rect2i();
//item.text=p_item;
item.selectable=p_selectable;
item.selected=false;
@@ -79,6 +81,7 @@ void ItemList::set_item_icon(int p_idx,const Ref<Texture>& p_icon){
}
+
Ref<Texture> ItemList::get_item_icon(int p_idx) const{
ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>());
@@ -87,6 +90,22 @@ Ref<Texture> ItemList::get_item_icon(int p_idx) const{
}
+void ItemList::set_item_icon_region(int p_idx,const Rect2& p_region) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+
+ items[p_idx].icon_region=p_region;
+ update();
+ shape_changed=true;
+}
+
+Rect2 ItemList::get_item_icon_region(int p_idx) const {
+
+ ERR_FAIL_INDEX_V(p_idx,items.size(),Rect2());
+
+ return items[p_idx].icon_region;
+}
+
void ItemList::set_item_custom_bg_color(int p_idx,const Color& p_custom_bg_color) {
ERR_FAIL_INDEX(p_idx,items.size());
@@ -362,7 +381,15 @@ Size2 ItemList::get_min_icon_size() const {
return min_icon_size;
}
+Size2 ItemList::Item::get_icon_size() const {
+ if (icon.is_null())
+ return Size2();
+ if (icon_region.has_no_area())
+ return icon->get_size();
+
+ return icon_region.size;
+}
void ItemList::_input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && p_event.mouse_button.pressed) {
@@ -702,7 +729,9 @@ void ItemList::_notification(int p_what) {
Size2 minsize;
if (items[i].icon.is_valid()) {
- minsize=items[i].icon->get_size();
+
+ minsize=items[i].get_icon_size();
+
if (min_icon_size.x!=0)
minsize.x = MAX(minsize.x,min_icon_size.x);
if (min_icon_size.y!=0)
@@ -851,18 +880,30 @@ void ItemList::_notification(int p_what) {
Vector2 text_ofs;
if (items[i].icon.is_valid()) {
+ Size2 icon_size = items[i].get_icon_size();
+
Vector2 icon_ofs;
if (min_icon_size!=Vector2()) {
- icon_ofs = (min_icon_size - items[i].icon->get_size())/2;
+ icon_ofs = (min_icon_size - icon_size)/2;
}
+ Point2 pos = items[i].rect_cache.pos + icon_ofs + base_ofs;
+
if (icon_mode==ICON_MODE_TOP) {
- draw_texture(items[i].icon,icon_ofs+items[i].rect_cache.pos+Vector2(items[i].rect_cache.size.width/2-items[i].icon->get_width()/2,0).floor()+base_ofs);
- text_ofs.y = MAX(items[i].icon->get_height(),min_icon_size.y)+icon_margin;
+
+ pos.x += Math::floor((items[i].rect_cache.size.width - icon_size.width)/2);
+ text_ofs.y = MAX(icon_size.height, min_icon_size.y) + icon_margin;
} else {
- draw_texture(items[i].icon,icon_ofs+items[i].rect_cache.pos+Vector2(0,items[i].rect_cache.size.height/2-items[i].icon->get_height()/2).floor()+base_ofs);
- text_ofs.x = MAX(items[i].icon->get_width(),min_icon_size.x)+icon_margin;
+
+ pos.y += Math::floor((items[i].rect_cache.size.height - icon_size.height)/2);
+ text_ofs.x = MAX(icon_size.width, min_icon_size.x) + icon_margin;
}
+
+ if (items[i].icon_region.has_no_area())
+ draw_texture(items[i].icon, pos);
+ else
+ draw_texture_rect_region(items[i].icon, Rect2(pos, icon_size), items[i].icon_region);
+
}
if (items[i].tag_icon.is_valid()) {
@@ -1061,6 +1102,9 @@ void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
+ ObjectTypeDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
+
ObjectTypeDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
ObjectTypeDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index bd3cf6484e..c9c575fd54 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -22,6 +22,7 @@ private:
struct Item {
Ref<Texture> icon;
+ Rect2i icon_region;
Ref<Texture> tag_icon;
String text;
bool selectable;
@@ -31,9 +32,10 @@ private:
String tooltip;
Color custom_bg;
-
Rect2 rect_cache;
+ Size2 get_icon_size() const;
+
bool operator<(const Item& p_another) const { return text<p_another.text; }
};
@@ -76,6 +78,9 @@ public:
void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
Ref<Texture> get_item_icon(int p_idx) const;
+ void set_item_icon_region(int p_idx,const Rect2& p_region);
+ Rect2 get_item_icon_region(int p_idx) const;
+
void set_item_selectable(int p_idx,bool p_selectable);
bool is_item_selectable(int p_idx) const;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 3953ef06a5..21dee62b38 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -274,6 +274,11 @@ void LineEdit::_input_event(InputEvent p_event) {
} break;
case KEY_DELETE: {
+ if (k.mod.shift && !k.mod.command && !k.mod.alt && editable) {
+ cut_text();
+ break;
+ }
+
if (editable) {
undo_text = text;
if (selection.enabled)
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 32f4be5d17..b80597560d 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1957,6 +1957,12 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly)
break;
+
+ if (k.mod.shift && !k.mod.command && !k.mod.alt) {
+ cut();
+ break;
+ }
+
int curline_len = text[cursor.line].length();
if (cursor.line==text.size()-1 && cursor.column==curline_len)
@@ -2169,35 +2175,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
- if (!selection.active){
-
- String clipboard = text[cursor.line];
- OS::get_singleton()->set_clipboard(clipboard);
- cursor_set_line(cursor.line);
- cursor_set_column(0);
- _remove_text(cursor.line,0,cursor.line,text[cursor.line].length());
-
- backspace_at_cursor();
- update();
- cursor_set_line(cursor.line+1);
- cut_copy_line = true;
-
- }
- else
- {
-
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
-
- cursor_set_line(selection.from_line);
- cursor_set_column(selection.from_column);
-
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
- update();
- cut_copy_line = false;
- }
+ cut();
} break;
case KEY_C: {
@@ -2207,16 +2185,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
- if (!selection.active){
- String clipboard = _base_get_text(cursor.line,0,cursor.line,text[cursor.line].length());
- OS::get_singleton()->set_clipboard(clipboard);
- cut_copy_line = true;
- }
- else{
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
- cut_copy_line = false;
- }
+ copy();
+
} break;
case KEY_Z: {
@@ -2237,25 +2207,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
- String clipboard = OS::get_singleton()->get_clipboard();
-
- if (selection.active) {
- selection.active=false;
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- cursor_set_line(selection.from_line);
- cursor_set_column(selection.from_column);
-
- }
- else if (cut_copy_line)
- {
- cursor_set_column(0);
- String ins="\n";
- clipboard += ins;
- }
-
- _insert_text_at_cursor(clipboard);
+ paste();
- update();
} break;
case KEY_SPACE: {
#ifdef OSX_ENABLED
@@ -2515,6 +2468,7 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
//see if it shold just be set as current op
if (current_op.type!=op.type) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
@@ -2522,6 +2476,7 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
}
//see if it can be merged
if (current_op.to_line!=p_line || current_op.to_column!=p_char) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
return; //set as current op, return
@@ -2565,6 +2520,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
//see if it shold just be set as current op
if (current_op.type!=op.type) {
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
return; //set as current op, return
@@ -2585,6 +2541,7 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
//return; //update current op
}
+ op.prev_version = get_version();
_push_current_op();
current_op=op;
@@ -3024,20 +2981,33 @@ void TextEdit::set_auto_indent(bool p_auto_indent) {
void TextEdit::cut() {
- if (!selection.active)
- return;
+ if (!selection.active) {
+
+ String clipboard = text[cursor.line];
+ OS::get_singleton()->set_clipboard(clipboard);
+ cursor_set_line(cursor.line);
+ cursor_set_column(0);
+ _remove_text(cursor.line,0,cursor.line,text[cursor.line].length());
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
+ backspace_at_cursor();
+ update();
+ cursor_set_line(cursor.line+1);
+ cut_copy_line = true;
- cursor_set_line(selection.from_line);
- cursor_set_column(selection.from_column);
+ } else {
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
- update();
+ String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ OS::get_singleton()->set_clipboard(clipboard);
+ cursor_set_line(selection.from_line);
+ cursor_set_column(selection.from_column);
+
+ _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ selection.active=false;
+ selection.selecting_mode=Selection::MODE_NONE;
+ update();
+ cut_copy_line = false;
+ }
}
void TextEdit::copy() {
@@ -3045,32 +3015,38 @@ void TextEdit::copy() {
if (!selection.active)
return;
- print_line("from line: "+itos(selection.from_line));
- print_line("from column: "+itos(selection.from_column));
- print_line("to line: "+itos(selection.to_line));
- print_line("to column: "+itos(selection.to_column));
-
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
-
+ if (!selection.active) {
+ String clipboard = _base_get_text(cursor.line,0,cursor.line,text[cursor.line].length());
+ OS::get_singleton()->set_clipboard(clipboard);
+ cut_copy_line = true;
+ } else {
+ String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ OS::get_singleton()->set_clipboard(clipboard);
+ cut_copy_line = false;
+ }
}
+
void TextEdit::paste() {
+ String clipboard = OS::get_singleton()->get_clipboard();
+
if (selection.active) {
+ selection.active=false;
+ selection.selecting_mode=Selection::MODE_NONE;
+ _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
+ } else if (cut_copy_line) {
+ cursor_set_column(0);
+ String ins="\n";
+ clipboard += ins;
}
- String clipboard = OS::get_singleton()->get_clipboard();
_insert_text_at_cursor(clipboard);
update();
-
}
void TextEdit::select_all() {
@@ -3418,11 +3394,15 @@ void TextEdit::undo() {
else
undo_stack_pos=undo_stack_pos->prev();
- _do_text_op( undo_stack_pos->get(),true);
+ TextOperation op = undo_stack_pos->get();
+ _do_text_op(op, true);
+ current_op.version=op.prev_version;
if(undo_stack_pos->get().chain_backward) {
do {
undo_stack_pos = undo_stack_pos->prev();
- _do_text_op(undo_stack_pos->get(), true);
+ op = undo_stack_pos->get();
+ _do_text_op(op, true);
+ current_op.version = op.prev_version;
} while(!undo_stack_pos->get().chain_forward);
}
@@ -3438,15 +3418,19 @@ void TextEdit::redo() {
if (undo_stack_pos==NULL)
return; //nothing to do.
- _do_text_op(undo_stack_pos->get(), false);
+ TextOperation op = undo_stack_pos->get();
+ _do_text_op(op, false);
+ current_op.version = op.version;
if(undo_stack_pos->get().chain_forward) {
do {
undo_stack_pos=undo_stack_pos->next();
- _do_text_op(undo_stack_pos->get(), false);
+ op = undo_stack_pos->get();
+ _do_text_op(op, false);
+ current_op.version = op.version;
} while(!undo_stack_pos->get().chain_backward);
}
- cursor_set_line(undo_stack_pos->get().from_line);
- cursor_set_column(undo_stack_pos->get().from_column);
+ cursor_set_line(undo_stack_pos->get().to_line);
+ cursor_set_column(undo_stack_pos->get().to_column);
undo_stack_pos=undo_stack_pos->next();
update();
}
@@ -3495,6 +3479,13 @@ void TextEdit::_push_current_op() {
}
+void TextEdit::set_tab_size(const int p_size) {
+ ERR_FAIL_COND(p_size <= 0);
+ tab_size = p_size;
+ text.set_tab_size(p_size);
+ update();
+}
+
void TextEdit::set_draw_tabs(bool p_draw) {
draw_tabs=p_draw;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 2eff8e89c7..d38c57804d 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -156,6 +156,7 @@ class TextEdit : public Control {
int from_line,from_column;
int to_line, to_column;
String text;
+ uint32_t prev_version;
uint32_t version;
bool chain_forward;
bool chain_backward;
@@ -378,7 +379,7 @@ public:
void redo();
void clear_undo_history();
-
+ void set_tab_size(const int p_size);
void set_draw_tabs(bool p_draw);
bool is_drawing_tabs() const;
diff --git a/scene/resources/baked_light.cpp b/scene/resources/baked_light.cpp
index 31282a0274..aa4aae03cb 100644
--- a/scene/resources/baked_light.cpp
+++ b/scene/resources/baked_light.cpp
@@ -256,6 +256,38 @@ float BakedLight::get_ao_strength() const {
return ao_strength;
}
+void BakedLight::set_realtime_color_enabled(const bool p_realtime_color_enabled) {
+
+ VS::get_singleton()->baked_light_set_realtime_color_enabled(baked_light, p_realtime_color_enabled);
+}
+
+bool BakedLight::get_realtime_color_enabled() const {
+
+ return VS::get_singleton()->baked_light_get_realtime_color_enabled(baked_light);
+}
+
+
+void BakedLight::set_realtime_color(const Color &p_realtime_color) {
+
+ VS::get_singleton()->baked_light_set_realtime_color(baked_light, p_realtime_color);
+}
+
+Color BakedLight::get_realtime_color() const {
+
+ return VS::get_singleton()->baked_light_get_realtime_color(baked_light);
+}
+
+void BakedLight::set_realtime_energy(const float p_realtime_energy) {
+
+ VS::get_singleton()->baked_light_set_realtime_energy(baked_light, p_realtime_energy);
+}
+
+float BakedLight::get_realtime_energy() const {
+
+ return VS::get_singleton()->baked_light_get_realtime_energy(baked_light);
+}
+
+
void BakedLight::set_energy_multiplier(float p_multiplier){
@@ -434,6 +466,15 @@ void BakedLight::_bind_methods(){
ObjectTypeDB::bind_method(_MD("set_ao_strength","ao_strength"),&BakedLight::set_ao_strength);
ObjectTypeDB::bind_method(_MD("get_ao_strength"),&BakedLight::get_ao_strength);
+ ObjectTypeDB::bind_method(_MD("set_realtime_color_enabled", "enabled"), &BakedLight::set_realtime_color_enabled);
+ ObjectTypeDB::bind_method(_MD("get_realtime_color_enabled"), &BakedLight::get_realtime_color_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_realtime_color", "tint"), &BakedLight::set_realtime_color);
+ ObjectTypeDB::bind_method(_MD("get_realtime_color"), &BakedLight::get_realtime_color);
+
+ ObjectTypeDB::bind_method(_MD("set_realtime_energy", "energy"), &BakedLight::set_realtime_energy);
+ ObjectTypeDB::bind_method(_MD("get_realtime_energy"), &BakedLight::get_realtime_energy);
+
ObjectTypeDB::bind_method(_MD("set_format","format"),&BakedLight::set_format);
ObjectTypeDB::bind_method(_MD("get_format"),&BakedLight::get_format);
@@ -480,6 +521,11 @@ void BakedLight::_bind_methods(){
ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_radius",PROPERTY_HINT_RANGE,"0.0,16.0,0.01"),_SCS("set_ao_radius"),_SCS("get_ao_radius"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_strength",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_ao_strength"),_SCS("get_ao_strength"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "realtime/enabled"), _SCS("set_realtime_color_enabled"), _SCS("get_realtime_color_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "realtime/color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_realtime_color"), _SCS("get_realtime_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "realtime/energy", PROPERTY_HINT_RANGE, "0.01,4096.0,0.01"), _SCS("set_realtime_energy"), _SCS("get_realtime_energy"));
+
+
BIND_CONSTANT( MODE_OCTREE );
BIND_CONSTANT( MODE_LIGHTMAPS );
diff --git a/scene/resources/baked_light.h b/scene/resources/baked_light.h
index 41e1e5f9e0..f9a1368e8d 100644
--- a/scene/resources/baked_light.h
+++ b/scene/resources/baked_light.h
@@ -116,6 +116,15 @@ public:
void set_ao_strength(float p_ao_strength);
float get_ao_strength() const;
+ void set_realtime_color_enabled(const bool p_enabled);
+ bool get_realtime_color_enabled() const;
+
+ void set_realtime_color(const Color& p_realtime_color);
+ Color get_realtime_color() const;
+
+ void set_realtime_energy(const float p_realtime_energy);
+ float get_realtime_energy() const;
+
void set_bake_flag(BakeFlags p_flags,bool p_enable);
bool get_bake_flag(BakeFlags p_flags) const;
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index eabc84c41e..40ae26ba5d 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -1351,13 +1351,21 @@ ShaderGraph::ShaderGraph(Mode p_mode) : Shader(p_mode) {
//shader = VisualServer::get_singleton()->shader_create();
_pending_update_shader=false;
- Node out;
- out.id=0;
- out.pos=Vector2(250,20);
- out.type=NODE_OUTPUT;
+
+ Node input;
+ input.id=1;
+ input.pos=Vector2(50,40);
+ input.type=NODE_INPUT;
+
+ Node output;
+ output.id=0;
+ output.pos=Vector2(350,40);
+ output.type=NODE_OUTPUT;
+
for(int i=0;i<3;i++) {
- shader[i].node_map.insert(0,out);
+ shader[i].node_map.insert(0,output);
+ shader[i].node_map.insert(1,input);
}
}
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 194df9596a..e2de20785a 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -528,6 +528,10 @@ public:
int octree_steps;
Vector2 octree_tex_pixel_size;
Vector2 light_tex_pixel_size;
+
+ bool realtime_color_enabled;
+ Color realtime_color;
+ float realtime_energy;
};
struct InstanceData {
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 6d293f0ce8..1db7971d3b 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -1081,6 +1081,9 @@ RID VisualServerRaster::baked_light_create() {
baked_light->data.octree_lattice_divide=0;
baked_light->data.octree_steps=1;
baked_light->data.lightmap_multiplier=1.0;
+ baked_light->data.realtime_color_enabled=false;
+ baked_light->data.realtime_color=Color(1.0, 1.0, 1.0);
+ baked_light->data.realtime_energy = 1.0;
return baked_light_owner.make_rid( baked_light );
@@ -1326,6 +1329,63 @@ void VisualServerRaster::baked_light_clear_lightmaps(RID p_baked_light){
}
+void VisualServerRaster::baked_light_set_realtime_color_enabled(RID p_baked_light, const bool p_enabled) {
+
+ VS_CHANGED;
+ BakedLight *baked_light = baked_light_owner.get(p_baked_light);
+ ERR_FAIL_COND(!baked_light);
+
+ baked_light->data.realtime_color_enabled = p_enabled;
+
+}
+
+bool VisualServerRaster::baked_light_get_realtime_color_enabled(RID p_baked_light) const{
+
+ const BakedLight *baked_light = baked_light_owner.get(p_baked_light);
+ ERR_FAIL_COND_V(!baked_light, false);
+
+ return baked_light->data.realtime_color_enabled;
+
+}
+
+void VisualServerRaster::baked_light_set_realtime_color(RID p_baked_light, const Color& p_color) {
+
+ VS_CHANGED;
+ BakedLight *baked_light = baked_light_owner.get(p_baked_light);
+ ERR_FAIL_COND(!baked_light);
+
+ baked_light->data.realtime_color = p_color;
+
+}
+
+Color VisualServerRaster::baked_light_get_realtime_color(RID p_baked_light) const{
+
+ const BakedLight *baked_light = baked_light_owner.get(p_baked_light);
+ ERR_FAIL_COND_V(!baked_light, Color(1.0, 1.0, 1.0));
+
+ return baked_light->data.realtime_color;
+
+}
+
+void VisualServerRaster::baked_light_set_realtime_energy(RID p_baked_light, const float p_energy) {
+
+ VS_CHANGED;
+ BakedLight *baked_light = baked_light_owner.get(p_baked_light);
+ ERR_FAIL_COND(!baked_light);
+
+ baked_light->data.realtime_energy = p_energy;
+
+}
+
+float VisualServerRaster::baked_light_get_realtime_energy(RID p_baked_light) const{
+
+ const BakedLight *baked_light = baked_light_owner.get(p_baked_light);
+ ERR_FAIL_COND_V(!baked_light, 1.0f);
+
+ return baked_light->data.realtime_energy;
+
+}
+
/* BAKED LIGHT SAMPLER */
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 06501d1b81..2b72b0b900 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -949,6 +949,15 @@ public:
virtual void baked_light_add_lightmap(RID p_baked_light,const RID p_texture,int p_id);
virtual void baked_light_clear_lightmaps(RID p_baked_light);
+ virtual void baked_light_set_realtime_color_enabled(RID p_baked_light, const bool p_enabled);
+ virtual bool baked_light_get_realtime_color_enabled(RID p_baked_light) const;
+
+ virtual void baked_light_set_realtime_color(RID p_baked_light, const Color& p_color);
+ virtual Color baked_light_get_realtime_color(RID p_baked_light) const;
+
+ virtual void baked_light_set_realtime_energy(RID p_baked_light, const float p_energy);
+ virtual float baked_light_get_realtime_energy(RID p_baked_light) const;
+
/* BAKED LIGHT SAMPLER */
virtual RID baked_light_sampler_create();
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 52e38c8438..b6018f1c25 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -391,6 +391,14 @@ public:
FUNC3(baked_light_add_lightmap,RID,RID,int);
FUNC1(baked_light_clear_lightmaps,RID);
+ FUNC2(baked_light_set_realtime_color_enabled, RID, const bool);
+ FUNC1RC(bool, baked_light_get_realtime_color_enabled, RID);
+
+ FUNC2(baked_light_set_realtime_color, RID, const Color&);
+ FUNC1RC(Color, baked_light_get_realtime_color, RID);
+
+ FUNC2(baked_light_set_realtime_energy, RID, const float);
+ FUNC1RC(float, baked_light_get_realtime_energy, RID);
FUNC0R(RID,baked_light_sampler_create);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 3a5b3d8d37..c70a72ef2a 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -626,6 +626,15 @@ public:
virtual void baked_light_add_lightmap(RID p_baked_light,const RID p_texture,int p_id)=0;
virtual void baked_light_clear_lightmaps(RID p_baked_light)=0;
+ virtual void baked_light_set_realtime_color_enabled(RID p_baked_light, const bool p_enabled)=0;
+ virtual bool baked_light_get_realtime_color_enabled(RID p_baked_light) const=0;
+
+ virtual void baked_light_set_realtime_color(RID p_baked_light, const Color& p_color)=0;
+ virtual Color baked_light_get_realtime_color(RID p_baked_light) const=0;
+
+ virtual void baked_light_set_realtime_energy(RID p_baked_light, const float p_energy) = 0;
+ virtual float baked_light_get_realtime_energy(RID p_baked_light) const = 0;
+
/* BAKED LIGHT SAMPLER */
virtual RID baked_light_sampler_create()=0;
diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp
index 0e6cf3277a..8e83726f96 100644
--- a/tools/editor/editor_file_dialog.cpp
+++ b/tools/editor/editor_file_dialog.cpp
@@ -273,13 +273,11 @@ void EditorFileDialog::_action_pressed() {
String f=dir_access->get_current_dir().plus_file(file->get_text());
- if (mode==MODE_OPEN_FILE && dir_access->file_exists(f)) {
+ if ((mode==MODE_OPEN_ANY || mode==MODE_OPEN_FILE) && dir_access->file_exists(f)) {
_save_to_recent();
emit_signal("file_selected",f);
hide();
- }
-
- if (mode==MODE_OPEN_DIR) {
+ }else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
String path=dir_access->get_current_dir();
@@ -413,7 +411,7 @@ void EditorFileDialog::_item_dc_selected(int p_item) {
//print_line("change dir: "+String(d["name"]));
dir_access->change_dir(d["name"]);
- if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR)
+ if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR || MODE_OPEN_ANY)
file->set_text("");
call_deferred("_update_file_list");
call_deferred("_update_dir");
@@ -771,8 +769,9 @@ void EditorFileDialog::set_mode(Mode p_mode) {
case MODE_OPEN_FILE: get_ok()->set_text("Open"); set_title("Open a File"); makedir->hide(); break;
case MODE_OPEN_FILES: get_ok()->set_text("Open"); set_title("Open File(s)"); makedir->hide(); break;
- case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break;
case MODE_OPEN_DIR: get_ok()->set_text("Open"); set_title("Open a Directory"); makedir->show(); break;
+ case MODE_OPEN_ANY: get_ok()->set_text("Open"); set_title("Open a File or Directory"); makedir->show(); break;
+ case MODE_SAVE_FILE: get_ok()->set_text("Save"); set_title("Save a File"); makedir->show(); break;
}
if (mode==MODE_OPEN_FILES) {
@@ -1149,6 +1148,7 @@ void EditorFileDialog::_bind_methods() {
BIND_CONSTANT( MODE_OPEN_FILE );
BIND_CONSTANT( MODE_OPEN_FILES );
BIND_CONSTANT( MODE_OPEN_DIR );
+ BIND_CONSTANT( MODE_OPEN_ANY );
BIND_CONSTANT( MODE_SAVE_FILE );
BIND_CONSTANT( ACCESS_RESOURCES );
diff --git a/tools/editor/editor_file_dialog.h b/tools/editor/editor_file_dialog.h
index 3590964a51..d37856e556 100644
--- a/tools/editor/editor_file_dialog.h
+++ b/tools/editor/editor_file_dialog.h
@@ -66,7 +66,8 @@ public:
MODE_OPEN_FILE,
MODE_OPEN_FILES,
MODE_OPEN_DIR,
- MODE_SAVE_FILE,
+ MODE_OPEN_ANY,
+ MODE_SAVE_FILE
};
typedef Ref<Texture> (*GetIconFunc)(const String&);
diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp
index fda51423d2..1133acb48c 100644
--- a/tools/editor/editor_settings.cpp
+++ b/tools/editor/editor_settings.cpp
@@ -406,6 +406,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("text_editor/scroll_past_end_of_file", false);
+ set("text_editor/tab_size", 4);
+ hints["text_editor/tab_size"]=PropertyInfo(Variant::INT,"text_editor/tab_size",PROPERTY_HINT_RANGE,"1, 64, 1"); // size of 0 crashes.
+
set("text_editor/idle_parse_delay",2);
set("text_editor/create_signal_callbacks",true);
set("text_editor/autosave_interval_secs",0);
diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp
index a1a881bec5..c5a4f6d58b 100644
--- a/tools/editor/editor_sub_scene.cpp
+++ b/tools/editor/editor_sub_scene.cpp
@@ -219,7 +219,7 @@ EditorSubScene::EditorSubScene() {
tree = memnew( Tree );
tree->set_v_size_flags(SIZE_EXPAND_FILL);
vb->add_margin_child("Import From Node:",tree,true);
- tree->connect("item_activated",this,"_ok");
+ tree->connect("item_activated",this,"_ok",make_binds(),CONNECT_DEFERRED);
file_dialog = memnew( EditorFileDialog );
List<String> extensions;
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp
index 2488c4cdd9..297145f408 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.cpp
+++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp
@@ -26,10 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "particles_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "io/image_loader.h"
-
+#include "scene/gui/separator.h"
void Particles2DEditorPlugin::edit(Object *p_object) {
@@ -49,12 +50,10 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- sep->show();
- menu->show();
+ toolbar->show();
} else {
- menu->hide();
- sep->hide();
+ toolbar->hide();
}
}
@@ -164,35 +163,36 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
particles=NULL;
editor=p_node;
undo_redo=editor->get_undo_redo();
- sep = memnew( VSeparator );
- CanvasItemEditor::get_singleton()->add_control_to_menu_panel(sep);
- sep->hide();
+
+ toolbar = memnew( HBoxContainer );
+ add_control_to_container(CONTAINER_CANVAS_EDITOR_MENU, toolbar);
+ toolbar->hide();
+
+ toolbar->add_child( memnew( VSeparator ) );
menu = memnew( MenuButton );
menu->get_popup()->add_item("Load Emission Mask",MENU_LOAD_EMISSION_MASK);
menu->get_popup()->add_item("Clear Emission Mask",MENU_CLEAR_EMISSION_MASK);
menu->set_text("Particles");
+ toolbar->add_child(menu);
- file = memnew(EditorFileDialog);
- add_child(file);
+ file = memnew( EditorFileDialog );
List<String> ext;
ImageLoader::get_recognized_extensions(&ext);
for(List<String>::Element *E=ext.front();E;E=E->next()) {
file->add_filter("*."+E->get()+"; "+E->get().to_upper());
}
file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- CanvasItemEditor::get_singleton()->add_control_to_menu_panel(menu);
+ toolbar->add_child(file);
+
epoints = memnew( SpinBox );
epoints->set_min(1);
epoints->set_max(8192);
epoints->set_step(1);
epoints->set_val(512);
file->get_vbox()->add_margin_child("Generated Point Count:",epoints);
- menu->hide();
-
}
-
Particles2DEditorPlugin::~Particles2DEditorPlugin()
{
}
diff --git a/tools/editor/plugins/particles_2d_editor_plugin.h b/tools/editor/plugins/particles_2d_editor_plugin.h
index f70a0e7b76..ce2056b482 100644
--- a/tools/editor/plugins/particles_2d_editor_plugin.h
+++ b/tools/editor/plugins/particles_2d_editor_plugin.h
@@ -33,7 +33,7 @@
#include "tools/editor/editor_node.h"
#include "scene/2d/collision_polygon_2d.h"
-#include "scene/gui/separator.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/file_dialog.h"
#include "scene/2d/particles_2d.h"
@@ -47,14 +47,14 @@ class Particles2DEditorPlugin : public EditorPlugin {
MENU_CLEAR_EMISSION_MASK
};
+ Particles2D *particles;
EditorFileDialog *file;
EditorNode *editor;
+ HBoxContainer *toolbar;
MenuButton *menu;
- VSeparator *sep;
- Particles2D *particles;
SpinBox *epoints;
UndoRedo *undo_redo;
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 76c64beb61..03db293959 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -1930,6 +1930,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste);
ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
+ ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
ste->get_text_edit()->set_callhint_settings(
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset"));
@@ -2067,6 +2068,7 @@ void ScriptEditor::_editor_settings_changed() {
ste->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/auto_brace_complete"));
ste->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/scroll_past_end_of_file"));
+ ste->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/tab_size"));
}
}
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index acacd37f66..30ec6c086c 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -26,206 +26,487 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "tile_map_editor_plugin.h"
-#include "tools/editor/editor_node.h"
+
#include "os/keyboard.h"
+#include "os/input.h"
#include "canvas_item_editor_plugin.h"
-#include "os/file_access.h"
#include "tools/editor/editor_settings.h"
-#include "os/input.h"
-#include "method_bind_ext.inc"
void TileMapEditor::_notification(int p_what) {
switch(p_what) {
- case NOTIFICATION_READY: {
+ case NOTIFICATION_ENTER_TREE: {
- transpose->set_icon( get_icon("Transpose","EditorIcons"));
- mirror_x->set_icon( get_icon("MirrorX","EditorIcons"));
- mirror_y->set_icon( get_icon("MirrorY","EditorIcons"));
- rotate_0->set_icon( get_icon("Rotate0","EditorIcons"));
- rotate_90->set_icon( get_icon("Rotate90","EditorIcons"));
- rotate_180->set_icon( get_icon("Rotate180","EditorIcons"));
- rotate_270->set_icon( get_icon("Rotate270","EditorIcons"));
+ transp->set_icon(get_icon("Transpose","EditorIcons"));
+ mirror_x->set_icon(get_icon("MirrorX","EditorIcons"));
+ mirror_y->set_icon(get_icon("MirrorY","EditorIcons"));
+ rotate_0->set_icon(get_icon("Rotate0","EditorIcons"));
+ rotate_90->set_icon(get_icon("Rotate90","EditorIcons"));
+ rotate_180->set_icon(get_icon("Rotate180","EditorIcons"));
+ rotate_270->set_icon(get_icon("Rotate270","EditorIcons"));
} break;
}
+}
+
+void TileMapEditor::_menu_option(int p_option) {
+
+ switch(p_option) {
+
+ case OPTION_BUCKET: {
+
+ tool=TOOL_BUCKET;
+
+ canvas_item_editor->update();
+ } break;
+ case OPTION_PICK_TILE: {
+
+ tool=TOOL_PICKING;
+
+ canvas_item_editor->update();
+ } break;
+ case OPTION_SELECT: {
+
+ tool=TOOL_SELECTING;
+ selection_active=false;
+
+ canvas_item_editor->update();
+ } break;
+ case OPTION_DUPLICATE: {
+
+ _update_copydata();
+
+ if (selection_active) {
+ tool=TOOL_DUPLICATING;
+
+ canvas_item_editor->update();
+ }
+ } break;
+ case OPTION_ERASE_SELECTION: {
+
+ if (!selection_active)
+ return;
+
+ undo_redo->create_action("Erase Selection");
+ for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
+ for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+
+ _set_cell(Point2i(j, i), TileMap::INVALID_CELL, false, false, false, true);
+ }
+ }
+ undo_redo->commit_action();
+ selection_active=false;
+ copydata.clear();
+
+ canvas_item_editor->update();
+ } break;
+ }
}
void TileMapEditor::_canvas_mouse_enter() {
mouse_over=true;
canvas_item_editor->update();
-
-
}
void TileMapEditor::_canvas_mouse_exit() {
mouse_over=false;
canvas_item_editor->update();
-
}
int TileMapEditor::get_selected_tile() const {
+
int item = palette->get_current();
+
if (item==-1)
return TileMap::INVALID_CELL;
+
return palette->get_item_metadata(item);
}
void TileMapEditor::set_selected_tile(int p_tile) {
- for (int i = 0; i < palette->get_item_count(); i++) {
- if (palette->get_item_metadata(i).operator int() == p_tile) {
- palette->select(i,true);
- palette->ensure_current_is_visible();
- break;
- }
- }
-}
-// Wrapper to workaround five arg limit of undo/redo methods
-void TileMapEditor::_set_cell_shortened(const Point2& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose) {
- ERR_FAIL_COND(!node);
- node->set_cell(floor(p_pos.x), floor(p_pos.y), p_value, p_flip_h, p_flip_v, p_transpose);
+ int idx = palette->find_metadata(p_tile);
+
+ if (idx >= 0) {
+ palette->select(idx, true);
+ palette->ensure_current_is_visible();
+ }
}
void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose,bool p_with_undo) {
ERR_FAIL_COND(!node);
+ int prev_val=node->get_cell(p_pos.x,p_pos.y);
+
bool prev_flip_h=node->is_cell_x_flipped(p_pos.x,p_pos.y);
bool prev_flip_v=node->is_cell_y_flipped(p_pos.x,p_pos.y);
bool prev_transpose=node->is_cell_transposed(p_pos.x,p_pos.y);
- int prev_val=node->get_cell(p_pos.x,p_pos.y);
if (p_value==prev_val && p_flip_h==prev_flip_h && p_flip_v==prev_flip_v && p_transpose==prev_transpose)
return; //check that it's actually different
-
if (p_with_undo) {
+
undo_redo->add_do_method(node,"set_cellv",Point2(p_pos),p_value,p_flip_h,p_flip_v,p_transpose);
undo_redo->add_undo_method(node,"set_cellv",Point2(p_pos),prev_val,prev_flip_h,prev_flip_v,prev_transpose);
} else {
node->set_cell(p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v,p_transpose);
-
}
}
-void TileMapEditor::_set_display_mode(int p_mode) {
- if (display_mode == p_mode) {
- return;
- }
+void TileMapEditor::_text_entered(const String& p_text) {
- switch (p_mode) {
- case DISPLAY_THUMBNAIL: {
- button_thumbnail->set_pressed(true);
- button_list->set_pressed(false);
- } break;
- case DISPLAY_LIST: {
- button_thumbnail->set_pressed(false);
- button_list->set_pressed(true);
- } break;
- }
+ canvas_item_editor->grab_focus();
+}
- display_mode = p_mode;
+void TileMapEditor::_text_changed(const String& p_text) {
_update_palette();
}
+void TileMapEditor::_sbox_input(const InputEvent& p_ie) {
+
+ if (p_ie.type==InputEvent::KEY && (
+ p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+
+ palette->call("_input_event", p_ie);
+ search_box->accept_event();
+ }
+}
+
void TileMapEditor::_update_palette() {
if (!node)
return;
+ int selected = get_selected_tile();
palette->clear();
Ref<TileSet> tileset=node->get_tileset();
- if (!tileset.is_valid())
+ if (tileset.is_null())
return;
List<int> tiles;
tileset->get_tile_list(&tiles);
- if (display_mode == DISPLAY_THUMBNAIL) {
- palette->set_max_columns(0);
- palette->set_icon_mode(ItemList::ICON_MODE_TOP);
- } else if (display_mode == DISPLAY_LIST) {
- palette->set_max_columns(1);
- palette->set_icon_mode(ItemList::ICON_MODE_LEFT);
- }
+ if (tiles.empty())
+ return;
+ palette->set_max_columns(0);
+ palette->set_icon_mode(ItemList::ICON_MODE_TOP);
palette->set_max_text_lines(2);
- for(List<int>::Element *E=tiles.front();E;E=E->next()) {
- palette->add_item("");
+ String filter = search_box->get_text().strip_edges();
+
+ for (List<int>::Element *E=tiles.front();E;E=E->next()) {
+
+ String name;
+
+ if (tileset->tile_get_name(E->get())!="") {
+ name = tileset->tile_get_name(E->get());
+ } else {
+ name = "#"+itos(E->get());
+ }
+
+ if (filter != "" && name.findn(filter) == -1)
+ continue;
+
+ palette->add_item(name);
Ref<Texture> tex = tileset->tile_get_texture(E->get());
if (tex.is_valid()) {
Rect2 region = tileset->tile_get_region(E->get());
- if (!region.has_no_area()) {
- Image data = VS::get_singleton()->texture_get_data(tex->get_rid());
+ if (!region.has_no_area())
+ palette->set_item_icon_region(palette->get_item_count()-1, region);
- Ref<ImageTexture> img = memnew( ImageTexture );
- img->create_from_image(data.get_rect(region));
-
- palette->set_item_icon(palette->get_item_count()-1, img);
- } else {
- palette->set_item_icon(palette->get_item_count()-1,tex);
- }
+ palette->set_item_icon(palette->get_item_count()-1, tex);
}
- if (tileset->tile_get_name(E->get())!="") {
- palette->set_item_text(palette->get_item_count()-1, tileset->tile_get_name(E->get()));
- } else {
- palette->set_item_text(palette->get_item_count()-1, "#"+itos(E->get()));
+ palette->set_item_metadata(palette->get_item_count()-1, E->get());
+ }
+
+ if (selected != -1)
+ set_selected_tile(selected);
+ else
+ palette->select(0, true);
+}
+
+void TileMapEditor::_pick_tile(const Point2& p_pos) {
+
+ int id = node->get_cell(p_pos.x, p_pos.y);
+
+ if (id==TileMap::INVALID_CELL)
+ return;
+
+ if (search_box->get_text().strip_edges() != "") {
+
+ search_box->set_text("");
+ _update_palette();
+ }
+
+ set_selected_tile(id);
+
+ mirror_x->set_pressed(node->is_cell_x_flipped(p_pos.x, p_pos.y));
+ mirror_y->set_pressed(node->is_cell_y_flipped(p_pos.x, p_pos.y));
+ transp->set_pressed(node->is_cell_transposed(p_pos.x, p_pos.y));
+
+ _update_transform_buttons();
+ canvas_item_editor->update();
+}
+
+DVector<Vector2> TileMapEditor::_bucket_fill(const Point2i& p_start) {
+
+ if (node->get_cell(p_start.x, p_start.y) != TileMap::INVALID_CELL)
+ return DVector<Vector2>();
+
+ int id = get_selected_tile();
+
+ if (id == TileMap::INVALID_CELL)
+ return DVector<Vector2>();
+
+ Rect2 r = node->get_item_rect();
+ r.pos = r.pos/node->get_cell_size();
+ r.size = r.size/node->get_cell_size();
+
+ DVector<Vector2> points;
+
+ List<Point2i> queue;
+ queue.push_back(p_start);
+
+ while (queue.size()) {
+
+ Point2i n = queue.front()->get();
+ queue.pop_front();
+
+ if (!r.has_point(n))
+ continue;
+
+ if (node->get_cell(n.x, n.y) == TileMap::INVALID_CELL) {
+
+ node->set_cellv(n, id, flip_h, flip_v, transpose);
+
+ points.push_back(n);
+
+ queue.push_back(n + Point2i(0, 1));
+ queue.push_back(n + Point2i(0, -1));
+ queue.push_back(n + Point2i(1, 0));
+ queue.push_back(n + Point2i(-1, 0));
}
+ }
- palette->set_item_metadata(palette->get_item_count()-1, E->get());
+ return points;
+}
+
+void TileMapEditor::_fill_points(const DVector<Vector2> p_points, const Dictionary& p_op) {
+
+ int len = p_points.size();
+ DVector<Vector2>::Read pr = p_points.read();
+
+ int id = p_op["id"];
+ bool xf = p_op["flip_h"];
+ bool yf = p_op["flip_v"];
+ bool tr = p_op["transpose"];
+
+ for (int i=0;i<len;i++) {
+
+ _set_cell(pr[i], id, xf, yf, tr);
}
}
-void TileMapEditor::_node_removed(Node *p_node) {
+void TileMapEditor::_erase_points(const DVector<Vector2> p_points) {
- if(p_node==node) {
- node=NULL;
- hide();
+ int len = p_points.size();
+ DVector<Vector2>::Read pr = p_points.read();
+
+ for (int i=0;i<len;i++) {
+
+ _set_cell(pr[i], TileMap::INVALID_CELL);
}
+}
+
+void TileMapEditor::_select(const Point2i& p_from, const Point2i& p_to) {
+
+ Point2i begin=p_from;
+ Point2i end=p_to;
+ if (begin.x > end.x) {
+
+ SWAP( begin.x, end.x);
+ }
+ if (begin.y > end.y) {
+
+ SWAP( begin.y, end.y);
+ }
+
+ rectangle.pos=begin;
+ rectangle.size=end-begin;
+
+ canvas_item_editor->update();
}
-void TileMapEditor::_menu_option(int p_option) {
- switch(p_option) {
+void TileMapEditor::_draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Matrix32& p_xform) {
+
+ Ref<Texture> t = node->get_tileset()->tile_get_texture(p_cell);
+
+ if (t.is_null())
+ return;
+
+ Vector2 tile_ofs = node->get_tileset()->tile_get_texture_offset(p_cell);
+
+ Rect2 r = node->get_tileset()->tile_get_region(p_cell);
+ Size2 sc = p_xform.get_scale();
+
+ Rect2 rect = Rect2();
+ rect.pos = node->map_to_world(p_point) + node->get_cell_draw_offset();
+
+ if (r.has_no_area()) {
+ rect.size = t->get_size();
+ } else {
+ rect.size = r.size;
+ }
+
+ if (rect.size.y > rect.size.x) {
+ if ((p_flip_h && (p_flip_v || p_transpose)) || (p_flip_v && !p_transpose))
+ tile_ofs.y += rect.size.y - rect.size.x;
+ } else if (rect.size.y < rect.size.x) {
+ if ((p_flip_v && (p_flip_h || p_transpose)) || (p_flip_h && !p_transpose))
+ tile_ofs.x += rect.size.x - rect.size.y;
+ }
+
+ if (p_transpose) {
+ SWAP(tile_ofs.x, tile_ofs.y);
+ }
+ if (p_flip_h) {
+ sc.x*=-1.0;
+ tile_ofs.x*=-1.0;
+ }
+ if (p_flip_v) {
+ sc.y*=-1.0;
+ tile_ofs.y*=-1.0;
+ }
+
+ if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
+ rect.pos+=tile_ofs;
+ } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
+ rect.pos+=node->get_cell_size()/2;
+ Vector2 s = r.size;
+ Vector2 center = (s/2) - tile_ofs;
+
+ if (p_flip_h)
+ rect.pos.x-=s.x-center.x;
+ else
+ rect.pos.x-=center.x;
+
+ if (p_flip_v)
+ rect.pos.y-=s.y-center.y;
+ else
+ rect.pos.y-=center.y;
}
+
+ rect.pos=p_xform.xform(rect.pos);
+ rect.size*=sc;
+
+ if (r.has_no_area())
+ canvas_item_editor->draw_texture_rect(t, rect, false, Color(1,1,1,0.5), p_transpose);
+ else
+ canvas_item_editor->draw_texture_rect_region(t, rect, r, Color(1,1,1,0.5), p_transpose);
}
-struct _TileMapEditorCopyData {
- Point2i pos;
- int cell;
- bool flip_h;
- bool flip_v;
- bool transpose;
-};
+void TileMapEditor::_update_copydata() {
-bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
+ copydata.clear();
+
+ if (!selection_active)
+ return;
+
+ for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
+
+ for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+
+ TileData tcd;
+
+ tcd.cell=node->get_cell(j, i);
+
+ if (tcd.cell!=TileMap::INVALID_CELL) {
+ tcd.pos=Point2i(j, i);
+ tcd.flip_h=node->is_cell_x_flipped(j,i);
+ tcd.flip_v=node->is_cell_y_flipped(j,i);
+ tcd.transpose=node->is_cell_transposed(j,i);
+ }
+
+ copydata.push_back(tcd);
+ }
+ }
+}
+
+static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) {
+
+ Vector<Point2i> points;
+
+ float dx = ABS(x1 - x0);
+ float dy = ABS(y1 - y0);
+
+ int x = x0;
+ int y = y0;
+
+ int sx = x0 > x1 ? -1 : 1;
+ int sy = y0 > y1 ? -1 : 1;
+
+ if (dx > dy) {
+ float err = dx/2;
+ for (; x != x1; x += sx) {
+ points.push_back(Vector2(x, y));
+
+ err -= dy;
+ if (err < 0) {
+ y += sy;
+ err += dx;
+ }
+ }
+ } else {
+ float err = dy/2;
+
+ for (; y != y1; y += sy) {
+ points.push_back(Vector2(x, y));
+
+ err -= dx;
+ if (err < 0) {
+ x += sx;
+ err += dy;
+ }
+ }
+ }
+
+ points.push_back(Vector2(x, y));
+
+ return points;
+}
+
+bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
if (!node || !node->get_tileset().is_valid() || !node->is_visible())
return false;
Matrix32 xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
Matrix32 xform_inv = xform.affine_inverse();
- Vector2 snap = node->get_cell_size();
-
switch(p_event.type) {
@@ -235,165 +516,260 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
if (mb.button_index==BUTTON_LEFT) {
+ if (mb.pressed) {
- if (mb.pressed && tool==TOOL_DUPLICATING) {
-
-
- List<_TileMapEditorCopyData> dupdata;
- Point2 ofs = over_tile-selection.pos;
+ if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
+ return false; //drag
- for(int i=selection.pos.y;i<=selection.pos.y+selection.size.y;i++) {
+ if (tool==TOOL_NONE) {
- for(int j=selection.pos.x;j<=selection.pos.x+selection.size.x;j++) {
+ if (mb.mod.shift) {
- _TileMapEditorCopyData tcd;
- tcd.pos=Point2i(j,i);
- tcd.cell=node->get_cell(j,i);
- tcd.flip_h=node->is_cell_x_flipped(j,i);
- tcd.flip_v=node->is_cell_y_flipped(j,i);
- tcd.transpose=node->is_cell_transposed(j,i);
- dupdata.push_back(tcd);
+ if (mb.mod.control)
+ tool=TOOL_RECTANGLE_PAINT;
+ else
+ tool=TOOL_LINE_PAINT;
+ selection_active=false;
+ rectangle_begin=over_tile;
+ return true;
}
- }
- undo_redo->create_action("Duplicate");
- for (List<_TileMapEditorCopyData>::Element *E=dupdata.front();E;E=E->next()) {
+ if (mb.mod.control) {
+ tool=TOOL_PICKING;
+ _pick_tile(over_tile);
- _set_cell(E->get().pos+ofs,E->get().cell,E->get().flip_h,E->get().flip_v,E->get().transpose,true);
- }
- undo_redo->commit_action();
-
- tool=TOOL_NONE;
- canvas_item_editor->update();
- selection.pos=over_tile;
-
- } else if (mb.pressed && tool==TOOL_NONE) {
+ return true;
+ }
- if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
- return false; //drag
- if (mb.mod.shift) {
+ tool=TOOL_PAINTING;
+ }
- tool=TOOL_SELECTING;
- selection_begin =node->world_to_map(xform_inv.xform(Point2(mb.x,mb.y)));
- selection.pos=selection_begin;
- selection.size=Point2(0,0);
- selection_active=true;
- canvas_item_editor->update();
- return true;
+ if (tool==TOOL_PAINTING) {
- } else if (mb.mod.control) {
- tool=TOOL_PICKING;
- set_selected_tile(node->get_cell(over_tile.x, over_tile.y));
- mirror_x->set_pressed(node->is_cell_x_flipped(over_tile.x, over_tile.y));
- mirror_y->set_pressed(node->is_cell_y_flipped(over_tile.x, over_tile.y));
- transpose->set_pressed(node->is_cell_transposed(over_tile.x, over_tile.y));
- _update_transform_buttons();
- canvas_item_editor->update();
- return true;
- } else {
int id = get_selected_tile();
+
if (id!=TileMap::INVALID_CELL) {
+
tool=TOOL_PAINTING;
- Point2i local =node->world_to_map((xform_inv.xform(Point2(mb.x,mb.y))));
+
paint_undo.clear();
- paint_undo[local]=_get_op_from_cell(local);
- node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed(),transpose->is_pressed());
- return true;
+ paint_undo[over_tile]=_get_op_from_cell(over_tile);
+
+ _set_cell(over_tile, id, flip_h, flip_v, transpose);
}
+ } else if (tool==TOOL_PICKING) {
+
+ _pick_tile(over_tile);
+ } else if (tool==TOOL_SELECTING) {
+
+ selection_active=true;
+ rectangle_begin=over_tile;
}
+
+ return true;
+
} else {
- if (tool==TOOL_PAINTING || tool == TOOL_SELECTING || tool == TOOL_PICKING) {
+ if (tool!=TOOL_NONE) {
if (tool==TOOL_PAINTING) {
- if (paint_undo.size()) {
+ int id=get_selected_tile();
+
+ if (id!=TileMap::INVALID_CELL && paint_undo.size()) {
+
undo_redo->create_action("Paint TileMap");
- for(Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
- Point2i p=E->key();
- undo_redo->add_do_method(node,"set_cellv",Point2(p),node->get_cell(p.x,p.y),node->is_cell_x_flipped(p.x,p.y),node->is_cell_y_flipped(p.x,p.y),node->is_cell_transposed(p.x,p.y));
- undo_redo->add_undo_method(node,"set_cellv",Point2(p),E->get().idx,E->get().xf,E->get().yf,E->get().tr);
+ Point2 p=E->key();
+ undo_redo->add_do_method(node,"set_cellv",p,id,flip_h,flip_v,transpose);
+ undo_redo->add_undo_method(node,"set_cellv",p,E->get().idx,E->get().xf,E->get().yf,E->get().tr);
}
+ undo_redo->commit_action();
+
+ paint_undo.clear();
+ }
+ } else if (tool==TOOL_LINE_PAINT) {
+
+ int id=get_selected_tile();
+
+ if (id!=TileMap::INVALID_CELL) {
+
+ undo_redo->create_action("Line Draw");
+ for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ _set_cell(E->key(), id, flip_h, flip_v, transpose, true);
+ }
undo_redo->commit_action();
+
paint_undo.clear();
+
+ canvas_item_editor->update();
+ }
+ } else if (tool==TOOL_RECTANGLE_PAINT) {
+
+ int id=get_selected_tile();
+
+ if (id!=TileMap::INVALID_CELL) {
+
+ undo_redo->create_action("Rectangle Paint");
+ for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
+ for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+
+ _set_cell(Point2i(j, i), id, flip_h, flip_v, transpose, true);
+ }
+ }
+ undo_redo->commit_action();
+
+ canvas_item_editor->update();
+ }
+ } else if (tool==TOOL_DUPLICATING) {
+
+ Point2 ofs = over_tile-rectangle.pos;
+
+ undo_redo->create_action("Duplicate");
+ for (List<TileData>::Element *E=copydata.front();E;E=E->next()) {
+
+ _set_cell(E->get().pos+ofs,E->get().cell,E->get().flip_h,E->get().flip_v,E->get().transpose,true);
}
+ undo_redo->commit_action();
+
+ copydata.clear();
+
+ canvas_item_editor->update();
+
+ } else if (tool==TOOL_SELECTING) {
+
+ canvas_item_editor->update();
+
+ } else if (tool==TOOL_BUCKET) {
+
+ DVector<Vector2> points = _bucket_fill(over_tile);
+
+ if (points.size() == 0)
+ return false;
+
+ Dictionary op;
+ op["id"] = get_selected_tile();
+ op["flip_h"] = flip_h;
+ op["flip_v"] = flip_v;
+ op["transpose"] = transpose;
+
+ undo_redo->create_action("Bucket Fill");
+
+ undo_redo->add_do_method(this, "_fill_points", points, op);
+ undo_redo->add_undo_method(this, "_erase_points", points);
+
+ undo_redo->commit_action();
}
+
tool=TOOL_NONE;
+
return true;
}
}
- }
+ } else if (mb.button_index==BUTTON_RIGHT) {
- if (mb.button_index==BUTTON_RIGHT) {
+ if (mb.pressed) {
- if (mb.pressed && tool==TOOL_DUPLICATING) {
+ if (tool==TOOL_SELECTING || selection_active) {
- tool=TOOL_NONE;
- canvas_item_editor->update();
- } else if (mb.pressed && tool==TOOL_NONE) {
+ tool=TOOL_NONE;
+ selection_active=false;
- tool=TOOL_ERASING;
- Point2i local =node->world_to_map(xform_inv.xform(Point2(mb.x,mb.y)));
- paint_undo.clear();
- paint_undo[local]=_get_op_from_cell(local);
- //node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed(),transpose->is_pressed());
- //return true;
- _set_cell(local,TileMap::INVALID_CELL);
- return true;
- } else if (!mb.pressed) {
+ canvas_item_editor->update();
+
+ return true;
+ }
+
+ if (tool==TOOL_DUPLICATING) {
+
+ tool=TOOL_NONE;
+ copydata.clear();
+
+ canvas_item_editor->update();
- if (tool==TOOL_ERASING) {
+ return true;
+ }
+
+ if (tool==TOOL_NONE) {
+
+ paint_undo.clear();
+
+ Point2 local = node->world_to_map(xform_inv.xform(Point2(mb.x, mb.y)));
+
+ if (mb.mod.shift) {
+
+ if (mb.mod.control)
+ tool=TOOL_RECTANGLE_ERASE;
+ else
+ tool=TOOL_LINE_ERASE;
+
+ selection_active=false;
+ rectangle_begin=local;
+ } else {
+
+ tool=TOOL_ERASING;
+
+ paint_undo[local]=_get_op_from_cell(local);
+ _set_cell(local, TileMap::INVALID_CELL);
+ }
+
+ return true;
+ }
+
+ } else {
+ if (tool==TOOL_ERASING || tool==TOOL_RECTANGLE_ERASE || tool==TOOL_LINE_ERASE) {
if (paint_undo.size()) {
undo_redo->create_action("Erase TileMap");
- for(Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ for (Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
- Point2i p=E->key();
- //undo_redo->add_do_method(node,"set_cell",p,node->get_cell(p.x,p.y),node->is_cell_x_flipped(p.x,p.y),node->is_cell_y_flipped(p.x,p.y),node->is_cell_transposed(p.x,p.y));
- //_set_cell(p,TileMap::INVALID_CELL,false,false,false,true);
- undo_redo->add_do_method(node,"set_cellv",Point2(p),TileMap::INVALID_CELL,false,false,false);
- undo_redo->add_undo_method(node,"set_cellv",Point2(p),E->get().idx,E->get().xf,E->get().yf,E->get().tr);
+ Point2 p=E->key();
+ undo_redo->add_do_method(node,"set_cellv",p,TileMap::INVALID_CELL,false,false,false);
+ undo_redo->add_undo_method(node,"set_cellv",p,E->get().idx,E->get().xf,E->get().yf,E->get().tr);
}
undo_redo->commit_action();
paint_undo.clear();
+ }
+ if (tool==TOOL_RECTANGLE_ERASE || tool==TOOL_LINE_ERASE) {
+ canvas_item_editor->update();
}
+
tool=TOOL_NONE;
+
return true;
}
}
}
-
} break;
case InputEvent::MOUSE_MOTION: {
const InputEventMouseMotion &mm=p_event.mouse_motion;
- Point2i new_over_tile = node->world_to_map(xform_inv.xform(Point2(mm.x,mm.y)));//(xform_inv.xform(Point2(mm.x,mm.y))/snap).floor();
+ Point2i new_over_tile = node->world_to_map(xform_inv.xform(Point2(mm.x,mm.y)));
+
if (new_over_tile!=over_tile) {
over_tile=new_over_tile;
canvas_item_editor->update();
}
-
-
if (tool==TOOL_PAINTING) {
int id = get_selected_tile();
if (id!=TileMap::INVALID_CELL) {
if (!paint_undo.has(over_tile)) {
-
paint_undo[over_tile]=_get_op_from_cell(over_tile);
}
- node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed(),transpose->is_pressed());
+
+ _set_cell(over_tile, id, flip_h, flip_v, transpose);
return true;
}
@@ -401,121 +777,178 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
if (tool==TOOL_SELECTING) {
- Point2i begin=selection_begin;
- Point2i end =over_tile;
+ _select(rectangle_begin, over_tile);
- if (begin.x > end.x) {
+ return true;
+ }
- SWAP( begin.x, end.x);
- }
- if (begin.y > end.y) {
+ if (tool==TOOL_LINE_PAINT || tool==TOOL_LINE_ERASE) {
+
+ int id = get_selected_tile();
+ bool erasing = (tool==TOOL_LINE_ERASE);
- SWAP( begin.y, end.y);
+ if (erasing && paint_undo.size()) {
+
+ for (Map<Point2i, CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+
+ _set_cell(E->key(), E->get().idx, E->get().xf, E->get().yf, E->get().tr);
+ }
}
- selection.pos=begin;
- selection.size=end-begin;
- canvas_item_editor->update();
+ paint_undo.clear();
- return true;
+ if (id!=TileMap::INVALID_CELL) {
+
+ Vector<Point2i> points = line(rectangle_begin.x, over_tile.x, rectangle_begin.y, over_tile.y);
+ for (int i=0;i<points.size();i++) {
+
+ paint_undo[points[i]]=_get_op_from_cell(points[i]);
+
+ if (erasing)
+ _set_cell(points[i], TileMap::INVALID_CELL);
+ }
+
+ canvas_item_editor->update();
+ }
+
+ return true;
}
+ if (tool==TOOL_RECTANGLE_PAINT || tool==TOOL_RECTANGLE_ERASE) {
+
+ _select(rectangle_begin, over_tile);
+
+ if (tool==TOOL_RECTANGLE_ERASE) {
+
+ if (paint_undo.size()) {
+
+ for (Map<Point2i, CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+
+ _set_cell(E->key(), E->get().idx, E->get().xf, E->get().yf, E->get().tr);
+ }
+ }
+
+ paint_undo.clear();
+ for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
+ for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
+
+ Point2i tile = Point2i(j, i);
+ paint_undo[tile]=_get_op_from_cell(tile);
+
+ _set_cell(tile, TileMap::INVALID_CELL);
+ }
+ }
+ }
+
+ return true;
+ }
if (tool==TOOL_ERASING) {
- Point2i local =over_tile;
+
if (!paint_undo.has(over_tile)) {
paint_undo[over_tile]=_get_op_from_cell(over_tile);
}
- //node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed(),transpose->is_pressed());
- _set_cell(local,TileMap::INVALID_CELL);
+
+ _set_cell(over_tile, TileMap::INVALID_CELL);
+
return true;
}
+ if (tool==TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+
+ _pick_tile(over_tile);
- if (tool==TOOL_PICKING) {
- set_selected_tile(node->get_cell(over_tile.x, over_tile.y));
- mirror_x->set_pressed(node->is_cell_x_flipped(over_tile.x, over_tile.y));
- mirror_y->set_pressed(node->is_cell_y_flipped(over_tile.x, over_tile.y));
- transpose->set_pressed(node->is_cell_transposed(over_tile.x, over_tile.y));
- _update_transform_buttons();
- canvas_item_editor->update();
return true;
}
-
} break;
case InputEvent::KEY: {
const InputEventKey &k = p_event.key;
- if (!node)
- break;
-
- if (k.pressed && k.scancode==KEY_DELETE && selection_active && tool==TOOL_NONE) {
- undo_redo->create_action("Delete");
- for(int i=selection.pos.y;i<=selection.pos.y+selection.size.y;i++) {
+ if (!k.pressed)
+ break;
- for(int j=selection.pos.x;j<=selection.pos.x+selection.size.x;j++) {
+ if (k.scancode==KEY_ESCAPE) {
+ if (tool==TOOL_DUPLICATING)
+ copydata.clear();
+ else if (tool==TOOL_SELECTING || selection_active)
+ selection_active=false;
- _set_cell(Point2i(j,i),TileMap::INVALID_CELL);
- }
- }
- undo_redo->commit_action();
+ tool=TOOL_NONE;
- selection_active=false;
canvas_item_editor->update();
+
return true;
}
- if (mouse_over && k.pressed && k.scancode==KEY_A && tool==TOOL_NONE && !k.mod.command) {
+ if (tool!=TOOL_NONE || !mouse_over)
+ return false;
- /*int cell = node->get_cell(over_tile.x,over_tile.y);
- if (cell!=TileMap::INVALID_CELL) {
- bool flip_h = node->is_cell_x_flipped(over_tile.x,over_tile.y);
- bool flip_v = node->is_cell_y_flipped(over_tile.x,over_tile.y);
- _set_cell(over_tile,cell,!flip_h,flip_v);
- }*/
+ if (k.scancode==KEY_DELETE) {
+
+ _menu_option(OPTION_ERASE_SELECTION);
- mirror_x->set_pressed( ! mirror_x->is_pressed() );
- canvas_item_editor->update();
return true;
}
- if (mouse_over && k.pressed && k.scancode==KEY_S && tool==TOOL_NONE && !k.mod.command) {
+ if (k.mod.command) {
- /*
- int cell = node->get_cell(over_tile.x,over_tile.y);
- if (cell!=TileMap::INVALID_CELL) {
+ if (k.scancode==KEY_F) {
- bool flip_h = node->is_cell_x_flipped(over_tile.x,over_tile.y);
- bool flip_v = node->is_cell_y_flipped(over_tile.x,over_tile.y);
- _set_cell(over_tile,cell,flip_h,!flip_v);
- }*/
+ search_box->select_all();
+ search_box->grab_focus();
- mirror_y->set_pressed( ! mirror_y->is_pressed() );
- canvas_item_editor->update();
- return true;
- }
+ return true;
+ }
+ if (k.scancode==KEY_B) {
- if (mouse_over && selection_active && k.pressed && k.mod.command && k.scancode==KEY_D && tool==TOOL_NONE) {
+ tool=TOOL_SELECTING;
+ selection_active=false;
- tool=TOOL_DUPLICATING;
- canvas_item_editor->update();
- return true;
- }
+ canvas_item_editor->update();
+
+ return true;
+ }
+ if (k.scancode==KEY_D) {
+
+ _update_copydata();
+ if (selection_active) {
+ tool=TOOL_DUPLICATING;
+
+ canvas_item_editor->update();
+
+ return true;
+ }
+ }
+ } else {
+ if (k.scancode==KEY_A) {
+ flip_h=!flip_h;
+ mirror_x->set_pressed(flip_h);
+ canvas_item_editor->update();
+ return true;
+ }
+ if (k.scancode==KEY_S) {
+
+ flip_v=!flip_v;
+ mirror_y->set_pressed(flip_v);
+ canvas_item_editor->update();
+ return true;
+ }
+ }
} break;
}
return false;
}
+
void TileMapEditor::_canvas_draw() {
if (!node)
return;
- Size2 cell_size=node->get_cell_size();
Matrix32 cell_xf = node->get_cell_transform();
Matrix32 xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
@@ -535,7 +968,7 @@ void TileMapEditor::_canvas_draw() {
int max_lines=2000; //avoid crash if size too smal
- for(int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
+ for (int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
Vector2 from = xform.xform(node->map_to_world(Vector2(i,si.pos.y)));
Vector2 to = xform.xform(node->map_to_world(Vector2(i,si.pos.y+si.size.y+1)));
@@ -549,9 +982,9 @@ void TileMapEditor::_canvas_draw() {
int max_lines=10000; //avoid crash if size too smal
- for(int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
+ for (int i=(si.pos.x)-1;i<=(si.pos.x+si.size.x);i++) {
- for(int j=(si.pos.y)-1;j<=(si.pos.y+si.size.y);j++) {
+ for (int j=(si.pos.y)-1;j<=(si.pos.y+si.size.y);j++) {
Vector2 ofs;
if (ABS(j)&1) {
@@ -575,7 +1008,7 @@ void TileMapEditor::_canvas_draw() {
if (node->get_half_offset()!=TileMap::HALF_OFFSET_Y) {
- for(int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
+ for (int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
Vector2 from = xform.xform(node->map_to_world(Vector2(si.pos.x,i)));
Vector2 to = xform.xform(node->map_to_world(Vector2(si.pos.x+si.size.x+1,i)));
@@ -590,9 +1023,9 @@ void TileMapEditor::_canvas_draw() {
} else {
- for(int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
+ for (int i=(si.pos.y)-1;i<=(si.pos.y+si.size.y);i++) {
- for(int j=(si.pos.x)-1;j<=(si.pos.x+si.size.x);j++) {
+ for (int j=(si.pos.x)-1;j<=(si.pos.x+si.size.x);j++) {
Vector2 ofs;
if (ABS(j)&1) {
@@ -608,46 +1041,31 @@ void TileMapEditor::_canvas_draw() {
break;
}
-
}
-
-
-
}
-/*
- for(int i=(si.pos.y/cell_size.y)-1;i<=(si.pos.y+si.size.y)/cell_size.y;i++) {
-
- int ofs = i*cell_size.y;
- Color col=i==0?Color(1,0.8,0.2,0.5):Color(1,0.3,0.1,0.2);
- canvas_item_editor->draw_line(xform.xform(Point2(si.pos.x,ofs)),xform.xform(Point2(si.pos.x+si.size.x,ofs)),col,1);*/
}
-
if (selection_active) {
Vector<Vector2> points;
- points.push_back( xform.xform( node->map_to_world(( selection.pos ) )));
- points.push_back( xform.xform( node->map_to_world((selection.pos+Point2(selection.size.x+1,0)) ) ));
- points.push_back( xform.xform( node->map_to_world((selection.pos+Point2(selection.size.x+1,selection.size.y+1)) ) ));
- points.push_back( xform.xform( node->map_to_world((selection.pos+Point2(0,selection.size.y+1)) ) ));
- Color col=Color(0.2,0.8,1,0.4);
+ points.push_back( xform.xform( node->map_to_world(( rectangle.pos ) )));
+ points.push_back( xform.xform( node->map_to_world((rectangle.pos+Point2(rectangle.size.x+1,0)) ) ));
+ points.push_back( xform.xform( node->map_to_world((rectangle.pos+Point2(rectangle.size.x+1,rectangle.size.y+1)) ) ));
+ points.push_back( xform.xform( node->map_to_world((rectangle.pos+Point2(0,rectangle.size.y+1)) ) ));
- canvas_item_editor->draw_colored_polygon(points,col);
+ canvas_item_editor->draw_colored_polygon(points, Color(0.2,0.8,1,0.4));
}
-
if (mouse_over){
Vector2 endpoints[4]={
-
- ( node->map_to_world(over_tile,true) ) ,
- ( node->map_to_world((over_tile+Point2(1,0)),true ) ),
- ( node->map_to_world((over_tile+Point2(1,1)),true ) ),
- ( node->map_to_world((over_tile+Point2(0,1)),true ) )
-
+ node->map_to_world(over_tile, true),
+ node->map_to_world((over_tile+Point2(1,0)), true),
+ node->map_to_world((over_tile+Point2(1,1)), true),
+ node->map_to_world((over_tile+Point2(0,1)), true)
};
- for(int i=0;i<4;i++) {
+ for (int i=0;i<4;i++) {
if (node->get_half_offset()==TileMap::HALF_OFFSET_X && ABS(over_tile.y)&1)
endpoints[i]+=cell_xf[0]*0.5;
if (node->get_half_offset()==TileMap::HALF_OFFSET_Y && ABS(over_tile.x)&1)
@@ -660,122 +1078,92 @@ void TileMapEditor::_canvas_draw() {
else
col=Color(1.0,0.4,0.2,0.8);
- for(int i=0;i<4;i++)
+ for (int i=0;i<4;i++)
canvas_item_editor->draw_line(endpoints[i],endpoints[(i+1)%4],col,2);
+ if (tool==TOOL_SELECTING || tool==TOOL_PICKING || tool==TOOL_BUCKET) {
- if (tool==TOOL_DUPLICATING) {
-
- Rect2i duplicate=selection;
- duplicate.pos=over_tile;
+ return;
+ }
+ if (tool==TOOL_LINE_PAINT) {
- Vector<Vector2> points;
- points.push_back( xform.xform( node->map_to_world(duplicate.pos ) ));
- points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,0)) ) ));
- points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,duplicate.size.y+1))) ));
- points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(0,duplicate.size.y+1))) ));
- Color col=Color(0.2,1.0,0.8,0.4);
+ if (paint_undo.empty())
+ return;
- canvas_item_editor->draw_colored_polygon(points,col);
+ int id = get_selected_tile();
- } else {
+ if (id==TileMap::INVALID_CELL)
+ return;
- Ref<TileSet> ts = node->get_tileset();
+ for (Map<Point2i, CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
+ _draw_cell(id, E->key(), flip_h, flip_v, transpose, xform);
+ }
- if (ts.is_valid()) {
+ } else if (tool==TOOL_RECTANGLE_PAINT) {
- int st = get_selected_tile();
- if (ts->has_tile(st)) {
+ int id = get_selected_tile();
- Ref<Texture> t = ts->tile_get_texture(st);
- if (t.is_valid()) {
- Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset();
- Vector2 tile_ofs = ts->tile_get_texture_offset(st);
- Rect2 r = ts->tile_get_region(st);
- Size2 sc = xform.get_scale();
+ if (id==TileMap::INVALID_CELL)
+ return;
- Rect2 rect;
- if (r==Rect2()) {
- rect=Rect2(from,t->get_size());
- } else {
+ for (int i=rectangle.pos.y;i<=rectangle.pos.y+rectangle.size.y;i++) {
+ for (int j=rectangle.pos.x;j<=rectangle.pos.x+rectangle.size.x;j++) {
- rect=Rect2(from,r.get_size());
- }
+ _draw_cell(id, Point2i(j, i), flip_h, flip_v, transpose, xform);
+ }
+ }
+ } else if (tool==TOOL_DUPLICATING) {
- bool transp = transpose->is_pressed();
- bool flip_h = mirror_x->is_pressed();
- bool flip_v = mirror_y->is_pressed();
+ if (copydata.empty())
+ return;
- if (rect.size.y > rect.size.x) {
- if ((flip_h && (flip_v || transp)) || (flip_v && !transp))
- tile_ofs.y += rect.size.y - rect.size.x;
- } else if (rect.size.y < rect.size.x) {
- if ((flip_v && (flip_h || transp)) || (flip_h && !transp))
- tile_ofs.x += rect.size.x - rect.size.y;
- }
+ Ref<TileSet> ts = node->get_tileset();
- if (transp) {
- SWAP(tile_ofs.x, tile_ofs.y);
- }
+ if (ts.is_null())
+ return;
- if (flip_h) {
- sc.x*=-1.0;
- tile_ofs.x*=-1.0;
- }
- if (flip_v) {
- sc.y*=-1.0;
- tile_ofs.y*=-1.0;
- }
+ Point2 ofs = over_tile-rectangle.pos;
- if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
- rect.pos+=tile_ofs;
+ for (List<TileData>::Element *E=copydata.front();E;E=E->next()) {
- } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
- rect.pos+=node->get_cell_size()/2;
- Vector2 s = r.size;
+ if (!ts->has_tile(E->get().cell))
+ continue;
- Vector2 center = (s/2) - tile_ofs;
+ TileData tcd = E->get();
+ _draw_cell(tcd.cell, tcd.pos+ofs, tcd.flip_h, tcd.flip_v, tcd.transpose, xform);
+ }
- if (flip_h)
- rect.pos.x-=s.x-center.x;
- else
- rect.pos.x-=center.x;
+ Rect2i duplicate=rectangle;
+ duplicate.pos=over_tile;
- if (flip_v)
- rect.pos.y-=s.y-center.y;
- else
- rect.pos.y-=center.y;
- }
+ Vector<Vector2> points;
+ points.push_back( xform.xform( node->map_to_world(duplicate.pos ) ));
+ points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,0)) ) ));
+ points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(duplicate.size.x+1,duplicate.size.y+1))) ));
+ points.push_back( xform.xform( node->map_to_world((duplicate.pos+Point2(0,duplicate.size.y+1))) ));
- rect.pos=xform.xform(rect.pos);
- rect.size*=sc;
+ canvas_item_editor->draw_colored_polygon(points, Color(0.2,1.0,0.8,0.2));
- if (r==Rect2()) {
+ } else {
- canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transp);
- } else {
+ int st = get_selected_tile();
- canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transp);
- }
- }
- }
- }
+ if (st==TileMap::INVALID_CELL)
+ return;
+ _draw_cell(st, over_tile, flip_h, flip_v, transpose, xform);
}
}
-
-
-
}
-
-
void TileMapEditor::edit(Node *p_tile_map) {
+ search_box->set_text("");
+
if (!canvas_item_editor) {
canvas_item_editor=CanvasItemEditor::get_singleton()->get_viewport_control();
}
@@ -815,27 +1203,32 @@ void TileMapEditor::edit(Node *p_tile_map) {
void TileMapEditor::_tileset_settings_changed() {
_update_palette();
+
if (canvas_item_editor)
canvas_item_editor->update();
}
void TileMapEditor::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_text_entered"),&TileMapEditor::_text_entered);
+ ObjectTypeDB::bind_method(_MD("_text_changed"),&TileMapEditor::_text_changed);
+ ObjectTypeDB::bind_method(_MD("_sbox_input"),&TileMapEditor::_sbox_input);
ObjectTypeDB::bind_method(_MD("_menu_option"),&TileMapEditor::_menu_option);
ObjectTypeDB::bind_method(_MD("_canvas_draw"),&TileMapEditor::_canvas_draw);
ObjectTypeDB::bind_method(_MD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter);
ObjectTypeDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
ObjectTypeDB::bind_method(_MD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
- ObjectTypeDB::bind_method(_MD("_set_cell_shortened","pos","tile","flip_x","flip_y","transpose"),&TileMapEditor::_set_cell_shortened,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("_set_display_mode","mode"),&TileMapEditor::_set_display_mode);
+
+ ObjectTypeDB::bind_method(_MD("_fill_points"),&TileMapEditor::_fill_points);
+ ObjectTypeDB::bind_method(_MD("_erase_points"),&TileMapEditor::_erase_points);
}
TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos)
{
CellOp op;
op.idx = node->get_cell(p_pos.x,p_pos.y);
- if (op.idx>=0) {
+ if (op.idx!=TileMap::INVALID_CELL) {
if (node->is_cell_x_flipped(p_pos.x,p_pos.y))
op.xf=true;
if (node->is_cell_y_flipped(p_pos.x,p_pos.y))
@@ -851,47 +1244,35 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) {
ToolButton *b=p_button->cast_to<ToolButton>();
//ERR_FAIL_COND(!b);
- mirror_x->set_block_signals(true);
- mirror_y->set_block_signals(true);
- transpose->set_block_signals(true);
- rotate_0->set_block_signals(true);
- rotate_90->set_block_signals(true);
- rotate_180->set_block_signals(true);
- rotate_270->set_block_signals(true);
-
if (b == rotate_0) {
mirror_x->set_pressed(false);
mirror_y->set_pressed(false);
- transpose->set_pressed(false);
+ transp->set_pressed(false);
}
else if (b == rotate_90) {
mirror_x->set_pressed(true);
mirror_y->set_pressed(false);
- transpose->set_pressed(true);
+ transp->set_pressed(true);
}
else if (b == rotate_180) {
mirror_x->set_pressed(true);
mirror_y->set_pressed(true);
- transpose->set_pressed(false);
+ transp->set_pressed(false);
}
else if (b == rotate_270) {
mirror_x->set_pressed(false);
mirror_y->set_pressed(true);
- transpose->set_pressed(true);
+ transp->set_pressed(true);
}
- rotate_0->set_pressed(!mirror_x->is_pressed() && !mirror_y->is_pressed() && !transpose->is_pressed());
- rotate_90->set_pressed(mirror_x->is_pressed() && !mirror_y->is_pressed() && transpose->is_pressed());
- rotate_180->set_pressed(mirror_x->is_pressed() && mirror_y->is_pressed() && !transpose->is_pressed());
- rotate_270->set_pressed(!mirror_x->is_pressed() && mirror_y->is_pressed() && transpose->is_pressed());
-
- mirror_x->set_block_signals(false);
- mirror_y->set_block_signals(false);
- transpose->set_block_signals(false);
- rotate_0->set_block_signals(false);
- rotate_90->set_block_signals(false);
- rotate_180->set_block_signals(false);
- rotate_270->set_block_signals(false);
+ flip_h=mirror_x->is_pressed();
+ flip_v=mirror_y->is_pressed();
+ transpose=transp->is_pressed();
+
+ rotate_0->set_pressed(!flip_h && !flip_v && !transpose);
+ rotate_90->set_pressed(flip_h && !flip_v && transpose);
+ rotate_180->set_pressed(flip_h && flip_v && !transpose);
+ rotate_270->set_pressed(!flip_h && flip_v && transpose);
}
TileMapEditor::TileMapEditor(EditorNode *p_editor) {
@@ -899,92 +1280,111 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
node=NULL;
canvas_item_editor=NULL;
editor=p_editor;
- undo_redo = editor->get_undo_redo();
-
- int mw = EDITOR_DEF("tile_map/palette_min_width",80);
- Control *ec = memnew( Control);
- ec->set_custom_minimum_size(Size2(mw,0));
- add_child(ec);
-
- HBoxContainer *hb = memnew( HBoxContainer );
- add_child(hb);
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
- hb->add_spacer(true);
-
- button_thumbnail = memnew( ToolButton );
- button_thumbnail->set_toggle_mode(true);
- button_thumbnail->set_pressed(true);
- button_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail","EditorIcons"));
- hb->add_child(button_thumbnail);
- button_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL));
-
- button_list = memnew( ToolButton );
- button_list->set_toggle_mode(true);
- button_list->set_pressed(false);
- button_list->set_icon(p_editor->get_gui_base()->get_icon("FileList","EditorIcons"));
- hb->add_child(button_list);
- button_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
+ undo_redo=editor->get_undo_redo();
+
+ tool=TOOL_NONE;
+ selection_active=false;
+ mouse_over=false;
+
+ flip_h=false;
+ flip_v=false;
+ transpose=false;
+
+ search_box = memnew( LineEdit );
+ search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ search_box->connect("text_entered", this, "_text_entered");
+ search_box->connect("text_changed", this, "_text_changed");
+ search_box->connect("input_event", this, "_sbox_input");
+ add_child(search_box);
+
+ int mw = EDITOR_DEF("tile_map/palette_min_width", 80);
// Add tile palette
palette = memnew( ItemList );
palette->set_v_size_flags(SIZE_EXPAND_FILL);
+ palette->set_custom_minimum_size(Size2(mw,0));
add_child(palette);
// Add menu items
- canvas_item_editor_hb = memnew( HBoxContainer );
- CanvasItemEditor::get_singleton()->add_control_to_menu_panel(canvas_item_editor_hb);
- canvas_item_editor_hb->add_child( memnew( VSeparator ));
- transpose = memnew( ToolButton );
- transpose->set_toggle_mode(true);
- transpose->set_tooltip("Transpose");
- transpose->set_focus_mode(FOCUS_NONE);
- transpose->connect("pressed", this, "_update_transform_buttons", make_binds(transpose));
- canvas_item_editor_hb->add_child(transpose);
+ toolbar = memnew( HBoxContainer );
+ toolbar->set_h_size_flags(SIZE_EXPAND_FILL);
+ toolbar->set_alignment(BoxContainer::ALIGN_END);
+ CanvasItemEditor::get_singleton()->add_control_to_menu_panel(toolbar);
+
+ options = memnew( MenuButton );
+ options->set_text("Tile Map");
+ options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("TileMap", "EditorIcons"));
+ options->set_process_unhandled_key_input(false);
+
+ PopupMenu *p = options->get_popup();
+
+ p->add_item("Bucket", OPTION_BUCKET);
+ p->add_separator();
+ p->add_item("Pick Tile", OPTION_PICK_TILE, KEY_CONTROL);
+ p->add_separator();
+ p->add_item("Select", OPTION_SELECT, KEY_MASK_CMD+KEY_B);
+ p->add_item("Duplicate Selection", OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D);
+ p->add_item("Erase Selection", OPTION_ERASE_SELECTION, KEY_DELETE);
+
+ p->connect("item_pressed", this, "_menu_option");
+
+ toolbar->add_child(options);
+
+ toolbar->add_child( memnew( VSeparator ) );
+
+ transp = memnew( ToolButton );
+ transp->set_toggle_mode(true);
+ transp->set_tooltip("Transpose");
+ transp->set_focus_mode(FOCUS_NONE);
+ transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp));
+ toolbar->add_child(transp);
mirror_x = memnew( ToolButton );
mirror_x->set_toggle_mode(true);
mirror_x->set_tooltip("Mirror X (A)");
mirror_x->set_focus_mode(FOCUS_NONE);
mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x));
- canvas_item_editor_hb->add_child(mirror_x);
+ toolbar->add_child(mirror_x);
mirror_y = memnew( ToolButton );
mirror_y->set_toggle_mode(true);
mirror_y->set_tooltip("Mirror Y (S)");
mirror_y->set_focus_mode(FOCUS_NONE);
mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y));
- canvas_item_editor_hb->add_child(mirror_y);
- canvas_item_editor_hb->add_child(memnew(VSeparator));
+ toolbar->add_child(mirror_y);
+
+ toolbar->add_child( memnew( VSeparator ) );
+
rotate_0 = memnew( ToolButton );
rotate_0->set_toggle_mode(true);
rotate_0->set_tooltip("Rotate 0 degrees");
rotate_0->set_focus_mode(FOCUS_NONE);
rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0));
- canvas_item_editor_hb->add_child(rotate_0);
+ toolbar->add_child(rotate_0);
rotate_90 = memnew( ToolButton );
rotate_90->set_toggle_mode(true);
rotate_90->set_tooltip("Rotate 90 degrees");
rotate_90->set_focus_mode(FOCUS_NONE);
rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90));
- canvas_item_editor_hb->add_child(rotate_90);
+ toolbar->add_child(rotate_90);
rotate_180 = memnew( ToolButton );
rotate_180->set_toggle_mode(true);
rotate_180->set_tooltip("Rotate 180 degrees");
rotate_180->set_focus_mode(FOCUS_NONE);
rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180));
- canvas_item_editor_hb->add_child(rotate_180);
+ toolbar->add_child(rotate_180);
rotate_270 = memnew( ToolButton );
rotate_270->set_toggle_mode(true);
rotate_270->set_tooltip("Rotate 270 degrees");
rotate_270->set_focus_mode(FOCUS_NONE);
rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270));
- canvas_item_editor_hb->add_child(rotate_270);
- canvas_item_editor_hb->hide();
+ toolbar->add_child(rotate_270);
+ toolbar->hide();
rotate_0->set_pressed(true);
- tool=TOOL_NONE;
- selection_active=false;
- mouse_over=false;
}
+///////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////
void TileMapEditorPlugin::edit(Object *p_object) {
@@ -999,33 +1399,24 @@ bool TileMapEditorPlugin::handles(Object *p_object) const {
void TileMapEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
- tile_map_editor->show();
- tile_map_editor->get_canvas_item_editor_hb()->show();
+ tile_map_editor->show();
+ tile_map_editor->get_toolbar()->show();
} else {
tile_map_editor->hide();
- tile_map_editor->get_canvas_item_editor_hb()->hide();
+ tile_map_editor->get_toolbar()->hide();
tile_map_editor->edit(NULL);
}
-
}
TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
- editor=p_node;
tile_map_editor = memnew( TileMapEditor(p_node) );
- CanvasItemEditor::get_singleton()->get_palette_split()->add_child(tile_map_editor);
- CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor,0);
-
+ add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor);
tile_map_editor->hide();
-
-
-
-
}
-
TileMapEditorPlugin::~TileMapEditorPlugin()
{
}
diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h
index 3cbf5ff68d..b1da1bc48e 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.h
+++ b/tools/editor/plugins/tile_map_editor_plugin.h
@@ -31,55 +31,57 @@
#include "tools/editor/editor_plugin.h"
#include "tools/editor/editor_node.h"
+
#include "scene/2d/tile_map.h"
+#include "scene/gui/line_edit.h"
#include "scene/gui/tool_button.h"
-#include "scene/gui/button_group.h"
+#include "scene/gui/menu_button.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class CanvasItemEditor;
class TileMapEditor : public VBoxContainer {
OBJ_TYPE(TileMapEditor, VBoxContainer );
- UndoRedo *undo_redo;
-
enum Tool {
TOOL_NONE,
TOOL_PAINTING,
- TOOL_SELECTING,
TOOL_ERASING,
+ TOOL_RECTANGLE_PAINT,
+ TOOL_RECTANGLE_ERASE,
+ TOOL_LINE_PAINT,
+ TOOL_LINE_ERASE,
+ TOOL_SELECTING,
+ TOOL_BUCKET,
+ TOOL_PICKING,
TOOL_DUPLICATING,
- TOOL_PICKING
};
- enum DisplayMode {
- DISPLAY_THUMBNAIL,
- DISPLAY_LIST
+ enum Options {
+
+ OPTION_BUCKET,
+ OPTION_PICK_TILE,
+ OPTION_SELECT,
+ OPTION_DUPLICATE,
+ OPTION_ERASE_SELECTION
};
- Tool tool;
+ TileMap *node;
+
+ EditorNode *editor;
+ UndoRedo *undo_redo;
Control *canvas_item_editor;
- int display_mode;
+ LineEdit *search_box;
ItemList *palette;
- ToolButton *button_thumbnail;
- ToolButton *button_list;
- EditorNode *editor;
- Panel *panel;
- TileMap *node;
- MenuButton *options;
- bool selection_active;
- Point2i selection_begin;
- Rect2i selection;
- Point2i over_tile;
- bool mouse_over;
+ HBoxContainer *toolbar;
- Label *mirror_label;
- ToolButton *transpose;
+ MenuButton *options;
+ ToolButton *transp;
ToolButton *mirror_x;
ToolButton *mirror_y;
ToolButton *rotate_0;
@@ -87,46 +89,83 @@ class TileMapEditor : public VBoxContainer {
ToolButton *rotate_180;
ToolButton *rotate_270;
- HBoxContainer *canvas_item_editor_hb;
+ Tool tool;
+ bool selection_active;
+ bool mouse_over;
+
+ bool flip_h;
+ bool flip_v;
+ bool transpose;
+
+ Point2i rectangle_begin;
+ Rect2i rectangle;
+
+ Point2i over_tile;
struct CellOp {
int idx;
bool xf;
bool yf;
bool tr;
+
CellOp() { idx=-1; xf=false; yf=false; tr=false; }
};
- Map<Point2i,CellOp> paint_undo;
+ Map<Point2i, CellOp> paint_undo;
+
+ struct TileData {
+ Point2i pos;
+ int cell;
+ bool flip_h;
+ bool flip_v;
+ bool transpose;
+ };
+
+ List<TileData> copydata;
+
+ void _pick_tile(const Point2& p_pos);
+
+ DVector<Vector2> _bucket_fill(const Point2i& p_start);
+
+ void _fill_points(const DVector<Vector2> p_points, const Dictionary& p_op);
+ void _erase_points(const DVector<Vector2> p_points);
+
+ void _select(const Point2i& p_from, const Point2i& p_to);
+
+ void _draw_cell(int p_cell, const Point2i& p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Matrix32& p_xform);
+ void _update_copydata();
int get_selected_tile() const;
void set_selected_tile(int p_tile);
- void _set_display_mode(int p_mode);
+ void _text_entered(const String& p_text);
+ void _text_changed(const String& p_text);
+ void _sbox_input(const InputEvent& p_ie);
void _update_palette();
void _canvas_draw();
void _menu_option(int p_option);
void _set_cell(const Point2i& p_pos, int p_value, bool p_flip_h=false, bool p_flip_v=false, bool p_transpose=false, bool p_with_undo=false);
- void _set_cell_shortened(const Point2& p_pos, int p_value, bool p_flip_h=false, bool p_flip_v=false, bool p_transpose=false);
void _canvas_mouse_enter();
void _canvas_mouse_exit();
void _tileset_settings_changed();
-
protected:
+
void _notification(int p_what);
- void _node_removed(Node *p_node);
static void _bind_methods();
CellOp _get_op_from_cell(const Point2i& p_pos);
- void _update_transform_buttons(Object *p_button=0);
+ void _update_transform_buttons(Object *p_button=NULL);
+
public:
- HBoxContainer *get_canvas_item_editor_hb() const { return canvas_item_editor_hb; }
+ HBoxContainer *get_toolbar() const { return toolbar; }
+
bool forward_input_event(const InputEvent& p_event);
void edit(Node *p_tile_map);
+
TileMapEditor(EditorNode *p_editor);
};
@@ -135,8 +174,6 @@ class TileMapEditorPlugin : public EditorPlugin {
OBJ_TYPE( TileMapEditorPlugin, EditorPlugin );
TileMapEditor *tile_map_editor;
- EditorNode *editor;
-
public:
diff --git a/tools/export/blender25/io_scene_dae/export_dae.py b/tools/export/blender25/io_scene_dae/export_dae.py
index 7ee0e179b8..370dc359b5 100644
--- a/tools/export/blender25/io_scene_dae/export_dae.py
+++ b/tools/export/blender25/io_scene_dae/export_dae.py
@@ -1087,7 +1087,7 @@ class DaeExporter:
self.writel(S_LAMPS,5,'<color>'+strarr(light.color)+'</color>')
att_by_distance = 2.0 / light.distance # convert to linear attenuation
self.writel(S_LAMPS,5,'<linear_attenuation>'+str(att_by_distance)+'</linear_attenuation>')
- self.writel(S_LAMPS,5,'<falloff_angle>'+str(math.degrees(light.spot_size))+'</falloff_angle>')
+ self.writel(S_LAMPS,5,'<falloff_angle>'+str(math.degrees(light.spot_size/2))+'</falloff_angle>')
self.writel(S_LAMPS,4,'</spot>')